akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = 2 * pow(10, 9) + 1;//+1しないとREになるかも(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };

ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }

////////////////////////////////////////////////////////////////

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = pow(10, 9) + 7;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

ll gcd(ll a, ll b){//greatest common divider 最大公約数を求める
  if(b==0) return a;
  return gcd(b, a%b);
}

////////////////////////////////////////////////////////////////

int main(void) {
	int K;
	cin >> K;


	ll ans = 0;
	for(int i=1; i<=K; i++){
		for(int j=1; j<=K; j++){
			for(int z=1; z<=K; z++){
				int tmp = gcd(i, j);
				ans += gcd(tmp, z);
			
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3632
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    D = int(input())
    c = [0] + list(map(int, input().split()))
    s = [[0]*27]
    t = [0]
    satisfy = 0
    last = [0] * 27
    for _ in range(D):
        s.append([0] + list(map(int, input().split())))
    for _ in range(D):
        t += [int(input())]
    for i in range(1, D+1):
        decrease = 0
        last[t[i]] = i
        for j in range(1, 27):
            decrease += (c[j] * (i - last[j]))
        satisfy += (s[i][t[i]] - decrease)
        print(satisfy)

if __name__ == '__main__':
    main()

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

#define LL long long
#define int long long
#define RG register

using namespace std;
template<class T> inline void read(T &x) {
	x = 0; RG char c = getchar(); bool f = 0;
	while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') c = getchar(), f = 1;
	while (c >= '0' && c <= '9') x = x*10+c-48, c = getchar();
	x = f ? -x : x;
	return ;
}
template<class T> inline void write(T x) {
	if (!x) {putchar(48);return ;}
	if (x < 0) x = -x, putchar('-');
	int len = -1, z[20]; while (x > 0) z[++len] = x%10, x /= 10;
	for (RG int i = len; i >= 0; i--) putchar(z[i]+48);return ;
}
const int N = 1e5 + 10;
int a[N], b[N], n, m, c[N], cnt[N], t[N * 2];
int lowbit(int x) {
	return x & (-x);
}
void add(int x) {
//	printf("add %d\n", x- N);
	for (; x <= n + N; x += lowbit(x)) t[x]++;
}
int sum(int x) {
//	printf("sum %d\n", x - N);
	int res = 0;
	for (; x; x -= lowbit(x)) res += t[x];
	return res;
}
int check(int x) {
	memset(t, 0, sizeof(t));
	for (int i = 1; i <= n; i++) if (b[x] < a[i]) c[i] = 1; else c[i] = 0;
	for (int i = 1; i <= n; i++)
		cnt[i] = cnt[i - 1] + (c[i] == 1 ? 1 : -1);
	int ans = 0;
	add(N);
	for (int i = 1; i <= n; i++) {
		ans += sum(cnt[i] + N);
		add(N + cnt[i]);
	}
	return ans;	
}
 main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	read(n);
	for (int i = 1; i <= n; i++) read(a[i]), b[i] = a[i];
	sort(b + 1, b + 1 + n);
	m = unique(b + 1, b + 1 + n) - b - 1;
	int l = 1, r = m, ans = 0, cnt = n * (n - 1) / 2 + n;
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (cnt - check(mid) >= (cnt / 2 + 1)) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	printf("%lld\n", b[ans]);
	return 0;
}


Measured memory_bytes: 4992
k = int(input())
s = 7
s = s % k
cnt = 0
if k % 2 == 1 and not k % 5 == 0:
    while(1):
        if s == 0:
            cnt += 1
            print(cnt)
            break
        else:
            s = (s * 10 + 7) % k
            cnt += 1
else:
    print(-1)

Measured memory_bytes: 9144
fn main() {
    use std::collections::HashSet;
    let n: u32 = read();
    let s: String = read();

    let mut ans = 0;
    for i in 0..n {
        let a: HashSet<_> = s[..(i as usize)].chars().collect();
        let b: HashSet<_> = s[(i as usize)..].chars().collect();
        let sz = a.intersection(&b).count();
        if ans < sz {
            ans = sz;
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().parse::<T>().ok().unwrap()
}


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

long long fib[45];

int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    fib[0]= 1;
    fib[1] = 1;
    
    for (int i = 2; i < 45; i++) {
        fib[i] = fib[i - 1] + fib[i - 2];
    }
    
    int n;
    cin >> n;
    cout << fib[n] << endl;
    
    return 0;
}



Measured memory_bytes: 3156
N = int(input())
A = list(map(int, input().split()))
isOK = True
B = [0]*(N+1)
B[0] = 1-A[0]
M = 1
i = 1
while i <= N:
  B[i] = B[i-1]*2-A[i]
  i += 1
if B[-1] < 0 or N > 0 and A[-1] == 0:
  isOK = False
B[-1] = A[-1]
i = N-1
while i >= 0:
  if B[i] < 1 or i > 0 and B[i] > B[i-1]*2:
    isOK = False
    break
  else:
    B[i] = min(B[i], B[i+1])+A[i]
  i -= 1
print(-1 if not isOK else sum(B))


Measured memory_bytes: 699760
import bisect
import sys
import math
from collections import deque
from heapq import heappush, heappop

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29

DIV = (10**9) + 7


def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    #calc shortest path costs by dijkstra
    #be careful edge definition
    #inputs
    #G is [[e for e in En for n in V]
    #  where as e is (cost,dest) and V is vertexes and En is n's edges
    #start is start vert
    #return
    #cost = [cn for n in V]
    #  where cn is shortest path cost from start to n
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    N,M,S = isRaw()
    UVABs = [isRaw() for _ in range(M)]
    Smax = N*51 
    G = [[] for _ in range(N*Smax)]
    
    for uvab in UVABs:
        u,v,a,b = uvab
        for s in range(a*N,Smax*N,N):
            G[s+u-1].append((b,s-(a*N)+v-1))
            G[s+v-1].append((b,s-(a*N)+u-1))
    for n in range(N):
        c,d = isRaw()
        for s in range(N, Smax*N, N):
            G[s+n].append((0,s-N+n))
            if s>=c*N:
                G[s-c*N+n].append((d,s+n))
    cost = dijkstra(G,min(S,Smax-N)*N)
    return "\n".join([str(c) for c in cost[1:N]])


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 130112
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; V<> d(2); cin >> n >> d[0] >> d[1];
  VV< pair<int, int> > adj(2);
  VV<> col; assign(col, 2, 4 * n * n);
  auto f = [&](int i, int j) { return i * 2 * n + j; };
  auto g = [&](int v) { return make_pair(v / (2 * n), v % (2 * n)); };
  for (int k = 0; k < 2; k++) {
    for (int i = 0; i < 2 * n; i++) for (int j = 0; j < 2 * n; j++) if (i * i + j * j == d[k]) {
      for (int s0 : {-1, 1}) for (int s1 : {-1, 1}) adj[k].emplace_back(s0 * i, s1 * j);
    }
    sort(adj[k].begin(), adj[k].end());
    adj[k].erase(unique(adj[k].begin(), adj[k].end()), adj[k].end());
    for (int s = 0; s < 4 * n * n; s++) if (!col[k][s]) {
      queue<int> que;
      col[k][s] = 1; que.push(s);
      while (!que.empty()) {
        int v = que.front(); que.pop();
        for (auto&& e : adj[k]) {
          int wi = g(v).first + e.first, wj = g(v).second + e.second;
          if (wi < 0 or wi >= 2 * n or wj < 0 or wj >= 2 * n or col[k][f(wi, wj)]) continue;
          col[k][f(wi, wj)] = -col[k][v]; que.push(f(wi, wj));
        } 
      }
    }
  }
  for (int k = 0; k < 4; k++) {
    int c = 0;
    for (int i = 0; i < 4 * n * n; i++) c += col[0][i] == (k & 1 ? 1 : -1) and col[1][i] == (k & 2 ? 1 : -1);
    if (c >= n * n) {
      c = 0;
      for (int i = 0; i < 4 * n * n; i++) if (col[0][i] == (k & 1 ? 1 : -1) and col[1][i] == (k & 2 ? 1 : -1)) {
        cout << g(i).first << ' ' << g(i).second << '\n';
        c++;
        if (c == n * n) return 0;
      }
    }
  }
}

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


int main() {
    int n,k;
    cin >> n >> k;
    vector<ll> v(n);
    for (int i=0;i<n;i++) {
        cin >> v[i];
    }
    int a=0,b=0,c=0;
    int ans=0,tans=0;
    priority_queue<int,vector<int>,greater<int>> p;
    for (int j=1;j<=min(n,k);j++) {
        for (int a=0;a<=j;a++) {
            int b=j-a;
            for (int l=0;l<a;l++) p.push(v[l]);
            for (int r=n-b;r<n;r++) p.push(v[r]);
            for (int m=0;m<min(j,k-j);m++) {
                if (!p.empty() && p.top()<0) p.pop();
            }
            while (!p.empty()) {
                tans+=p.top();
                p.pop();
            }
            ans=max(ans,tans);
            tans=0;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll>   pairl;
typedef vector<ll>     vl;
typedef vector<ll>     vll;
typedef vector<vector<ll> > vvl;
const   int            infi = numeric_limits<int>::max();
const   ll             infl = numeric_limits<ll>::max();
const   double         eps = 0;
const   int            ms  = 0;



int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    string S;
    cin >> S;
    int a = 0;
    for(int i = 0; i < S.size()/2; i++){
        if(S[i] != S[S.size() - i-1])a++;
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	N := ReadInt()
	As := ReadInts(N)

	max1 := 0
	max2 := 0
	m := make(map[int]bool)
	for _, a := range As {
		if m[a] {
			delete(m, a)
			if max1 < a {
				max1, a = a, max1
				if max2 < a {
					max2 = a
				}
				continue
			}
			if max2 < a {
				max2, a = a, max2
				if max1 < a {
					max1 = a
				}
			}
		} else {
			m[a] = true
		}
	}
	fmt.Println(max1 * max2)
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }

    // 集合をマージする
    // すでに同じ集合ならfalseが返る
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if(x == y) return false;
        //要素数の少ない方を多い方に繋げる
        if(data.at(y) < data.at(x)) swap(x, y);
        data.at(x) += data.at(y);
        data.at(y) = x;
        return true;
    }

    // ある要素がどの集合に属しているかを答える
    int root(int x) {
        // 根に直接つなぎ直す
        return data.at(x) < 0 ? x : (data.at(x) = root(data.at(x)));
    }

    // ある集合の大きさを答える
    int size(int x) {
        return -data.at(root(x));
    }
};

int main() {
    long long n, m;
    cin >> n >> m;
    vector<long long> a(m), b(m);
    for(int i = 0; i < m; ++i) {
        cin >> a.at(i) >> b.at(i);
        a.at(i)--; b.at(i)--;
    }    

    UnionFind UF(n);
    vector<long long> ans(m, 0);

    ans.at(m-1) = n*(n-1)/2;

    for(int i = m-1; i > 0; --i) {
        if(UF.root(a.at(i)) == UF.root(b.at(i))) {
            ans.at(i-1) = ans.at(i);
            continue;
        }
        // 新たに行き来できる頂点の分だけ減少させる
        ans.at(i-1) = ans.at(i) - (long long )1 * UF.size(a.at(i)) * UF.size(b.at(i));

        UF.merge(a.at(i), b.at(i)); 
    }

    for(int i = 0; i < m; ++i) {
        cout << ans.at(i) << endl;
    }
}

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

int main()
{
    int n;
    int i, j, k = 0, ans = 0, count = 0, judge;
    
    cin >> n;
    
    int a[n];
    
    for(i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    sort(a, a+n);
    
    do {
        count++;
        
        if(a[k] != a[k+1]) {
            
            if(a[k] > count) {
                ans = ans + count;
            } else if(a[k] < count) {
                ans = ans + (count - a[k]);
            }
            
            count = 0;
        }
        
        k++;
    } while(k < n);
    
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 640
N = int(input())
XY = [[] for _ in range(N)]
for i in range(N):
    c = int(input())
    XY[i] = [[int(j) for j in input().split()] for _ in range(c)]

"""
・N < 15
・O(N * 2^N)
"""


def popcnt(n):
    return bin(n).count('1')


def func(bits):
    for i in range(N):
        if (bits >> i) & 1 == 0:
            continue
        for x, y in XY[i]:
            x -= 1  # 0-indexed
            if (bits >> x) & 1 != y:
                return False
    return True


ans = 0
for mask in range(1 << N):
    if func(mask):
        tmp = popcnt(mask)
        ans = max(ans, tmp)
print(ans)


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

struct state{
	  int h,p,q;
	  state (int hi, int pi, int qi){
			h = hi; p = pi; q = qi;
	  }
	  bool operator > (const state& tgt) const {
			return h > tgt.h;
	  }
	  bool operator < (const state& tgt) const {
			return h < tgt.h;
	  }
};

int main(){

	  while(1){
			int n,m,a;
			cin >> n >> m >> a;
			if(!n) break;
			vector<int> x(n+1);
			for(int i=0; i<=n; i++) x[i] = i;

			vector<state> yoko;
			for(int i=0; i<m; i++){
				  int h,p,q;			cin >> h >> p >> q;
				  yoko.push_back( state(h,p,q) );
			}
			sort(yoko.begin(),yoko.end());
			reverse(yoko.begin(),yoko.end());

			for( state tgt : yoko )
				  swap(x[tgt.p],x[tgt.q]);

			for(int i=0; i<=n; i++){
				  if(x[i] == a) cout << i << endl;
//				  cout << x[i] << " ";
			}

	  }

}

Measured memory_bytes: 3096
N, x = map(int, input().split())
A = list(map(int, input().split()))
s = 0
sum_s = 0

A.sort()

for i in range(N):
    sum_s += A[i]
    if sum_s > x:
        s = i
        break

if sum_s < x:
    print(N - 1)
elif sum_s == x:
    print(N)
else:
    print(s)

Measured memory_bytes: 3064
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let n: usize = parse!(it);
    let a: Vec<usize> = parse!(it, n);
    let mut counts = std::collections::HashMap::<usize, usize>::new();
    for ai in a.iter() {
        *counts.entry(*ai).or_insert(0) += 1;
    }
    let mut s = 0;
    for (k, &v) in &counts {
        if v > 1 {
            s += v * (v - 1) / 2;
        }
    }
    let s = s;
    for i in 0..n {
        let v = counts[&a[i]];
        let mut ret = s;
        if v > 1 {
            ret -= v * (v - 1) / 2;
            ret += (v - 1) * (v - 2) / 2;
        }
        println!("{}", ret);
    }
}

fn test() {
    let mut f = fs::File::open("foo.txt").unwrap();
    let mut s = String::new();
    f.read_to_string(&mut s).unwrap();
    solve(&s);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_main() {
        test();
    }
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 18416
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int a, b;
	cin >> a >> b;
	if (a > 9 || b > 9)
		cout << -1;
	else
		cout << a * b;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if((c+b-1)/b<=(a+d-1)/d) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main(){
	int K=38;
	printf("%d %d\n",K*(K-1)+1,K);
	for(int i=1;i<=K;++i)printf("%d%c",i," \n"[i==K]);
	for(int j=0;j<K-1;++j){
		printf("1");
		for(int k=0;k<K-1;++k)
			printf(" %d",K+1+j*(K-1)+k);
		puts("");
	}
	for(int i=0;i<K-1;++i)
		for(int j=0;j<K-1;++j){
			printf("%d",2+i);
			for(int k=0;k<K-1;++k)
				printf(" %d",K+1+k*(K-1)+(k*i+j)%(K-1));
			puts("");
		}
}


Measured memory_bytes: 512
void main() {
  problem();
}

void problem() {
  auto N = scan!int;
  auto L = scan!long(N);

  long solve() {
    long ans;
    foreach(x; 0..N-2) {
      auto lx = L[x];
      foreach(y; x+1..N-1) {
        auto ly = L[y];
        if (lx == ly) continue;
        foreach(z; y+1..N) {
          auto lz = L[z];
          if (lx == lz || ly == lz) continue;
          if (lx+ly > lz && ly+lz > lx && lz+lx > ly) {
            [lx,ly,lz].deb;
            ans++;
          }
        }
      }
    }

    return ans;
  }

  solve().writeln;
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

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


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

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(ll i=ll(m); i<ll(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

const int  INF = (1 << 30) - 1;
const ll INFL = 1LL << 60;
const ll mod = 10000000007;




int main() {

	int n;
	cin >> n;
	if (n < 600)cout << 8 << endl;
	else if (n < 800)cout << 7 << endl;
	else if (n < 1000)cout << 6 << endl;
	else if (n < 1200)cout << 5 << endl;
	else if (n < 1400)cout << 4 << endl;
	else if (n < 1600)cout << 3 << endl;
	else if (n < 1800)cout << 2 << endl;
	else cout << 1 << endl;

}

Measured memory_bytes: 3644
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<cstdlib>
#define N 100010
#define M 3010
#define ll long long
#define ld long double
#define top 1e12
using namespace std;

struct data{ll x; int sum;};
int n, flag[M], l, p[M], y, ans;
ll w[N], x, x1, W;
ld xx;
map<ll, int>mp;
vector<data>son[N];

inline void prev(){
	memset(flag, 0, sizeof(flag)); l=0;
	for(int i=2; i<=3000; i++){
		if(!flag[i])p[++l]=i;
		for(int j=1; j<=l&&i*p[j]<=3000; j++){
			flag[i*p[j]]=1;
			if(i%p[j]==0)break;
		}
	}
}

inline ll ABS(ll a){return max(a, -a);}
inline ll gcd(ll a, ll b){return b?gcd(b, a%b):a;}
inline ll mul(ll a, ll b, ll p){
	ll x=(ld)a/p*b+1e-3;
	return ((a*b-x*p)%p+p)%p;
}
inline ll pow(ll y, ll x, ll p){
	ll s=1, t=y;
	while(x){if(x&1)s=mul(s, t, p); t=mul(t, t, p); x>>=1;}
	return s;
}
inline int check_p(ll a, ll r, ll sum, ll n){
	ll x=pow(a, r, n), now=x;
	for(int i=1; i<=sum; i++){
		x=mul(x, x, n);
		if(x==1&&now!=1&&now!=n-1)return 1;
		now=x;
	}
	if(x!=1)return 1;
	return 0;
}
inline int miller_rabin(ll n){
	if(n==2)return 1; if(n%2==0)return 0;
	ll r=n-1, sum=0; while(r%2==0){sum++; r>>=1;}
	for(int i=1; i<=20; i++)if(check_p(rand()%(n-1)+1, r, sum, n))return 0;
	return 1;
}
inline ll pollard_rho(ll a, ll n){
	ll k=2, x=rand()%(n-1)+1, y=x, p=1;
	for(ll i=1; p==1; i++){
		x=(mul(x, x, n)+a)%n;
		p=gcd(ABS(x-y), n);
		if(i==k){y=x; k<<=1;}
	}
	return p;
}
inline ll find_fac(ll n){
	if(n==1)return 1;
	if(miller_rabin(n))return n;
	ll t=n;
	while(t==n)t=pollard_rho(rand()%(n-1)+1, n);
	return t;
}

int main(){
	srand(1999);
	prev();
	scanf("%d", &n); mp.clear();
	for(int i=1; i<=n; i++){
		scanf("%lld", &w[i]); son[i].clear();
		for(int j=1; j<=l; j++){x=(ll)p[j]*p[j]*p[j]; while(w[i]%x==0)w[i]/=x;}
		W=w[i];
		for(int j=1; j<=l; j++){
			y=0; while(W%p[j]==0){y++; W/=p[j];}
			if(y)son[i].push_back((data){p[j], y});
		}
		if(W==1)continue;
		x=find_fac(W);
		if(x==W)son[i].push_back((data){W, 1});
		else{
			x1=W/x;
			if(x1==x)son[i].push_back((data){x, 2});
			else{son[i].push_back((data){x, 1}); son[i].push_back((data){x1, 1});}
		}
	}
	for(int i=1; i<=n; i++)mp[w[i]]++;
	ans=0;
	for(int i=1; i<=n; i++)if(w[i]>=2&&mp[w[i]]){
		xx=1.0;
		for(int j=0; j<son[i].size(); j++)xx*=son[i][j].sum==1?son[i][j].x*son[i][j].x:son[i][j].x;
		if(xx>top){ans+=mp[w[i]]; mp[w[i]]=0; continue;}
		x=1;
		for(int j=0; j<son[i].size(); j++)x*=son[i][j].sum==1?son[i][j].x*son[i][j].x:son[i][j].x;
		ans+=max(mp[w[i]], mp[x]); mp[w[i]]=mp[x]=0;
	}
	if(mp[1])ans++;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 19840
#include<bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long n,k,ft=1,sc=1,nd,ans;
long long pww(long long x,long long y)
{
	nd=1;
	while(x)
	{
		if(x%2==1)
		{
			nd*=y;
			nd%=md;
		}
		y*=y;
		y%=md;
		x/=2;
	}
	return nd;
}
int main()
{
	cin>>n>>k;
	k=min(n-1,k);
	long long nw=n,nww=1;
	for(int i=0;i<=k;i++)
	{
		ans+=ft*sc;
		ans%=md;
//		cout<<ft<<' '<<sc<<endl; 
		sc*=nw;
		sc%=md;
		sc*=pww(md-2,n-nw+1);
		sc%=md;
		ft*=n-nww;
		ft%=md;
		ft*=pww(md-2,nww);
		ft%=md;
		nw--;
		nww++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
A = sorted(A)
q = int(input())
lst = [0] * q
for i in range(q):
    lst[i] = list(map(int, input().split()))
s = sum(A)
num = [0] * 10**5
for i in A:
    num[i-1] += 1
for i in range(q):
    s += num[lst[i][0]-1] * (lst[i][1] - lst[i][0])
    num[lst[i][1]-1] += num[lst[i][0]-1]
    num[lst[i][0]-1] = 0
    print(s)

Measured memory_bytes: 90796
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<vector>
#define dint __int128
using namespace std;
#define gc getchar()
#define st first
#define nd second
#define pf push_front
#define pb push_back
#define fup(i,a,b) for(int i=a,i##e=b;i<=i##e;++i)
#define fdn(i,a,b) for(int i=a,i##e=b;i>=i##e;--i)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(a) a.begin(),a.end()
#define hh putchar(10)
#define ll long long
template<class T>inline void qin(T &x){char a,f(1);while((a=gc)<48)
(a==45)&&(f=-1);for(x=a^48;(a=gc)>47;x=(x<<3)+(x<<1)+(a^48));x*=f;}



void Main()
{
    ll a,b;
    char f;
    scanf("%lld %c %lld",&a,&f,&b);
    if(f=='+')printf("%lld",a+b);
    else printf("%lld",a-b);
}










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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

template<long long mod = 1000000007>
struct modint{
	long long a;

	modint() : a(0){}
	modint(long long t){
		a = t % mod;
		if(a < 0) a += mod;
	}

	operator long long() const{ return a; }

	bool operator==(const modint &x) const{ return a == x.a; }
	bool operator!=(const modint &x) const{ return a != x.a; }

	modint operator-() const{ return modint(a ? (mod - a) : 0); }
	modint operator~() const{ return pow(mod - 2); }

	modint operator+(const modint &x) const{ return modint(*this) += x; }
	modint operator-(const modint &x) const{ return modint(*this) -= x; }
	modint operator*(const modint &x) const{ return modint(*this) *= x; }
	modint operator/(const modint &x) const{ return modint(*this) /= x; }

	modint &operator+=(const modint &x){
		a += x.a;
		if(a >= mod) a -= mod;
		return *this;
	}
	modint &operator-=(const modint &x){
		a -= x.a;
		if(a < 0) a += mod;
		return *this;
	}
	modint &operator*=(const modint &x){
		a = a * x.a % mod;
		return *this;
	}
	modint &operator/=(const modint &x){
		a = a * (~x).a % mod; 
		return *this;
	}

	friend ostream &operator<<(ostream &os,const modint &x){
		return os << x.a;
	}
	friend istream &operator>>(istream &is,modint &x){
		long long t;
		is >> t;
		x = modint(t);
		return is;
	}

	modint pow(long long x) const{
		modint ret = 1,tmp = a;
		for(;x;tmp *= tmp,x >>= 1){
			if(x & 1) ret *= tmp;
		}
		return ret;
	}
};

signed main(){
	int n,k;
	cin >> n >> k;
	modint<> ans = 0;
	for(int i = k;i <= n + 1;i++){
		ans += modint<>(n * 2 - i + 1) * modint<>(i) / modint<>(2);
		ans -= modint<>(i - 1) * modint<>(i) / modint<>(2);
		ans += 1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3596
package main

import "fmt"

func main() {
	var q, h, s, d, n int
	fmt.Scan(&q, &h, &s, &d, &n)

	m := min(min(q*4, h*2), s)
	if n < 2 || m*2 < d {
		fmt.Println(m * n)
	} else {
		fmt.Println((n/2)*d + (n%2)*m)
	}
}

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


Measured memory_bytes: 512
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<set>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<stack>
#include<tuple>
#include<utility>
#define mod 1000000007;
typedef long long ll;
#define rep(i,n) for(ll i=0; i<n; i++)
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(a >= 13){
    cout << b;
  }else if(6 <= a and a <= 12){
    cout << b/2;
  }else{
    cout << 0;
  }
  return 0;
}


Measured memory_bytes: 256
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

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

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int n,x,y;
vvi edges;
deque<int> q;
int dp[2][100010],visited[100010], ret;

int accum(int n){
    visited[n] = 1;
    dp[0][n] = 1;
    dp[1][n] = 1;
    for(auto ch: edges[n]){
        if (visited[ch]) continue;
        accum(ch);
        dp[0][n] *= (dp[0][ch] + dp[1][ch]);
        dp[0][n] %= mod;
        dp[1][n] *= (dp[0][ch]);
        dp[1][n] %= mod;
    }
    return (dp[0][n] + dp[1][n]) % mod;
}

signed main(){
    I(n);
    edges.resize(n);
    REP(i,n-1){
        I(x); I(y);
        x--; y--;
        edges[x].pb(y);
        edges[y].pb(x);
    }
    
    cout << accum(0) << endl;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define mod2 998244353
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	int fpow(int base, int power, int MOD) {
    int result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 
	int modinv(int x) {return fpow(x, mod - 2, mod);}
		ll power(ll a, ll b)	//a is base, b is exponent
		{
			if(b==0)
				return 1;
			if(b==1)
				return a;
			if(b%2 == 1)
				return (power(a,b-1)*a);
			ll q = power(a,b/2);
			return (q*q);
		}
	
	void solve()
	{
		ll n;
		cin>>n;
		string ans="";

		ll pr=26;
		if(n==1)
		{
			cout<<"a"<<endl;
			return;
		}
		forab(i,1,99)
		{
			if(n<=power(26,i))
			{
				n-=1;
				forn(j,i)
				{
					ans+='a'+n%26;
					n/=26;
				}
				break;
			}
			else
			{
				n-=power(26,i);
			}
		}
		reverse(all(ans));
		cout<<ans<<endl;
	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
		//cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		return 0;
	}


Measured memory_bytes: 3616
import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main()
{
auto ip = readln.split.to!(int[]);
writeln((ip[0]*ip[1]).to!string ~ " " ~ (ip[0]*2+ip[1]*2).to!string);
}


Measured memory_bytes: 2432
N = int(input())
A = list(map(int, input().split(' ')))

mod = 10 ** 9 +7
amount = sum(A)
calc = []
for i in range(N - 1):
  amount = amount - A[i]
  calc.append(amount)

for i in range(N - 1):
  calc[i] *= A[i]

print(sum(calc) % mod)

Measured memory_bytes: 31432
#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

int main(){
    string S;
    cin >> S;
    if(S[2]==S[3]&&S[4]==S[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	string s,t;
	cin>>s>>t;
	int ans=0;
	int i;
	int n=s.length();
	for(i=0;i<n;i++)
	if(s[i]!=t[i])
	ans++;
	cout<<ans<<endl;
	return 0;
}



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

int main() {
    int n;
    cin >> n;
    string s, p;
    set<string> st;
    for(int i = 0; i < n; i++) {
        cin >> s;
        if ((i == 0 || p[p.size() - 1] == s[0]) && st.count(s) == 0) {
            st.insert(s);
            p = s;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
//Created by Aminul on 7/5/2020.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = in.nextInt();
        int res = n / 1000;
        if (n % 1000 != 0) res++;
        res = (res * 1000) - n;
        pw.println(res);

        pw.close();
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}

Measured memory_bytes: 27064
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
const double pi=acos(-1.0);
int main()
{
	ll a,c,d;
	float b;
	scl(a);scanf("%f",&b);
	c=(long long)b;
	d=a*c;
	c=((long long)(b*100+.5))%100;
	d+=a*c/100;
	pf("%lld\n",d);
}

Measured memory_bytes: 3776
#include<iostream>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int L,A,B,C,D;//L:winter vacation A:Japanese homework B:math homework
	cin>>L>>A>>B>>C>>D;
	double spentA=(double)A/C;
	double spentB=(double)B/D;
	int wasteA=(int)spentA;
	int wasteB=(int)spentB;
	int ansA,ansB;
	if(spentA==wasteA)ansA=wasteA;
	else ansA=wasteA+1;
	if(spentB==wasteB)ansB=wasteB;
	else ansB=wasteB+1;
	//cout<<ansA<<" "<<ansB<<endl;
	cout<<L-max(ansA,ansB)<<endl;
	return 0;
}

Measured memory_bytes: 1160
datos=input().split()
d12=int(datos[0])
d13=int(datos[1])
d23=int(datos[2])
#Comenzado por ciudad 1
dm=d12+d23
dm1=d13+d12
dm2=d13+d23
if dm<=dm1 and dm<=dm2:
    print(str(dm))
elif dm1<=dm and dm1<=dm2:
    print(str(dm1))
elif dm2<=dm and dm2<=dm1:
    print(str(dm2))

Measured memory_bytes: 8912
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}
import java.lang

import scala.collection.mutable.ArrayBuffer
import scala.reflect.ClassTag

object Main {
  def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {
    converter(in.readLine)
  }

  def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {
    get[String].split("\\s+").map[T](converter)
  }

  implicit val idConverter: String => String = s => s
  implicit val intConverter: String => Int = s => Integer.parseInt(s)
  implicit val longConverter: String => Long = s => lang.Long.parseLong(s)

  def get[T1, T2](
                   implicit in: BufferedReader,
                   converter1: String => T1,
                   converter2: String => T2
                 ): (T1, T2) = {
    getArray[String] match {
      case Array(v1, v2) => (converter1(v1), converter2(v2))
    }
  }

  def get[T1, T2, T3](
                       implicit in: BufferedReader,
                       converter1: String => T1,
                       converter2: String => T2,
                       converter3: String => T3
                     ): (T1, T2, T3) = {
    getArray[String] match {
      case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))
    }
  }

  implicit class TimesInt(val n: Int) {
    def times(f: Int => Unit): Unit = {
      for (i <- 0 until n) {
        f(i)
      }
    }
  }

  def primes(n: Long): ArrayBuffer[Long] = {
    val buf = ArrayBuffer.empty[Long]
    val s = Math.sqrt(n).toInt

    var v = n
    for (i <- 2 to s) {
      if (v == 1 || v == 0) {
        return buf
      } else {
        while (v % i == 0) {
          buf.append(i)
          v /= i
        }
      }
    }
    if (v > s) {
      buf.append(v)
    }
    buf
  }

  def main(args: Array[String]): Unit = {
    implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val (a, v) = get[Int, Int]
    val (b, w) = get[Int, Int]
    val t = get[Int]

    out.println(
      if (v > w && 1L * (v - w) * t >= Math.abs(a - b)) {
        "YES"
      } else {
        "NO"
      }
    )

    out.flush()
  }
}

Measured memory_bytes: 56972
def partition(arr, p, r):
    x = arr[r]
    i = p - 1
    for j in range(p, r):
        if arr[j] <= x:
            i += 1
            arr[i], arr[j] = arr[j], arr[i]
    arr[i + 1], arr[r] = arr[r], arr[i + 1]
    print(" ".join(str(ele) if j != i + 1 else "[{}]".format(ele) for j, ele in enumerate(arr)))


n = int(input())
arr = list(map(int, input().split()))
partition(arr, 0, n - 1)



Measured memory_bytes: 16400
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    s[3] = '8';
    cout << s << '\n';
}


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

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i = 0 ; i < N ; i++) cin >> A[i];
	sort(A.rbegin(),A.rend());
	map<int,int> c;
	vector<long long> a(4);

	for(int i = 0 ; i < A.size() ; i++){
		c[A[i]]++;
		if( c[A[i]] >= 2){
			c[A[i]] -= 2;
			a.push_back(A[i]);
		}
	}
	sort(a.rbegin(),a.rend());
	cout << a[0] * a[1] << endl;
}

Measured memory_bytes: 5376
// finish date: 2018/01/22
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}


int main() {
    int N, M;
    cin >> N >> M;
    if (abs(N - M) >= 2) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 1;
    int n=N,m=M;
    while (n != 0) {
        ans = mul(ans, n);
        n--;
    }
    while (m != 0) {
        ans = mul(ans, m);
        m--;
    }
    if (N == M) cout << mul(2, ans) << endl;
    else cout << ans << endl;

    return 0;
}



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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int N = 200005;
const int MOD = 2019;

int ten[N], t[N], cnt[MOD];

int main() {

    FAST;

    string a;
    cin >> a;
    ten[0] = 1;
    int n = a.length();
    a = ' ' + a;
    for (int i = 1; i <= n; i ++) {
        ten[i] = (ten[i - 1] * 10) % MOD;
    }
    t[n] = 0;
    for (int i = n - 1; i >= 0; i --) {
        t[i] = (t[i + 1] + (ten[n - i - 1]) * (int(a[i + 1]) - '0')) % MOD;
    }
    for (int i = 0; i <= n; i ++) {
        cnt[t[i]] ++;
    }
    int ans = 0;
    for (int i = 0; i < MOD; i ++) {
        ans += cnt[i] * (cnt[i] - 1) / 2;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 5268
/**
*	  Name: Ajay
*	  Institute: IIITH 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
#define fi first
#define se second
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void input()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}
int main()
{      
 int H, W;
    cin >> H >> W;
    bool s[H][W];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            s[i][j] = false;
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            char c;
            cin >> c;
            if (c == '#') s[i][j] = true;
        }
    }
 
    for (int i = 0; i < H; i++ ) {
        for (int j = 0; j < W; j++) {
            if (s[i][j] == true) {
                if (s[min(H, i+1)][j] == false && s[i][min(W, j+1)] == false &&
                    s[max(0, i-1)][j] == false && s[i][max(0, j-1)] == false) {
 
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
 
    cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
vi out,in;
int n;
bool f(int a,int t){
	if(a==0){
		rep(i,n){
			if(i)cout<<" ";
			cout<<out[n-1-i];
		}
		cout<<endl;
		return true;
	}
	loop(i,1,14)if(in[i]&&(a-i)%i==0){
		in[i]--;
		out[t]=i;
		if(f(a-i,t+1))return true;
		in[i]++;
	}
	return false;
}
int main(){
	while(cin>>n,n){
		out=vi(n);
		in=vi(14);
		int sum=0;
		rep(i,n){
			int a;cin>>a;
			sum+=a;
			in[a]++;
		}
		if(!f(sum,0))cout<<"No"<<endl;
	}
}

Measured memory_bytes: 1216