akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for (int i = s; i < (int)(n); i++)
using ll = long long;
using pll = pair<ll,ll>;
using vvll = vector<vector<ll>>;
using vll = vector<ll>;
using vstr = vector<string>;
const ll MOD=1000000007;
vll dx{0,1,0,-1};
vll dy{1,0,-1,0};
int i,j,k,n,m,a,b,c;
ll res,ans;

template <class type> void printVector(vector<type> vec){
    stringstream ss;
    ll n=vec.size();
    for(ll i=0;i<n;i++)
    {
        ss<<vec[i]<<" ";
        if(i!=n-1)ss<<" ";
    }
    cout<<ss.str()<<endl;
}

void solve(){
    string S;
    cin>>S;
    ll size=S.size()-1;
    ll sum=0;
    for(ll b=0;b<(1<<size);b++)
    {
        vll terms;
        string t=S;
        for(ll i=0;i<size;i++)
        {
            if(b & (1<<i))
            {
                terms.emplace_back(stol(t.substr(0,i+1)));
                for(ll j=0;j<i+1;j++)t[j]='0';
            }
        }
        terms.emplace_back(stol(t));
        for(ll i=0;i<terms.size();i++)sum+=terms[i];
    }
    cout<<sum;
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
using u64 = uint_fast64_t;
using i64 = int_fast64_t;

int main(){
  u64 n;
  cin >> n;
  u64 k;
  cin >> k;
  vector<u64> h(n);
  for(auto &e : h) cin >> e;
  cout << count_if(h.cbegin(), h.cend(), [k](u64 x){return x >= k;});
}


Measured memory_bytes: 1024
a = list(map(int, input().split()))
n = int(input())
a[0] *= 4
a[1] *= 2
a[3] /= 2
m = min(a)
i = a.index(m)
if i != 3:
    print(n*a[i])
else:
    k = min(a[:-1])
    j = a.index(k)
    print((n//2)*int(2*a[3])+(n%2)*a[j])



Measured memory_bytes: 3188
from scipy.special import comb
s = int(input())
mod = 10 **9 + 7
i = 1
ans = 0

if s >= 3:
    while 3 * i <= s:
        k = 2 * i
        ans = ans + comb(s-k-1, i-1, exact=True)
        i += 1

print(int(ans % mod))

Measured memory_bytes: 41960
package main

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

type Node struct {
	value int
	left *Node
	right *Node
}


/****************************************************************
*関数insert():													*
*	 挿入される二分探索木のrootノードを表すポインタrootと				*
*	 挿入したいノードのvalueを引数に、適切な葉に新たなノードを挿入して、	*
*	 挿入された二分探索木のルートノードのポインタを返す関数				*
*****************************************************************/
func insert(root *Node, val int) *Node {

	// 二分探索木がまだ構築されていないときはここが呼び出される
	if root == nil {
		return &Node{val, nil,nil}
	}

	// すでにある二分探索木に対するノード（value: val）を挿入する
	// ここを抜けるとparentに挿入されるノードの親へのポインタが入っている
	// 変数nodeは、挿入すべき場所を探すための一時的なポインタ変数
	var parent *Node
	node := root
	for node != nil {
		parent = node
		if node.value > val {
			node = node.left
		} else {
			node = node.right
		}
	}

	// 新たなノードの挿入を実行
	if parent.value > val {
		parent.left = &Node{val, nil,nil}
	} else {
		parent.right = &Node{val, nil, nil}
	}

	// 二分探索木の根は変わらないのでそのまま返す
	return root
}

func printNodes(nodes []int) {
	// 木の走査によって得られたint型スライスを引数に、
	// 指定されたフォーマットに出力する関数
	writer := bufio.NewWriter(os.Stdout)
	for _, v := range nodes{
		writer.Write([]byte(fmt.Sprintf(" %d", v)))
	}
	writer.Write([]byte("\n"))
	writer.Flush()
}

func preorder(root *Node, memo []int) []int {
	// 引数rootが根となっている二分探索木に対して先行巡回によって
	// 各ノードをを舐めて、引数memoで与えられる空のスライスに書き込み、
	// 書き込まれた後のスライスを返す関数
	if root != nil {
		memo = append(memo, root.value)
		memo = preorder(root.left, memo)
		memo = preorder(root.right, memo)
	}
	return memo
}

func inorder(root *Node, memo []int) []int {
	// 引数rootが根となっている二分探索木に対して中間巡回によって
	// 各ノードをを舐めて、引数memoで与えられる空のスライスに書き込み、
	// 書き込まれた後のスライスを返す関数
	if root != nil {
		memo = inorder(root.left, memo)
		memo = append(memo, root.value)
		memo = inorder(root.right, memo)
	}
	return memo
}

/****************************************************************
*関数find():														*
*	 探索対象の二分探索木のrootノードを表すポインタrootと				*
*	 探したいノードのtargetを引数に、								*
*	 存在すればtrueを、なければfalseを返す関数						*
*****************************************************************/
func find(root *Node, target int) bool {
	switch {
	//　rootを根とする二分探索木が未構築
	case root == nil:
		return false
	case root.value == target:
		return true
	case root.value > target:
		return find(root.left, target)
	default:
		return find(root.right, target)
	}
}

func main() {
	var n int
	var root *Node
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _  = strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		scanner.Scan()
		operation := scanner.Text()
		switch operation {
		case "insert":
			scanner.Scan()
			value, _ := strconv.Atoi(scanner.Text())
			root = insert(root, value)
		case "print":
			printNodes(inorder(root, []int{}))
			printNodes(preorder(root, []int{}))
		case "find":
			scanner.Scan()
			target, _ := strconv.Atoi(scanner.Text())
			if find(root, target) {
				fmt.Println("yes")
			} else {
				fmt.Println("no")
			}
		default:
			panic("No such operation!")
		}
	}
}


Measured memory_bytes: 37580
#if __has_include("D:/dhiraj/Programming/debug.h")
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
#endif

// Loops --------------------------------------------------------------------

#define loop(i,s,e)         for(ll i=(s); i<(e); i++)
#define rloop(i,s,e)        for(ll i=(s); i>=(e); i--)
#define iter(it,var)        for(auto it=var.begin(); it!=var.end(); it++)
#define riter(it,var)       for(auto it=var.rbegin(); it!=var.rend(); it++)

// Extra --------------------------------------------------------------------

#define fast                ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ull                 unsigned long long int
#define ll                  long long int
#define ld                  long double
#define endl                '\n'
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()

// Template -----------------------------------------------------------------

template <typename T> 
inline bool inrange(T a, T l, T r) {
    if(l>r) swap(l,r);
    return (a>=l and a<=r);
}
template <typename T, typename U> 
inline bool exist(T val, U &any) {
    return (any.find(val) != any.end());
}
// multiple input
template <typename T> 
inline void inp(T &any) {
    cin >> any;
}
template <typename T, typename... U> 
inline void inp(T &a, U &...b) {
    cin >> a; inp(b...);
}
// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

#define pie (2*acos(0.0))
void solve(ll &T)
{
    ll r;
    std::cin>>r;
    cout<<fixed<<setprecision(20);
    std::cout<<2ll*r*pie<<endl;
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt","r",stdin);
        freopen("D:/dhiraj/Programming/o1.txt","w",stdout);
    #endif
    
    fast;
    int t = 1;
    loop(i,1,t+1)
    {
        cerr<<"Case #"<<i<<"\n";
        solve(i);
    }
    return 0;
}


Measured memory_bytes: 3800
#include<stdio.h>
int main()
{
    char s[4];
    scanf("%s", s);
    int a, b, c;
    a = b = c = 0;
    int i;
    for (i = 0; i < 3; i++)
    {
        if (s[i] == 'a')
            a++;
        if (s[i] == 'b')
            b++;
        if (s[i] == 'c')
            c++;
    }
    if (a == 1 && b == 1 && c == 1)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 128
N = int(input())
S = input()

#print(N)
if (N % 2 != 0):
    print('No')
else:
    half = len(S) / 2
    part = S[0:int(len(S)/2)]
    #print(S[int(len(S)/2):])
    if S[int(len(S)/2):] == part:
        print("Yes")
    else:
        print('No')


Measured memory_bytes: 2940
package main

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

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	a, b, c := r.nextInt(), r.nextInt(), r.nextInt()

	fmt.Fprintln(stdout, []string{"No", "Yes"}[b2i(c-a-b > 0 && 4*a*b < pow(c-a-b, 2, 0))])
}


Measured memory_bytes: 640
def solve(n, xs, ys)
  len = [*0...n].combination(2).map do |i, j|
    dx = xs[i] - xs[j]
    dy = ys[i] - ys[j]
    Math.sqrt(dx ** 2 + dy ** 2)
  end.inject(:+)
  sprintf('%.10f', len / (n / 2.0))
end

n = gets.to_i
xs = []
ys = []
n.times do |_|
  xy = gets.chomp.split.map(&:to_i)
  xs << xy.first
  ys << xy.last
end

puts solve(n, xs, ys)


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380



int main() {
	int n;
	LLI c[5] = {0,0,0,0,0};
	cin >> n;
	REP(i, n) {
		string tmp;
		cin >> tmp;
		switch (tmp[0]) {
		case 'M':
			c[0]++;
			break;
		case 'A':
			c[1]++;
			break;
		case 'R':
			c[2]++;
			break;
		case 'C':
			c[3]++;
			break;
		case 'H':
			c[4]++;
			break;
		}
	}

	LLI ans = 0;
	FOR(i,0, 3) {

		FOR(j, i+1, 4) {

			FOR(k, j+1, 5) {
				ans += c[i] * c[j] * c[k];
			}
		}
	}
	cout << ans;

	return 0;
}

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

int main() {
    int N, L;
    cin >> N >> L;
    int ans = 0;
    if (L > 0) {
        for (int i = L + 1; i <= L + N - 1; i++) ans += i;
    } else if (L + N - 1 < 0) {
        for (int i = L; i <= L + N - 2; i++) ans += i;
    } else {
        for (int i = L; i <= L + N - 1; i++) ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# from inspect import currentframe
# from sys import exit, stderr


# debug function
# def debug(*args):
#     names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
#     print(', '.join(names.get(id(arg),'???') + str(id(arg)) +' = '+repr(arg) for arg in args), file=stderr)


src = list(str(input()))
tokens = [tok for tok in src if tok != " "]
# debug(tokens)

# "" as EOF
tokens.append("")
cur = 0
def parse_formula():
    return parse_or()

def parse_or():
    global cur
    lhs = parse_and()
    if tokens[cur] == "|":
        cur += 1
        rhs = parse_or()
        zero = lhs[0] + rhs[0]
        one = min(lhs[1], lhs[0] + rhs[1])
        return (zero, one)
    return lhs

def parse_and():
    global cur
    lhs = parse_term()
    if tokens[cur] == "&":
        cur += 1
        rhs = parse_and()
        zero = min(lhs[0], lhs[1] + rhs[0])
        one = lhs[1] + rhs[1]
        return (zero, one)
    return lhs

def parse_term():
    global cur
    if tokens[cur] == "?":
        cur += 1
        # debug(cur, 1)
        return [1, 1]
    elif tokens[cur] == "(":
        cur += 1
        # debug(cur, "or")
        res = parse_or()
        if tokens[cur] != ")":
            raise Exception("not closed")
        cur += 1
        # debug(cur)
        return res
ans = parse_formula()
print(ans[0], ans[1])
# debug(cur)
# print(len(tokens))



Measured memory_bytes: 9072
// template {{{

#include <bits/stdc++.h>
using namespace std;

#define loop(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) loop(i, 0, n)
#define rloop(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define rrep(i, n) rloop(i, 0, n)
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define all(c) std::begin(c), std::end(c)
#define mp std::make_pair
#define mt std::make_tuple
#define fi first
#define se second
#define popcnt __builtin_popcountll

using uint = std::uint32_t;
using ll = std::int64_t;
using ull = std::uint64_t;
using ld = long double;

template<typename T, size_t H, size_t W>
using matrix = std::array<std::array<T, W>, H>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 10;
const ll LLINF = 1e18 + 10;

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

template<typename T>
inline T sq(T x){ return x * x; }

template<typename T, typename U>
inline bool chmax(T &x, U y){ if (x >= y) return false; x = y; return true; }

template<typename T, typename U>
inline void chmin(T &x, U y){ if (x <= y) return false; x = y; return true; }

template<typename T>
inline void sort(T &c){ std::sort(all(c)); }

template<typename T>
inline void reverse(T &c){ std::reverse(all(c)); }

template<typename T>
inline void unique(T &c){ std::sort(c); c.erase(std::unique(all(c)), std::end(c)); }

// }}}

using pr = pair<int, int>;

int conv[256];

int main()
{
	rep(i, 4) conv["CHSD"[i]] = i;
	rep(i, 13) conv["23456789TJQKA"[i]] = i;

	string s;
	while (cin >> s, s != "#"){
		int t = conv[s[0]];
		pr c[13][4];
		int ns = 0, ew = 0;
		rep(i, 4) rep(j, 13){
			cin >> s;
			c[j][i] = pr(conv[s[1]], conv[s[0]]);
		}
		int d = 0;
		rep(i, 13){
			pr cmp[4][13];
			rep(j, 4) rep(k, 13){
				cmp[j][k] = pr(0, k);
				if (j == c[i][d].fi) cmp[j][k].fi = 1;
				else if (j == t) cmp[j][k].fi = 2;
			}
			pr mx(-1, -1);
			rep(j, 4){
				if (mx < cmp[c[i][j].fi][c[i][j].se]){
					mx = cmp[c[i][j].fi][c[i][j].se];
					d = j;
				}
			}
			(d & 1 ? ew : ns)++;
		}
		if (ns > ew) cout << "NS " << ns - 6 << endl;
		else cout << "EW " << ew - 6 << endl;
	}
}

Measured memory_bytes: 3096
import math as mt
import numpy as np

string = input()
collect = []
word = ''
count = 0
n = len(string)
i = 0
for x in string:
    if x != 'x':
        word += x
        collect.append(count)
        if i == n-1:
            collect.append(0)
        count = 0
    elif i == n-1:
        count += 1
        collect.append(count)
    else:
        count += 1
    i += 1

nl = len(word) - 1
i = 0
while i < nl:
    if word[i] != word[nl]:
        print(-1)
        exit()
    i += 1
    nl -=  1
nl = len(collect) - 1
i = 0
out = 0
while i < nl:
    out += np.abs(collect[i] - collect[nl])
    i += 1
    nl -= 1
print(out)


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

int main() {
    int K, S;
    cin >> K >> S;
    int count = 0;
    for(int x = 0; x <= K ; x++) {
        for(int y = 0; y <= K; y++) {
            int z = S - x - y;
            if(z >= 0 && z <= K) {
                count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int mod = 1e9+7;

int a[1000000];
signed main(){
	int n, ans = 1;
	scanf("%lld", &n);
	rrep(i,n){
		int x;
		scanf("%lld", &x);
		a[x] = i;
	}
	a[n+1] = inf;
	int cnt = 0;
	rrep(i,n){
		if(a[i] < a[i+1])cnt++;
		else{
			ans = max(ans, cnt+1);
			cnt = 0;
		}
	}
	ans = max(ans, cnt);
	printf("%lld\n", n-ans);
	return 0;
}




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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int n, k, cur=0;
int a[N];

int32_t main()
{
	IOS;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];

    //for( int i = 1; i <= n; i++ ) cout << bitset <50>(a[i]) << endl;
	for(int i=50;i>=0;i--)
	{
		int cnt=0;
		for(int j=1;j<=n;j++)
		{
			if((a[j]>>i)&1)
				cnt++;
		}
		//cout << i << " " << cnt <<endl;
		if(cnt*2<=n && (cur+(1LL<<i)<=k))
			cur+=(1LL<<i);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		ans+=(cur^a[i]);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
// To give an input string after a integer or double is taken input
//cin.ignore();			// better to use 2 times getline(cin,s);
// g++ file.cpp -std=c++17
#define pb push_back
#define mk make_pair
#define siz size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
}


int main(void)
{
	fast();
	int a,b;
	cin>>a>>b;
	if(a>=10)
	{
	    cout<<b<<endl;
	}
	else
	{
	    int c = 100*(10-a);
	    cout<<b+c<<endl;
	}
}

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

int main() {
	int s = 0;
	int k = 0;
	int v;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> v;
			if (i == j)s += v;
			else k += v;
		}
	}
	if (2*s == k) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define INF 1e9
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N, M, Q, H, W, D, L, R, K,X;
ll A;
ll B;
ll ans;
string S;
char s[52][52];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll x[100000];
int main() {
	cin >> A >> B;
	if ((A*B)%2 != 0)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	cin >> ans;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
F = [int(input().replace(' ', ''), 2) for _ in range(N)]
P = [list(map(int,input().split())) for _ in range(N)]

ans = -(10**9+7)
for i in range(1, 2**10):
  tmp = 0
  for f, p in zip(F, P):
    tmp += p[bin(f&i).count('1')]
  ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[2][n];
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  int dp[2][n];
  dp[0][0] = a[0][0];
  dp[1][0] = a[0][0] + a[1][0];
  for (int i = 1; i < n; i++) {
    dp[0][i] = dp[0][i - 1] + a[0][i];
    dp[1][i] = max(dp[0][i], dp[1][i - 1]) + a[1][i];
  }
  cout << dp[1][n - 1] << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	Scanner in = new Scanner(System.in);

	public Main() {
		while (true) {
			int N = in.nextInt();
			int M = in.nextInt();
			if (N == 0 && M == 0) break;
			int[][] dp = new int[N+1][256];
			int[] c = new int[M];
			
			for (int i = 0; i < M; i++) {
				c[i] = in.nextInt();
			}
			
			for (int i = 0; i < dp.length; i++) 
				for (int j = 0; j < dp[i].length; j++) 
					dp[i][j] = Integer.MAX_VALUE;
			
			dp[0][128] = 0;
			
			for (int i = 0; i < N; i++) {
				int next = in.nextInt();
				for (int j = 0; j < 256; j++) {
					if (dp[i][j] != Integer.MAX_VALUE) {
						for (int k = 0; k < c.length; k++) {
							int dif = j + c[k];
							if (dif < 0) dif = 0;
							else if (dif >= 256) dif = 255;						
							int x = (next - dif) * (next - dif);
							dp[i+1][dif] = Math.min(dp[i+1][dif], dp[i][j] + x);
						}
					}
				}
			}
			
			int ans = Integer.MAX_VALUE;
			for (int i = 0; i < 256; i++) {
				ans = Math.min(ans, dp[N][i]);
			}
			System.out.println(ans);
			
		}
 	}
	
	public static void main(String[] args) {
		new Main();
	}
}

Measured memory_bytes: 134184
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

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

    cout << min(A, B) + min(C, D) << endl;
}


Measured memory_bytes: 256
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let h: usize = itr.next().unwrap().parse().unwrap();
    let w: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();
    let d: Vec<Vec<char>> = (0..h)
        .map(|_| itr.next().unwrap().chars().collect())
        .collect();
    let mut s: Vec<Vec<usize>> = vec![vec![0; w + 5]; h + 5];
    for i in 0..h {
        for j in 0..w {
            s[i + 1][j + 1] = (d[i][j] == '1') as usize;
        }
    }
    for i in 1..h + 1 {
        for j in 1..w + 1 {
            s[i][j + 1] += s[i][j];
        }
    }
    for i in 1..h + 1 {
        for j in 1..w + 1 {
            s[i + 1][j] += s[i][j];
        }
    }

    let mut ans = 1 << 30;
    // hの選び方では絶対達成できない場合がある？
    for bit in 0..(1 << h - 1) {
        let mut count = 0;
        let mut x = 0;
        let mut good = false;
        for i in 0..w {
            let mut ok = true;
            let mut y = 0;
            for j in 0..h {
                if bit >> j & 1 == 1 || j == h - 1 {
                    if s[j + 1][i + 1] + s[y][x] - s[j + 1][x] - s[y][i + 1] > k {
                        ok = false;
                    }
                    y = j + 1;
                }
            }
            if !ok {
                count += 1;
                x = i;
            } else {
                good = true;
            }
        }
        if good {
            ans = std::cmp::min(ans, count + (bit as u32).count_ones());
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
def getlist():
	return list(map(int, input().split()))

N, M = getlist()
L = [0 for i in range(N + 100)]
L[0] = 1

for i in range(M):
	a = int(input())
	L[a] = -1


for i in range(N):
	if L[i] != -1:
		if L[i + 1] != -1:
			L[i + 1] += L[i]
			L[i + 1] = L[i + 1] % 1000000007
		if L[i + 2] != -1:
			L[i + 2] += L[i]
			L[i + 2] = L[i + 2] % 1000000007


print(L[N] % 1000000007)

Measured memory_bytes: 7048
<?php

fscanf(STDIN, "%d %d", $n, $m);

$max = 1;
$divs = [];
for ($i = 1; $i <= sqrt($m); ++$i) {
    if ($m % $i == 0) {
        $md = $m / $i;
        if ($n - 1 <= $md - 1) {
            $max = max($i, $max);
        }

        $md = $i;
        if ($n - 1 <= $md - 1) {
            $max = max($m / $i, $max);
        }
    }
}

echo $max;


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

struct point
{
	long long dist; int name;
	bool operator<(const point& rhs) const {
		return dist > rhs.dist;
	}
};
struct edge {
	long long length; int from; int to;
};
const long long INFTY = 1000000000000000000;
const int MAX_V = 100003;
const int BLACK = 1;
const int WHITE = 0;
int color[MAX_V];
vector<edge> V1[MAX_V], V2[MAX_V];
priority_queue<point> q;

bool allblack(int v) {
	for (int i = 0; i < v; i++) {
		if (color[i] == WHITE) { return 0; }
	}
	return 1;
}

void dijkstra(int r, int v, point p[], vector<edge> V[]) {//rは始点、n頂点
	for (int i = 0; i < MAX_V; i++) {
		color[i] = WHITE;
		p[i].dist = INFTY;
		p[i].name = i;
	}
	p[r].dist = 0;
	q.push(p[r]);
	while (!q.empty() && !allblack(v)) {
		point t;
		t = q.top();
		q.pop();
		if (color[t.name] == WHITE) {
			color[t.name] = BLACK;	
			for (int i = 0; i < V[t.name].size(); i++) {
				edge x = V[t.name][i];
				if (x.length + t.dist < p[x.to].dist && color[x.to] == WHITE) {
					p[x.to].dist = x.length + t.dist;
					q.push(p[x.to]);
				}
			}
		}
	}
}

point cost_y[MAX_V];
point cost_s[MAX_V];
long long anss[MAX_V];
int main() {
	int v, e; int r1,r2;
	cin >> v >> e >> r1 >> r2;
	for (int i = 0; i < e; i++) {
		long long s, t, d, sss;
		cin >> s >> t >> d >> sss;
		edge a, b;
		a.length = d; a.from = s; a.to = t;
		b.length = sss; b.from = s; b.to = t;
		V1[s].push_back(a);
		V2[s].push_back(b);
		swap(a.from, a.to);
		swap(b.from, b.to);
		V1[t].push_back(a);
		V2[t].push_back(b);
	}
	dijkstra(r1, v, cost_y, V1);
	dijkstra(r2, v, cost_s, V2);
	for (int i = 1; i <= v; i++) {
		anss[i] = cost_y[i].dist + cost_s[i].dist;
	}
	for (int i = v - 1; i >= 1; i--) {
		anss[i] = min(anss[i], anss[i + 1]);
	}
	for (int i = 1; i <= v; i++) {
		cout << 1000000000000000 - anss[i] << endl;
	}
}

Measured memory_bytes: 21624
#include <bits/stdc++.h>
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    int N;
    cin >> N;
    vector<int> res(N, 0);
    for (int i = 0; i < N-1; ++i) {
        int a; cin >> a; --a;
        res[a]++;
    }
    for (auto v : res) cout << v << endl;
}



Measured memory_bytes: 4060
#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define M 1000000007
#define SI(x) scanf("%d", &x)
#define PI(x) printf("%d\n", x)
#define SL(x) scanf("%I64d", &x)
#define PL(x) printf("%I64d\n", x)
#define PB push_back
#define MP make_pair

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    int g = __gcd(a, b);

    if(c%g == 0) cout << "YES" << endl;

    else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
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; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{
    int n,m,x;
    cin >> n >> m >> x;
    int col[n+1],cumsum[n+1];
    for (int i=0; i<n+1; ++i)
    {
      col[i] = cumsum[i] = 0;  
    }
    for (int i=0; i<m; ++i)
    {
        int tmp = 0;
        cin >> tmp;
        col[tmp] = 1;
    }

    cumsum[0] = col[0];
    for (int i=0; i<n; ++i)
    {
        cumsum[i+1] = cumsum[i] + col[i+1];
    }

    cout << min(cumsum[x],cumsum[n]-cumsum[x]) << endl;

    return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

const ll mod = 1000000007;

ll mpow(ll x, ll n) {
	ll ans = 1; x %= mod;
	while (n != 0) {
		if (n & 1) ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}

ll inv_mod(ll a) { return mpow(a, mod - 2); }

class Factorial {
private:
	vector<ll> fac;
	vector<ll> ifac;
public:

	Factorial(ll N) {
		fac.push_back(1);
		for (int i = 0; i < N; i++) fac.push_back(fac[i] * (i + 1) % mod);
		ifac.resize(N + 1);
		ifac[N] = inv_mod(fac[N]);
		for (int i = 0; i < N; i++) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
	}

	ll fact(ll a) { return fac[a]; }
	ll ifact(ll a) { return ifac[a]; }

	ll cmb(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		ll tmp = ifact(a - b) * ifact(b) % mod;
		return tmp * fac[a] % mod;
	}
	ll per(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		return fac[a] * ifac[a - b] % mod;
	}
};


int main() {
	ll n, m;
	cin >> n >> m;
	Factorial f(m);

	ll total = f.per(m, n);
	total *= total;
	total %= mod;
	ll s = 1;
	for (int i = 1; i <= n; i++) {
		s *= -1;
		ll elem = f.cmb(n, i);
		elem *= f.per(m, i);
		elem %= mod;
		elem *= f.per(m - i, n - i);
		elem %= mod;
		elem *= f.per(m - i, n - i);
		elem %= mod;
		total += s * elem + mod;
		total %= mod;
	}
	cout << total << endl;
	return 0;
}


Measured memory_bytes: 11100
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200000



long long kai[N];
long long rkai[N];
long long xx[30];
int yy[30];

void kaiz(void) {
	kai[0] = 1;
	f(i, N - 1) {
		kai[i + 1] = kai[i] * (i + 1);
		kai[i + 1] = kai[i + 1] % MOD;
	}
	int x = MOD - 2;
	f(i, 30) {
		if (x % 2 == 1)yy[i] = 1;
		else yy[i] = 0;
		x = x / 2;
	}
	f(i, N) {
		xx[0] = kai[i];
		f(j, 29) {
			xx[j + 1] = xx[j] * xx[j];
			xx[j + 1] = xx[j + 1] % MOD;
		}
		rkai[i] = 1;
		f(j, 30) {
			if (yy[j] == 1) {
				rkai[i] = rkai[i] * xx[j];
				rkai[i] = rkai[i] % MOD;
			}
		}
	}
}

long long ni(long long x, long long y) {
	if (x < 0 || y<0 || y>x)return 0;
	long long re = kai[x];
	re = re * rkai[x - y];
	re = re % MOD;
	re = re * rkai[y];
	re = re % MOD;
	return re;
}




int main() {
	vector<long long>a;
	long long b[N];
	long long c[N];
	long long n, k;
	long long x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	kaiz();
	scanf("%lld %lld", &n, &k);
	if (k == 1) {
		printf("0\n");
		return 0;
	}
	f(i, n) {
		scanf("%lld", &x);
		a.push_back(x);
	}
	sort(a.begin(), a.end());
	b[0] = 0;
	f(i, n)b[i + 1] = (b[i] + a[i]+MOD) % MOD;
	c[0] = b[n];
	f(i, n)c[i + 1] = (c[i] - a[i] + MOD) % MOD;
	for(int i=k-1;i<=(n-1);i++) {
		x = (c[i] - b[n - i] + MOD) % MOD;
		y = ni(i - 1, k-2);
		z = (x*y) % MOD;
		ans = (ans + z) % MOD;
	}

	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 6772
#include <bits/stdc++.h>
using namespace std;
int main(void){
    char c;
    int n;
    set<char> s;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>c;
        s.insert(c);
    }
    cout<<(s.size()==3?"Three":"Four")<<endl;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void main() {
  int a, b;
  readf (" %d %d %d", &a, &b);
  foreach (t; 1 .. 4) {
    if (t != a && t != b) {
      writeln (t);
      break;
    }
  }
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int n;
  int ans = 0;
  cin >> n;
  for(int i = 0; i < n; i++){
    int l, r;
    cin >> l >> r;
    ans += r-l+1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
main(){
  int q,n,k,a[1000001];
  cin>>q;
  while(q--){
    cin>>n>>k;
    vector<int>v;
    r(i,n)cin>>a[i];
    for(int i=1;i<n;i++)
      v.push_back(a[i]-a[i-1]);
    sort(v.begin(),v.end(),greater<int>());
    int sum=0,p;
    r(i,k-1){
     if(i>=v.size())break;
     sum+=v[i];
    }
    p=a[n-1]-a[0]-sum;
    if(p<0)p=0;
    cout<<p<<endl;
  }
}

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

using namespace std;

int main() {
  long n, k;
  cin >> n >> k;

  long a, i;
  for (i = 0; i < 100000; i++) {
    cin >> a;
    if (a == 1) {
      break;
    }
  }

  // long left = i + 1;
  // long right = n - i;

  // long left_search = (left + (k - 1) - 1 - 1) / (k - 1);
  // long right_search = (right + (k - 1) - 1 - 1) / (k - 1);

  // cout << left << " " << right << endl;
  // cout << left_search << " " << right_search << endl;

  // cout << left_search + right_search << endl;

  cout << (n - 1 + (k - 1) - 1) / (k - 1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  int sum = 0;

  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    if (2*(std::abs(0-x)) > 2*(std::abs(K-x)))
         sum += 2*(std::abs(K-x));
    else
         sum += 2*(std::abs(0-x));
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int s; cin >> s;
    int a[200];
    a[1] = s;
    for(int i = 2; i < 200; ++i){
    	int x = a[i - 1];
    	if(x % 2 == 0) a[i] = x / 2;
    	else a[i] = 3 * x + 1;
    }
    //for(int x : a) cout << x << " ";
    int ans = 0;
    for(int i = 2; i < 200; ++i){
    	int flag = 1;
    	for(int j = i - 1; j >= 1; --j){
    		//cout << a[i] << " " << a[j] << endl;
    		if(a[i] == a[j]){
    			ans = i;
    			flag = 0;
    			break;
    		}
    	}
    	if(flag == 0) break;
    }
    cout << ans << endl;
	return 0;
} 	

Measured memory_bytes: 256
line = gets.split(' ').map(&:to_i)
a=line[0]
b=line[1]
k=line[2]
if a<=k then
  b=b-(k-a)
  a=0
else
  a=a-k
end
if b<0 then
  b=0
end
puts [a,b].join(" ")

Measured memory_bytes: 1916
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
   int a,b,c,d,e,k;
   cin>>a>>b>>c>>d>>e>>k;
   if(e-a<=k){
       cout<<"Yay!"<<endl;
   }
   else{
       cout<<":("<<endl;
   }
}

Measured memory_bytes: 256
n = int(input())
x = str(input())
kosu1 = 0
kazu = 0
for i in range(n):
    kazu += 2 ** (n - i - 1) * int(x[i])
    if x[i] == '1':
        kosu1 += 1
if kosu1 ==1:
    kazup = kazu % (kosu1 + 1)
    magic17 = [0, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 3, 1, 2]
    box = [0] * (kosu1 + 1)

    amarip = [1] * n
    amarim = [1] * n
    for i in range(1, n):
        amarip[i] = (amarip[i - 1] * 2) % (kosu1 + 1)
    for i in range(n):
        if x[i] == '1':
            print(0)
        else:
            a = (kazup + amarip[n - 1 - i]) % (kosu1 + 1)

            if a <= 18:
                print(magic17[a] + 1)
            else:
                num = 0
                for i in range(len(str(bin(a)))-2):
                    if str(bin(a))[-1 - i] == '1':

                        num += 1
                print(magic17[a % num] + 2)
else:
    kazup = kazu % (kosu1 + 1)
    kazum = kazu % (kosu1 - 1)
    magic17 = [0,1,1,2,1,2,1,2,1,2,1,2,1,2,2,3,1,2,1]
    box = [0] * (kosu1 +1)

    amarip = [1] * n
    amarim = [1] * n
    for i in range(1,n):
        amarip[i] = (amarip[i - 1]*2) % (kosu1 + 1)
        amarim[i] = (amarim[i - 1]*2) % (kosu1 - 1)
    for i in range(n):
        if x[i] == '1':
            a = (kazum - amarim[n-1-i]) % (kosu1 - 1)

            if a <= 18:
                print(magic17[a]+1)
            else:
                num = 0

                for i in range(len(str(bin(a)))-2):
                    if str(bin(a))[-1-i] == '1':

                        num += 1
                print(magic17[a % num] + 2)
        else:
            a = (kazup + amarip[n - 1 - i]) % (kosu1 + 1)
            if a <= 18:
                print(magic17[a] + 1)
            else:
                num = 0
                for i in range(len(str(bin(a)))-2):
                    if str(bin(a))[-1 - i] == '1':

                        num += 1
                print(magic17[a % num] + 2)

Measured memory_bytes: 101040
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int maxn=1e4+5;
int n,k,u,v,c;
vector<pair<int,int> >adj[maxn];
void dijkstra(){
	priority_queue<pair<int,int> >PQ;
	int color[maxn],d[maxn];
	for(int i=0;i<n;i++){
		color[i]=0;
		d[i]=INF;
	}
	d[0]=0;
	PQ.push(make_pair(0,0));
	while(!PQ.empty()){
		pair<int,int> f=PQ.top();
		PQ.pop();
		int u=f.second;
		color[u]=1;
		if(d[u]<f.first*(-1)) continue;
		for(int j=0;j<adj[u].size();j++){
			int v=adj[u][j].first;
			if(color[v]==1) continue;
			if(d[v]>d[u]+adj[u][j].second){
				d[v]=d[u]+adj[u][j].second;
				PQ.push(make_pair(d[v]*(-1),v));
			}
		}
	}
	for(int i=0;i<n;i++){
		printf("%d ",i);
		if(d[i]==INF) printf("-1\n");
		else printf("%d\n",d[i]);	
	}
}
int main(){
	n=read();
	for(int i=0;i<n;i++){
		u=read(),k=read();
		for(int j=0;j<k;j++){
			v=read(),c=read();
			adj[u].push_back(make_pair(v,c));
		}
	}
	dijkstra();
	return 0;
}


Measured memory_bytes: 8092
package main

import "fmt"

func gcd(a, b int) int {
	if a > b {
		a, b = b, a
	}
	if a == 0 {
		return b
	}
	return gcd(b%a, a)
}

func max(n []int) int {
	ans := n[0]
	for _, v := range n {
		if v > ans {
			ans = v
		}
	}
	return ans
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}

	l := make([]int, n+1)
	r := make([]int, n+1)
	l[0] = 0
	r[n] = 0
	for i := 0; i < n; i++ {
		l[i+1] = gcd(l[i], a[i])
		r[n-i-1] = gcd(r[n-i], a[n-i-1])
	}
	m := make([]int, n)
	for i := 0; i < n; i++ {
		m[i] = gcd(l[i], r[i+1])
	}
	fmt.Println(max(m))
}


Measured memory_bytes: 6272
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 1234567890123456
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn =1e5 + 10;

//initialization here
//

//
//initialization finish


// your function is here
//

//
// your function finished

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here
	//

	ll n,k;cin>>n>>k;
	if(k == 0)
	{
		Print(n*n);
		return 0;
	}
	ll cnt =0;
	FOR(b,k+1,n+1)
	{
		cnt += (n/b) * (b-k);
		ll amari = n-(n/b)*b;
		cnt += max((ll)0,amari-k+1);
	}
	Print(cnt);
	//
	// your code finished


	return 0;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif 

vl all, pat;

ll rec(ll n, ll rem) {
    if (n == 0) return 1;

    // eat the bottom bun
    if (rem >= 1) rem--;

    ll res = 0;
    if (rem>=1) {
        // eat a n-1 burger
        if (rem >= all[n-1]) {
            rem -= all[n - 1];
            res += pat[n - 1];
        } else {
            res += rec(n - 1, rem);
            rem = 0;
        }
    }

    // eat the middle pat
    if (rem >= 1) {
        res++;
        rem--;
    }

    if (rem>=1) {
        // eat a n-1 burger
        if (rem >= all[n-1]) {
            rem -= all[n - 1];
            res += pat[n - 1];
        } else {
            res += rec(n - 1, rem);
            rem = 0;
        }
    }

    // eat the top bun
    if (rem >= 1) rem--;

    return res;
}

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

    ll N, X; cin >> N >> X;

    all = vl(N + 1, 0);
    pat = vl(N + 1, 0);
    all[0] = 1;
    pat[0] = 1;
    REP(i, N) {    
        all[i + 1] = all[i] * 2 + 3;
        pat[i + 1] = pat[i] * 2 + 1;
    }

    ll ans = rec(N, X);

    cout <<  ans << endl;
    all.clear();
    pat.clear();

    return 0;
}

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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> p(n, k-q);
  rep(i,q) {
    int a;
    cin >> a;
    --a;
    p[a]++;
  }
  rep(i,n) {
    if (p[i] <= 0) puts("No");
    else puts("Yes");
  }
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  string S, T;
  cin >> S >> T;
  int ans = 0;
  for (int i = 0; i < 3; ++i) {
    if (S[i] == T[i]) ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////


///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

	int wynik = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(i != j){
				wynik += (tab[i] * tab[j]);
			}
		}
	}
	
	cout << wynik / 2 << endl;

    
	return 0;
}


Measured memory_bytes: 256