akhauriyash/Code-Regression huggingface dataset:
package main

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

// const abcd = "abcdefghijklmnopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

// var dy = [...]int{1, 1, 0, -1, -1, -1, 0, 1}
// var dx = [...]int{0, 1, 1, 1, 0, -1, -1, -1}

// var dx = [...]int{0, 1, 0, -1}
// var dy = [...]int{1, 0, -1, 0}

var inf int = 1e13
var mod = 1000000007

// ---------------------------------------------------------
func main() {
	log.SetFlags(log.Lshortfile)
	next := newScanner()
	n := next.Int()
	m := next.Int()

	n--
	m--
	fmt.Println(n * m)
}

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

// Pair is liked C++ pair
type Pair struct {
	a, b int
}

// Pairs is sorted by []Pair struct
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 {
	if p[i].a < p[j].a {
		return true
	} else if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return false
}

// -------------------------------
func in(c, a, z int) bool {
	return c >= a && c < z
}

func btoi(b bool) int {
	if b {
		return 1
	}
	return 0
}

func itob(a int) bool {
	if a == 0 {
		return false
	}
	return true
}

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 sum(a ...int) int {
	r := a[0]
	if len(a) > 1 {
		for i := 1; i < len(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 minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

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

// ---------- buffered scanner -----------------------------------------
type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) Line() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) Int() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) Int64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
n = int(input())
s = [str(input()) for _ in range(n)]
s.sort()
t = list(set(s))
t.sort()
u = []
i = 0
j = 0
tmp = 0
while i < n:
    if s[i] == t[j]:
        tmp += 1
    else:
        u.append(tmp)
        tmp = 0
        j += 1
        i -= 1
    i += 1
u.append(tmp)
a = max(u)
for i in range(len(t)):
    if u[i] == a:
        print(t[i])

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = k;
  rep(i, n - 1) ans *= k - 1;

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;


#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> // find_by_order(); order_of_key();
#define mod 1000000007
#define ll long long int
#define mk make_pair
#define pb push_back
#define xx first
#define yy second



double pi=3.141592653589793238;
const int M = 1e9+7;
const int Nmax=5005;
const int MM = 1e7+1;
const int N=100005;



int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int T=1;
//cin>>T;
while(T--){

int l,r,d;
cin>>l>>r>>d;
int ans=0;
for(int i=l;i<=r;i++)if(i%d==0)ans++;
cout<<ans<<"\n";

}
return 0;
}


Measured memory_bytes: 3608
using System;
public class Aprob {
    public static void Main() {
        string[] read = new string[3];
        read = Console.ReadLine().Split(' ');
        int A = int.Parse(read[0]);
        int B = int.Parse(read[1]);
        int C = int.Parse(read[2]);
        string outp = "No";
        if (A + B == C) {
            outp = "Yes";
        }
        if (B + C == A) {
            outp = "Yes";
        }
        if (C + A == B) {
            outp = "Yes";
        }
        Console.WriteLine(outp);
    }
}

Measured memory_bytes: 2648
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int n = sc.nextInt();
        if(d == 0) {
            if(n < 100) {
                System.out.println(n);
            } else {
                int tmp = n / 100;
                System.out.println(n + tmp);
            }
        } else if(d == 1) {
            if(n < 100) {
                System.out.println(100 * n);
            } else {
                int tmp = n;
                System.out.println(n * 100 + tmp);
            }
        } else {
            if(n < 100) {
                System.out.println(100 * 100 * n);
            } else {
                int tmp = n * 100;
                System.out.println(100 * 100 * n + tmp);
            }
        }
    }
}


Measured memory_bytes: 35632
N = int(input())
n_l = [1]
n = 1
A = [int(a) for a in input().split()]
for i in range(1,N+1):
    a = A[i-1]
    n = (n - a) * 2
    n_l.append(n)
    if n <= 0:
        Good = False
        break
if n >= A[N]:
    counter = A[N]
    m = A[N]
    Good = True
else:
    Good = False
if Good:
    for i in range(N-1,-1,-1):
        n = n_l[i]
        m = min(m+A[i],n)
        counter += m
    print(counter)
else:
    print(-1)

Measured memory_bytes: 702048
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):

    C = None
    n = 0
    l = []
    for c in S:
        if c != C:
            l.append((C, n))
            C = c
            n = 1
        else:
            n += 1
    l.append((C, n))
    l.pop(0)

    if l[0][0] == '>':
        l.insert(0, ('<', 0))
    if l[-1][0] == '<':
        l.append(('>', 0))

    ans = 0
    for i in range(0, len(l), 2):
        _, n1 = l[i]
        _, n2 = l[i+1]
        
        gn = max(n1, n2)
        ln = min(n1, n2) - 1
        ans += (gn**2 + gn)//2
        if ln > 0:
            ans += (ln**2 + ln)//2
    return ans

# ><>>><<><<<<<>>><
def main():
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 95172
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n, m;
    cin>>n>>m;
    out(n * (n - 1) / 2 + m * (m - 1) / 2);
}

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

using namespace std;

int main()
{
	char inp[111111];
	scanf("%s", inp);

	int cnt[26] = {0};
	
	int len = strlen(inp);
	for(int i = 0; i < len; i++) 
		cnt[inp[i] - 'a']++;
	
	int pos = -1;
	for(int i = 0; i < 26; i++)
		if(cnt[i] == 0) {
			pos = i;
			break;
		}
	
	if(pos == -1)
		printf("None\n");
	else
		printf("%c\n", pos + 'a');

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
  #define dbg(x) cout << #x << " : " << x << endl;
#else 
  #define dbg(x)
#endif
#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 100010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

map<int, int> killed[MX];

int powmod(int a, int b) {
    if (b == 0)
        return 1;
    int res = powmod(a, b / 2);
    res = res * res % MOD;
    if (b & 1)
        res = res * a % MOD;
    return res;
}

int pw[MX];

void process(int d, int i) {
    fx(x, killed[d]) 
        killed[i][x.first] += x.second;
    dbg(d);
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, k;
    cin >> n >> k;
    fi(0, MX) 
        pw[i] = powmod(i, n);
    int sum = 0;
    fi(1, k + 1) {
        dbg(i);
        int d = 1;
        while (d * d <= i) {
            int d1 = i / d;
            if (d1 * d == i) {
                if (d != i) process(d, i);
                if (d1 != i && d1 != d) process(d1, i);
            }
            ++d;
        }
        fx(x, killed[i]) {
            int y = -x.second;
            sum += y * x.first % MOD * pw[k / i] % MOD;
            dbg(x.first);
            dbg(x.second);
            dbg(sum);
            x.second = y;
        }
        killed[i][i] = 1;
        sum += i * pw[k / i] % MOD;
        sum %= MOD;
        dbg(sum);
    }
    cout << sum;
}

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

const int N = 2005;
const int mod = 1e9 + 7;

int nr, nb;
int c[N][N];
int g[N][N];
int f[N][N][2];

int cal(int r, int b, int t) {
	int &ret = f[r][b][t];
	if (ret != -1) return ret;
	if (r == nr && b == nb) return 1;
	ret = 0;
	if (!t) {
		int need = nb - 1;
		for (int i = 0; i <= need; ++i) {
			if (need - i + r > nr) continue;
			ret = (ret + 1LL * c[need][i] * cal(r + need - i, 1 + i, 1)) % mod; 
			//cout << "at " << r << ' ' << b << " cal " << r + need - i << ' ' << 1 + i << ' ' << cal(r + need - i, 1 + i, 1) << '\n';
		}
		if (r < nr) ret = (ret + cal(r + 1, 0, 0)) % mod;
		return ret;
	}
	int need = nb - b - 1;
	if (need >= 0) {
		int tmp = max(0, need + r - nr);
		ret = (ret + g[need][need]) % mod;
		if (tmp) {
			ret = (ret - g[need][tmp - 1] + mod) % mod;
		}
	}	
	if (r < nr) ret = (ret + cal(r + 1, b, 1)) % mod;
	return ret;
}

int main() {
	cin >> nr >> nb;
	for (int i = 0; i < N; ++i) g[i][0] = c[i][0] = 1;
	for (int i = 1; i < N; ++i) {
		for (int j = 1; j <= i; ++j) {
			c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
			g[i][j] = (g[i][j - 1] + c[i][j]) % mod;
		}
	}
	memset(f, -1, sizeof f);
	cout << cal(0, 0, 0);
}

Measured memory_bytes: 63232
#include <bits/stdc++.h>
using namespace std;
int dp[100000];
int main(){
	int n;
	cin>>n;
	vector<vector<int> > dp(n, vector<int>(3));
	for(int i = 0; i<n; i++){
		cin>>dp[i][0]>>dp[i][1]>>dp[i][2];
		if(i != 0){
			dp[i][0] += max(dp[i-1][1], dp[i-1][2]);
			dp[i][1] += max(dp[i-1][0], dp[i-1][2]);
			dp[i][2] += max(dp[i-1][0], dp[i-1][1]);
		}
	}
	cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
	return 0;
}

Measured memory_bytes: 5760
//AOJ-GRL-1-B
#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>
struct edge{
    int from, to;
    T cost;
    edge(int from, int to, T cost = 1) : from(from), to(to), cost(cost){}
    bool operator < (const edge & e) const{
        return cost < e.cost;
    }
};

/*
    sからたどりつける負の閉路を検出したとき、空の vector を返す
    頂点数 V, 始点 s, 辺の集合 es, INF として LINF を使うとき : 
    vector<ll> dist = BellmanFord(V, s, es, LINF);
*/
template <typename T>
vector<T> BellmanFord(int V, int s, vector<edge<T>> & es, const T INF = 1e9){
    int E = es.size();
    vector<T> dist(V, INF);
    dist[s] = 0;
    for(int i = 0; i < V - 1; i++){
        for(edge<T> & e : es){
            if(dist[e.from] == INF) continue;
            dist[e.to] = min(dist[e.to], dist[e.from] + e.cost);
        }
    }
    for(edge<T> & e : es){
        if(dist[e.from] == INF) continue;
        if(dist[e.from] + e.cost < dist[e.to]) return vector<T>();
    }
    return dist;
}

//グラフ全体をみて、負の閉路が存在するとき true を返す
template <typename T>
bool Find_Negative_Loop(int V, vector<edge<T>> & es){
    vector<T> dist(V, 0);
    for(int i = 0; i < V; i++){
        for(edge<T> & e : es){
            if(dist[e.to] > dist[e.from] + e.cost){
                dist[e.to] = dist[e.from] + e.cost;
                if(i == V - 1) return true;
            }
        }
    }
    return false;
}

signed main(){
    int v,e,r;
    cin >> v >> e >> r;
    int s,t;
    ll d;
    vector<edge<ll>> es;
    REP(i,e){
        cin >> s >> t >> d;
        es.emplace_back(s, t, d);
    }
    vector<ll> dist = BellmanFord(v, r, es, LINF);
    if(dist.size() == 0){
        cout << "NEGATIVE CYCLE" << endl;
    }else{
        REP(i,v){
            if(dist[i] == LINF) cout << "INF" << endl;
            else cout << dist[i] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#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 REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll mpow(ll a, ll b){
	if(b==0){
		return 1;
	}else if(b%2==0){
		ll memo = mpow(a,b/2);
		return memo*memo%MOD;
	}else{
		return mpow(a,b-1) * a % MOD;
	}
}

ll gcd(ll a, ll b){
	if(b==0){
		return a;
	}else{
		return gcd(b, a%b);
	}
}

int main(void){
	int n;
	cin>>n;
	vector<int> H;
	int h;
	rep(i,n){
		cin>>h;
		H.push_back(h);
	}
	rep(i,n){
		if(i==0){
			H[i] -= 1;
			continue;
		}
		if(H[i-1] <= H[i] - 1){
			H[i] -= 1;
			continue;
		}else if(H[i-1] > H[i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define ar array

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int &x : a) cin >> x;
    vector<int> b(n / 2);
    for (int i = 0; i < n / 2; i++) {
        b[i] = a[i] ^ a[n - 1 - i];
    }
    int tot = 0;
    for (int i : b) tot ^= i;
    for (int i = 0; i < n; i++) {
        cout << (tot ^ a[i]) << ' ';
    }
    cout << '\n';
}

Measured memory_bytes: 4520
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin>>n>>m;
    int arr[m], sum=0;
    for (int i=0; i<m; i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    if(sum>n)
        cout<<-1<<endl;
    else
        cout<< n-sum<< endl;
}


Measured memory_bytes: 3636
N = int(input())
nums = [0]
for _ in range(N):
  nums.append(int(input()))
check_cnt = 1
_next = nums[1]
while True:
  if check_cnt >= N:
    break
  else:
    if _next == 2:
      print(check_cnt)
      exit()
    _next = nums[_next]
    check_cnt += 1
print(-1)


Measured memory_bytes: 7080
from collections import deque
import numpy

N, M, X = [int(x) for x in input().split()]

stack = deque()
stack.appendleft((numpy.array([0] * M, dtype='int64'), 0, 0))

min_cost = 10**9

book_list = {}

while stack:
    info = stack.popleft()
    skill = info[0]
    cost = info[1]
    book_idx = info[2]

    if book_idx < N:
        if book_idx in book_list:
            book = book_list[book_idx]
        else:
            book = numpy.array([int(x)
                                for x in input().split()], dtype='int64')
            book_list[book_idx] = book

        after_skill = skill + book[1:]
        after_cost = cost+book[0]

        stack.appendleft((after_skill, after_cost, book_idx+1))
        stack.appendleft((skill, cost, book_idx+1))

    else:
        if cost < min_cost:
            if numpy.all(skill >= X):
                min_cost = cost

if min_cost == 10**9:
    print(-1)
else:
    print(min_cost)


Measured memory_bytes: 27268
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;  
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll x,y,a,b,c;cin>>x>>y>>a>>b>>c;
  priority_queue<PL> q;
  V<int> cnt(3,0),lim(3);
  lim[0]=x,lim[1]=y,lim[2]=a+b+c+1;

  rep(i,0,a){
    ll z;cin>>z;
    q.push({z,0});
  }
  rep(i,0,b){
    ll z;cin>>z;
    q.push({z,1});
  }
  rep(i,0,c){
    ll z;cin>>z;
    q.push({z,2});
  }

  ll ans=0;

  while(q.size() && cnt[0]+cnt[1]+cnt[2]<x+y){
    ll type=q.top().sc;
    ll sco=q.top().fs;
    q.pop();
    if(cnt[type]<lim[type]){
      ans+=sco;
      cnt[type]++;
    }
  }
  cout<<ans<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 10476
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(x) for(auto it=(x).begin();it!=(x).end();it++) 
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    while(1){
    int n,m,a;
    cin>>n>>m>>a;
    if(n==0&&m==0&&a==0)break;
    vector<int> ans(n);
    rep(i,0,n)ans[i]=i+1;
    
    vector<pair<int,pair<int,int>>> v(m);
    rep(i,0,m){
        cin>>v[i].first>>v[i].second.first>>v[i].second.second;
    }
    
    Sort(v);
    rep(i,0,m){
        swap(ans[v[i].second.first-1],ans[v[i].second.second-1]);
    }
    cout<<ans[a-1]<<endl;
    }
    return 0;
}



Measured memory_bytes: 3140
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    int Q;
    cin >> Q;

    deque<char> h, t;
    int cnt = 0;
    for(int q = 0; q < Q; q++) {
        int x, f;
        char c;
        cin >> x;

        if(x == 1) cnt++;
        else {
            cin >> f >> c;

            if(f == 1) {
                if(cnt % 2 == 0) {
                    h.push_front(c);
                } else {
                    t.push_back(c);
                }
            }
            else  {
                if(cnt % 2 == 0) {
                    t.push_back(c);
                } else {
                    h.push_front(c);
                }
            }
        }
    }

    if(cnt % 2 == 0) {
        while(!h.empty()){
            cout << h.front();
            h.pop_front();
        }
        cout << s;
        while(!t.empty()){
            cout << t.front();
            t.pop_front();
        }
    }
    else {
        while(!t.empty()){
            cout << t.back();
            t.pop_back();
        }
        int N = s.size();
        for(int i = 0; i < N; i++) {
            cout << s[N - i - 1];
        }
        while(!h.empty()){
            cout << h.back();
            h.pop_back();
        }
    }

    return 0;
}

Measured memory_bytes: 896
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n, k; cin >> n >> k;
	vector<int> p(n + 1); rep(i, n)cin >> p[i + 1];
	vector<ll> c(n + 1); rep(i, n)cin >> c[i + 1];
	ll res = -1e18;
	for (int i = 1; i <= n; ++i)
	{
		int now = i;
		ll tmp = 0;
		ll mx = -1e18;
		for (int j = 1; j <= k; ++j)
		{
			now = p[now];
			tmp += c[now];
			chmax(mx, tmp);
			if (now == i)
			{
				if (tmp < 0)break;
				chmax(mx, mx + ((k / j - 1)*tmp));
				tmp *= k / j;
				j = j * (k / j);
			}
		}
		chmax(res, mx);
	}
	cout << res << endl;
}

Measured memory_bytes: 3684
K = int(input())
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(L[K-1])

Measured memory_bytes: 38256
Num = int(input())
Num2, Num3 = map(int,input().split())
Num_Array = list(map(int,input().split()))
result = 1000000000

for i  in range(0,Num):
    Check = Num3 - ( Num2 - (Num_Array[i] *0.006))
    if result > abs ( Check ):
        result = abs(Check)
        kekka = i + 1
print(kekka)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var M = ReadInt();
            var dSum = 0L;
            var cSum = 0L;
            for (int i = 0; i < M; i++)
            {
                var input = ReadArrayLong();
                var d = input[0];
                var c = input[1];
                dSum += d * c;
                cSum += c;
            }

            Console.WriteLine(cSum - 1 + (dSum - 1) / 9);
            Console.ReadKey();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 17428
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;
typedef long long ll;

int main(){

  string s;

  while(getline(cin, s)){
    if(s=="0"){
      break;
    }
    int t=0;
    for(int i=0; i<s.size(); i++){
      t = t+s[i]-'0';
    }
    cout<<t<<endl;
  }
}

Measured memory_bytes: 3204
#include <iostream>
#include <fstream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <unordered_set>
#include <stack>
#include <iomanip>
using namespace std;



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

    int n;
    cin >> n;
    cout << (n+1)/2 << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
  
const int MAX = 10000001; 
  
struct Query 
{ 
    int l, r, idx; 
}; 
  
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
   
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
  
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 
  
int main() 
{ 
    int n,q;
    cin >> n >> q;
    int a[n];
    for (int i = 0;i < n;++i) {
        cin >> a[i];
    }
    Query queries[q]; 
    for (int i = 0;i < q;++i) {
        queries[i].idx = i;
        cin >> queries[i].l >> queries[i].r;
        --queries[i].l,--queries[i].r;
    }
    sort(queries, queries+q, cmp); 
    answeringQueries(a, n, queries, q); 
    return 0; 
} 

Measured memory_bytes: 54636
#include<bits/stdc++.h>
using namespace std;
int a[51],b[51],c[110];
int main(){
	int n,m,i,j;
	cin>>n>>m;
	for(i=1;i<=m;i++){
		cin>>a[i];
		cin>>b[i];
	}
	for(i=1;i<=m;i++){
		for(j=1;j<=n;j++){
			if(a[i]==j||b[i]==j) c[j]++;
		}
	}
	for(i=1;i<=n;i++){
		cout<<c[i]<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
x1, y1, x2, y2 = map(complex, input().split())
OA = x1 + y1 * 1j
OB = x2 + y2 * 1j
OD = (1 - 1j) * OA + 1j * OB
OC = OD + OB - OA

x4, y4 = int(OD.real), int(OD.imag)
x3, y3 = int(OC.real), int(OC.imag)
print(x3, y3, x4, y4)


Measured memory_bytes: 3060
using System;

namespace JKTX_AOJ2015
{
    class Program
    {
        static void Main(string[] args)
        {
            int s;
            int hour, min, sec;
            s = int.Parse(Console.ReadLine());

            hour = s / 3600;
            min = (s - 3600 * hour) / 60;
            sec = s - 3600 * hour - 60 * min;

            Console.WriteLine("{0}:{1}:{2}", hour, min, sec);
        }
    }
}

Measured memory_bytes: 19952
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include <functional>
#include <queue>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;

int main() {

	int n; cin >> n;
	string s; cin >> s;
	int k; cin >> k;

	char x = s[k - 1];

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == x) {
			cout << s[i];
		}
		else {
			cout << "*";
		}
	}

	cout << endl;






}

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

long long dfs(vector<vector<long long>> &dp, const vector<long long> &a, const vector<long long> &sum, int begin, int end, const long long init)
{
    if (dp[begin][end] == init)
    {
        if (end - begin > 1)
        {
            for (int i = begin + 1; i < end; i++)
            {
                dp[begin][end] = min(
                    dp[begin][end],
                    dfs(dp, a, sum, begin, i, init) + dfs(dp, a, sum, i, end, init) + (sum[end] - sum[begin]));
            }
        }
        else
        {
            dp[begin][end] = 0;
        }
    }
    return dp[begin][end];
}

int main()
{
    int N;
    cin >> N;

    vector<long long> a(N + 1, 0);
    vector<long long> sum(N + 1, 0);
    for (int i = 1; i <= N; i++)
    {
        cin >> a[i];
        sum[i] = a[i] + sum[i - 1];
    }

    const long long init = LONG_LONG_MAX;
    vector<vector<long long>> dp(N + 1, vector<long long>(N + 1, init));

    cout << dfs(dp, a, sum, 0, N, init) << endl;
}


Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

static uint64_t gcd(uint64_t a, uint64_t b)
{
	uint64_t temp;

	if (a < b) {
		temp = a;
		a = b;
		b = temp;
	}

	uint64_t r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int main()
{
	int32_t N, X;
	cin >> N >> X;

	vector<int32_t> x(N);
	for (int32_t i = 0; i < N; i++) {
		cin >> x[i];
		x[i] -= X;
	}

	int32_t res = abs(x[0]);
	for (int32_t i = 1; i < N; i++) {
		res = gcd(res, abs(x[i]));
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=510;
int n,m,b[N][N],c[N][N];
char a[N][N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%s",a[i]+1);
	for(int i=1;i<=m;i++)
		b[1][i]=c[n][i]=1;
	for(int i=2;i<n;i++){
		for(int j=1;j<=m;j++)
			if(j&1)
				b[i][j]=1;
			else c[i][j]=1;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(b[i][j]||a[i][j]=='#')
				putchar('#');
			else putchar('.');
		}
		putchar('\n');
	}
	putchar('\n');
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(c[i][j]||a[i][j]=='#')
				putchar('#');
			else putchar('.');
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


vector<int> v[100000];
vector<bool> u(100000,false);

int main(){
  int N, D;
  cin >> N >> D;
  cout << (N-1)/(2*D+1)+1 << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if(s[i] == 'R'){
            ans++;
        }
    }
    if(s == "RSR"){
        ans = 1;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 3700
import sys
A,B,K = map(int,input().split())
#euclid algorithm
if A < B: 
    A, B = B, A
while A%B != 0:
    A,B = B,A%B

count = 0
for I in range(B,0,-1):
    if B % I == 0:
        count += 1
    if count == K:
        print(I)
        break


Measured memory_bytes: 9128
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int n;cin>>n,n!=-1;){
		double x=0.5*n;
		for(;;){
			if(abs(pow(x,3)-n)<0.00001*n){
				printf("%f\n",x);
				break;
			}
			x=x-(pow(x,3)-n)/(3*pow(x,2));
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    A.reverse()
    s = 0
    for i in range(1,N):
        s += A[i//2]
    print(s)

main()


Measured memory_bytes: 31616
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 10, LOG=20;

ll n, m, k, u, v, x, y, t, a, b;
pll A[MAXN];

ld sq(ll x){
	return x*x;
}

ld get(pll p1, pll p2){
	return sqrt(sq(p1.first-p2.first)+sq(p1.second-p2.second));
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	for (int i=0; i<n; i++) cin>>x>>y, A[i]={x, y};
	sort(A, A+n);
	ld ans=0;
	do{
		for (int i=1; i<n; i++) ans+=get(A[i-1], A[i]);
	}while(next_permutation(A, A+n));
	//debug(ans)
	for (int i=1; i<=n; i++) ans/=i;
	cout<<setprecision(12)<<fixed<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();
        int M = sc.nextInt();

        HashSet<Integer> distFromOne = new HashSet<>();
        HashSet<Integer> distToN = new HashSet<>();
        for (int i = 0; i < M; i++) {
            int from = sc.nextInt();
            int to = sc.nextInt();

            if (from == 1) {
                distFromOne.add(to);
            }
            if (to == N) {
                distToN.add(from);
            }
        }
        for (Integer dist : distFromOne)  {
            if (distToN.contains(dist)) {
                System.out.println("POSSIBLE");
                return;
            }
        }
        System.out.println("IMPOSSIBLE");
    }
}

Measured memory_bytes: 109720
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  char grid[110][110];
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin >> grid[i][j];
    }
  }
  set<int> num1;
  set<int> num2;
  for(int i=0; i<h; i++){
    int cnt=0;
    for(int j=0; j<w; j++){
      if(grid[i][j] == '.'){
        cnt++;
      }
    }
    if(cnt == w){
      num1.insert(i);
    }
  }
    for(int i=0; i<w; i++){
    int cnt=0;
    for(int j=0; j<h; j++){
      if(grid[j][i] == '.'){
        cnt++;
      }
    }
    if(cnt == h){
      num2.insert(i);
    }
  }
  for(int i=0; i<h; i++){
    if(num1.count(i)){
      continue;
    }
    for(int j=0; j<w; j++){
      if(j != w-1){
        if(num2.count(j)){
          continue;
        }
        cout << grid[i][j];
      }
      else{
        if(num2.count(j)){
          cout << endl;
        }
        else{
          cout << grid[i][j] << endl;
        }
      }
    }
  }
}

Measured memory_bytes: 256
n = int(input())
t, a = map(float,input().split())
h = list(map(int,input().split()))
l = []
j = 0

for i in range(n):
    l.append(abs(a-(t-h[j]*0.006)))
    j+=1

maxv = min(l)
print(l.index(maxv)+1)


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

using namespace std;

int main(){
	int n;
	int k;
	cin >> n >> k;
	int heights[n];
	for(int i = 0;i<n;i++){
		cin >> heights[i];
	}
	int dp[n];
	dp[0] = 0;
	for(int i = 1; i < n;i++){
		dp[i] = INT_MAX;
		for(int j = 1;j<=k;j++){
			if(i>= j)
			dp[i] = min(dp[i], dp[i-j] + abs(heights[i-j] - heights[i]));

		}
		
	}
	cout << dp[n-1] << "\n";
	return 0;
}

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

    ///--------------------------------------------------------------------------------
    #define     T()                 ll t;    cin>>t;        while(t--)
    #define        ll                  long long
    #define        vi                     vector<ll>
    #define     pii                 pair<ll,ll>
    #define     vpair                 vector< pii >
    #define     fast                 ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    #define     repp(i,a,n)         for(ll i= a ; i < n ; ++i)
    #define     rep(i,n)            for(ll i= 0 ; i < n ; ++i)
    #define     p_b                     push_back
    #define     p_f                 push_front
    #define     pop_b                 pop_back()
    #define     pop_f                 pop_front()
    #define     m_p                 make_pair
    #define      sumv(v)              accumulate(v.begin(),v.endd(),0);
    #define     sortv(v)             sort(v.begin(),v.endd())
    #define     sort_dec(v)         sort(v.begin(),v.endd(),greater<ll>() )
    #define     l_b(v,l)               lower_bound (v.begin(), v.endd(), l)
    #define     u_b(v,l)               upper_bound (v.begin(), v.endd(), l)
    #define     pq                     priority_queue
    #define     ff                     first
    #define     ss                     second
    #define     len                 length()
    #define     all(v)              v.begin(),v.endd()
    #define     mset(a,b)           memset(a,b,sizeof(a));

    ///==========INPUT=============///
    #define     sc(a)           cin>>a;
    #define     sc2(a,b)        cin>>a>>b;
    #define     sc3(a,b,c)      cin>>a>>b>>c;
    #define     sc4(a,b,c,d)    cin>>a>>b>>c>>d;
    ///==========PRINTING=============///
    #define     prarr(arr)      rep(i,sizeof(arr)/sizeof(ll)) cout<<arr[i]<<" "; nl
    #define     prvec(v)        rep(i,v.size()) cout<<v[i]<<" "; nl
    #define     pr(x)           cout<<x<<"\n";
    #define     pr2(x, y)       cout<<x<<" "<<y<<"\n";
    #define     pr3(x, y, z)    cout<<x<<" "<<y<<" "<<z<<"\n";

    ///==========DEBUGGING=============///
    #define     debug(a)             cout<<"*"<<a<<enddl;
    #define     debug2(a,b)         cout<<"$"<<a<<" "<<b<<enddl;
    #define     debug3(a,b,c)         cout<<"$"<<a<<" "<<b<<" "<<c<<enddl;
    #define     bug                 cout<<"#"<<enddl;
    #define     nl                     cout<<'\n';
    #define     enddl                '\n'

    ///==========CONSTANTS=============///
    #define     max6     1000005
    #define     max5     100004
    #define     max4     10003
    #define     mod       1000000007
    #define     inf      1e9
    ll powermod(ll _a,ll _b,ll _m)    {ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}

    using namespace std;

    int main()
    {
        fast
        ll n ,k;
        sc2(n,k)
        string s;
        cin>>s;
        rep(i,n)
        {
            if(i==k-1)
                cout<<char(tolower(s[i]));
            else
                cout<<s[i];
        }
    }


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue> 
using namespace std;
const int N=100001;
char a[N];
int l;
void dfs(int now)
{
    int i,k;
    bool t;
    if(now>l)  {cout<<"YES";exit(0);}
    if(now+4<=l&&a[now]=='d'&&a[now+1]=='r'&&a[now+2]=='e'&&a[now+3]=='a'&&a[now+4]=='m')
        dfs(now+5);
    else
        if(now+4<=l&&a[now]=='e'&&a[now+1]=='r'&&a[now+2]=='a'&&a[now+3]=='s'&&a[now+4]=='e')
            dfs(now+5);
    if(now+6<=l&&a[now]=='d'&&a[now+1]=='r'&&a[now+2]=='e'&&a[now+3]=='a'&&a[now+4]=='m'&&a[now+5]=='e'&&a[now+6]=='r')
        dfs(now+7);
    if(now+5<=l&&a[now]=='e'&&a[now+1]=='r'&&a[now+2]=='a'&&a[now+3]=='s'&&a[now+4]=='e'&&a[now+5]=='r')
        dfs(now+6);
    return;
}
int main()
{
    int i;
    cin>>a+1;
    l=strlen(a+1);
    dfs(1);
    cout<<"NO";
    return 0;
}


Measured memory_bytes: 1152
import sys
from collections import deque


N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for s in sys.stdin.readlines():
    a, b = map(lambda x: int(x) - 1, s.split())
    edge[a].append(b)
    edge[b].append(a)

path = [-1] * N
cnt = 0
for i in range(N):
    if path[i] < 0:
        cnt += 1
        q = deque()
        path[i] = i
        q.append(i)
        while q:
            p = q.popleft()
            for np in edge[p]:
                if path[np] < 0:
                    path[np] = i
                    q.append(np)

print(cnt - 1)


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

#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ldb long double 
#define db double
#define str string
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

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

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a*=a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

double dp[3005][3005];

int32_t main()
{
    fast;
    for(int i=0;i<3005;i++)
     for(int j=0;j<3005;j++)
      dp[i][j]=0;
     dp[0][0]=1;
     int n;
     cin>>n;
     double arr[n+1];
     for(int i=1;i<=n;i++)
      cin>>arr[i];
     for(int i=1;i<=n;i++)
     {
         double ph=arr[i];
         double pt=(double)1-arr[i];
         dp[0][i]=pt*dp[0][i-1];
         for(int j=1;j<=i;j++)
         {
            dp[j][i]=ph*dp[j-1][i-1]+pt*dp[j][i-1];
         }
     }
     double res=0;
     for(int i=(n/2)+1;i<=n;i++)
     {
         res+=dp[i][n];
     }
     cout.precision(17);
     cout<<res<<"\n";
     return 0;
}

Measured memory_bytes: 70784
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 1e5 + 10;
int dp[maxn][3];
int abc[3];
int main()
{
	int n;
	while(~scanf("%d",&n)){
		scanf("%d%d%d",&abc[0],&abc[1],&abc[2]);
		dp[0][0] = abc[0];
		dp[0][1] = abc[1];
		dp[0][2] = abc[2];
		for(int i = 1; i<n; i++){
			scanf("%d%d%d",&abc[0],&abc[1],&abc[2]);
			dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + abc[0];
			dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + abc[1];
			dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + abc[2];
		} 
		int ans = max(dp[n-1][0],dp[n-1][1]);
		ans = max(ans,dp[n-1][2]);
		printf("%d\n",ans);
	}
	return 0;
 } 

Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main(void){
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  int x3,y3,x4,y4;
  x3=y1-y2+x2;
  y3=-x1+x2+y2;
  x4=y2-y3+x3;
  y4=-x2+x3+y3;
  cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    ll mx = 0;
    for (ll i = 0; i < n; i++)
    {
        ll x;
        cin >> x;
        if (i == 0)
        {
            mx = x;
        }
        else
        {
            ans += max(0LL, mx - x);
            mx = max(mx, x);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3192