akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <queue>
#include <tuple>

using namespace std;

using V = tuple<int, int, int>;
int h, w;
priority_queue<V, vector<V>, greater<V>> q;
int dist[1'000][1'000];

int main()
{
    cin >> h >> w;
    for (int i = 0; i < h; i++)
    {
        string s;
        cin >> s;
        for (int j = 0; j < w; j++)
        {
            if (s[j] == '#')
            {
                dist[i][j] = 0;
                q.push(make_tuple(0, i, j));
            }
            else
            {
                dist[i][j] = 1'000 * 1'000;
            }
        }
    }

    while (!q.empty())
    {
        int d, x, y;
        tie(d, x, y) = q.top();
        q.pop();

        if (d > dist[x][y])
        {
            continue;
        }

        for (int dx = -1; dx <= 1; dx++)
        {
            for (int dy = -1; dy <= 1; dy++)
            {
                if (dx * dx + dy * dy == 1)
                {
                    int nx = x + dx, ny = y + dy;
                    if (nx >= 0 && nx < h && ny >= 0 && ny < w)
                    {
                        int nd = dist[x][y] + 1;
                        if (nd < dist[nx][ny])
                        {
                            dist[nx][ny] = nd;
                            q.push(make_tuple(nd, nx, ny));
                        }
                    }
                }
            }
        }
    }

    int result = 0;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            result = max(result, dist[i][j]);
        }
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 16872
def main():
    lr = list(map(int, input().split()))
    divmod_lr = [divmod(x, 2019) for x in lr]

    if divmod_lr[0][1] == 0 or divmod_lr[1][1] == 0 or divmod_lr[0][0] != divmod_lr[1][0]:
        ans = 0
    else:
        ans = (2 * (10**9) + 10)**2
        for i in range(lr[0], lr[1]+1):
            for j in range(i+1, lr[1]+1):
                temp = (i * j) % 2019
                ans = min(ans, temp)

    print(ans)


if __name__ == '__main__':
    main()


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

int main()
{
    int a,b,ans;
    cin >> a >> b;
    if(a>b){
        ans=a+a-1;
    }
    else if(a==b){
        ans=a+b;
    }
    else{
        ans=b+b-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var n int
	fmt.Scan(&n)
	fmt.Println(n * n)
}

func nextSlice() []string {
	sc.Scan()
	return strings.Split(sc.Text(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

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

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

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

func larger(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func largest(a, b, c int) (lgst int) {
	if a > b {
		lgst = a
	} else {
		lgst = b
	}
	if c > lgst {
		lgst = c
	}
	return
}

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

func smallest(a, b, c int) (slst int) {
	if a < b {
		slst = a
	} else {
		slst = b
	}
	if c < slst {
		slst = c
	}
	return
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

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

func yesOrNo(b bool) string {
	if b {
		return "Yes"
	}
	return "No"
}

func yesorNO(b bool) string {
	if b {
		return "YES"
	}
	return "NO"
}

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

int N;
string s;

bool check(string& ans) {
	for (int i = 1; i < N;i++) {
		if (s[i] == 'o') {
			if(ans[i] == 'S')ans += ans[i - 1];
			else{
				if (ans[i - 1] == 'S') ans += 'W';
				else ans += 'S';
			}
		}
		else {
			if (ans[i] == 'S') {
				if (ans[i - 1] == 'S') ans += 'W';
				else ans += 'S';
			}
			else {
				ans += ans[i - 1];
			}
		}
	}
	if (ans[0] == ans[N]) {
		if (s[0] == 'o') {
			if (ans[0] == 'S') {
				if (ans[1] == ans[N - 1]) return true;
			}
			else {
				if (ans[1] != ans[N - 1]) return true;
			}
		}
		else {
			if (ans[0] == 'S') {
				if (ans[1] != ans[N - 1]) return true;
			}
			else {
				if (ans[1] == ans[N - 1]) return true;
			}
		}
	}
	return false;
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	cin >> N >> s;
	string ans;
	ans = "SS";
	if (check(ans)) { cout << ans.substr(0,N) << endl; return 0; }
	ans = "SW";
	if (check(ans)) { cout << ans.substr(0, N) << endl; return 0; }
	ans = "WW";
	if (check(ans)) { cout << ans.substr(0, N) << endl; return 0; }
	ans = "WS";
	if (check(ans)) { cout << ans.substr(0, N) << endl; return 0; }
	cout << -1 << endl;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  
  ll ans=0;
  ll tmp=0;
  rep(i,n-1){
    if(a[i]>=a[i+1]) tmp++;
    else{
      chmax(ans, tmp);
      tmp=0;
    }
  }
  chmax(ans, tmp);
  cout<<ans<<endl;
}

Measured memory_bytes: 3976
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       N: usize,
    }

    let mut ans: usize = 0;
    for i in 1..=N {
        if i % 3 != 0 && i % 5 != 0 {
            ans += i;
        }
    }

    echo!(ans);
}


Measured memory_bytes: 2148
fh = int(input())
oh = int(input())
ft = int(input())
to = int(input())
count = 0

for i in range(fh+1):
    for n in range(oh+1):
        for s in range(ft+1):
             if 500*i+100*n+50*s == to:
                 count += 1
print(count)
    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    int n;  cin >> n;
    vector<ll> a(n);
    REP(i, n)   cin >> a[i];
    multiset<ll> mp;
    REP(i, n){
        auto itr = mp.lower_bound(a[i]);
        if(itr != mp.begin()) mp.erase(--itr);
        mp.insert(a[i]);
    }
    cout << mp.size() << endl;
}

Measured memory_bytes: 5760
def p_j_dp():
    n = int(input())
    *a, = map(int, input().split())
    c1 = a.count(1)
    c2 = a.count(2)
    c3 = a.count(3)
    dp = [[[0.0] * (n + 1) for _ in range(n + 1)] for _ in range(n + 1)]
    for k in range(c3 + 1):
        for j in range(c3 + c2 + 1 - k):
            for i in range(n + 1 - k - j):
                if i + j + k == 0:
                    continue
                res = n
                if i > 0:
                    res += i * dp[i - 1][j][k]
                if j > 0:
                    res += j * dp[i + 1][j - 1][k]
                if k > 0:
                    res += k * dp[i][j + 1][k - 1]
                res /= i + j + k
                dp[i][j][k] = res
    print(dp[c1][c2][c3])
    
p_j_dp()

Measured memory_bytes: 253832
#include <iostream>
#include <string>
using namespace std;
int getMinEditCount(string org, string input){
	int num = 0;
	for (int i = 0; i < org.size(); i ++)
	{
		if(org[i] != input[i])
			num ++;
	}
	return num;
}
int main(){
	string org = "CODEFESTIVAL2016";
	string s;
	cin >> s;
	cout << getMinEditCount(org, s) << endl;
	return 0;
}

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

int N;
int h[100];
int E = 0;
int V = 0;

int main() {
   cin >> N;
   rep(i, N) cin >> h[i]; 

   rep(i, N) {
       V += h[i];
   }

   for (int i = 0; i <= N - 2; i++) {
       E += min(h[i], h[i + 1]);
   }

   cout << V - E << endl;
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
h = []
for i in range(n):
    h.append(int(input()))
ac = (max(h) - 1) // b + 1
wa = 0
while ac - wa > 1:
    wj = (ac + wa) // 2
    num = 0
    for i in range(n):
        num += max((h[i] - b * wj - 1) // (a - b) + 1, 0)
    if num <= wj:
        ac = wj
    else:
        wa = wj
print(ac)

Measured memory_bytes: 13016
#include <bits/stdc++.h>
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)


int main(){

    int N; std::cin >> N;
    std::vector<std::pair<std::string, std::pair<int, int>>> restaurant(N);
    rep(i , N){
        std::cin >> restaurant[i].first >> restaurant[i].second.first;
        restaurant[i].second.first *= -1;
        restaurant[i].second.second = i + 1;
    }

    std::sort(restaurant.begin(), restaurant.end());
    for(auto &v : restaurant)std::cout << v.second.second << std::endl;

    system("pause");

    return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    int sum = 0;
    sum += A.at(0)/2;
    for(int i = 1; i < N; i++){
        sum += A.at(i);
    }
    cout << sum << endl;


}

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

struct Pair{
	int x,y;
	Pair(int X,int Y)
	{
		x = X;
		y = Y;
	}
	bool operator<(Pair& a)
	{
		return y<a.y;
	}
};
vector<Pair> q;
int main()
{
	int N;
	cin>>N;
	int k;
	for(int i = 1;i <= N; i++ )
	{
		cin>>k;
		q.push_back(Pair(i,k));
	}
	sort(q.begin(),q.end());
	for(int i = 0;i<q.size();i++)
	{
		cout<<q[i].x<<" ";
	}
	return 0;
 } 

Measured memory_bytes: 1780
#include <stdio.h>

char s[100001];

void check(long long);

int main(void){
	
	long long K;
	
	scanf("%s",s);
	
	scanf("%lld",&K);
	
	check(K);
	
	printf("%s\n",s);
	
	return 0;
}
void check(long long K){
	
	int i;
	
	for(i=0;s[i] != '\0';i++){
		if(s[i] != 'a' && K >= 123-s[i]){
			K -= (123-s[i]);
			s[i] = 'a';
		}
	}
	
	if(K >= 26){K %= 26;}
	
	s[i-1] += K;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int mxn=2e5+5;
int n,k,md,c[333][333];
inline int A(int x,int y){int rt=x+y;if(rt>=md)rt-=md;return rt;}
inline void add(int&x,int y){x=A(x,y);}
inline int mul(int a,int b){
	int ret;
	__asm__ __volatile__ ("\tmull %%ebx\n\tdivl %%ecx\n":"=d"(ret):"a"(a),"b"(b),"c"(md));
	return ret;
}
inline void solve(){
	cin>>n>>k>>md;
	for(int i=0;i<333;++i)for(int j=0;j<333;++j){
		if(!j)c[i][j]=1;
		else if(!i)c[i][j]=0;
		else c[i][j]=A(c[i-1][j],c[i-1][j-1]);
	}
	vector<int>f(n+1,1);
	for(int t=k-1;t;--t){
		vector<int>g(n);for(int i=0;i<n;++i)g[i]=f[i];
		for(int i=0;i<n;++i)for(int j=i+1;j<n;++j)add(g[j],mul(g[i],mul(f[j-i-1],c[j][i+1])));
		for(int i=n;i;--i)for(int j=0;j<i;++j)add(f[i],mul(g[j],mul(f[i-j-1],c[i][j+1])));
	}
	cout<<f[n]<<'\n';
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int T=1;//cin>>T;
	for(;T--;)solve();
}


Measured memory_bytes: 3972
#include<iostream>

using namespace std;

int main(int argc, char **argv) {
    int a[5];
    int ans = 0, min = 9, min_index = 0;

    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];

    for (int i = 0; i < 5; i++){
        if (a[i] % 10 != 0 && a[i] % 10 < min){
            min = a[i] % 10;
            min_index = i;
        }
    }
    for (int j = 0; j < 5; j++){
        if (j != min_index){
            if (a[j] % 10 == 0){
                ans += a[j] / 10 * 10;
            }
            else {
                ans += a[j] / 10 * 10 + 10;
            }

        }
    }

    ans += a[min_index];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ac = [False] * N # index means p
wa = [0] * N # index means p
wa_cnt = 0
for i in range(M):
  p, s = map(str, input().split())
  p = int(p) - 1 # index starts from 0
  if ac[p] is False and s == "AC":
    wa_cnt += wa[p]
    ac[p] = True
  elif s == "WA":
    wa[p] += 1
print(ac.count(True), wa_cnt)

Measured memory_bytes: 4596
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Main
fn main(){
    input!{
        N: usize,
        P: [u64; N]
    }
    let mut ans = 0;
    let mut max_p = 0;
    // 全部足し合わせながら、最大値を調べる
    for i in 0..N{
        ans += P[i];
        max_p = max(max_p, P[i]);
    }
    // 最大値を割引処理
    ans -= max_p/2;
    
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned
#define ull unsigned ll
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define y1 wzpakking
#define fi first
#define se second
#define BG begin
#define ED end
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?(x)-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define sqr(x) (1ll*x*x)
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
#define inf 2147480000
using namespace std;
int n,k;
struct perm{
	int a[100005];
	perm operator +(const perm &b)const{
		perm c;
		For(i,1,n) c.a[i]=a[b.a[i]];
		return c;
	}
	perm operator -(const perm &b)const{
		perm c,d;
		For(i,1,n) d.a[b.a[i]]=i;
		For(i,1,n) c.a[i]=a[d.a[i]];
		return c;
	}
	void init(){
		For(i,1,n) scanf("%d",&a[i]);
	}
}a,b;
void output(perm a){
	For(i,1,n) printf("%d ",a.a[i]);
}
int main(){
	scanf("%d%d",&n,&k);
	a.init();
	b.init();
	if (k==1) return output(a),0;
	if (k==2) return output(b),0;
	int T=(k-2)/6;
	perm tmp,S;
	For(i,1,n) tmp.a[i]=i;
	S=b-a-b+a;
	for (;T;T>>=1,S=S+S)
		if (T&1) tmp=tmp+S;
	a=tmp+a-tmp;
	b=tmp+b-tmp;
	k-=(k-2)/6*6;
	For(i,3,k){
		perm c=b-a;
		a=b; b=c;
	}
	output(b);
}

Measured memory_bytes: 5120
import Control.Monad
import Data.Array
import Data.Array.Unboxed as UA
import Data.Array.ST
import Control.Monad.ST
import qualified Data.ByteString.Char8 as B

main=B.interact $ B.pack.f.take 2.B.lines

f [s,t]=mk "" (ls-1) (lt-1) where
    ls = B.length s
    lt = B.length t
    mk as si ti
        | si<0 || ti<0 = as
        | B.index s si == B.index t ti = mk (((:) $! B.index s si) $! as) (si-1) (ti-1)
        | aa UA.! (si+1,ti)>aa UA.! (si,ti+1) = mk as si (ti-1)
        | otherwise = mk as (si-1) ti
    aa :: UA.UArray (Int,Int) Int
    aa = runSTUArray $ do
        dp <- newArray ((0,0),(ls,lt)) 0 :: ST s (STUArray s (Int,Int) Int)
        forM_ [(i,j)|i<-[1..ls], j<-[1..lt]] $ \(i,j)->
            if B.index s (i-1) == B.index t (j-1)
                then writeArray dp (i,j) =<< (+1) <$> readArray dp (i-1,j-1)
                else writeArray dp (i,j) =<< max <$> readArray dp (i-1,j) <*> readArray dp (i,j-1)
        return dp


Measured memory_bytes: 71548
#include<iostream>
#include<algorithm>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<utility>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define multiCase int T;cin>>T;for(int t=1;t<=T;t++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repp(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define perr(i,a,b) for(int i=a;i>b;i--)
#define pb push_back
#define eb emplace_back
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=0x3f3f3f3f;
const ll LINF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-12;
const double PI=acos(-1.0);
const double ATRconst=PI/180.0;
const ll mod=998244353;
ll max_3(ll a,ll b,ll c){if(a>b&&a>c)return a;if(b>c)return b;return c;}
ll min_3(ll a,ll b,ll c){if(a<b&&a<c)return a;if(b<c)return b;return c;}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll qpow(ll a,ll n){ll r=1;while(n){if(n&1)r=(r*a)%mod;n>>=1;a=(a*a)%mod;}return r;}

char str[200050];

void solve()
{
    cin>>(str+1);
    for(int i=1;str[i]!='\0';i++)
    {
        if(str[i]=='?')
            str[i]='D';
    }
    cout<<str+1<<'\n';
}
int main()
{
    closeSync;
    //multiCase
    {
        solve();
    }
    return 0;
}


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

void solve()
{
    long long int N, W, i, j, sum = 0;
    cin>>N>>W;
    vector<long int> v(N+1), w(N+1);
    for(i=1;i<=N;i++) {
        cin>>w[i]>>v[i];
        sum  = sum + v[i]; 
    }
    vector<vector<long long int>> dp(N+1, vector<long long int>(sum+1, INT_MAX));
    for(i=1;i<=N;i++)
    {
        dp[i][v[i]] = w[i];
    }
    for(i=1;i<=N;i++) {
        for(j=1;j<=sum;j++) {
            if(v[i] > j)
                dp[i][j] = dp[i-1][j];
            else
                dp[i][j] = min({dp[i][j], dp[i-1][j], w[i] + dp[i-1][j-v[i]]});
        }
    }
    long long int ans = 0;
    for(i=1;i<=sum;i++) {
        if(dp[N][i]<=W) {
            ans = i;
        }
    }
    cout<<ans;
}

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

Measured memory_bytes: 83248
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

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

int main()
{
    ll D;
    cin >> D;
    string ans;
    switch (D)
    {
    case 25:
        ans = "Christmas";
        break;
    case 24:
        ans = "Christmas Eve";
        break;
    case 23:
        ans = "Christmas Eve Eve";
        break;
    case 22:
        ans = "Christmas Eve Eve Eve";
        break;
    default:
        break;
    }
    cout << ans << endl;
}

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

int main(){
	set <char> sit;
	string s;
	cin >> s;
	bool flag=true;
	for(int i=0;i<s.size();i++){
		auto find = sit.find(s[i]);
		if(find==sit.end()) sit.insert(s[i]);
		else{
			flag = false;
			break;
		}
	}
	if(!flag) printf("no\n");
	else printf("yes\n");
}

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

int main() {
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    for (int i = 0; i < a; i++) cin >> p[i];
    for (int i = 0; i < b; i++) cin >> q[i];
    for (int i = 0; i < c; i++) cin >> r[i];

    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());
    sort(r.begin(), r.end(), greater<int>());

    vector<int> all(x+y+c, 0);
    for (int i = 0; i < x; i++) all[i] = p[i];
    for (int i = 0; i < y; i++) all[i+x] = q[i];
    for (int i = 0; i < c; i++) all[i+x+y] = r[i];
    sort(all.begin(), all.end(), greater<int>());

    long long res = 0;
    for (int i = 0; i < x + y; i++) res += all[i];
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9 + 7;

vector<vector<P>> G;
vector<P> E;
int odd[100010];
int rev[100010];
int visit[100010];

int dfs(int n){
  visit[n] = 1;
  int res = odd[n];
  for(auto p : G[n]){
    if(!visit[p.first]){
      if(dfs(p.first)){
        rev[p.second] = 1;
        res = !res;
      }
    }
  }
  return res;
}

int main(void){
  int n,m;
  scanf("%d %d", &n, &m);
  G = vector<vector<P>>(n);
  E = vector<P>(m);
  for(int i = 0;i < m;++i){
    int u,v;
    scanf("%d %d", &u, &v);
    --u;--v;
    ++odd[u];
    E[i] = P(u,v);
    G[u].push_back(P(v,i));
    G[v].push_back(P(u,i));
  }
  for(int i = 0;i < n;++i){
    odd[i] %= 2;
  }
  fill(rev, rev+100010, 0);
  fill(visit, visit+100010, 0);
  if(dfs(0)){
    puts("-1");
  }else{
    for(int i = 0;i < m;++i){
      if(rev[i]){
        printf("%d %d\n", E[i].second+1, E[i].first+1);
      }else{
        printf("%d %d\n", E[i].first+1, E[i].second+1);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 13440
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
ansIndex = 0
smallestDiff = 999999
for index, height in enumerate(H):
    temp = T - height * 0.006
    diff = abs(A - temp)
    if smallestDiff > diff:
        smallestDiff = diff
        ansIndex = index

print(ansIndex+1)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    
    boolean ans = true;
    for (int i = 0; i < S.length(); i++) {
      char c = S.charAt(i);
      if (i%2 == 0) {
        if (c != 'R' && c != 'U' && c != 'D') {
          ans = false;
          break;
        }
      } else {
        if (c != 'L' && c != 'U' && c != 'D') {
          ans = false;
          break;
        }
      }
    }

    System.out.println(ans ? "Yes" : "No");
  }
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>

using namespace std;

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

    int s = 0;
    int b1 = 0;
    int b2 = 0;

    cin >> b1;
    b2 = b1;
    s += b1;
    for(int i=2; i<=N-1; i++)
    {
        cin >> b2;
        s += min(b1, b2);
        b1 = b2;
    }
    s += b2;

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
 
int main() {
    int N;
    cin >> N;
    ll A, B, S, X = 0;
    cin >> A >> B;
    S = A + B;
    REP(i, N - 2) {
        ll tmp; cin >> tmp;
        X ^= tmp;
    }
 
    ll dp[42][2][2] = {};
    REP(i, 42) REP(j, 2) REP(k, 2) dp[i][j][k] = -1;
    dp[0][0][0] = 0;
    REP(i, 41) {
        int cx = (X >> i) & 1;
        int cs = (S >> i) & 1;
        int ca = (A >> i) & 1;
 
        REP(j, 2) REP(k, 2) {
            if (dp[i][j][k] == -1) continue;
 
            REP(na, 2) {
                int nb = cx ^ na;
                int ns = na + nb + j;
                if ((ns & 1) != cs) continue;
 
                int ni = i + 1, nj, nk;
                if (ns >= 2) nj = 1;
                else nj = 0;
 
                if (na > ca) nk = 1;
                else if (na == ca) nk = k;
                else nk = 0;
 
                dp[ni][nj][nk] = max(dp[ni][nj][nk], dp[i][j][k] | ((ll)na << i));
            }
        }
    }
 
    ll a = dp[41][0][0];
    if (a == -1 || a == 0) cout << -1 << endl;
    else cout << A - a << endl;
    return 0;
}

Measured memory_bytes: 3612
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static boolean solve() {
		int n = in.nextInt();
		if (n == 0) return false;

		int[][] table = new int[n][n];

		int cx = n/2, cy = n/2+1;

		int cnt = 0;
		while (cnt < n*n) {
			if (table[cy][cx] == 0) {
				table[cy][cx] = ++cnt;
				cx = (cx+1)%n;
				cy = (cy+1)%n;
			} else {
				cx = (cx+n-1)%n;
				cy = (cy+1)%n;
			}
		}

		for (int i=0; i<n; i++) {
			for (int j=0; j<n; j++) {
				out.printf("%4d",table[i][j]);
			}
			out.println();
		}

		return true;
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		while(solve());
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 27436
#include "bits/stdc++.h"
using namespace std;
long long mod=1e9+7;
#define int long long

signed main(){
  int n,c;
  cin>>n>>c;
  vector<int> x(n);
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>x[i]>>v[i];
  if(n==1){
    int a=(v[0]+x[0]-c);
    int b=v[0]-x[0];
    int ans=0;
    ans=max(ans,max(b,a));
    cout<<ans<<endl;
    return 0;
  }
  vector<int> bestr(n);
  bestr[0]=max((int)0,v[0]-x[0]);
  int tmp=v[0]-x[0];
  for(int i=1;i<n;i++){
    tmp+=v[i];
    tmp-=abs(x[i]-x[i-1]);
    bestr[i]=max(bestr[i-1],tmp);
  }

  vector<int> bestl(n);
  bestl[n-1]=max((int)0,v[n-1]-abs(c-x[n-1]));
  tmp=v[n-1]-abs(c-x[n-1]);
  for(int i=n-2;i>=0;i--){
    tmp+=v[i];
    tmp-=abs(x[i]-x[i+1]);
    bestl[i]=max(bestl[i+1],tmp);
  }

  //for(int i=0;i<n;i++)cout<<bestr[i]<<" "<<bestl[i]<<endl;

  int ans=0;
  ans=max(ans,bestr[n-1]);
  ans=max(ans,bestl[0]);

  int np=v[0]-x[0];
  ans=max(ans,np+bestl[1]-x[0]);
  for(int i=1;i<n-1;i++){
    np+=v[i];
    np-=abs(x[i]-x[i-1]);
    ans=max(ans,np+bestl[i+1]-x[i]);
  }

  np=v[n-1]-abs(c-x[n-1]);
  ans=max(ans,np+bestr[n-2]-abs(c-x[n-1]));
  for(int i=n-2;i>0;i--){
    np+=v[i];
    np-=abs(x[i]-x[i+1]);
    ans=max(ans,np+bestr[i-1]-abs(c-x[i]));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
	return (b?gcd(b,a%b):a);
}
const int N=1e5+5;
int x[N],y[N],n,a[N],ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)x[i]=gcd(x[i-1],a[i]);
	for(int i=n;i>=1;i--)y[i]=gcd(y[i+1],a[i]);
	for(int i=1;i<=n;i++)ans=max(ans,gcd(x[i-1],y[i+1]));
	cout<<ans<<endl;
	return 0;
}

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

int	main()
{
	int N, K;
	cin >> N >> K;
	bool	has_sweet[100];
	for (int i = 0; i < N; ++i)
		has_sweet[i] = false;
	int	d, A;
	for (int i = 0; i < K; ++i) {
		cin >> d;
		for (int j = 0; j < d; ++j) {
			cin >> A;
			--A;
			has_sweet[A] = true;
		}
	}
	int	sum = 0;
	for (int i = 0; i < N; ++i) {
		if (!has_sweet[i])
			++sum;
	}
	cout << sum << endl;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vb = vector<bool>;
using vs = vector<string>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const ld eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i, a, b) for (ll i=(a); i<(b);i++)
#define FORD(i, a, b) for (ll i=ll(b)-1; i>=(a); i--)
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })


int heights[100005] = {0};
int minCosts[100005] = {0};

int main() {
	cin.sync_with_stdio(0);


	ll n;
	cin >> n;
	FOR(i, 0, n) {
		ll tmp;
		cin >> tmp;
		heights[i] = tmp;
	}
	minCosts[n - 1] = 0;
	minCosts[n - 2] = abs(heights[n - 1] - heights[n - 2]);
	FORD(i, 0, n - 2) {
		minCosts[i] = min(abs(heights[i] - heights[i + 1]) + minCosts[i + 1],
						  abs(heights[i] - heights[i + 2]) + minCosts[i + 2]);
	}
	cout << minCosts[0];
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int was[55];
int s[555];
int main(void)
{
    int n;
    cin>>n;
    while (n --)
    {
        int v;
        cin>>v;
        was[v] += 1;
    }
    for (int i = 0;i <= 12;++i)
        if (was[i] > 2)
            return puts("0") * 0;
    vi p;
    for (int i = 0;i <= 12;++i)
        if (was[i] == 1)
            p.pb(i);
    const int sz = (p.size());
    const int N = 1 << sz;
    int answer = 0;
    for (int mask = 0;mask < N;++mask)
    {
        memset(s,0,sizeof(s));
        s[0] = 1;
        for (int i = 0;i < sz;++i)
            if ((mask >> i) & 1)
                s[p[i]] += 1;
            else
                s[(24 - p[i]) % 24] += 1;
        for (int i = 0;i <= 12;++i)
            if (was[i] == 2)
                s[i] += 1,s[(24 - i) % 24] += 1;
        for (int i = 0;i < 24;++i)
            s[i + 24] = s[i];
        int ans = 1e9;
        int prev = -666;
        for (int i = 0;i < 48;++i)
            if (s[i])
            {
                ans = min(ans,i - prev);
                prev = i;
                if (s[i] >= 2)
                    ans = 0;
            }
        smax(answer,ans);
    }
    cout << answer << '\n';
    return 0;
}


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

int main(){
    ll n,z,w;
    cin >>n >>z >>w;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    if(n==1){
        cout<<abs(a[0]-w)<<endl;
        return 0;
    }
    ll all = (ll)abs(w-a[n-1]);
    ll ans = (ll)abs(a[n-2]-a[n-1]);
    cout<<max(all,ans)<<endl;
    return 0;    

    

}

Measured memory_bytes: 256
N,M = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A, reverse=True)
fav = sum(A) / (4 * M)
ans = 'Yes'

for i in range(M):
    if A[i] < fav:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 9196
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    p = LI()

    cnt = len([j for i, j in zip(p, sorted(p)) if i != j])
    if cnt <= 2:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10032
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
#include<queue>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

int main(){

  int a,b; cin >> a >> b;
  
  cout << max(max(a+b,a-b),a*b);

  return 0;
}


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

int main(){
  int n,T;
  cin >>n >>T;
  vector<int> t(n);
  rep(i,n) cin >>t[i];
  ll ans = 0;
  rep(i,n-1){
    if(t[i+1]-t[i]>=T) ans += T;
    else ans += t[i+1]-t[i];
  }
  ans += T;
  cout << ans << endl;
  return 0; 
}

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

int C(int a, int b)
{
    if (a < b) return 0;
    if (a==b) return 1;
    int ans=1;

    for(int i=0; i < b; i++)
    {
        ans = ans * (a-i) / (i+1);
    }
    return ans;
}

int main()
{
    int N, M;
    cin >> N >> M;
    int answer;
    answer = C(M, 2) + C(N, 2);
    cout << answer << endl;
    // cout << C(100, 2) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define maxn 100010
#define inf 1000000007
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,K;
int head[maxn],nxt[maxn*2],to[maxn*2],tot;
void add(int u,int v)
{
    tot++;
    nxt[tot]=head[u];
    head[u]=tot;
    to[tot]=v;
}
int book[maxn],val[maxn],L[maxn],R[maxn],rt;
void dfs(int x,int las,int op)
{
    if(las)
    {
        L[x]=max(L[x],L[las]-1);
        R[x]=min(R[x],R[las]+1);
    }
    if(book[x])
    {
        if(op!=((val[x]^val[rt])&1))
        {
            puts("No");
            exit(0);
        }
    }
    for(int i=head[x];i;i=nxt[i])
    {
        if(to[i]==las)  continue;
        dfs(to[i],x,op^1);
        L[x]=max(L[x],L[to[i]]-1);
        R[x]=min(R[x],R[to[i]]+1);
    }
    if(L[x]>R[x])
    {
        puts("No");
        exit(0);
    }
}
void solve(int x,int las)
{
    for(int i=head[x];i;i=nxt[i])
    {
        if(to[i]==las)  continue;
        if(val[x]-1>=L[to[i]]&&val[x]-1<=R[to[i]])  val[to[i]]=val[x]-1;
        else                                        val[to[i]]=val[x]+1;
        solve(to[i],x);
    }
}
int main()
{
    n=read();
    for(int i=1;i<n;i++)
    {
        int q=read(),w=read();
        add(q,w);
        add(w,q);
    }
    for(int i=1;i<=n;i++)  L[i]=-inf,R[i]=inf;
    K=read();
    for(int i=1;i<=K;i++)
    {
        int x=read(),y=read();
        if(i==1)  rt=x;
        book[x]=1;
        val[x]=y;
        L[x]=R[x]=y;
    }
    dfs(rt,0,0);
    solve(rt,0);
    puts("Yes");
    for(int i=1;i<=n;i++)  printf("%d\n",val[i]);
    return 0;
}

Measured memory_bytes: 9088
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	int i,a[4],b,c,sum;
	for(i=0;i<4;i++){
		scanf("%d",&a[i]);
	}
	scanf("%d %d",&b,&c);
	sort(a,a+4,greater<int>());
	for(i=0;i<3;i++){
		sum+=a[i];
	}
	if(b>c){
		sum+=b;
	}
	else{
		sum+=c;
	}
	printf("%d\n",sum);
	return 0;
}



Measured memory_bytes: 2740
#include<cstdio>
#include<algorithm>
#include<queue>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=2000+10;
struct dong{
    int x,y;
    friend bool operator <(dong a,dong b){
        return a.x<b.x;
    }
} zlt;
priority_queue<dong> dl;
bool bz[maxn][maxn],pd[maxn];
int a[maxn],d[maxn];
int h[maxn],go[maxn*maxn],nxt[maxn*maxn];
int i,j,k,l,t,n,m,tot,now;
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
void add(int x,int y){
    d[y]++;
    go[++tot]=y;
    nxt[tot]=h[x];
    h[x]=tot;
}
void dfs(int x){
    pd[x]=1;
    int i;
    fo(i,1,n)
        if (bz[x][i]&&!pd[i]){
            add(x,i);
            dfs(i);
        }
}
int main(){
    scanf("%d",&n);
    fo(i,1,n) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    fo(i,1,n-1)
        fo(j,i+1,n)
            if (gcd(a[i],a[j])>1) bz[i][j]=bz[j][i]=1;
    fo(i,1,n)
        if (!pd[i]) dfs(i);
    fo(i,1,n)
        if (!d[i]){
            zlt.x=a[i];
            zlt.y=i;
            dl.push(zlt);
        }
    fo(i,1,n){
        zlt=dl.top();
        dl.pop();
        now=zlt.y;
        printf("%d ",a[now]);
        t=h[now];
        while (t){
            d[go[t]]--;
            if (!d[go[t]]){
                zlt.x=a[go[t]];
                zlt.y=go[t];
                dl.push(zlt);
            }
            t=nxt[t];
        }
    }
}

Measured memory_bytes: 7296
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
	string s;
	cin >> s;
	
	s[3] = '8';
	cout << s << endl;

	return 0;
}

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

int main(){
	int n, m, c;
	int b[21];
	int a_buf[21];

	cin >> n >> m >> c;

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

	int count = 0;
	for(int i = 0; i < n; ++i){
		int sum = 0;
		for(int j = 0; j < m; ++j){
			cin >> a_buf[j];
			sum += b[j] * a_buf[j];
		}
		sum += c;
		if(sum > 0){
			++count;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
//
// Created by Imamura, Yuta on 2020/02/09.
//

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

// repr(i,10,13) -> 10,11,12
#define repr(i,a,b) for(int i=a;i<b;i++)
// rep(i,3) -> 0,1,2
#define rep(i,n) for(int i=0;i<n;i++)
// reprrev(i,10,13) -> 12,11,10
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)
// reprev(i,3) -> 2,1,0
#define reprev(i,n) reprrev(i,0,n)

int main() {
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int left = max(a, c);
    int right = min(b, d);
    if (right - left <= 0) {
        cout << 0 << endl;
    } else {
        cout << right - left << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

using namespace std;

typedef long long ll;

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

    int A, B, C; cin >> A >> B >> C;
    std::cout << min(B / A, C) << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n;
  scanf("%d", &n);
  
  int c[n - 1];
  int s[n - 1];
  int f[n - 1];
  
  for(int i = 0; i < n - 1; i++){
    scanf("%d %d %d", &c[i], &s[i], &f[i]);
  }
  
  for(int i = 0; i < n - 1; i++){
    int t = 0;
    for(int j = i; j < n - 1; j++){
      t = (((t - 1) / f[j] + 1) * f[j] < s[j]) ? s[j] : ((t - 1) / f[j] + 1) * f[j];
      t += c[j];
    }
    
    printf("%d\n", t);
  }
  
  printf("0\n");
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	int n,a,b,c;

	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a >> b >> c;

		int x,y,z;

		x = max(max(a,b),max(b,c));
		z = min(min(a,b),min(b,c));
		y = a+b+c-x-z;

		if (x*x == y*y + z*z)
		{
			cout << "YES" << endl;
		}else
		{
			cout << "NO" << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 2980
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, n) for(int i = 0; i < n; i = i + 2)
#define repv(i, n, v) for(int i = 0; i < n; i = i + v)
#define rrep(i, n) for(int i = n; i >= 0; i--)
#define sortI(a, b, c) c == 0 ? sort(a, a + b) : sort(a, a + b, greater<int>())
#define sortS(s, a) a == 0 ? sort(s.begin(), s.end()) : sort(s.begin(), end(), greater<char>)
#define vi vector<int>
#define vf vector<float>
#define vc vector<char>
#define vs vector<string>
#define ll long long
#define lint long int
#define llint long long int

int digit(int n){
  int res = 0;
  while(n > 0){
    res += n%10;
    n /= 10;
  }
 
  return res;
}

int main(void){

  //入力
  string S;
  cin >> S;
  
  //aからzまで
  string all = "abcdefghijklmnopqrstuvwxyz";
  int i;
  for(i = 0; i < all.size(); i++){
    if( S.find(all[i]) == -1){
      break;
    }
  }
  
  if( i != all.size() ) cout << all[i] << endl;
  else cout << "None" << endl;

  return 0;
}

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

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

    int ans = 700;
    for (char t : S)
    {
        if (t == 'o')
        {
            ans += 100;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3608
import math
a,b,x = map(int,input().split())
s = x / a
if s >= a*b/2:
    left = a*b-s
    si = (left * 2)/(a*a)
    ans = math.degrees(math.atan(si))
else:
    si = (2*s)/(b*b)
    ans = 90.0-math.degrees(math.atan(si))
print(ans)


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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    int x;
    cin >> x;
    if(x <1200){
        cout << "ABC" << endl;
    }else{
        cout << "ARC" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}
template<class T>istream&operator>(istream&i,T&t){return i>>t;}
#ifndef LOCAL
struct ostdmy{
template<class T>ostdmy&operator<<(const T&t){return*this;}
template<class T>ostdmy&operator<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int A,B,k;
    cin>A>B>k;
    int *a=&A;
    int *b=&B;
    REP(i,k){
        if(*a%2)(*a)--;
        *a>>=1;
        *b+=*a;
        swap(a,b);
    }
    cout<A<' '<B<endl;

    return 0;
}


Measured memory_bytes: 256