akhauriyash/Code-Regression huggingface dataset:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
"""
n = I()
d = defaultdict(int)
a = LI()
for i in a:
    d[i] += 1
    d[i+1] += 1
    d[i-1] += 1
d = list(d.values())
print(max(d))
"""

#D
n = I()
a = LI()
k = 0
for i in range(n-1):
    if a[i] == i+1:
        x = a[i]
        a[i] = a[i+1]
        a[i+1] = x
        k += 1
if a[n-1] == n:k += 1
print(k)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 56080
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main() {
	ll N,x;
	cin >> N >> x;
	vector<ll> a(N);
	for(ll i=0; i<N; i++) cin >> a[i];

	ll cnt=0;
	for (ll i = 0; i < N-1; i++) {
		if (i == 0) {
			if (a[i] > x) {
				cnt += a[i]-x;
				a[i] = x;
			}
			if ((a[i] + a[i + 1]) > x) {
				cnt += (a[i]+a[i+1]-x);
				a[i+1] -= a[i]+a[i+1]-x;
			}
		}
		else {
			if ((a[i] + a[i + 1]) > x) {
				cnt += (a[i] + a[i + 1] - x);
				a[i + 1] -= a[i] + a[i + 1] - x;
			}
		}
	}

	cout << cnt << endl;

}

Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>

int main(void){
	double r;
	double a;
	double b;

	scanf("%lf", &r);

	a = M_PI*r*r;
	b = 2*M_PI*r;

	printf("%f %f\n", a,b);

	return 0;
}




Measured memory_bytes: 2692
#include <iostream>
using namespace std;
int main() {
  int i, n;
  cin >> n;
  int a[n], b[n];
  for(i = 0; i < n; i++) { cin >> a[i]; }
  for(i = n - 1; i >= 0; i--) {
	if (i) { cout << a[i] << " "; }
	else { cout << a[i] << endl; }
  }
  return 0;
}

Measured memory_bytes: 3076
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

if __name__ == "__main__":
    p = 998244353
    N = 2 *(10**5)  # N は必要分だけ用意する
    fact = [1, 1]  # fact[n] = (n! mod p)
    factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
    inv = [0, 1]  # factinv 計算用

    for i in range(2, N + 1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)
    n = 1
    A = [1]
    ans = 0
    N,M,K = map(int,input().split())
    for i in range(N-1):
        n = n*(M-1)%p
        A.append(n)
    for i in range(K+1):
        a = A[N-1-i]*M % p
        b = cmb(N-1,i,p)
        ans = (ans +(a*b)%p)%p
    print(ans)

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

FIRST = "first"
SECOND = "second"

def solve(N: int, a: "List[int]"):
    for i in range(N):
        if a[i]%2 == 1:
            print(FIRST)
            return
    print(SECOND)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 7076
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vs = vector<string>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    ll q, h, s, d;
    cin >> q >> h >> s >> d;
    h = min(h, q+q);
    s = min(s, h+h);
    d = min(d, s+s);
    ll n;
    cin >> n;
    ll ans = n/2*d + n%2*s;
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
int main() {
	int n, k, q;
	cin >> n >> k >> q;

	vector<int>vec(q);
	rep(i, q) cin >> vec[i];

	vector<int>ans(n);
	int m = k - q;
	rep(i, n) ans[i] = m;

	rep(i, q) {
		ans[vec[i] - 1]++;
	}

	vector<string>mxm(n);
	rep(i, n) {
		if (ans[i] > 0) {
			mxm[i] = "Yes";
		}
		else {
			mxm[i] = "No";
		}
	}
	rep(i, n)cout << mxm[i] << endl;
}

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

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> dp(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	dp[0] = 0;
	dp[1] = abs(v[1] - v[0]);
	for (int i = 2; i < n; i++)
		dp[i] = min(dp[i - 1] + abs(v[i] - v[i - 1]), dp[i - 2] + abs(v[i] - v[i - 2]));
	cout << dp[n - 1];
}


Measured memory_bytes: 1024
package main
 
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)
func main(){
    cnt := 1
    for {
        i := nextInt()
        if i == 0 {
            break
        }
        fmt.Printf("Case %v: %v\n", cnt, i)
        cnt++
    } 
}
 
/* templates */
 
func Max(a ...int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r < a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Min(a ...int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r > a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Sum(a []int) (r int) {
    for i := range a {
        r += a[i]
    }
    return r
}
 
func Abs(a float64) float64 {
    if a < 0 {
        return -a
    }
    return a
}
 
type Pair struct {
    a, b int
}
 
type Pairs []Pair
 
func (p Pairs) Len() int {
    return len(p)
}
 
func (p Pairs) Swap(i, j int) {
    p[i], p[j] = p[j], p[i]
}
 
func (p Pairs) Less(i, j int) bool {
    return p[i].b < p[j].b
}
 
var nextReader func() string
 
func init() {
    nextReader = NewScanner()
}
 
func NewScanner() func() string {
    r := bufio.NewScanner(os.Stdin)
    r.Buffer(make([]byte, 1024), int(1e+11))
    r.Split(bufio.ScanWords)
    return func() string {
        r.Scan()
        return r.Text()
    }
}
 
func nextString() string {
    return nextReader()
}
 
func nextInt64() int64 {
    v, _ := strconv.ParseInt(nextReader(), 10, 64)
    return v
}
 
func nextInt() int {
    v, _ := strconv.Atoi(nextReader())
    return v
}
 
func nextInts(n int) []int {
    r := make([]int, n)
    for i := 0; i < n; i++ {
        r[i] = nextInt()
    }
    return r
}
 
func nextFloat64() float64 {
    f, _ := strconv.ParseFloat(nextReader(), 64)
    return f
}


Measured memory_bytes: 1312
#!/usr/bin/env python3
# vim: set fileencoding=utf-8

# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation


"""Module docstring
"""

import functools
import heapq
import itertools
import logging
import math
import random
import string
import sys
from argparse import ArgumentParser
from collections import defaultdict, deque
from copy import deepcopy
from typing import Dict, List, Optional, Set, Tuple


def solve(a: int, b: int, n: int) -> int:
    x = min(n, b - 1)
    return (a * x) // b - a * (x // b)


def do_job():
    "Do the work"
    LOG.debug("Start working")
    # first line is number of test cases
    A, B, N = list(map(int, input().split()))
    # values = []
    # for _ in range(N):
    #     values.append(input().split())
    result = solve(A, B, N)
    print(result)


def print_output(testcase: int, result) -> None:
    "Formats and print result"
    if result is None:
        result = "IMPOSSIBLE"
    print("Case #{}: {}".format(testcase + 1, result))
    # 6 digits float precision {:.6f} (6 is the default value)
    # print("Case #{}: {:f}".format(testcase + 1, result))


def configure_log() -> None:
    "Configure the log output"
    log_formatter = logging.Formatter("%(lineno)d - " "%(message)s")
    handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(log_formatter)
    LOG.addHandler(handler)


LOG = None
# for interactive call: do not add multiple times the handler
if not LOG:
    LOG = logging.getLogger("template")
    configure_log()


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    parser = ArgumentParser()
    parser.add_argument(
        "-v",
        "--verbose",
        dest="verbose",
        action="store_true",
        default=False,
        help="run as verbose mode",
    )
    args = parser.parse_args(argv)
    if args.verbose:
        LOG.setLevel(logging.DEBUG)
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())


class memoized:
    """Decorator that caches a function's return value each time it is called.
    If called later with the same arguments, the cached value is returned, and
    not re-evaluated.
    """

    def __init__(self, func):
        self.func = func
        self.cache = {}

    def __call__(self, *args):
        try:
            return self.cache[args]
        except KeyError:
            value = self.func(*args)
            self.cache[args] = value
            return value
        except TypeError:
            # uncachable -- for instance, passing a list as an argument.
            # Better to not cache than to blow up entirely.
            return self.func(*args)

    def __repr__(self):
        """Return the function's docstring."""
        return self.func.__doc__

    def __get__(self, obj, objtype):
        """Support instance methods."""
        return functools.partial(self.__call__, obj)


Measured memory_bytes: 82552
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
int n;
int a[1000001];
int cnt[201][2];
signed main()
{
	scanf("%lld",&n);
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		for(int j=0;j<=60;j++)
			ans+=1ll*(1ll<<j)%mod*cnt[j][((a[i]>>j)&1)^1]%mod,
			ans%=mod;
		for(int j=0;j<=60;j++)
			cnt[j][((a[i]>>j)&1)]++;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("0fast")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i=0;i<(int)(n);++i)

template <typename T> lint gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> lint lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b)a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b)a=b;}
typedef pair<int,int> P ;

int h, w;
int dis[20][20];
char grid[30][30];

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

inline bool inside(int x, int y) {
  return 0 <= x && x < h && 0 <= y && y < w;
}

int bfs(int x, int y) {
  rep(i, h) {
    rep(j, w) {
      dis[i][j] = 100000;
    }
  }
  dis[x][y] = 0;
  queue<P> que;
  que.push(P(x,y));
  while (que.size()) {
    int s, t;
    tie(s,t) = que.front();
    que.pop();
    
    for (int i = 0; i < 4; ++i) {
      int nx = s + dx[i], ny = t + dy[i];
      if (!inside(nx,ny) || grid[nx][ny] == '#') {
        continue;
      }
      if (dis[nx][ny] > dis[s][t] + 1) {
        dis[nx][ny] = dis[s][t] + 1;
        que.push(P(nx,ny));
      }
    }
  }
  int ret = 0;
  rep(i,h) {
    rep(j,w) {
      if (grid[i][j] == '.') {
        chmax(ret, dis[i][j]);
      }
    }
  }
  return ret;
}


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> w;
  rep(i,h) {
    rep(j,w) {
      cin >> grid[i][j];
    }
  }
  int ans = 0;
  rep(i,h) rep(j,w) {
    if (grid[i][j]=='.') {
      chmax(ans, bfs(i,j));
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    ll ans = (n-1)*b + a;
    ans -= b + (n-1)*a;
    ans++;
    ans = max(ans, 0ll);
    if (a == b) ans = 1;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
x = []
s = 0
for i in range(n):
    s += a[i]
    if i > 0:
        x.append(x[i-1] + a[i])
    else:
        x.append(a[i])
for i in range(n-1):
    if i > 0:
        ans = min(abs(2 * x[i] - s), ans)
    else:
        ans = abs(2 * x[i] - s)
print(ans)

Measured memory_bytes: 23800
#include<iostream>
using namespace std;
#define N  200000
int main()
{
	int i;
	int n;
	int min;
	int max;
	int num[N];
	cin >> n;
	for (i = 0;i < n;i++)
	{
		cin >> num[i];
	}
	min = num[0];
	max = -2000000000;
	for (i = 1;i < n;i++)
	{
		if ((num[i] - min) > max)
		{
			max = num[i] - min;
		}
		if (num[i] < min)
		{
			min = num[i];
		}
	}
	cout << max << endl;
    return 0;
}


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

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    long long N;
    cin >> N;
    auto pf = prime_factorize(N);
    long long res = 0;
    for (auto p : pf) {
        long long e = p.second;
        long long tmp = 0, cur = 1;
        while (e >= cur) e -= cur++, ++tmp;
        res += tmp;
    }
    cout << res << endl;
}

Measured memory_bytes: 3560
N,M = map(int,input().split())
PY = [tuple(map(int,input().split())) for i in range(M)]
ypi = sorted((y,p,i) for i,(p,y) in enumerate(PY))

from collections import defaultdict
d = defaultdict(lambda: 0)
ans = [None] * M
for y,p,i in ypi:
    d[p] += 1
    ans[i] = str(p).zfill(6) + str(d[p]).zfill(6)
print(*ans, sep='\n')

Measured memory_bytes: 44008
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef long long LL;
const int INF = 999999999;

struct edge
{
  int src, to, cost;
};
using Edges = vector<edge>;
using WeightedGraph = vector<Edges>;

vector<int> tsort(WeightedGraph &G){
    vector<int> tsorted;
    vector<int> used(G.size(), 0);
    bool f = false;
    function<void(int)> dfs = [&](int u){
        if(used[u] > 0){
            if(used[u] == 1) f = true;
            return;
        }
        used[u] = 1;
        for(auto &e : G[u]) dfs(e.to);
        used[u] = 2;
        tsorted.pb(u);
    };
    rep(i, G.size()) dfs(i);
    if(f) return vector<int>();
    reverse(all(tsorted));
    return tsorted;
}

int main()
{
  int n, m;
  cin >> n >> m;
  WeightedGraph G(n);
  rep(i, m)
  {
    int s, t;
    cin >> s >> t;
    G[s].emplace_back((edge){s, t, 1});
  }
  vector<int> ans = tsort(G);
  cout << (ans.size() == 0 ? 1:0) << endl;
}



Measured memory_bytes: 3180
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN= (int)1e5+10;
const ll MOD = (ll)1e9+7;
char str[MAXN];
int main()
{	
	cin>>(str+1);
	int ans=0;
	int len=strlen(str+1);
	for(int i=len/2;i>=1;i--){
		for(int j=0;j+i+i<len;j++){
			int f=1;
			for(int k=0;k<i&&f;k++){
				if(str[j+k]!=str[i+j+k])f=0;
			}
			if(f){
				ans=i;
				break;
			}
		}
		if(ans!=0)break;
	}
	cout<<ans*2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

using namespace std;

typedef long long ll;

#define f first
#define s second

ifstream fin ("hmmm.in");
ofstream fout ("hmmm.out");

ll n, a, b;


int main()
{
  cin >> n >> a >> b;
  if (abs(a - b) % 2 == 0)
    cout << abs(a - b) / 2;
  else {
    ll aux = a - 1 + (b - a + 1) / 2;
    aux = min(aux, n - b + (b - a + 1) / 2);
    cout << aux;
  }
  return 0;
}


Measured memory_bytes: 256
import sys
N = int(sys.stdin.readline())
S = [sys.stdin.readline() for i in range(N)]
M = int(sys.stdin.readline())
T = [sys.stdin.readline() for j in range(M)]
ans = 0
for s in S:
  money = S.count(s) + T.count(s) * -1
  ans = max(ans, money)
print(ans)

Measured memory_bytes: 3064
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/26/20 20:17:32
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

constexpr ll MOD = 2019;

ll modpow(ll x, ll p) {
  ll u = x;
  ll t = 1;
  while (p) {
    if (p&1) (t *= u)%=MOD;
    (u *= u)%=MOD;
    p>>=1;
  }
  return t;
}

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

  string s; cin>>s;
  auto n = s.size();
  map<int, ll> bit;
  bit[0]++;
  ll num = 0;
  ll ans = 0;
  for (int i = n-1; i >= 0; i--) {
    auto x = s[i]-'0';
    (num += (x*modpow(10, n-1-i)))%=MOD;
    ans += bit[num];
    bit[num]++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3788
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = in.nextInt();
        int [][] arr = new int[2][n];
        for (int i = 0; i < 2; i++){
            for (int j = 0; j < n; j++){
                arr[i][j] = in.nextInt();
            }
        }
        int best = 0, row_jump = 0;
        for(int k = 0; k < n; k++){
            int sum = 0, i = 0;
            for (int j = 0; j < n; j++){
                sum += arr[i][j];
                if (i == 0 && j == row_jump){
                    i++;
                    row_jump++;
                    sum += arr[i][j];
                }
            }
            best = Math.max(best, sum);
        }
        System.out.println(best);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

template <typename T>
vector<vector<T>> PascalTriangle(int n){
    vector<vector<T>> C(n + 1, vector<T>(n + 1));
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= i; j++){
            if(j == 0 || j == i) C[i][j] = 1;
            else C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        }
    }
    return C;
}

signed main(){
    int n,a,b;
    cin >> n >> a >> b;
    ll v[n];
    REP(i,n){
        cin >> v[i];
    }
    sort(v, v + n);
    reverse(v, v + n);
    double maxave = 0.0;
    for(int i = 0; i < a; i++){
        maxave += (double)v[i];
    }
    maxave /= a;
    printf("%.10lf\n", maxave);
    vector<vector<ll>> C = PascalTriangle<ll>(50);
    if(v[0] != v[a - 1]){
        int cntall = 0, cntin = 0;
        for(int i = 0; i < n; i++){
            if(v[i] == v[a - 1]) cntall++;
        }
        for(int i = 0; i < a; i++){
            if(v[i] == v[a - 1]) cntin++;
        }
        cout << C[cntall][cntin] << endl;
    }else{
        int cntall = 0;
        for(int i = 0; i < n; i++){
            if(v[i] == v[0]) cntall++;
        }
        ll ans = 0;
        for(int i = a; i <= min(cntall, b); i++){
            ans += C[cntall][i];
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int A,p;
int main(){
    cin >> A >> p;
    print((A*3+p)/2);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);


	Int a, b;
	cin >> a >> b;

	Int ans = max({ a + b,a - b,a * b });
	cout << ans << endl;


}

Measured memory_bytes: 256
/*
 Educational Dp Contest Atcoder
 
 */

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define all(x) x.begin(),x.end()

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}

const ll MOD =998244353;
const ll hell=1000000007;
const int INF=1e16;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

const int N=3000+5;
int dp[N][N];
void solve()
{
    string s,t;
    cin>>s>>t;
    int n=s.length(),m=t.length();
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(s[i-1]==t[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int i=n,j=m;stack<char>ans;
    while(i>0&&j>0)
    {
        if(s[i-1]==t[j-1])
        {
            ans.push(s[i-1]);
            i--;j--;
        }
        else
        {
            if(dp[i][j]==dp[i-1][j])
                i--;
            else
                j--;
        }
    }
    while(!ans.empty())
    {
        cout<<ans.top();
        ans.pop();
    }
    cout<<endl;
}

int32_t main()
{
    
    IOS;
    //FILE *fin = freopen("in","r",stdin);
    //FILE *fout = freopen("out","w",stdout);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 70784
/*  ITP1_10_C:Standard Deviation */
/* 20181125 AOJ */

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <math.h>
#define N 1000

int main(void) {
	int n, i;
	double score[N], sum, ave, a;

	while(1) {
		scanf("%d", &n);
		if(n == 0) break;
		
		sum = 0;
		for(i = 0; i < n; i++) {
			scanf("%lf", score + i);
			sum += score[i];
		}
		ave = sum / n;
		sum = 0;
		for(i = 0; i < n; i++) {
			sum += pow(score[i] - ave, 2);
		}
		a = sqrt(sum / n);
		printf("%lf\n", a);
	}
	
	return 0;
}


Measured memory_bytes: 2108
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    int W,H,a = 0,b = 0;
    char s ='#',d = '.';
    while(1){
        cin>>H>>W; 
        if(W==0||H==0)break;
        for( a=0;a<H;a++){
            for(b = 0; b<W;b++){
               if(a == 0){ 
                   cout<<s;
               }else if(a > 0 && a<H -1){
                   if(b == 0)cout<<s;
                   else if (b == W-1)cout<<s;
                    else cout<<d;
               }else if(a<H){
                   cout<<s;
               }
            }
           
            cout<<endl;
        }
cout<<endl;
      
    }
    
}




Measured memory_bytes: 2984
h,w=map(int, input().split())

a=[]
for _ in range(h):
    # 追加の前に、行での除去を行う
    s=input()
    if not s.count(".")==w:
        a.append(list(s))
h=len(a)

j=0
while(j<len(a[0])):
    white_count=0
    for i in range(h):
        if a[i][j]=="#":
            j+=1
            break
        else:
            white_count+=1
    if white_count==h:
        for i in range(h):
            a[i]=a[i][:j] +a[i][j+1:]

for i in range(h):
    print("".join(a[i]))

Measured memory_bytes: 3188
N=int(input())
ac = wa = tle = re =0
for cnt in range(N):
  S=input()
  if S=='AC':
    ac=ac+1
  elif S=='WA':
    wa=wa+1
  elif S=='TLE':
    tle=tle+1
  elif S=='RE':
    re=re+1
print('AC x '+str(ac)+'\nWA x '+str(wa)+'\nTLE x '+str(tle)+'\nRE x '+str(re))

Measured memory_bytes: 9204
#include<bits/stdc++.h>
#define int long long
int a[214514];
int b[214514];
using namespace std;
signed main(){
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int j=0;j<n;j++){
        b[a[j]]+=1;
    }
    sort(b+1,b+n+1);
    int shurui=0;
    for(int l=1;l<n+1;l++){
        if(b[l]>0){
            shurui++;
        }
    }
    int ans=0;
    for(int m=0;m<n;m++){
        if(b[m]>0&&shurui>k){
            ans+=b[m];
            shurui--;
        }
        if(shurui<=k){
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3328
#include <stdio.h>

long long ticket[] = {0, 6000, 4000, 3000, 2000};
long long ans[5];

int main()
{
    long long t, n;

    for (long long i = 0; i < 4; i++) {
        scanf("%lld %lld", &t, &n);
        //  ans[t] = ticket[t] * n;
        printf("%lld\n", ticket[t] * n);
    }

    /*
    for (long long i = 1; i <= 4; i++) {
        printf("%d\n", ans[i]);
    }
    */
    
    return 0;
}



Measured memory_bytes: 2056
import java.util.Scanner;

public class Main {
	static int check(char[] str) {
		int sum = 0;
		int temp = 1;
		for(int i=0; i<str.length; i++) {
			if(Character.isDigit(str[i])) {
				temp = Character.getNumericValue(str[i]);
			}
			switch (str[i]) {
			case 'm':
				sum += 1000 * temp;
				temp = 1;
				break;
			case 'c':
				sum += 100 * temp;
				temp = 1;
				break;
			case 'x':
				sum += 10 * temp;
				temp = 1;
				break;
			case 'i':
				sum += 1 * temp;
				temp = 1;
				break;
			}

		}
		return sum;
	}
	static String toStr(int sum) {
		String str = "";
		if(sum/1000 != 0) {
			int a = sum/1000;
			if(a==1) {
				str += "m";
			}else {
				str += a + "m";
			}
			sum -= 1000*a;
		}if(sum/100 != 0) {
			int a = sum/100;
			if(a == 1) {
				str += "c";
			}else {
				str += a + "c";
			}
			sum -= 100*a;
		}if(sum/10 != 0) {
			int a = sum / 10;
			if(a == 1) {
				str += "x";
			}else {
				str += a + "x";
			}
			sum -= 10*a;
		}if(sum != 0) {
			if(sum == 1) {
				str += "i";
			}else {
				str += sum + "i";
			}
		}
		
		
		return str;
	}
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			for(int i=0; i<n; i++) {
				String s1 = sc.next();
				String s2 = sc.next();
				char[] str1 = new char[s1.length()];
				char[] str2 = new char[s2.length()];
				str1 = s1.toCharArray();
				str2 = s2.toCharArray();
				
				int sum = check(str1) + check(str2);
				
				System.out.println(toStr(sum));
				
				
				
				
				
			}
			
			
				
		}
	}
}


Measured memory_bytes: 38284
#include<stdio.h>
#include<string.h>
#define STRINGLENGTH 101

int main (void){
    int n, scorep1 = 0, scorep2 = 0;
    char cardp1[STRINGLENGTH], cardp2[STRINGLENGTH];
    
    scanf("%d",&n);

    for (int i = 0; i < n; i++)
    {
        scanf("%s",cardp1);
        scanf("%s",cardp2);
        if ( strcmp(cardp1, cardp2) == 0 ){scorep1++;scorep2++;}
        else if ( strcmp(cardp1, cardp2) > 0 ){scorep1+=3;}
        else if ( strcmp(cardp1, cardp2) < 0 ){scorep2+=3;}
    }
    printf("%d %d\n",scorep1,scorep2);
    return 0;
}





Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod=1e9+7;
int n;
vector<vector<ll> >multi(vector<vector<ll> >a,vector<vector<ll> > b)
{
  vector<vector<ll > >ans(n+1,vector<ll>(n+1));
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=n;j++)
    {
      for(int k=1;k<=n;k++)
        ans[i][j]=(ans[i][j]+(a[i][k]*b[k][j])%mod)%mod;
    }
  }
  return ans;
}
vector<vector<ll> >power(vector<vector<ll> >a,ll k)
{
  if(k==1)
   return a;
  vector<vector<ll> >b=power(a,k/2);
  b=multi(b,b);
  if(k&1)
  return multi(b,a);
  return b;
}
int main()
{
  ll k;
  cin>>n>>k;
  vector<vector<ll> >mat(n+1,vector<ll>(n+1));
  for(int i=1;i<=n;i++)
  for(int j=1;j<=n;j++)
  cin>>mat[i][j];
  mat=power(mat,k);
  ll ans=0;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
      ans=(ans+mat[i][j])%mod;
  cout<<ans<<endl;
}
  
      

Measured memory_bytes: 1664
N = int(input())
S = input()
ans = 0

numlist = [str(i) for i in range(10)]
for a in numlist:
    idx_a = S.find(a)
    if idx_a == -1 or idx_a >= N - 2:
        continue
    
    for b in numlist:
        idx_b = S[idx_a+1:].find(b)
        if idx_b == -1 or idx_a + idx_b + 1 >= N - 1:
            continue
        
        for c in numlist:
            if c in S[idx_a + idx_b + 2:]:
                ans += 1
print(ans)

Measured memory_bytes: 9220
s = input().strip()
t = input().strip()

if not set(t) <= set(s):
  print(-1)
  exit()
  
result = 0
now_i = 0
for c in t:
  #print(c, now_i, result)
  if not c in s[now_i:]: # リセット
    result += len(s)-now_i
    now_i = 0
  di = s[now_i:].index(c)
  di += 1
  result += di
  now_i = (now_i + di) % len(s)
print(result)

Measured memory_bytes: 3316
#include <stdio.h>
#include <math.h>

int main(void) {
	_Bool flag[60000];
	int answer[2];
	int i, j;
	int n;
	while (scanf("%d", &n) != EOF) {
		memset(flag, 0, sizeof(flag));
		i = 2;
		for (i = 2; i <= 3 || i <= sqrt(n); i++) {
			for (j = 2; i*j <= 60000; j++) {
				flag[i*j-1] = 1;
			}
		}
		for (i = n-1; i >= 2 ;i--) {
			if (!flag[i-1]) {
				answer[0] = i;
				break;
			}
		}
		for (i = n+1; i <= 60000; i++) {
			if (!flag[i-1]) {
				answer[1] = i;
				break;
			}
		}
		printf("%d %d\n", answer[0], answer[1]);
	}
	return 0;
}

Measured memory_bytes: 660
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		}
		int x = partition(arr, 0, arr.length - 1);
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
		    if (i > 0) {
		        sb.append(" ");
		    }
		    if (i == x) {
		        sb.append("[").append(arr[i]).append("]");
		    } else {
		        sb.append(arr[i]);
		    }
		}
		System.out.println(sb);
	}
	
	static int partition(int[] arr, int p, int r) {
	    int x = arr[r];
	    int idx = p - 1;
	    for (int i = p; i < r; i++) {
	        if (arr[i] <= x) {
	            idx++;
	            int tmp = arr[i];
	            arr[i] = arr[idx];
	            arr[idx] = tmp;
	        }
	    }
	    int tmp = arr[idx + 1];
	    arr[idx + 1] = arr[r];
	    arr[r] = tmp;
	    return idx + 1;
	}
}



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


int main()
{
	int N, Q;
	cin >> N >> Q;
	vector<vector<int>> t( N );
	for( int i = 0; i < N - 1; i++ ) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		t[a].push_back( b );
	}

	vector<int> point( N );
	for( int i = 0; i < Q; i++ ) {
		int p, x;
		cin >> p >> x;
		p--;
		point[p] += x;
	}
	queue<int> que;
	que.push( 0 );
	while( !que.empty() ) {
		int u = que.front();
		que.pop();
		int last = point[u];
		for( auto v : t[u] ) {
			point[v] += last;
			que.push( v );
		}
	}

	for( int i = 0; i < N; i++ ) {
		if( i ) cout << " ";
		cout << point[i];
	}
	cout << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main()
{
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];

    int zero = 0;
    rep(i, n) if(a[i] == 0) zero++;
    if(zero > 0) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    rep(i, n) {
        if(a[i] <= 1000000000000000000 / ans) ans *= a[i];
        else {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4056
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

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

	string N;

	cin >> N;

	if(N == "SUN") {
		cout << 7 << endl;
	} else if(N == "MON") {
		cout << 6 << endl;
	} else if(N == "TUE") {
		cout << 5 << endl;
	} else if(N == "WED") {
		cout << 4 << endl;
	} else if(N == "THU") {
		cout << 3 << endl;
	} else if(N == "FRI") {
		cout << 2 << endl;
	} else {
		cout << 1 << endl;
	}
			
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <random>
#include <bitset>
#include <chrono>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
	
#ifndef ONLINE_JUDGE
// #include "debug.h"
#else
// #define debug(...) 42
#endif

const int M = 3e3+1;
const int MD=998244353;


int ans[M];
int main() {
	fast_cin();
	int n,x,y;
	cin>>n>>x>>y;
	for(int i=1;i<=n;i++){
		ans[i]=n-i;
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			int dis=j-i;
			int fi=min(abs(x-i),abs(y-i))+min(abs(x-j),abs(y-j))+1;
			if(dis>fi){
				ans[dis]--;
				ans[fi]++;
			}
		}
	}
	for(int i=1;i<n;i++){
		cout<<ans[i]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include "limits.h"
#include <limits>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename H,typename... T>
void debug_out(H head,T... tail){
  std::cerr<<" "<<head;
  debug_out(tail...);
}

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<long long,long long>;

//NまでのMOD逆元をコンパイル時計算する
template<long long N,long long MOD>
class ModInv_calc{
  public:
  long long inv[N+1];
  constexpr ModInv_calc():inv(){
    inv[1]=1;
    for(int i=2;i<=N;i++)inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
  }

  constexpr long long operator[](size_t i)const noexcept{return inv[i];}
};

constexpr ModInv_calc<100010,MOD> inv{ModInv_calc<100010,MOD>()};

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

  ll n,x;
  std::cin>>n>>x;

  std::vector<ll> s(n);
  rep(i,0,n)std::cin>>s[i];

  std::sort(all(s),std::greater<ll>());

  std::vector<std::vector<ll>> dp(n+1,std::vector<ll>(100010,0));

  rep(i,0,100010)dp[n][i]=i;

  for(ll i=n-1;i>=0;i--){
    rep(j,0,100010){
      dp[i][j]=inv[n-i]*dp[i+1][j%s[i]]%MOD+(MOD+1-inv[n-i])*dp[i+1][j]%MOD;
      dp[i][j]%=MOD;
    }
  }

  rep(i,1,n+1)dp[0][x]=dp[0][x]*i%MOD;

  std::cout<<dp[0][x]<<"\n";

  return 0;
}

Measured memory_bytes: 158592
using System;

namespace Binary_search_trees
{
    class Binary_Search_Tree_I
    {
        class BinaryTree
        {
            public class Node
            {
                internal int val;
                internal Node left, right, parent;

                internal Node() : this(0, null) { }

                internal Node(int val, Node parent)
                {
                    this.val = val;
                    this.parent = parent;
                    left = right = null;
                }
            }

            Node root;

            public BinaryTree()
            {
                root = null;
            }

            public void Insert(int elem)
            {
                if (root == null)
                {
                    root = new Node(elem, null);
                    return;
                }

                Node n = root;
                Node p = null;
                while (n != null)
                {
                    p = n;
                    if (n.val > elem) n = n.left;
                    else n = n.right;
                }

                n = new Node(elem, p);
                if (p.val > elem) p.left = n;
                else p.right = n;
            }

            public void PrintPreorder(Node n)
            {
                if (n == null) return;
                Console.Write(" " + n.val);
                PrintPreorder(n.left);
                PrintPreorder(n.right);
            }

            public void PrintPreorder()
            {
                PrintPreorder(root);
                Console.WriteLine();
            }

            public void PrintInorder(Node n)
            {
                if (n == null) return;
                PrintInorder(n.left);
                Console.Write(" " + n.val);
                PrintInorder(n.right);
            }

            public void PrintInorder()
            {
                PrintInorder(root);
                Console.WriteLine();
            }
        }

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var bt = new BinaryTree();
            for (int i = 0; i < n; i++)
            {
                var line = Console.ReadLine();
                if (line.Length == 5) { bt.PrintInorder(); bt.PrintPreorder(); }
                else bt.Insert(int.Parse(line.Substring(7)));
            }
        }
    }
}

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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}


struct ice{
    ll yen, id;
    ll yy;
};
bool comp(const ice& i1, const ice& i2){
    return i1.yy < i2.yy;
}
ice q[4];
ll n;
double qq[4];

int main(){
    for(int i = 0; i < 4; i++){
        cin >> q[i].yen;
    }
    cin >> n;

    q[0].id = 1;
    q[0].yen *= 4;
    q[1].id = 1;
    q[1].yen *= 2;
    q[2].id = 1;
    q[3].id = 2;
    for(int i = 0; i < 4; i++){
        q[i].yy = q[i].yen/q[i].id;
    }
    
    sort(q, q+4, comp);

    ll ans = 0;
    for(int i = 0; i < 4; i++){
        ans += (n/q[i].id)*q[i].yen;
        n -= (n/q[i].id)*q[i].id;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int b[100005],v[100005],t[100005];
using namespace std;
int main()
{
	int n,m,cnt=0,x,y,ans=0,p,q;
	scanf("%d %d",&n,&m);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&b[i]);
	}
	memset(v,1,sizeof(v));
	for (int i=1;i<=m;i++)
	{
		scanf("%d %d",&x,&y);
		if (b[x]!=b[y])  
		{
			if (b[x]>b[y])
			{
				v[x]&=1;
				v[y]&=0;
			}   
			else
			{
				v[y]&=1;
				v[x]&=0;
			}
		} 
		else   v[x]=v[y]=0;
		t[x]=1;
		t[y]=1;
	}
	for (int i=1;i<=n;i++)
	{
		if (!t[i])   ans++;
		else
		{
			if (v[i])   ans++;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 4932
#include <cstdio>
#include <vector>

const int MN = 100005;

int N;
std::vector<int> G[MN];

int DFS(int u, int p) {
	int ret = 0;
	for (int v : G[u]) if (v != p) ret ^= DFS(v, u) + 1;
	return ret;
}

int main() {
	scanf("%d", &N);
	for (int i = 1, x, y; i < N; ++i)
		scanf("%d%d", &x, &y),
		G[x].push_back(y),
		G[y].push_back(x);
	puts(DFS(1, 0) ? "Alice" : "Bob");
	return 0;
}

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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream& operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template <typename T>
inline void printV(vector<T>& a, int n) { for(int i=0; i<n; i++) { cerr<<a[i]<<" "; } cerr<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a) { for(int i=0; i<sz(a); i++) { cerr<<a[i]<<"\n"; } cerr<<"\n"; }
template <typename T>
inline void clearVV(vector<vector<T>>& a) { for(auto &x : a) { x.clear(); } a.clear(); }
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val) { for(int i=0; i<sz(a); i++) { a[i].assign(sz(a[i]), val); } }
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 1e5;


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	int lc = c/gcd(c, d)*d;
	int ans = b/c+1;
	ans -= b/lc+1;
	ans += b/d+1;
	
	int ans2 = (a-1)/c+1;
	ans2 -= (a-1)/lc+1;
	ans2 += (a-1)/d+1;
	
	ans -= ans2;
	ans = b-a+1 - ans;
	cout<<ans<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
int main(){
	int N,K;
	std::cin>>N>>K;
	long* A=new long[N];
	for (int i=0; i<N; i++){
		std::cin>>A[i];
	}
	std::sort(A,A+N);
	long ans=1;
	int prev=0,back=N-1;
	int flag=1;
	if(K%2==1){
		ans*=A[back];
		K--;
		ans%=1000000007;
		if(A[back]<0){
			flag*=-1;
			ans+=1000000007;
		}
		back--;
	}
	while(K>=1){
		if((flag*(long long)A[prev]*A[prev+1])>(flag*(long long)A[back]*A[back-1])){
			ans*=A[prev]*A[prev+1]%1000000007;
			if(A[prev]*A[prev+1]<0)flag*=-1;
			K-=2;
			prev+=2;
		}else{
			ans*=A[back]*A[back-1]%1000000007;
			if(A[back]*A[back+1]<0)flag*=-1;
			K-=2;
			back-=2;
		}
		ans%=1000000007;
		if(ans<0)ans+=1000000007;
	}
	std::cout<<ans;
	return 0;
}


Measured memory_bytes: 5188
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	vector<int> vec = {a, b, c};
	sort(vec.begin(), vec.end(), greater<int>());
	cout << max({a, b, c}) * 10 + vec[1] + vec[2] << endl;
}

Measured memory_bytes: 256