akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;

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

void solve(){
	int a = rint, b = rint;
	
	int ans = a - b * 2;
	if(ans < 0) ans = 0;
	
	ans.writeln;
	
}


Measured memory_bytes: 256
package main

import "os"
import "fmt"
import "strconv"
import "bufio"
import "strings"


func min(a ...int64) int64 {
    v := int64(-1)
    for i := 0; i < len(a); i++ {
        if a[i] == -1 {
            continue
        }
        if v == -1 || v > a[i] {
            v = a[i]
        }
    }
    // fmt.Println(a, v)
    return v
}

func solve(n int64, v int64, w int64, arr [][]int64) int64 {
    dp := make([]int64, v+1)
    t := make([]int64, v+1)
    for j := int64(1); j < v+1; j++ {
        dp[j] = -1
        t[j] = -1
    }
    for i := int64(0); i < n; i++ {
        for j := int64(1); j < v+1; j++ {
            if j-arr[i][1] >= 1 && dp[j-arr[i][1]] != -1 {
                t[j] = min(t[j], dp[j-arr[i][1]]+arr[i][0])
            }
        }
        t[arr[i][1]] = min(t[arr[i][1]], arr[i][0])

        for j := int64(1); j < v+1; j++ {
            dp[j] = min(dp[j], t[j])
            t[j] = -1
        }
    }

    rs := int64(0)
    for j := int64(0); j < v+1; j++ {
        // fmt.Println(j, dp[j])
        if dp[j] > -1 && dp[j] <= w {
            rs = j
        }
    }
    return rs
}

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    var n int64 = 0
    var w int64 = 0
    var v int64 = 0
    var arr [][]int64
    i := int64(0)
    j := int64(0)
    for scanner.Scan() {
        if i > 0 && i > n {
            break
        }
        if i == 0 {
            strs := strings.Split(scanner.Text(), " ")
            n, _ = strconv.ParseInt(strs[0], 10, 64)
            w, _ = strconv.ParseInt(strs[1], 10, 64)
        } else {
            if i == 1 {
                arr = make([][]int64, n)
            }
            arr[j] = make([]int64, 2)
            strs := strings.Split(scanner.Text(), " ")
            arr[j][0], _ = strconv.ParseInt(strs[0], 10, 64)
            arr[j][1], _ = strconv.ParseInt(strs[1], 10, 64)
            v += arr[j][1]
            j++
        }
        i++ 
    }
    fmt.Println(solve(n, v, w, arr))
}

Measured memory_bytes: 2304
"use strict";
    
const main = arg => {
    arg = arg.split("\n");
    const blueN = parseInt(arg[0]);
    const blueS = arg.slice(1,blueN + 1);
    const redN  = parseInt(arg[blueN + 1]);
    const redS  = arg.slice(blueN+2);

    const set = new Set(redS.concat(blueS));
    let answer = [];

    set.forEach(item => {
        let temp = 0;
        let foundInBlue = blueS.filter(n=>n==item).length;
        let foundInRed  = redS.filter(n=>n==item).length;
        
        if(foundInBlue > 0) {
            temp += foundInBlue;
        }
        
        if(foundInRed > 0) {
            temp -= foundInRed;
        }
        
        answer.push(temp);
    })
    
    console.log(Math.max(...answer) > 0 ? Math.max(...answer) : 0);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7500
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine

main = do
    n <- getInt
    mapM_ putStrLn $ sort (map (\(x, _) -> reverse x) (solve n))

solve 1 = [("a", 1)]
solve k = [ (c : ss, max m m')  | (ss, m) <- solve (k - 1), (c, m') <- cs, m' - m <= 1 ]
    where cs = take k $ zip "abcdefghij" [1..]

Measured memory_bytes: 52860
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>


using namespace std;

int main(){

	int N;
	int X[10001];

	cin >> N;

	int ans = -1;

	for(int i = 0; i<10000;i++){  
		for(int j = 0; j < i; j++){
			if(N == X[j]){
				ans = i;
				goto END;
			}
		}
		X[i] = N;
		if(N % 2 == 0){
			N /= 2;
		} else {
			N = 3 * N + 1;
		}
	}

END:
	cout << ans+1 << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
from fractions import gcd

class SegmentTree:
    def __init__(self, N, func, I):
        self.sz = N
        self.func = func
        self.I = I
        self.seg = [I]*(N*2)
 
    def assign(self, k, x):
        self.seg[k + self.sz] = x
 
    def build(self):
        for i in range(self.sz - 1, 0, -1):
            self.seg[i] = gcd(self.seg[2 * i], self.seg[2 * i + 1])
 
    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k //= 2
            self.seg[k] = gcd(self.seg[2 * k], self.seg[2 * k + 1])
 
    def query(self, a, b):
        R = self.I
        a += self.sz
        b += self.sz
        while a < b:
            if a & 1:
                R = gcd(R, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = gcd(self.seg[b], R)
            a //= 2
            b //= 2
        return R

def main():
    N = int(readline())
    m = map(int,read().split())
    seg = SegmentTree(N , gcd , 0)
    for i in range(N):
        seg.assign(i , next(m))
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))
    print(ans)

main()


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

const int N = 2010;

struct edge {
    int to, next;
} e[N * 2];

int head[N], ecnt;

inline void adde(int from, int to) {
    e[++ecnt] = (edge){to, head[from]}, head[from] = ecnt;
    e[++ecnt] = (edge){from, head[to]}, head[to] = ecnt;
}

// sum: 子树内棋子个数 dp: 子树内最少操作步数
int sum[N], dp[N];

int val[N];

void dfs(int u, int f) {
    sum[u] = val[u], dp[u] = 0;
    for (int i = head[u]; i; i = e[i].next)
        if (e[i].to != f) {
            dfs(e[i].to, u);
            sum[u] += sum[e[i].to], dp[u] += dp[e[i].to] + sum[e[i].to];
        }
}

// 子树的最小剩余深度
int dfs2(int u, int f) {
    int mx = 0;
    for (int i = head[u]; i; i = e[i].next)
        if (e[i].to != f) 
            if (dp[e[i].to] + sum[e[i].to] > dp[mx] + sum[mx]) 
                mx = e[i].to;
    if (!mx) return 0;
    int tmp = dfs2(mx, u) + sum[mx];
    if (dp[u] - dp[mx] - sum[mx] >= tmp) return dp[u] & 1;
    return tmp - (dp[u] - dp[mx] - sum[mx]);
}

char s[N];

int main() {
    int n; scanf("%d%s", &n, s + 1);
    for (int i = 1; i <= n; i++) val[i] = s[i] == '1';
    for (int i = 1, a, b; i < n; i++) scanf("%d%d", &a, &b), adde(a, b);
    int res = 1e9;
    for (int i = 1; i <= n; i++) {
        dfs(i, 0);
        if (!dfs2(i, 0)) res = min(res, dp[i] / 2);
    }
    if (res < 1e8) printf("%d\n", res);
    else puts("-1");
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <array>
#include <functional>
#include <utility>
#include <regex>

int main()
{
    int64_t N, D;
    std::cin >> N >> D;
    size_t c = 0;
    for (int64_t n = 0; n < N; ++n)
    {
        int64_t X, Y;
        std::cin >> X >> Y;
        if ((D * D) >= (X * X + Y * Y)) ++c;
    }

    std::cout << c << std::endl;

    return 0;
}



Measured memory_bytes: 3652
def examA():
    S = SI()
    T = SI()
    N = len(S)
    ans = "No"
    for i in range(N):
        cur = S[i:] + S[:i]
        #print(cur)
        if cur==T:
            ans = "Yes"
    print(ans)
    return

def examB():
    H, W = LI()
    S = [SI()for _ in range(H)]
    flag = True
    ans = 0
    print(ans)
    return

def examC():
    L, R = LI()
    ans = inf
    if R-L>=3000:
        R = L+3000

    for l in range(L, R + 1):
        for r in range(l+1, R + 1):
            now = (l*r) %2019
            ans = min(ans,now)
    print(ans)
    return

def examD():
    T = {"dream", "dreamer", "erase", "eraser"}
    S = SI()
    ans = "NO"
    t = ""
    for s in S[::-1]:
        t += s
        if t[::-1] in T:
            t = ""
        if len(t)>10:
            print(ans)
            return
    if t=="":
        ans = "YES"
    print(ans)
    return

def examE():
    N = 50
    K = I()
    base = K//N
    A = [base+i for i in range(N)]
    rest = K%N
    for i in range(rest):
        A[-i-1] += 1
    print(N)
    print(" ".join(map(str,A)))
    return

def examF():
    N = 20
    C = [2**i for i in range(N)]
    L = I()
    cur = 1
    V = [[i+1, i+2, 0]for i in range(N-1)]
    now = 1
    while(now<N):
        if C[now]<=L:
            cur = C[now]
            V.append([now,now+1,C[now-1]])
            now += 1
        else:
            break
    #print(cur)

    for i in range(now)[::-1]:
        if C[i]<=L-cur:
            cost = cur
            V.append([i+1,N,cost])
            cur += C[i]

    print(N,len(V))
    for s,t,c in V:
        print(s,t,c)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examD()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

int V[101][10001];
int v[101];
int w[101];

int main(){
  int N,W;
  cin >> N >> W;
  v[0]=0;
  w[0]=0;
  for(int i=0;i<=N;++i){
    for(int j=0;j<=W;++j){
      V[i][j]=0;
    }
  }
  
  for(int i=1;i<=N;++i){
    cin >> v[i] >> w[i] ;
  }
  
  for(int i=1;i<=N;++i){
    for(int c=1;c<=W;++c){
      V[i][c]=V[i-1][c];
      if(c>=w[i]) V[i][c]=max(V[i][c],v[i]+V[i][c-w[i]]);
    }
  }
  cout << V[N][W] << endl;				  
}

Measured memory_bytes: 5104
import itertools

A = [input().split() for _ in range(3)]
A = list(itertools.chain.from_iterable(A))
N = int(input())
B = [input() for _ in range(N)]

l = [a in B for a in A]
if l[0] == l[1] == l[2] == True:
    print("Yes")
elif l[3] == l[4] == l[5] == True:
    print("Yes")
elif l[6] == l[7] == l[8] == True:
    print("Yes")
elif l[0] == l[3] == l[6] == True:
    print("Yes")
elif l[1] == l[4] == l[7] == True:
    print("Yes")
elif l[2] == l[5] == l[8] == True:
    print("Yes")
elif l[0] == l[4] == l[8] == True:
    print("Yes")
elif l[2] == l[4] == l[6] == True:
    print("Yes")
else:
    print("No")

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

int main(){
    long long A, B;
    int K;
    cin >> A >> B >> K;

    long long upper_A = A+K-1;
    long long lower_B = B-K+1;
    
    if(A+K-1 < B-K+1){
        for(long long i=A; i<=upper_A; i++){
            cout << i << endl;
        }
        for(long long i=lower_B; i<=B; i++){
            cout << i << endl;
        }
    }else{
        for(long long i=A; i<=B; i++){
            cout << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define endl '\n'
#define mod 1000000007

using namespace std;

int main()
{

    ll a, b;
    cin>>a>>b;
    if(abs(a-b)>1)return cout<<0,0;
    ll ans =1;
    for(int i=2;i<=a;i++)
        ans*=i,
        ans%=mod;

    for(int i=2;i<=b;i++)
        ans*=i,
        ans%=mod;

    if(a==b)ans*=2;
    ans%=mod;
    cout<<ans;


    return 0;
}


Measured memory_bytes: 256
#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() {
  int a, b, h;
  cin >> a >> b >> h;
  cout << (a+b) * h /2 << endl;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;
const int inf = 1e9;


int n, m;
int L[maxn], R[maxn];

bool isect(int l, int r, int a, int b) {
    return max(l,a) <= min(r,b);
}

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

    cin>>n>>m;
    for (int i=1; i<=n; i++) {
	cin>>L[i]>>R[i];
    }



    // map<key,value> a[i]: min # of left moves to get to column i.
    // the value between 2 sparse keys is just an incrementing function
    // multiset ms: just maintains values from a
    // example:
    // key 1 2 3 4 5 6
    //     1 2 3 0 1 inf
    
    // key 1     4   6
    //     1     0   inf

    // ms: {0,1,inf}
    

    
    map<int,int> a;
    multiset<int> ms;
    for (int i=1; i<=m; i++) {
	a[i] = 0;
	ms.insert(0);
    }
    a[0]=inf;
    ms.insert(inf);
    a[m+1]=inf;
    ms.insert(inf);
    

    assert(ms.size() == a.size());



    // Insert blocker at [l,r]
    // This blocker will affect [l,r]. We will delete all entries between [l,r], and add 2 new sparse
    // entries at a[l] and a[r+1]. For both of these locations, we just look at the key just before us, and add the distance.
    // We don't need to look further back because a[i] is optimal for all i, and if we needed to look further back, the previous
    // entry already handled it for us.

    
    auto update = [&](int l, int r) {
	vector<pair<int,int>> upds;
	auto iter = std::prev(a.lower_bound(l));
	set<int> rm;

	// update l
	upds.push_back({l,(l-iter->first) + iter->second});
	if (a.count(l)) rm.insert(l);

	// update r
	if (r+1<=m) {
	    auto iter = std::prev(a.lower_bound(r+1));
	    int res = r+1-iter->first+iter->second;
	    if (a.count(r+1)) {
		rm.insert(r+1);
		res = min(res, a[r+1]);
	    }
	    upds.push_back({r+1,res});
	}

	iter = a.lower_bound(l);
	while (iter != a.end() && iter->first <=r) {
	    rm.insert(iter->first);
	    ++iter;
	}

	for (int k: rm) {
	    ms.erase(ms.find(a[k]));
	}

	iter = a.lower_bound(l);
	while (iter != a.end() && iter->first <=r) {
	    iter = a.erase(iter);
	}

	for (auto p: upds) {
	    a[p.first] = p.second;
	    ms.insert(p.second);
	}
	assert(ms.size() == a.size());
    };

    function<int()> qry = [&]() {
	assert(!ms.empty());
	return *ms.begin();
    };
    
    
    for (int i=1; i<=n; i++) {
	int l=L[i]; int r=R[i];
	update(l,r);
	int res = qry() + i;
	if (res > inf/2) res = -1;
	cout<<res<<"\n";
    }
    
    
    return 0;
}


Measured memory_bytes: 24020
#include <cstdio>
using namespace std;

int main(){
    int i,n,b,c=0,cnt=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&b);
        if(b==c){
            cnt++;
            c=0;
        }
        else{
            c=b;
        }
    }
    printf("%d\n",cnt);
}

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

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

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

ll ten[20];
unordered_map<int,ll> coef[2];

ll dfs(int digits,ll val, int flag){
	//cout << digits << " " << val << endl;
	if(digits == 0){
		return (val == 0LL) ? 1LL : 0LL;
	}

	if(digits == 1){
		return (val == 0LL) ? (flag + 9LL) : 0LL;
	}

	ll ret = 0LL;

	const ll idx = (10 - val % 10) % 10;
	{	
		ll nval = (val - idx * (ten[digits - 1] - 1LL)) / 10LL;
		ret += coef[flag][idx] * dfs(digits - 2, nval, 1);	
	}

	if(idx != 0){	
		ll nval = (val - (idx - 10) * (ten[digits - 1] - 1LL)) / 10LL;
		ret += coef[flag][(idx - 10)] * dfs(digits - 2, nval, 1);	
	}

	return ret;
}

int main(void){
	ll d;
	cin >> d;
		
	ten[0] = 1LL;
	rep(i,1,19) ten[i] = 10LL * ten[i-1];

	rep(i,2)rep(a,10)rep(b,10){
		if(i == 0 and a * b == 0) continue;
		coef[i][a-b]++;
	}

	const int n = to_string(d).size();
	ll ans = 0LL;

	rep(i,n,2*n+1){
		ll cur = dfs(i,d,0);
		ans += cur;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    loop {
        let v = read_vec::<u32>();
        let a = v[0];
        let b = v[1];
        if a == 0 && b == 0 { break; }

        for _ in 0..a {
            let line = (0..b).map(|_| '#').collect::<String>();
            println!("{}", line);
        }
        println!("");
    }
}



Measured memory_bytes: 5028
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n;
	cin >> n;
	int flag = 0;
	vector<int> v;
	while (n > 0) {
		int digit  = n % 10;
		v.push_back(digit);
		n = n / 10;
	}
	for (int i = 0 ; i < v.size(); i++) {
		if (v[i] == 7) {
			flag = 1;
		}
	}
	if (flag == 1) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int arr[3];
    cin>>arr[0]>>arr[1]>>arr[2];
    sort(arr,arr+3);
    if (arr[0]==5&&arr[1]==5&&arr[2]==7){
        cout<<"YES"<<endl;
    }else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
using namespace std;

int a,b,C;
double rad;
double PI=acos(-1);
double S,L,h;

int main(){
    cin>>a>>b>>C;
    rad=C*PI/180;
    h=b*sin(rad);
    S=0.5*a*h;
    double c;
    c=sqrt(-2*a*b*cos(rad)+a*a+b*b);
    L=a+b+c;
    printf("%.5lf %.5lf %.5lf\n",S,L,h);
    return 0;
}



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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

int n, m;
int s, t;

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

  int res = m;
  rep(i, n){
    cin >> s >> t;
    m += s - t;
    if(m < 0){
      cout << 0 << endl;
      return 0;
    }
    maxup(res, m);
  }

  cout << res << endl;

  return 0;
}

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

vector<vector<int>> g(100001);
vector<int> d_corbeau(100001, -1), d_saba(100001, -1);

void dfs1(int now, int depth){
    d_corbeau[now] = depth;
    rep(i, g[now].size()){
        int next = g[now][i];
        if(d_corbeau[next] == -1) dfs1(next,depth+1);
    }
}

void dfs2(int now, int depth){
    d_saba[now] = depth;
    rep(i, g[now].size()){
        int next = g[now][i];
        if(d_saba[next] == -1) dfs2(next,depth+1);
    }
}

int main(){
    int n, corbeau, saba; cin >> n >> corbeau >> saba;
    corbeau--; saba--; // なんかさばって人がめっちゃ追いかけてくるんですけど！
    int a,b;
    rep(i,n-1){
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs1(corbeau,0);
    dfs2(saba,0);
    int max=-1, max_node;
    rep(i,n){
        if(d_corbeau[i] < d_saba[i] && d_saba[i] > max){
            max_node = i;
            max = d_saba[i];
        }
    }
    int dis = d_corbeau[saba];
    cout << d_saba[max_node]-1 << "\n";
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds ;
#define ll long long
#define ld float
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define hell (ll)1000000007
#define f first
#define s second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree< ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
void solve()
{
    ll n ;
    cin >> n ;
    cout << 180 + ( n - 3 ) * 180 ;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}


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


int main()
{
    int a, i, flag;
    cin >> a;
    int arr[100100];
    while (a < 100100)
    {
        flag = 0;
        for(i = 2; i <= a/2; ++i)
        {
            if(a % i == 0)
            {
                flag = 1;
                break;
            }
        }
        if (flag == 0)
    {
            cout << a << " ";
              break;
    }
             ++a;
          
        
    }
    return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  
  if (A < B) {
    if (A == 1) {
      cout << "Alice" << endl;
      return 0;
    }  
    cout << "Bob" << endl; 
  } else if (A > B) {
    if (B == 1) {
      cout << "Bob" << endl;
      return 0;
    }
    cout << "Alice" << endl;
  } 
  else if (A == B) cout << "Draw" << endl;  
}

Measured memory_bytes: 3616
<?php
$n=trim(fgets(STDIN));
if($n==100000){
  echo 90909;
}elseif($n>=10000){
  echo 909+$n-10000+1;
}elseif($n>=999){
  echo 909;
}elseif($n>=100){
  echo 9+$n-100+1;
}elseif($n>=9){
  echo 9;
}else{
  echo $n;
}

Measured memory_bytes: 4728
import java.util.*;

public class Main {
	public static void main ( String[] args ) {
		int n , count , max , maxID;
		int[][] deta = new int[10000][2];
		Scanner sc = new Scanner(System.in);
		while ( !sc.hasNext("0") ) {
			n = sc.nextInt();
			count = 0;
			for ( int i = 0 ; i < n; i++ ) {
				deta[i][0] = sc.nextInt();
				deta[i][1] = sc.nextInt();
				deta[i][1] += sc.nextInt();
				count++;
			}
			max = 0; maxID = 0;
			for ( int i = 0; i < count; i++ ) {
				if ( max < deta[i][1] ) {
					max = deta[i][1];
					maxID = deta[i][0];
				}
			}
			System.out.println(maxID+" "+max);
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
const ll INF = 1LL << 60;
//cout << fixed << setprecision(10);

int main(){
    int n;
    cin>>n;
    if (n%1000==0){
        cout << 0 <<endl;
        return 0;
    }
    cout << 1000 - (n % 1000) <<endl;
}

Measured memory_bytes: 3596
// in the name of Allah

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

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second
#define mod 1000000007

const int N = 2e5+5;

vector <int> g[N];

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

	int n;
	cin >> n;
	int x, y;
	for(int i=1; i<n; i++) {
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}

	int dist[N];
	memset(dist, 63, sizeof dist);
	dist[1] = 0;
	queue <int> q;
	q.push(1);
	while(sz(q)) {
		int u = q.front(); q.pop();
		for(int v : g[u]) {
			if(dist[u] + 1 < dist[v]) {
				dist[v] = dist[u] + 1;
				q.push(v);
			}
		}
	}

	int cnt2[2] = {0, 0};
	int cnt3[3] = {0, 0, 0};
	for(int i=1; i<=n; i++) {
		cnt3[i%3]++;
		cnt2[dist[i]%2]++;
	}

	int mn = (cnt2[0] > cnt2[1]);
	int put = (cnt3[1] > cnt3[2]);

	int cnt[3] = {3, 1, 2};

	if(min(cnt2[0], cnt2[1]) < min(cnt3[1], cnt3[2])) {
		vector <int> ans;
		for(int i=1; i<=n; i++) {
			if(dist[i]&1) {
				if(mn) {
					ans.pb(cnt[0]);
					cnt[0] += 3;
				}
				else {
					if(cnt[put+1] <= n) {
						ans.pb(cnt[put+1]);
						cnt[put+1] += 3;
					}
					else if(cnt[2 - put] <= n) {
						ans.pb(cnt[2 - put]);
						cnt[2 - put] += 3;
					}
					else {
						ans.pb(cnt[0]);
						cnt[0] += 3;
					}
				}
			}
			else {
				if(mn) {
					if(cnt[put+1] <= n) {
						ans.pb(cnt[put+1]);
						cnt[put+1] += 3;
					}
					else if(cnt[2 - put] <= n) {
						ans.pb(cnt[2 - put]);
						cnt[2 - put] += 3;
					}
					else {
						ans.pb(cnt[0]);
						cnt[0] += 3;
					}
				}
				else {
					ans.pb(cnt[0]);
					cnt[0] += 3;
				}
			}	
		}
		for(int e : ans) cout << e << " ";
		return 0;
	}

	vector <int> ans;
	for(int i=1; i<=n; i++) {
		if(dist[i]&1) {
			if(mn) {
				if(cnt[put+1] <= n) {
					ans.pb(cnt[put+1]);
					cnt[put+1] += 3;
				}
				else {
					ans.pb(cnt[0]);
					cnt[0] += 3;
				}
			}
			else {
				if(cnt[2 - put] <= n) {
					ans.pb(cnt[2 - put]);
					cnt[2 - put] += 3;
				}
				else {
					ans.pb(cnt[0]);
					cnt[0] += 3;
				}
			}
		}
		else {
			if(mn) {
				if(cnt[2 - put] <= n) {
					ans.pb(cnt[2 - put]);
					cnt[2 - put] += 3;
				}
				else {
					ans.pb(cnt[0]);
					cnt[0] += 3;
				}
			}
			else {
				if(cnt[put+1] <= n) {
					ans.pb(cnt[put+1]);
					cnt[put+1] += 3;
				}
				else {
					ans.pb(cnt[0]);
					cnt[0] += 3;
				}
			}
		}
	}
	for(int e : ans) cout << e << " ";

	return 0;
}

Measured memory_bytes: 16112
S = input()
T = input()

def f():
    l = []
    for i in range(len(S)):
        if i + len(T) > len(S):
            break
        flag = True
        for j in range(len(T)):
            if S[i + j] not in [T[j], "?"] :
                flag = False
                break
        if flag:
            s = S
            s = s[:i] + T + s[i+len(T):]
            s = s.replace("?", "a")
            l.append(s)
    l.sort()
    if len(l):
        return l[0]
    else:
        return "UNRESTORABLE"

print(f())

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        long w = Integer.parseInt(scan.next());
        long h = Integer.parseInt(scan.next());
        long x = Integer.parseInt(scan.next());
        long y = Integer.parseInt(scan.next());
        
        if((2*x == w)&& (2*y == h)){
            System.out.println(w * h / 2.0 + " 1");
        }else{
            System.out.println(w * h / 2.0 + " 0");
        }
    }
}


Measured memory_bytes: 21460
#include<iostream>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int n,cnt=0;

void merge(int a[], int left, int mid, int right){
    int n1=mid-left;
    int n2=right-mid;
    int L[n1+1],R[n2+1];
    F(i,0,n1) L[i]=a[left+i];
    F(i,0,n2) R[i]=a[mid+i];
    L[n1]=2000000000;
    R[n2]=2000000000;
    int i=0,j=0;
    F(k,left,right){
        if(L[i]<=R[j]){
            a[k]=L[i];
            ++i;
        }
        else{
            a[k]=R[j];
            ++j;
        }
        ++cnt;
    }
}

void mergeSort(int a[], int left, int right){
    if(left+1<right){
        int mid=(left+right)/2;
        mergeSort(a,left,mid);
        mergeSort(a,mid,right);
        merge(a,left,mid,right);
    }
}

int main()
{
    cin >> n;
    int a[n];
    F(i,0,n) cin >> a[i];
    mergeSort(a,0,n);
    F(i,0,n){
        cout << a[i];
        if(i!=n-1) cout << " ";
    }
    cout << endl << cnt << endl;
    return 0;
}


Measured memory_bytes: 6988
#include <algorithm>
#include <climits>
#include <iostream>
using namespace std;

int main() {
	int N, x, a = 0, b = INT_MAX;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> x;
		a = max(a, x);
		b = min(b, x);
	}
	cout << (1 + a - b) / 2 << endl;
}


Measured memory_bytes: 3084
import copy
N = int(input())
MM = input().split()
M = int(input())
for i in range(M):
  cc = copy.copy(MM)
  total = 0
  
  aa = input().split()
  a = int(aa[0])
  b = int(aa[1])
  cc[a-1] = b
  for j in cc:
    total += int(j)
  print(total)
    

Measured memory_bytes: 9348
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    i64 n;
    i64 L, T;
    std::cin >> n >> L >> T;

    vec<i64> ans(n);
    i64 cnt = 0;
    for (i64 i=0; i<n; i++) {
        i64 x, w;
        std::cin >> x >> w;

        i64 y = x + (w==1 ? T : -T);
        i64 r = (y % L + L) % L;
        i64 q = (y - r) / L;
        ans.at(i) = r;
        cnt += q;
    }
    cnt = (cnt % n + n) % n;
    std::sort(ALL(ans));
    std::rotate(ans.begin(), ans.begin() + cnt, ans.end());

    for (i64 x: ans) {
        std::cout << x <<'\n';
    }
}


Measured memory_bytes: 2048
#include<cstdio>
#define ll long long
#define N 100005

int n,q;

int b[N];

ll ans;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int a;
		scanf("%d",&a);
		b[a]++;
		ans+=a;
	}
	scanf("%d",&q);
	while(q--){
		int x,y;
		scanf("%d%d",&x,&y);
		ans+=1ll*b[x]*(y-x);
		b[y]+=b[x];
		b[x]=0;
		printf("%lld\n",ans);
	}
}

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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define trav(i,a) for(auto& (i) : (a))
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)
#define dbg(x) cerr << "STDERR => " << __LINE__ << ": " << #x << " = " << (x) << "  :(\n";
#define eb emplace_back
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void cpuTime() { cerr << "cpu time : " << double(clock())/CLOCKS_PER_SEC << "\n"; return; }
using ll = long long;
using ull = unsigned long long;
using F = float;
using D = double;
using vi = vector<int>;
using pii = pair<int,int>;



void solve(){

    string s;
    cin >> s;
    char a = s[0],b;
    int na = 1, nb = 0;

    rep(i,1,sz(s)) {
        if(a != s[i])  b = s[i];
        else ++na;
    }
    rep(i,1,sz(s)){
        if(b == s[i]) ++nb;
    }
    if( na == 2 && nb == 2){
        cout << "Yes\n";
    }else cout << "No\n";

    return;
}

int main(){

    fast_io;
    int t=1;
    // cin >> t;

    while(t--){
        solve();
    }

    cpuTime();
return 0;
}


/*
 read the question carefully ( what're the exact constraints? )
 look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS
 Check datatypes
*/


Measured memory_bytes: 256
n=gets.to_i
a=[]
h=0
(1..n).each{|k|
if(k.odd?)
for c in 1..k
  if((k%c)==0)
    a<<c
    a<<(k/c)
  end
 
  
  end
  end
  if(a.uniq.length==8)
    h+=1
    end
    a.clear
}
puts h

Measured memory_bytes: 14260
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]

lst = [0]*(N+1)

for i in range(N):
    ref = S[i]
    lst[i] = S.count(ref) - T.count(ref)

ans = max(lst)
print(ans)


Measured memory_bytes: 9060
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

const int infI=1e9+5;
const long long infL=1e16;
const int MOD=1e9+7;
const int MAX=1e5+5;

#define mp make_pair
#define in &
#define pb push_back
#define ii pair<int,int>
#define iii pair<ii,int>
#define ll long long
#define pll pair<ll,ll>
#define vvl vector<vector<ll> >
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define eb emplace_back
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define popb pop_back();
#define se second
#define fi first
#define debug(x) cerr<<x<<endl
#define test(t) int t;cin>>t;while(t--)
#define fordebug(x) cerr<<x<<" "

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    if(b==1){
        return a;
    }
    ll temp=power(a,b/2);
    temp=(temp*temp)%MOD;
    if(b%2){
        temp=(temp*a)%MOD;
    }
    return temp;
}

//only use if mod is prime
ll mod_inv(ll a,ll mod){
    a%=mod;
    return power(a,mod-2);
}

void extended_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return;
    }
    ll x1,y1;
    extended_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-((a/b)*y1);
    return;
}

//TLE can also occur if vectors are not passed by reference

ll dp[MAX],a[105];

int main(){
    int n,K;
    cin>>n>>K;
    //dp[i] = 1 if first wins, else 0
    dp[0]=0;
    ll mn=infL;
    forn(i,0,n){
        cin>>a[i];
        mn = min(mn,a[i]);
    }
    //if dp[k-a[i]] = 0, then dp[k] = 1
    forn(k,0,K+1){
        if(k<mn){
            // cout<<"0 
            dp[k] = 0;
            continue;
        }
        dp[k]=0;
        forn(i,0,n){
            if(a[i]>k){
                continue;
            }
            if(dp[k-a[i]]==0){
                dp[k]=1;
                break;
            }
        }
        // cout<<dp[k]<<" ";
    }
    cout<<(dp[K]==0?"Second":"First");
    return 0;
}

Measured memory_bytes: 1024
R, G, B, N = map(int, input().split())
cnt = 0

for r in range(N // R + 1):
    for g in range(N // G + 1):
        if (N - r * R - g * G) % B == 0 and (N - r * R - g * G) >= 0:
            cnt += 1

print(cnt)

Measured memory_bytes: 40940
n,k = map(int,input().split())

if(n%k==0):
    print("0")
elif(n>k):
    ans1 = n % k
    ans2 = abs(ans1-k)

    if(abs(ans1)<abs(ans2)):
        print(ans1)
    else:
        print(ans2)
else:
    ans = abs(n-k)
    if(ans<n):
        print(ans)
    else:
        print(n)

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


int main(){
  int n, d;
  cin >> n >> d;
  vector<int> x(n*d);
  rep(i, n*d) cin >> x.at(i);
  int ans = 0;
  
  for(int i = 0; i < n-1; i++){
    for(int j = i+1; j < n; j++){
      double dp2 = 0;
      for(int k = 0; k < d; k++){
        dp2 += pow((x.at(d*i+k) - x.at(d*j+k)), 2);
      }
      double d = sqrt(dp2);
      int di = (int)sqrt(dp2);
      if(d == di) ans++;
    }
  }
  cout << ans << endl;
}

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

    using namespace std;
    template <typename T>
    void debug(string t, T input) {
        cout<<t<<"-> "<<input<<"\n";
    }
    template <typename T>
    void debug(int i,string t, T input) {
        cout<<"Case#"<<i<<" "<<t<<"-> "<<input<<"\n";
    }

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int n,k;
        cin>>n>>k;
        vector<int>a(n);
        for(int i=0;i<k;i++){
            int d;
            cin>>d;
            for(int j=0;j<d;j++){
                int x;
                cin>>x;
                --x;
                a[x]++;
            }
        }
        int total=0;
        for(int i=0;i<n;i++){
            if(a[i]==0)
                total++;
        }
        cout<<total;
        return 0;
    }


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

using namespace std;

int mp[90][90];

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

int m, n;

int dfs(int y, int x)
{
	if (y < 0 || y >= n || x < 0 || x >= m) return 0;

	if (mp[y][x] == 0) return 0;

	int res = 0;

	for (int i = 0; i < 4; ++i) {
		mp[y][x] = 0;
		res = max(res, 1 + dfs(y + dy[i], x + dx[i]));
		mp[y][x] = 1;
	}

	return res;
}

int main()
{
	while (cin >> m >> n, m || n) {
		for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) cin >> mp[i][j];

		int ans = 0;

		for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) ans = max(ans, dfs(i, j));

		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1168
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	bNums := ScanNums(n-1)
	aNums := make([]int, n)
	aNums[n-1] = bNums[len(bNums)-1]
	for i := n-2; i >= 0; i-- {
		var max int
		if i-1 < 0 || bNums[i] < bNums[i-1] {
			max = bNums[i]
		} else {
			max = bNums[i-1]
		}
		aNums[i] = max
	}

	maxSum := 0
	for _, num := range aNums {
		maxSum += num
	}
	fmt.Println(maxSum)
}

func ScanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


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

using namespace std;

#define endl '\n'
#define ll long long

void solve(){
    ll n;
    cin>>n;
    string ans = "";
    map<int,char> mp;
    mp.insert({0,'z'});
    for(int i = 1;i<26;i++){
        mp.insert({i,char(96+i)});
    }
    vector<int> vec;
    while(n){
        vec.push_back(n%26);
        if(n % 26 == 0)n--;
        n /= 26;
    }
    //cout<<vec.size()<<endl;

    for(int i = 0;i<vec.size();i++){
        //cout<<vec[i]<<endl;
        ans += mp[vec[i]];
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int t = 1;
    while(t--){
        solve();
    }
    return 0;
}

// 2
// 1 2
// 3
// 1 100
// 2 100
// 100 1000

Measured memory_bytes: 3612
//Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;

typedef long long              ll;
typedef long double            ld;
typedef pair<int, int>         pi;
typedef vector<int>            vi;
typedef vector<pair<int, int>> vpi;

#define pb       push_back
#define all(x)   begin(x), end(x)
#define sz(x)    (int)(x).size()
#define ff       first
#define ss       second
#define mp       make_pair
#define lb       lower_bound
#define ub       upper_bound
#define tcase()  int t; cin >> t; while(t--)

const int MOD = 1e9 + 7; // 998244353;
const int MX  = 2e5 + 5;
const ll  INF = 1e18;
const ld  PI  = acos((ld) -1);

void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(sz(name)){
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

int main(){

    setIO();

    ll n;
    cin >> n;

    ll arr[n];
    for(int i = 0; i < n; i++) cin >> arr[i];

    sort(arr, arr + n);

    ll sum = 0;

    for(int i = 1; i < n; i++) sum += arr[n - i / 2 - 1];

    cout << sum;
}


Measured memory_bytes: 5156
import math
a,b,x=map(int,input().split())


check=(a*a*b)-x
check=check /(a*a)

check2=check*a
x=check*2
if check<=b/2:
    ans=math.degrees(math.atan(x/a))
    print(ans)
else:
    x=(((b-check)*a)/b)*2
    ans=math.degrees(math.atan(x/b))
    print(90-ans)

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


using namespace std;


int solve(int n, vector <long long> &a, string &s) {
    const int BASE = 61;
    vector <long long> basis(BASE, -1);

    auto addToBasis = [&](long long v) {
        int lead = -1;

        for (int i = BASE - 1; i >= 0; i--) if (v & (1LL << i)) {
            if (basis[i] != -1) {
                v ^= basis[i];
            } else if (lead == -1) {
                lead = i;
            }
        }

        if (lead != -1) {
            basis[lead] = v;
        }
    };

    auto canBeObtained = [&](long long v) {
        for (int i = BASE - 1; i >= 0; i--) if (v & (1LL << i)) {
            if (basis[i] != -1) {
                v ^= basis[i];
            } else {
                return false;
            }
        }

        return true;
    };

    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == '0') {
            addToBasis(a[i]);
        } else {
            if (!canBeObtained(a[i])) {
                return 1;
            }
        }
    }

    return 0;
}


int main() {
    ios_base::sync_with_stdio(false);

    int t;
    cin >> t;

    while (t--) {
        int n;
        cin >> n;

        vector <long long> a(n);
        string s;

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

        cin >> s;

        cout << solve(n, a, s) << '\n';
    }

    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define first F
#define second S

typedef vector<int> vi;
typedef pair<int,int> pii;

char s1[100000000];
char s2[100000000];

int main(void) {
  int i,j,n;
  cin>>n;
  vi a(n),ans;
  rep(i,n)cin>>a[i];
  sort(all(a));
  rep(i,min(n,5))rep(j,min(n,5))if(i!=j){
    int t=a[i];
    int tmp=a[j];
    for(;tmp;tmp/=10)t*=10;    
    ans.push_back(t+a[j]);
  }
  sort(all(ans));
  cout<<ans[2]<<endl;
}

Measured memory_bytes: 3192
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<tuple>
#include<ctime>
#include<functional>
#include<cmath>
#include<cassert>
#include<string.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p; 
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
   int x,y,flag=0;
   cin>>x>>y;
   for(int i=0;i<=x;i++){
       
           if(y==2*i+4*(x-i)) {
               flag=1;
           }
       }
   
   if(flag) p("Yes");
   else p("No");
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N,L;
  cin >> N >> L;

  i64 ans;
  if(L>=0) ans = (L + 1 + L + N - 1) * (N - 1) / 2;
  else if(L + N - 1 <= 0) ans = (L + L + N - 2) * (N - 1) / 2;
  else ans = (L + L + N - 1) * N / 2;

  cout << ans << "\n";

}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int n;
  scanf("%d", &n);
  char s[50][101];
  int sum[51] = {0};
  rep(i, 0, n) {
    int x;
    scanf("%s %d", s[i], &x);
    sum[i + 1] = sum[i] + x;
  }

  char ans[101];
  scanf("%s", ans);

  int idx;
  rep(i, 0, n) {
    if (strcmp(s[i], ans) == 0) {
      idx = i;
      break;
    }
  }
  printf("%d\n", sum[n] - sum[idx + 1]);
  return 0;
}


Measured memory_bytes: 128