akhauriyash/Code-Regression huggingface dataset:
import sys
readline = sys.stdin.readline

A = list(map(int, readline().strip()))
B = list(map(int, readline().strip()))
N = len(A)
Ao = A[:]
inf = 10**9+7
if sum(B):
    ans = inf
    CRo = [None]*N
    A2 = A + A
    B2 = B + B
    pre = None
    for i in range(2*N-1, N-1, -1):
        if B2[i]:
            pre = i
    for i in range(N-1, -1, -1):
        if B2[i]:
            pre = i
        CRo[i] = pre - i
    
    prel = None
    for i in range(N-1, -1, -1):
        if B[i]:
            prel = i - N
            break
    prer = None
    for i in range(N):
        if B[i]:
            prer = N + i
            break
    
    CLo = [None]*N
    pre = prel
    for i in range(N):
        if B[i]:
            pre = i
        CLo[i] = i - pre
    
    CR = CRo[:]
    for j in range(N):
        C = [a^b for a, b in zip(A, B)]
        for i in range(N):
            if B[i]:
                CR[i] = 0
        res = sum(C)
        if res >= ans:
            A = A[1:] + [A[0]]
            CR = CR[1:] + [CR[0]]
            continue
        CL = [0]*N
        pre = prel
        for i in range(N):
            if B[i]:
                pre = i
            if C[i]:
                CL[i] = i - pre
        
        mc = max(CL)
        table = [0]*(1+mc)
        for i in range(N):
            if CL[i]:
                table[CL[i]] = max(table[CL[i]], CR[i])
        cnt = min(N, 2*mc)
        for i in range(mc-1, -1, -1):
            table[i] = max(table[i+1], table[i])
        for i in range(mc):
            cnt = min(cnt, 2*i+2*table[i+1])
        ans = min(ans, res + cnt + j)

        A = A[1:] + [A[0]]
        CR = CR[1:] + [CR[0]]
    
    A = Ao
    CL = CLo[:]
    for j in range(N):
        C = [a^b for a, b in zip(A, B)]
        res = sum(C)
        for i in range(N):
            if B[i]:
                CL[i] = 0
        if res >= ans:
            A = [A[-1]] + A[:-1]
            CL = [CL[-1]] + CL[:-1]
            continue
        CR = [0]*N
        pre = prer
        for i in range(N-1, -1, -1):
            if B[i]:
                pre = i
            if C[i]:
                CR[i] = pre - i
        mc = max(CR)
        table = [0]*(mc+1)
        for i in range(N):
            if CR[i]:
                table[CR[i]] = max(table[CR[i]], CL[i])
        
        for i in range(mc-1, -1, -1):
            table[i] = max(table[i+1], table[i])
        cnt = min(N, 2*mc)
        for i in range(mc):
            cnt = min(cnt, 2*i+2*table[i+1])
        ans = min(ans, cnt + res + j)

        A = [A[-1]] + A[:-1]
        CL = [CL[-1]] + CL[:-1]
else:
    ans = -1 if sum(A) else 0
print(ans)

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


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

    cout<<((n%500 <= a )? "Yes" : "No" )<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << max(0,min(b,d) - max(a,c)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=1e5+9;
int main()
{
    FASTINOUT;
    int y[3];
    cin>>y[0]>>y[1]>>y[2];
    sort(y,y+3);
    cout<<y[2]*10+y[1]+y[0];
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,x;
set<int>a;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        a.insert(x);
    }
    if(a.size()==n)
        puts("YES");
    else
        puts("NO");
    return 0;
}

Measured memory_bytes: 9600
import numpy as np
N = int(input())
As = np.array(list(map(int, input().split())))
modNum = 10**9 + 7
sum = 0
for d in range(60):
	n1 = np.count_nonzero((As >> d) & 1 == 1)
	sum += (2 ** d) * n1 * (N - n1)
print(sum % modNum)

Measured memory_bytes: 48824
open Printf

let n = int_of_string @@ read_line ()
let a =
  Str.split (Str.regexp " ") @@ read_line ()
  |> List.map int_of_string

let cnt = Array.make 4 0
let dp = Array.make (n+1) @@ Array.make_matrix (0) (0) (-1.0)

let rec calc: int -> int -> int -> float = fun i1 i2 i3 ->
  if dp.(i1).(i2).(i3) <> -1.0 then dp.(i1).(i2).(i3)
  else
    let numer =
      (float n)
      +. (if i1 = 0 then 0. else ((float i1) *. calc (i1-1) i2 i3))
      +. (if i2 = 0 then 0. else ((float i2) *. calc (i1+1) (i2-1) i3))
      +. (if i3 = 0 then 0. else ((float i3) *. calc i1 (i2+1) (i3-1))) in
    let denom = float @@ i1 + i2 + i3 in

    let res = numer /. denom in

    dp.(i1).(i2).(i3) <- res ;
    res


let () =
  List.iter (fun x -> cnt.(x) <- cnt.(x) + 1) a ;
  for z = 0 to n do
        dp.(z) <- Array.make_matrix (n+1) (n+1) (-1.0)
      done;
  dp.(0).(0).(0) <- 0.0 ;
  begin
    calc cnt.(1) cnt.(2) cnt.(3)
    |> string_of_float
    |> print_endline
  end


Measured memory_bytes: 220276
S = input()
N = len(S)
flag = 0

be = int((N-1)/2)
af = int((N+3)/2-1)

for i in range(be):
  if S[i] != S[be-1-i]:
    flag = 1
    break
  
for i in range(af, N):
  if S[i] != S[N-1-i]:
    flag = 1
    break

if flag:
  print('No')
else:
  print('Yes')
  

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define n_l '\n'
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: "; cerr << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cerr << to_string(H) << " | "; dbgm(T...); } 
#define dbgm(...) cerr << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cerr << endl
#define run(a, b) cerr << fixed << setprecision(6) << (double) (b - a) / (double) (CLOCKS_PER_SEC) << " s" << endl;
#define ll long long
#define ld long double
#define INF (1e18L + 5)
#define MOD (ll)(1e9 + 7)

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;
    if(a == 0 or b == 0 or a > 9 or b > 9) {
        cout << -1 << endl;
    }
    else {
        cout << a * b << endl;
    }
    return 0;
}

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

#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int INF = 1e9 + 7;

char val(ll num) 
{ 
	return 'a'+num;
} 

int main(void)
{
	FAST

	ll n; cin >> n;

	string res = "";
	ll base = 26;

	while(n > 0)
	{
		n--;
		res += val((n%base));
		n /= base;
	}
	
	reverse(res.begin(), res.end());

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


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>

int** make2dArray(int x,int y){
	int** array = (int**)malloc(sizeof(int*) * x);
	for (int i = 0; i < x; i++) {
		array[i] = (int*)malloc(sizeof(int) * y);
	}
	return array;
}
void printArray(int* a, int length) {
	for (int i = 0; i < length; i++) {
		printf("%d ", a[i]);
	}
}
void print2dIntArray(int** a,int x,int y) {
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < y; j++) {
			if (j == y - 1) {
				printf("%d\n", a[i][j]);
			}
			else {
				printf("%d ", a[i][j]);
			}
		}
	}
}
void print2dLongArray(long long** a, int x, int y) {
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < y; j++) {
			if (j == y - 1) {
				printf("%llu\n", a[i][j]);
			}
			else {
				printf("%llu ", a[i][j]);
			}
		}
	}
}
int* getColFromArray(int** array, int x, int j) {
	int* a = (int*)malloc(sizeof(int) * x);
	for (int i = 0; i < x; i++) {
		a[i] = array[i][j];
	}
	return a;
}
long long int arrayTimes(int* a1, int* a2, int length) {
	long long int res = 0;
	for (int i = 0; i < length; i++) {
		res = res + a1[i] * a2[i];
	}
	return res;
}
void call(int n) {
	for (int i = 1; i <= n; i++) {
		int x = i;
		if (x % 3 == 0) {
			printf(" %d", i);
			continue;
		}
		do{
			if (x % 10 == 3) {
				printf(" %d", i);
				break;
			}
			x /= 10;
		} while (x);
	}
}
char change(char ch) {
	if (ch >= 'a' && ch <= 'z') {
		ch = ch - 'a' + 'A';
	}
	else if (ch >= 'A' && ch <= 'Z') {
		ch = ch - 'A' + 'a';
	}
	return ch;
}
int toNumber(char ch) {
	return ch - '0';
}
int main() {
	char str[1001];
	while (1) {
		int sum = 0;
		scanf("%s", str);
		if (str[0] == '0') {
			break;
		}
		for (int i = 0; str[i] != '\0'; i++) {
			sum = sum + toNumber(str[i]);
		}
		printf("%d\n", sum);

	}
	
}




Measured memory_bytes: 2036
#include <stdio.h>
int main()
{
	int A,B;
	1<A<16;
	A+B <= 16;
	1<B<16;
	scanf ("%d", &A);
	scanf ("%d", &B);
	if (A > 8 & B < 8){
	 printf (":(");
	}else if (A < 8 & B > 8){
	 printf (":(");
	}else if (A <= 8 & B <= 8){
	 printf ("Yay!");
}
	return 0;
}

Measured memory_bytes: 128
n, a, b = map(int, input().split())
SUM1 = 0
for i in range(1, n + 1):
  l = list(str(i))
  if sum([int(m) for m in l]) >= a and sum([int(m) for m in l]) <= b:
    SUM1 += i
print(SUM1)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#define maxn 300030
using namespace std;
int n,t1[maxn],t2[maxn];char s[maxn];
void init(){
	scanf("%d%s",&n,s+1);
	for(int i=1;i<=n;++i)
	if(s[i]=='W')t1[i]=1;
	else t2[i]=1;
	for(int i=1;i<=n;++i)t1[i]+=t1[i-1];
	for(int i=n;i;--i)t2[i]+=t2[i+1];
}
void solve(){
	int ans=maxn;
	for(int i=1;i<=n;++i)
	ans=min(ans,t1[i-1]+t2[i+1]);
	printf("%d\n",ans);
}
int main(){
	init();
	solve();
	return 0;
}

Measured memory_bytes: 2944
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	a := iSScan(n)
	ans := 0
	for i := 1; i < n; i++ {
		if a[i-1] > a[i] {
			ans += a[i-1] - a[i]
			a[i] = a[i-1]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5856
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        String first = S.substring(0,2);
        String end = S.substring(2,4);

        int YY = Integer.parseInt(first);
        int MM = Integer.parseInt(end);
        
        if (YY >= 1 && YY <=12){
            if(MM >= 1 && MM <= 12){
                System.out.print("AMBIGUOUS");
            }else{
                System.out.print("MMYY");
            }
        }else{
            if(MM >= 1 && MM <= 12){
                System.out.print("YYMM");
            }else{
                System.out.print("NA");
            }
        }



    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using llu=unsigned long long;
#define mod 1000000007
#define mode 998244353
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mms(x,y) memset(x,y,sizeof(x))
#define pqm priority_queue<ll,vector<ll>,greater<ll>>
#define pb push_back
#define um unordered_map
#define pr pair
#define mm multimap
#define ms multiset
#define mp make_pair
#define vr vector
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define inf INT_MAX
#define ninf INT_MIN
#define ff first
#define ss second
#define gcd __gcd
int main()
{
    fast;
    ll t,n,m,i,j,k;
    cin>>n>>k;
    ll w[n],val[n];
    for(i=0;i<n;i++)cin>>w[i]>>val[i];
    ll dp[n+1][100001];
    for(i=0;i<=n;i++)dp[i][0]=0;
    for(i=1;i<=100000;i++)dp[0][i]=inf;
    for(i=1;i<=n;i++)
    {
        for(j=0;j<=100000;j++)
        {
            if(j>=val[i-1])
            {
                dp[i][j]=min(dp[i-1][j-val[i-1]]+w[i-1],dp[i-1][j]);
            }
            else dp[i][j]=dp[i-1][j];
        }
    }
    for(i=100000;i>=0;i--)
    {
        if(dp[n][i]<=k)
        {
            cout<<i;
            break;
        }
    }
}


Measured memory_bytes: 79232
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int main(){
	int h,w;
	vector<vector<int>> v;
	vector<string> s;
	cin >>h>>w;
	v.resize(h);
	rep(i,h)
		rep(j,w){
		int t;
		cin >>t;
		v[i].push_back(t);
		}
	rep(i,h-1)
		rep(j,w){
			if (v[i][j]%2){
				s.push_back(to_string(i+1)+" "+to_string(j+1)+" "+to_string(i+2)+" "+to_string(j+1));
				v[i+1][j]++;
			}
		}
	h--;
	rep(j,w-1){
		if (v[h][j]%2){
				s.push_back(to_string(h+1)+" "+to_string(j+1)+" "+to_string(h+1)+" "+to_string(j+2));
				v[h][j+1]++;
		}
	}
	cout<<s.size()<<endl;
	for(auto i:s)
		cout <<i<<endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

#define INF 1e13

using namespace std;

ll dp[301][301][302];

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, k; cin>>n>>k;
	unordered_map<int, ll> Map, RMap;
	set<ll> Set; Set.ins(0);
	vll h(n);
	rep(i, n){
		cin>>h[i];
		Set.ins(h[i]);
	}
	int idx=0;
	for(auto e:Set){
		Map[idx] = e;
		RMap[e] = idx;
		idx++;
	}

	rep(i, n+1)rep(j, k+1)rep(l, Map.size()+1){
		dp[i][j][l] = INF;
	}
	dp[0][0][0] = 0ll;
	for(int i=0; i<n; i++){
		for(int j=0; j<=k; j++){
			for(int l=0; l<=Map.size(); l++){
				if (dp[i][j][l] != INF){
					dp[i+1][j][RMap[h[i]]] = min(dp[i+1][j][RMap[h[i]]], dp[i][j][l]+max(0ll, h[i]-Map[l]));
					dp[i+1][j+1][l] = min(dp[i+1][j+1][l], dp[i][j][l]);
				}
			}
		}
	}

	ll ans = INF;
	for(int l=0; l<=Map.size(); l++){
		ans = min(ans, dp[n][k][l]);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 214016
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const int mod = 1000000007;
using namespace std;

int N;
int G[22][22];
ll f[22][(1<<21)+5];

ll solve(){
    for(int j = 0;j<N;j++){
        if(G[0][j] == 1) f[0][1<<j] += 1;
    }
    for(int i = 1;i<N;i++){
        for(int j = 0;j<N;j++){
            if(G[i][j] == 1){
                for(int hs = 0;hs<(1<<N);hs++){
                    if(!(hs>>j & 1)) f[i][hs | (1<<j)] =  (f[i][hs | (1<<j)] + f[i-1][hs])%mod;
                }
            }
        }
    }
    return f[N-1][(1<<N)-1];
}
int main(){
    // debug;
    ios;

    cin>>N;
    for(int i = 0;i<N;i++){
        for(int j = 0;j<N;j++){
            cin>>G[i][j];
        }
    }

    cout<<solve()<<"\n";


    
    return 0;
}


Measured memory_bytes: 336128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define ifaxb(a, x, b) if (a < x && x < b)
#define toInt(x) (x - '0')
#define vi vector<int>
#define vs vector<string>
#define all(x) x.begin(), x.end()
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
  int k;
  cin >> k;
  cout << (k / 2) * ((k + 1) / 2) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		if(a+b>=c) System.out.println("Yes");
		else System.out.println("No");
	}

}


Measured memory_bytes: 27008
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main(){
    ios::sync_with_stdio(false);
	int a,b;
	cin >> a >> b;
	cout << a*b << endl;
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int c = 2 * 1e5;
vector<int> v(c, 1e6);

int main()
{
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    rep(i, n)
    {
        int a;
        cin >> a;
        if (v[a] == 1e6)
        {
            v[a] = 0;
            cnt++;
        }
        v[a]++;
    }

    sort(ALL(v));

    int add = max(0, cnt - k);

    OP(accumulate(v.begin(), v.begin() + add, 0));
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int diff(int a,int b){return a>b?a-b:b-a;}
int N,K,x,ans;
int main(){
    cin>>N>>K;
    for(int i{};i<N;++i){
        cin>>x;
        ans+=2*min(diff(0,x),diff(K,x));
    }
    cout<<ans<<endl;
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<vector<int>> dp(n + 1, vector<int>(n + 1, 0));
  int ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = n - 1; j >= 0; j--) {
      if (i > j) {
        if (s[i] == s[j])
          dp[i][j] = min(dp[i + 1][j + 1] + 1, i - j);
        ans = max(ans, dp[i][j]);
      }
    }
  }
  cout << ans << endl;
}


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


int main() {
  int cnt = 0;
  rep(i,3){
    char a;
    cin >> a;
    if(a == 'o')cnt++;
  }
  int ans = 700 + 100 * cnt;
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,k;
    cin>>n>>k;
    int height[n];
    for(int i=0;i<n;i++) cin>>height[i];
    int dp[n];
    dp[0]=0;
    
    for(int i=1;i<n;i++){
        int count=1;
        dp[i]=INT_MAX;
        while(count<=k && (i-count)>=0){
            dp[i]=min(dp[i],dp[i-count]+abs(height[i]-height[i-count]));
            count++;
        }
        //cout<<dp[i]<<" ";
    }
    
    cout<<dp[n-1];
}


Measured memory_bytes: 4464
def main():
  while True:
    n = int(input())
    if n == 0:
      break
    
    mp = ["0" + input() + "0" for _ in range(n)]
    mp.insert(0, "0" * (n + 2))
    mp.append("0" * (n + 2))
    
    score = [[[0] * 4 for _ in range(n + 2)] for _ in range(n + 2)]
    max_score = 0
    for i in range(1, n + 1):
      for j in range(1, n + 1):
        if mp[i][j] == "1":
          score[i][j][0] = score[i - 1][j][0] + 1
          score[i][j][1] = score[i][j - 1][1] + 1
          score[i][j][2] = score[i - 1][j - 1][2] + 1
          score[i][j][3] = score[i - 1][j + 1][3] + 1
          max_score = max(max_score, score[i][j][0], score[i][j][1], score[i][j][2], score[i][j][3])
    
    print(max_score)

main()


Measured memory_bytes: 19296
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
    string S;
    string T;
    int N;

    cin >> S >> T;
    cin >> N;

    int s_s = 0;
    int s_e = 0;
    int t_s = 0;
    int t_e = 0;

    int s_a = 0;
    int S_asum[S.length()+1];
    S_asum[0] = 0;
    for(int j=1;j<=S.length();j++){
        S_asum[j] = S_asum[j-1] + S[j -1] - 'A' + 1;
    }
    int t_a = 0;
    int T_asum[T.length()+1];
    T_asum[0] = 0;
    for(int j=1;j<=T.length();j++){
        T_asum[j] = T_asum[j-1] + T[j -1] - 'A' + 1;
    }
    S_asum[0] = 0;
    T_asum[0] = 0;

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

        cin >> s_s >> s_e >> t_s >> t_e;
        int s_tmp = 0;
        int t_tmp = 0;

        s_tmp = S_asum[s_e] - S_asum[s_s-1];
        t_tmp = T_asum[t_e] - T_asum[t_s-1];

        string ans = "NO";
        if(s_tmp % 3 == t_tmp % 3){
            ans = "YES";
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
def test_coordinates(arr, coord):
    return sum([(x - coord) * (x - coord) for x in arr])


N = int(input())

coordinates = input().strip().split()
coordinates = [int(x) for x in coordinates]
costs = []

for i in range(1, max(coordinates)+1):
    costs.append(test_coordinates(coordinates, i))
print(min(costs))

Measured memory_bytes: 3064
/*
螺旋本 p371

circumcenter:
    https://ja.wikipedia.org/wiki/%E5%A4%96%E6%8E%A5%E5%86%86#%E5%A4%96%E5%BF%83%E3%81%AE%E4%BD%8D%E7%BD%AE
    https://mathtrain.jp/goshin
*/
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 55
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

signed main(){
    int N;
    cin>>N;
    int C[110000];
    for(int i=1;i<=N;i++){
        int a;
        cin>>a;
        C[a]=i;
    }
    multiset<int> S;
    S.insert(0);
    S.insert(0);
    S.insert(N+1);
    S.insert(N+1);
    ll ans=0;
    for(int i=N;i>=1;i--){
        int v=C[i];
        S.insert(v);
        auto it=S.find(v);
        int A=*it--,B=*it--,D=*it;
        it++; it++;it++;
        int C=*it++,E=*it;
        int l=B-D,k=A-B,x=C-A,y=E-C;
        if(B!=0) ans+=(ll)(l)*(x)*i;
        if(C!=N+1) ans+=(ll)(k)*(y)*i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
typedef string str;
typedef long l;
typedef long long ll;
const ll INF=1e18;
const int mod=1e9+7; 
#define rep(i,n) for(int i=0;i<n;i++)
#define print(a) cout << a << endl



void solve()
{

}

void yesno(bool n)
{
    if(n){
        print("Yes");
    }else{
        print("No");
    }
}

int main()
{
    int a,b;cin >> a >> b;
    if(a+b>9)print("error");
    else print(a+b);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int ,int> P;
int main(void){
    int n, l, ans = 0;
    int a[100005], length[100005];
    vector<int> front, back;

    cin >> n >> l;

    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    for(int i=0; i<n-1; i++){
        length[i] = a[i] + a[i+1];
        if(length[i] >= l && ans == 0){
            ans = i+1;
        }else{
            if(ans == 0){
                front.push_back(i);
            }else{
                back.push_back(i);
            }
        }
    }

    reverse(back.begin(), back.end());

    for(int i=0; i<back.size(); i++){
        front.push_back(back[i]);
    }

    if(ans == 0){
        cout << "Impossible" << endl;
        return 0;
    }else{
        cout << "Possible" << endl;
    }

    for(int i=0; i<front.size(); i++){
        cout << front[i]+1 << endl;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2168
#!/usr/bin/env python3
import sys

def fact(n):
    a=[]
    tmp=n
    for i in range(2, int(-(-n**0.5//1))+1):
        if tmp%i==0:
            cnt=0
            while tmp%i==0:
                cnt+=1
                tmp//=i
            a.append(cnt)
    if tmp!=1:
        a.append(1)
    if a==[]:
        a.append(1)
    return a

def solve(N: int):
    if N==1:
        print(0)
        sys.exit()

    a=fact(N)

    ans=0
    for i in a:
        nz=i
        k=1
        while True:
            if nz>=k:
                nz-=k
                k+=1
                ans+=1
            else:
                break

    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<int>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define mem(a) memset((a),0,sizeof(a))
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
const int N=7,M=1<<5|2,C=50;
ld f[M][N*C],g[M][N*C],h[N][M][N*C];
int l[N],s[M];
int main(){
	int n=read(),C=read();
	For(i,0,n-1)l[i]=read();
	sort(l,l+n); n--;
	f[0][l[n]*(n+1)]=1;
	For(i,1,(1<<n)-1)s[i]=s[i>>1]+(i&1);
	For(i,0,C-1){
		mem(h);
		For(j,0,(1<<n)-1){
			For(k,0,C*(n+1)){
				g[j][k]=f[j][k];
				h[k%(n+1)][j][k]=k/(n+1)==i?f[j][k]:0;
			}
		}
		For(j,0,n-1){
			Rep(zt,(1<<n)-1,0)if((zt>>j&1)==0){
				For(k,0,C*(n+1)){
					int P=k%(n+1),nm=(i+l[j])*(n+1);
					For(q,1,s[zt]+1){
						nm++;
						int jj=min(max(k+(q<=P&&zt),nm),C*(n+1));
						//if(i==0)cout<<k+(q<=P&&s[zt])<<" "<<nm<<" "<<g[zt][k]<<endl;
						g[zt|(1<<j)][jj]+=g[zt][k];
						For(p0,0,q-1){
							h[p0][zt|(1<<j)][jj]+=h[p0][zt][k];
						}
					}
				}
			}
		}
		For(j,0,(1<<n)-1){
			For(k,0,C*(n+1)){
				f[j][k]=g[j][k];
				For(p0,0,s[j]+1){
					f[j][k]-=h[p0][j][k];
				}
			}
		}
		//if(i==2)cout<<f[(1<<n)-1][6]<<" "<<h[2][0][2]<<endl;
	}
	ld ans=f[(1<<n)-1][C*(n+1)]/pow(C,n);
	For(i,1,n)ans/=i;
	printf("%.12f\n",ans);
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    int N,K;
    private static Scanner sc;
    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            N = sc.nextInt();
            K = sc.nextInt();
            long[] input = new long[100000];
            for (int i = 0; i < N; i++) {
                input[i] = sc.nextLong();
            }

            long min = Long.MAX_VALUE;

            for (int i = 0; i < N - K + 1; i++) {
                int left = i;
                int right = i + K - 1;
                long leftAbs = Math.abs(input[left]);
                long rightAbs = Math.abs(input[right]);
                long tmp;
                if ((input[left] > 0 && input[right] > 0) || (input[left] < 0 && input[right] < 0)) {
                    tmp = Math.max(leftAbs, rightAbs);
                }else
                    tmp = Math.min(leftAbs, rightAbs)*2 + Math.max(leftAbs, rightAbs);
                // System.out.println(String.format("%d: %d => %d",left,right, tmp));

                if (min > tmp) min = tmp;
            }

            System.out.println(min);


        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 49364
if __name__ == "__main__":
  list_N_M = input().split(' ')
  N = int(list_N_M[0])
  M = int(list_N_M[1])
  
  list_str_H_all = input().split(' ')
  H = [0] * N
  for i in range(len(list_str_H_all)):
    H[i] = int(list_str_H_all[i])
  
  is_good_vp = [True] * N
  
  for _ in range(M):
    str_A_B = input().split(' ')
    A = int(str_A_B[0])
    B = int(str_A_B[1])
    
    if H[A-1] > H[B-1]:
      is_good_vp[B-1] = False
    elif H[B-1] > H[A-1]:
      is_good_vp[A-1] = False
    else:
      is_good_vp[A-1] = False
      is_good_vp[B-1] = False
    
  output = 0
  for i in range(N):
    if is_good_vp[i]:
      output += 1
      
  print(output)


Measured memory_bytes: 20804
import sys,math,copy,queue,itertools,bisect
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

R = NI()
print (2 * math.pi * R)


Measured memory_bytes: 68672
#include<iostream>
#include<algorithm>

using namespace std;

static const int MAX = 1000000;

void output(int A[], int N);

void insertionSort(int A[],int n,int g);
void shellSort(int A[],int n);

static int cnt = 0;

int main() {

	int A[MAX], N;

	//input
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}

	shellSort(A, N);

	return 0;
}

void insertionSort(int A[],int n,int g) {
	int v;
	int j;
	for (int i = g; i <n; i++)
	{
		v = A[i];
		j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j = j - g;
			cnt++;
		}
		A[j + g] = v;
	}
}

void shellSort(int A[],int n) {
	const int m = 11;
	int m_count = 0;
	int G[m] = { 90000,30000,10000,3000 ,729,243 ,81 , 27 ,9,4,1};


	for (int i = 0; i < m;i++)
	{
		if (G[i] > n) {
			continue;
		}
		else {
			m_count++;
			insertionSort(A, n, G[i]);
		}
	}

	cout << m_count<< endl;

	for (int i = 0; i < m_count-1; i++)
	{
		cout << G[m - m_count+i] <<" "<<flush;
	}
	cout << G[10] << endl;
	cout << cnt << endl;
	output(A, n);
}


void output(int A[], int N) {
	for (int i = 0; i < N; i++)
	{
		cout << A[i] <<endl;
	}
}


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

int main() {
  int n, l;
  cin >> n >> l;
  int a[n], sum = 0;
  for ( int i = 0; i < n; i++ ) {
    a[i] = l + i;
    sum += a[i];
  }
  int min = 20001, pos = -1;
  for ( int i = 0; i < n; i++ ) {
    if ( min > abs(a[i]) ) { min = abs(a[i]); pos = i; }
  }
  cout << sum-a[pos] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define show(x) cout << x << '\n'
#define showh(x) cout << x << ' '
#define go(i, a, n) for (ll i = a; i < n; i++)
#define gor(i, a, n) for (ll i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
auto t1 = chrono::high_resolution_clock::now();
bool prime[1000001];
ll expo(ll a, ll b)
{
  a = a % mod;
  b = b % mod;
  if (b == 0)
    return 1;
  if (b % 2)
    return ((a % mod) * (expo((a * a) % mod, b / 2) % mod)) % mod;
  return expo((a * a) % mod, b >> 1) % mod;
}
ll mul(ll a, ll b)
{
  a = a % mod;
  b = b % mod;
  if (b == 0)
    return 0;
  if (b % 2)
    return ((a % mod) + (mul((a + a) % mod, b >> 1) % mod)) % mod;
  return mul((a + a) % mod, b >> 1) % mod;
}

bool ispoweroftwo(ll x)
{
  return x && !(x & (x - 1));
}
ll xorcal(ll n)
{
  if (n % 4 == 0)
    return n;
  if (n % 4 == 1)
    return 1;
  if (n % 4 == 2)
    return n + 1;
  if (n % 4 == 3)
    return 0;
}
void sieve(ll n)
{
  memset(prime, true, sizeof(prime));
  prime[0] = false;
  prime[1] = false;
  for (ll i = 2; i * i <= n; i++)
  {
    if (prime[i] == true)
    {
      for (ll j = i * i; j <= n; j += i)
        prime[j] = false;
    }
  }
}
bool isprime(ll n)
{
  if (n <= 1)
    return false;
  if (n <= 3)
    return true;

  if (n % 2 == 0 or n % 3 == 0)
    return false;

  for (ll i = 5; i * i <= n; i += 6)
  {
    if (n % i == 0 or n % (i + 2) == 0)
      return false;
  }
  return true;
}

ll modinverse(ll a, ll m)
{
  ll m0 = m;
  ll y = 0, x = 1;

  if (m == 1)
    return 0;

  while (a > 1)
  {
    ll q = a / m;
    ll t = m;

    m = a % m;
    a = t;
    t = y;

    y = x - q * y;
    x = t;
  }

  if (x < 0)
    x += m0;

  return x;
}

ll gcd(ll a, ll b)
{
  if (a == 0)
    return b;
  return (b % a, a);
}
bool ispalindrome(string s)
{
  string t = s;
  reverse(t.begin(), t.end());
  if (t == s)
    return true;
  return false;
}
void binary(ll a[], ll n)
{
  gor(i, 0, 64)
  {
    ll k = n >> i;
    a[i] = k & (ll)1;
  }
}
ll countBits(ll n)
{
  if (n == 0)
    return 0;
  return 1 + countBits(n & (n - 1));
}
bool sorted(vector<ll> &v, ll n)
{
  if (n == 0)
    return true;
  return v[n - 1] >= v[n - 2] and sorted(v, n - 1);
}
ll getsum(vector<ll> &v, ll n)
{
  ll sum = 0;
  go(i, 0, n) sum += v[i];
  if (sum != (n * (n + 1)) / 2)
    return 1;
  return 0;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  //cout << "Case #" << p << ": " << str << endl;
  int a, b, c;
  cin >> a >> b >> c;
  cout << c << " " << a << " " << b << endl;
  auto t2 = chrono::high_resolution_clock::now();
  auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
  clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
  return 0;
}

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

using ll = long long;

int main() {
  while (true) {
    ll n, m, H, K;
    cin >> n >> m >> H >> K; // only 'H' and 'K' are capital
    if (n + m + H + K == 0) return 0;
    
    vector<vector<tuple<ll, ll, ll, ll>>> G(n); // to, cost, time, company
    
    for (int i = 0; i < m; i++) {
      ll a, b, c, h, r;
      cin >> a >> b >> c >> h >> r;
      a--;
      b--;
      r--;
      G[a].emplace_back(make_tuple(b, c, h, r));
      G[b].emplace_back(make_tuple(a, c, h, r));
    }
    
    ll s, t, p;
    cin >> s >> t >> p;
    s--;
    t--;
    
    vector<ll> d(p);
    vector<ll> k(p);
    for (int i = 0; i < p; i++) {
      ll l;
      cin >> l >> d[i];
      for (int j = 0; j < l; j++) {
        ll keep;
        cin >> keep;
        keep--;
        k[i] += (1 << keep);
      }
    }
    
    // bit DP
    vector<ll> dp_pass((1 << K), 1e18);
    dp_pass[0] = 0;
    for (int bit = 0; bit < (1 << K); bit++) {
      for (int i = 0; i < p; i++) {
        dp_pass[bit | k.at(i)] = min(dp_pass[bit | k.at(i)], dp_pass[bit] + d.at(i));
      }
    }
    
    // extended dijkstra
    ll ans = 1e18;
    for (int bit = 0; bit < (1 << K); bit++) {
      if (dp_pass[bit] == 1e18) continue;
      vector<vector<ll>> dp(n, vector<ll>(H + 1, 1e18)); // dp[i][j]: min cost at vertex i, rest time = j
      dp[s][H] = 0;
      priority_queue<tuple<ll, ll, ll>, vector<tuple<ll, ll, ll>>, greater<tuple<ll, ll, ll>>> pq; // cost, present position(vertex), rest time
      pq.push(make_tuple(0, s, H));
      while (!pq.empty()) {
        auto tmp = pq.top();
        ll cost = get<0>(tmp), now = get<1>(tmp), time = get<2>(tmp);
        pq.pop();
        if (dp[now][time] < cost) continue;
        for (int i = 0; i < G[now].size(); i++) {
          auto tmp = G[now][i];
          ll nto = get<0>(tmp), ncost = get<1>(tmp), ntime = get<2>(tmp), ncom = get<3>(tmp);
          if (bit & (1 << ncom)) {
            if (time >= ntime && dp[nto][time - ntime] > cost) {
              dp[nto][time - ntime] = cost;
              pq.push(make_tuple(cost, nto, time - ntime));
            }
          }
          else {
            if (time >= ntime && dp[nto][time - ntime] > cost + ncost) {
              dp[nto][time - ntime] = cost + ncost;
              pq.push(make_tuple(cost + ncost, nto, time - ntime));
            }
          }
        }
      }
      
      ll keep = 1e18;
      for (int j = 0; j <= H; j++) keep = min(keep, dp[t][j]);
      if (keep + dp_pass[bit] < ans) ans = min(ans, keep + dp_pass[bit]);
    }
    
    if (ans == 1e18) cout << -1 << '\n';
    else cout << ans << '\n';
  }
}


Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e9+7;
const ll N = 11;
ll a;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>a;
	char d = 'C';
	if(a>999)d='D';
	cout<<"AB"<<d<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
int main() {
    ll H;
    cin >> H ;
    ll sum=0;
    int count=0;
    ll a=1;
    
    while(H>0){
        count++;
        H/=2;
    }
    for(int i=0;i<count;i++){
        sum+=a;
        a=a*2;
    }
    
    cout << sum << endl;
    
}


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

using namespace std;

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

    int n, m;
    cin >> n >> m;

    map <int, int> mp;
    unsigned long long sol = 0;
    for(int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        ++mp[x];
    }

    for(int i = 0; i < m; ++i) {
        long long x, y;
        cin >> x >> y;
        mp[y] += x;
    }

    for(auto iter = mp.rbegin(); iter != mp.rend() && n > 0; ++iter) {
        if (iter->second >= n) {
            sol = sol + 1ll * n * iter->first;
            n = 0;
        } else {
            n -= iter->second;
            sol = sol + 1ll * iter->second * iter->first;
        }
    }

    cout << sol;

    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int h,w;

void solve(vector<string> &board , vector<vector<int>> &min_vv,int x,int y,int count, bool streak){
    if (x < 0 || x > w-1 || y < 0 || y > h-1)return;
    if (board.at(y).at(x) == '#'){
        if(streak);
        else{
            count++;
            streak = true;
        }
    }
    else streak = false;
    if (count >= min_vv.at(y).at(x))return;
    min_vv.at(y).at(x) = count;

    solve(board,min_vv,x+1,y,count,streak);
    solve(board,min_vv,x,y+1,count,streak);
}



int main(void){
    // Your code here!
    cin >> h>> w;
    vector<string> board(h);
    vector<vector<int>> min_vv(h,vector<int>(w,10000));
    rep(i,h) cin >> board.at(i);
    solve(board,min_vv,0,0,0,false);
    cout << min_vv.at(h-1).at(w-1) << endl;

}


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

using namespace std;

typedef long long ll;

int main(){
    int n;
    cin>>n;
    vector<ll> t(n);
    for(int i=0;i<n;i++){
        cin>>t[i];
    }

    ll res = t[0];
    for(int i=1;i<n;i++){
        res = res/__gcd(res,t[i])*t[i];
    }
    cout<<res;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,  P[1001], K, i, sum;
int main()
{
    cin >> N >> K;
    for(i=0;i<N;i++)
    {
        cin >> P[i];
    }
    sort(P, P+N);
    for(i=0;i<K;i++)
        sum+=P[i];
    cout << sum << endl;
    return 0;
}


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

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

	string ans = strS;
	if (strS[strS.size()-1]== 's')
	{
		ans += "es";
	}
	else
	{
		ans += 's';
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var xi = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var mean = (int)Math.Round(xi.Average());
            Console.WriteLine(xi.Select(x => CalcHealth(x, mean)).Sum());
        }

        static int CalcHealth(int x, int p) => (x - p) * (x - p);
    }
}


Measured memory_bytes: 11348
#include <iostream>
#include <vector>

int main() {
    int n;
    std::cin >> n;
    std::vector<int> x(n);
    for (int i = 0; i < n; i++) {
        std::cin >> x[i];
    }

    int ans = 1e9;
    for (int p = 0; p <= 100; p++) {
        int cand = 0;
        for (int i = 0; i < n; i++) {
            cand += (x[i] - p) * (x[i] - p);
        }
        ans = std::min(ans, cand);
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
using namespace std;
int main()
{
    long long sum,num,min;
    vector<int> v1;
    while(cin>>num)
    {
        min=pow(2,63);
        for(int i=0;i<num;i++)
        {
            int in;
            cin>>in;
            v1.push_back(in);
        }
       for(int i=1;i<=100;i++)
        {
            sum=0;
            for(int j=0;j<num;j++)
            {
                sum+=(i-v1[j])*(i-v1[j]);
            }
            if(sum<min)
            {
            min=sum;
            }
        }
        cout<<min<<endl;
        v1.clear();
        
    }
}

Measured memory_bytes: 256