akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AGC013_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int amount = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int[] numbers = new int[amount];
            for (int i = 0; i < amount; i++)
            {
                numbers[i] = int.Parse(input[i]);
            }

            int split = 0;
            for (int i = 0; i < amount - 1; i++)
            {
                if (numbers[i] == numbers[i + 1])
                {
                    continue;
                }

                if (numbers[i] < numbers[i + 1])
                {
                    int a = i + 1;
                    while (a < amount - 1)
                    {
                        if (numbers[a] <= numbers[a + 1])
                        {
                            a++;
                        }
                        else
                        {
                            i += a - i;
                            break;
                        }
                    }
                    if (a == amount - 1)
                    {
                        break;
                    }
                    split++;
                }
                else if (numbers[i] > numbers[i + 1])
                {
                    int a = i + 1;
                    while (a < amount - 1)
                    {
                        if (numbers[a] >= numbers[a + 1])
                        {
                            a++;
                        }
                        else
                        {
                            i += a - i;
                            break;
                        }
                    }
                    if (a == amount - 1)
                    {
                        break;
                    }
                    split++;
                }
            }
            Console.WriteLine(split + 1);
        }
    }
}


Measured memory_bytes: 20448
#include <iostream>
#include <string>
using namespace std;
 // tokyo tokyotokyo
int main(){
  string s,t;
  int n;
  cin >> s >> t;
  s += s;
  n = s.length();
  if(s.find(t) != string::npos){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

signed main() {
	int n ; cin >> n ; 
	int ans = 0 ; 
	int temp = n ; 
	std::map<int, int> m;
	while ( n % 2 == 0 ) {
		m[2]++ ;
		n /= 2 ;
	}
	for ( int i=3; i<=sqrt(temp) && n > 1; i += 2 ) {
		while ( n % i == 0 ) {
			m[i]++ ; 
			n /= i ; 
		}
	}
	std::map<int, int>::iterator it = m.begin();
	for ( it=m.begin(); it!=m.end(); ++it ) {
		// cout << it->first << ' ' << it->second << endl ; 
		ans += (sqrt(1+(8*(it->second)))-1)/2 ;
	}
	if ( n > sqrt(temp) ) {
		ans += 1 ; 
	}
	cout << ans << endl ; 
	return 0 ; 
}

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

using namespace std;

typedef long long ll;
const ll MOD=1e9+7;

ll C[2100][2100];

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

    for (int i=0;i<=N;i++) {
        for (int j=0;j<=i;j++) {
            if (j==0) C[i][j]=1;
            else C[i][j]=C[i-1][j]+C[i-1][j-1];
            C[i][j] %= MOD;
        }
    }

    for (int i=1;i<=K;i++) {
         cout << C[N-K+1][i] * C[K-1][i-1] % MOD << endl;
    }

    return 0;
}

Measured memory_bytes: 31616
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	static long mod = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		long sum = 0;
		sum += power(2, n);
		sum -= 1 + combination(n, a) + combination(n, b);
		sum %= mod;
		if (sum < 0) {
			sum += mod;
		}
		System.out.println(sum);
	}

	static long power(long n, long m) {
		if (m == 1) {
			return n % mod;
		}
		if (m % 2 == 0) {
			return power(n * n % mod, m / 2);
		} else {
			return power(n * n % mod, m / 2) * n % mod;
		}
	}

	static long modinv(long a) {
		return power(a, mod - 2);
	}

	static long combination(long n, long k) {
		long ans = 1;
		while (k > 0) {
			ans *= n - k + 1;
			ans %= mod;
			ans *= modinv(k);
			ans %= mod;
			k--;
		}
		return ans;
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

int main()
{
	long long n, k;
	cin >> n >> k;
	vector<long long> av;
	vector<long long> pv;
	vector<long long> nv;
	for (long long i = 0; i < n; ++i) {
		long long a;
		cin >> a;
		av.push_back(a);
		if (a < 0) {
			nv.push_back(a);
		}
		else {
			pv.push_back(a);
		}
	}

	bool retIsP = false;
	if (pv.empty()) {
		if (k % 2 == 0) {
			retIsP = true;
		}
	}
	else {
		if (n == k && nv.size() % 2 == 0) {
			retIsP = true;
		}
		else if (k < n) {
			retIsP = true;
		}
	}

	const long long mod = 1000000007;
	long long ret = 1;
	if (retIsP) {
		sort(pv.rbegin(), pv.rend());
		sort(nv.begin(), nv.end());
		vector<long long> newv;
		if (k % 2 == 1) {
			ret = ret * pv[0];
			for (size_t i = 2; i < pv.size(); i += 2) {
				newv.push_back(pv[i] * pv[i - 1]);
			}
			--k;
		}
		else {
			for (size_t i = 1; i < pv.size(); i += 2) {
				newv.push_back(pv[i] * pv[i - 1]);
			}
		}
		for (size_t i = 1; i < nv.size(); i += 2) {
			newv.push_back(nv[i] * nv[i - 1]);
		}
		sort(newv.rbegin(), newv.rend());
		if (k != 0) {
			for (size_t i = 0; i < newv.size(); ++i) {
				ret = ret * (newv[i] % mod) % mod;
				k -= 2;
				if (k == 0) {
					break;
				}
			}
		}
	}
	else {
		sort(av.begin(), av.end(), [](long long x, long long y) {
			return abs(x) < abs(y);
		});
		for (long long i = 0; i < k; ++i) {
			ret = ret * av[i] % mod;
		}
	}

	if (ret < 0) {
		ret += mod;
	}
	cout << ret << endl;

	return 0;
}

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

int main(){
  int N;
  std::cin >> N;
  std::vector<int> v(N);
  for (int i = 0; i < N; i++){
    int val;
    std::cin >> val;
    v.at(i) = val;
  }
  sort(v.begin(), v.end());
  
  double ans = v.at(0);
  for (int i = 1; i < N; i++){
    ans = (ans + v.at(i)) / 2.0;
  }
  std::cout << ans << std::endl;
}

Measured memory_bytes: 3796
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

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

    long long f[n][5][2];
    long long p[n][11];

    for(long long i = 0; i < n; i++){
        for(long long j = 0; j < 5; j++){
            for(long long k = 0; k < 2; k++){
                cin >> f[i][j][k];
            }
        }
    }

    for(long long i = 0; i < n; i++){
        for(long long j = 0; j < 11; j++){
            cin >> p[i][j];
        }
    }

    vector<bool> open(10, false);
    vector<bool> close(10, false);
    long long maxv = -1e15;

    for(long long bit = 0; bit < (1 << 10); bit++){
        for(long long mask = 0; mask < 10; mask++){
            if(bit & (1 << mask)) open[mask] = true;
            else open[mask] = false;
        }
        if(open == close) continue;

        long long money = 0;
        for(long long i = 0; i < n; i++){
            long long cnt = 0;
            for(long long j = 0; j < 5; j++){
                for(long long k = 0; k < 2; k++){
                    if(f[i][j][k] == 1 and open[j + 5*k] == true) cnt++;
                }
            }
            money += p[i][cnt];
        }
        //printf("money %lld\n", money);
        maxv = max(maxv, money);
    }
    cout << maxv << endl;
    return 0;
}

Measured memory_bytes: 3592
n=int(input())
c=10**9+7
def pow_c(x,n,c):
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K= (K%c)*(x%c)%c
        x = ((x%c)**2)%c
        n //= 2
    return (K%c) * (x%c) %c

k10=pow_c(10,n,c)
k9=pow_c(9,n,c)
k8=pow_c(8,n,c)
ans=(k10-2*k9+k8)%c 
print(ans)

Measured memory_bytes: 61948
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);++i)
int n;
int a[100]; 
int main()
{
cin>>n;
int sum=0;
REP(i,n)
{
    cin>>a[i];
    sum+=a[i];
}
int diff=(sum>=0?(sum+(n/2))/n:(sum-(n/2))/n);
int ans=0;
REP(i,n)
  ans+=(a[i]-diff)*(a[i]-diff);
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * @author kep
 * @date 2019-10-17
 */
public class Main {

    private static int[] vis = new int[100005];
    private static long[] sum = new long[100005];
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long x = scanner.nextLong();
        long mod = scanner.nextLong();
        long ans = 0;
        int index = 1;
        int startIndex = -1;
        for(;index<=n;index++){
            if(vis[(int)x] != 0){
                startIndex = vis[(int)x];
                break;
            }
            vis[(int)x] = index;
            sum[index] = sum[index-1]+x;
            ans += x;
            x = (x*x)%mod;
        }
        if(n >= index){
            n = n - index + 1;
            ans = ans + (n/(index-startIndex))*(sum[index-1]-sum[startIndex-1]);
            if(n%(index-startIndex) != 0){
                int xx = (int)(n%(index-startIndex));
                ans = ans + sum[startIndex+xx-1] -sum[startIndex-1];
            }
        }
        System.out.println(ans);
    }



}

Measured memory_bytes: 36768
fn main () {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).unwrap();
    let n: Vec<char> = n.trim().chars().collect();

    let s = if n[0] < n[1] || n[0] < n[2] {
        ((n[0] as u8) + 1) as char
    } else {
        n[0]
    };
    println!("{}", vec![s; n.len()].into_iter().collect::<String>());
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
//#define lop(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, m;
	cin >> n >> m;
	if (n == m) {
		cout << "Yes" << "\n";
	}
	else cout << "No" << "\n";
}

Measured memory_bytes: 3616
import java.lang.Math.*

const val MOD = 1000000007L

fun main(args: Array<String>) {
    val (A, B, C) = readIntList()
    println(max(C - (A - B), 0))
}


fun readList() = readLine()!!.split(' ')
fun readInt() = readLine()!!.split(' ').map(String::toInt).first()
fun readIntList() = readList().map(String::toInt)
fun readLongList() = readList().map(String::toLong)
fun readDoubleList() = readList().map(String::toDouble)

fun readPair(): Pair<String, String> {
    val splite = readLine()!!.split(' ')
    return Pair(splite[0], splite[1])
}

fun <T> List<T>.copy() = this.map { it }

// 速度のためforEachは避ける
inline fun Int.rep(start: Int = 0, body: (Int) -> Unit) {
    for (i in start until this + start) {
        body(i)
    }
}

inline fun Long.rep(start: Long = 0, body: (Long) -> Unit) {
    for (i in start until this + start) {
        body(i)
    }
}

// 約数のList
fun divisor(value: Long): List<Long> {
    val max = sqrt(value.toDouble()).toLong()
    return (1..max)
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from: Long, to: Long = from): List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j -> i % j != 0L }
    }
}

// 素因数分解
fun decom(value: Long): List<Long> {
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a: Long, b: Long): Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base: String, a: String, b: String): String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

Measured memory_bytes: 36328
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int n,m;
int s[5];
int c[5];

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
    scanf("%d %d",&s[i],&c[i]);

    for(int i=0;i<1000;i++)
    {
        char num[5];
        sprintf(num,"%d",i);
        // itoa(i,num,10);
        if(strlen(num)!=n) continue;
        bool flag=true;
        for(int j=0;j<m;j++)
        {
            if(num[s[j]-1]!=c[j]+'0')
            {
                flag=false;
                break;
            }
        }
        if(flag)
        {
            printf("%d\n",i);
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}

Measured memory_bytes: 1696
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;
use std::io::Write;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let n: usize = read();
    let a: Vec<i32> = readn(n);
    let mut a: Vec<(i32, usize)> = a.into_iter().zip(0..n).collect();
    a.sort();

    let mut diff = 0;
    for i in 0..n {
        if a[i].1 % 2 != i % 2 {
            diff += 1;
        }
    }

    println!("{}", diff / 2);
}

Measured memory_bytes: 6396
n = int(input())
ans = ''

for i in range(1, 99):
    if n <= 26**i:
        n -= 1
        for j in range(i):
            ans += chr(ord('a') + n % 26)
            n //= 26
        break
    else:
        n -= 26 ** i

print(ans[::-1])

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

using namespace std;

int main() {
	int n;
	cin >> n;
	// int n = 2000;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		// a[i] = rand() % 2 + 1;
	}
	sort(a.begin(), a.end());
	set<int> s;
	map<int, int> c;
	long long tot = 0, ans = 0;
	for (int i = 0; i < n; i++) {
		// cout << ans << endl;
		while (s.size() && *s.begin() <= a[i]) {
			tot -= c[*s.begin()];
			c.erase(*s.begin());
			s.erase(s.begin());
		}
		ans += tot;
		for (int j = 0; j < i; j++) {
			int l = a[i] + a[j];
			s.insert(l);
			if (!c.count(l)) {
				c[l] = 0;
			}
			c[l]++;
			tot++;
		}
	}
	cout << ans << endl;
}

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

void solve(){
    ll N; cin >> N;
    vector<P> data(N);
    for (int i = 0; i < N; i++){
        ll x, l; cin >> x >> l;
        data[i].first = x - l;
        data[i].second = x + l;
    }
    sort(data.begin(), data.end(),
         [](const P& x, const P& y){return x.second < y.second;}
    );
    ll cnt = 0;
    ll now_right = data[0].second;
    for (int i = 1; i < N; ++i){
        if (now_right <= data[i].first) now_right = data[i].second;
        else cnt++;
    }
    cout << N - cnt << endl;
}
int main(void){
    //////////////////////////

    solve();

    //////////////////////////
    return 0;
}

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

int main(){
    vector<ll> a(5);
    ll rec = -1;
    ll mx = 9;
    rep(i, 0, 5){
        cin >> a[i];
        if(a[i]%10 != 0 && mx >= a[i]%10){
            rec = i;
            mx = a[i]%10;
        }
    }
    if(rec == -1) rec = 0;

    ll ans = 0;
    rep(i, 0, 5){
        
        if(rec == i){
            ans += a[i];
        }else if(a[i]%10 == 0){
            ans += a[i];
        }else{
            ans += ((ll)(a[i]/10)+1)*10;
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 


int main()
{
  __;
  string s;
  cin >> s;
  string tf = "", tr = "";
  int q;
  cin >> q;
  bool is_reverse = false;
  while(q--)
  {
    int a;
    cin >> a;
    if(a==1)
    {
      is_reverse ^= 1;
    }
    else
    {
      int b;
      cin >> b;
      char c;
      cin >> c;
      if(b == 1)
      {
        if(!is_reverse) tf += c;
        else tr += c;
      }
      else
      {
        if(!is_reverse) tr +=c;
        else tf += c;
      }
    }

  }
  if(is_reverse)
  {
    reverse(s.begin(),s.end());
    reverse(tr.begin(),tr.end());
    cout << tr + s + tf << endl;
  }
  else
  {
    reverse(tf.begin(),tf.end());
    cout << tf + s + tr << endl;
  }
  return 0;
}


Measured memory_bytes: 1300
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
# import statistics
import bisect
import copy
import fractions
import math
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]
def dfs(v):
    # ノードに訪れた
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  # そもそもvとv2が辺でつながっていない
            continue
        if visited[v2] == True:  # もう見た
            continue
        dfs(v2)


x, y, z, k = MI()
a = LI()
b = LI()
c = LI()
tmp = []
ans = []
for i in a:
    for j in b:
        tmp.append(i+j)
tmp = sorted(tmp, reverse=True)
for p in tmp[:k]:
    for q in c:
        ans.append(p+q)
ans = sorted(ans, reverse=True)
for num in ans[:k]:
    print(num)


Measured memory_bytes: 156416
import sys
from collections import Counter


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    A = input()
    N = len(A)
    answer = N * (N - 1) // 2 + 1
    count = Counter(A)
    key = list(count.keys())
    for k in key:
        if count[k] > 1:
            answer -= count[k] * (count[k] - 1) // 2
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
  int L, R, d;
  cin >> L >> R >> d;

  cout << R / d - (L - 1) / d << endl;
}


Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		Integer[] a = new Integer[n];
		Integer[] f = new Integer[n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		for (int i = 0; i < n; i++) {
			f[i] = sc.nextInt();
		}

		Arrays.sort(a);
		Arrays.sort(f, Comparator.reverseOrder());

		long l = -1;
		long r = Math.max(a[n - 1], f[0]);
		r *= r;
		while (r - l > 1) {
			long m = (l + r) / 2;
			long remain = k;

			for (int i = 0; i < n; i++) {
				remain -= Math.max(a[i] - m / f[i], 0);
				if (remain < 0) break;
			}

			if (remain >= 0) {
				r = m;
			} else {
				l = m;
			}
		}

		System.out.println(r);
	}

}


Measured memory_bytes: 114736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  string s;
  cin>>s;
  ll n=s.length(),a[11][11]={},ans=0;
  fr(i,n){
    fr(j,n-i){
      if(i==0) a[j][j]=s[j]-'0';
      else a[j][j+i]=a[j][j+i-1]*10+s[j+i]-'0';
    }
  }
  fr(i,1<<(n-1)){
    ll s=0,t=0;
    fr(j,n-1){
      if((i>>j)&1){ans+=a[s][t];s=++t;}
      else t++;
    }
    ans+=a[s][t];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){

int a, b;
scanf("%d %d", &a, &b);
	
	if(a<b){
		printf("a < b\n");
	}
	
	else if(a>b){
		printf("a > b\n");
	}
	else{
		printf("a == b\n");
	}
	
return 0;
}


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

using namespace std ;

typedef long long LL ; 

LL a, b ; 

int sa[70], sb[70] ; 

LL dp[70][2][2] ; 
LL Dodp() { 
		int tp = 59 ; 
		while (sa[tp] == sb[tp]) tp -- ; 

		int nxt = -1 ; 
		for (int i = tp - 1; ~i; i --) { 
				if (sb[i]) {
						nxt = i ; 
						break ; 
				}
		}

		LL ans = 0 ; 
		if (nxt > 0) ans += (1LL << nxt) - 1 - (b & ((1LL << nxt) - 1)) ; 
		a &= ((1LL << tp) - 1);
	    b &= ((1LL << tp) - 1) ; 
		
		if (nxt > 0) b |= ((1LL << nxt) - 1) ; 
		
		a = max(a, b + 1)  ; 

		return ans + (1LL << tp) - a ; 

}
int main() { 

		cin >> a >> b ; 
		if (a == b) {
				puts("1");
				return 0 ;
		}
		for (int i = 0; i < 60; i ++) sa[i] = (a >> i) & 1  ;

		for (int i = 0; i < 60; i ++) sb[i] = (b >> i) & 1 ; 
		
		LL ans = b - a + 1;  

		ans += Dodp() ; 

		cout << ans << endl ; 
}



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 vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#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 rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
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>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&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>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    cout<<setprecision(10);
    int n;
    cin>>n;
    string s;
    cin>>s;
    REPA(i,s){
        cout<<(char)((s[i]-'A'+n)%26+'A');
    }
    cout<<endl;
}


Measured memory_bytes: 256
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

N = int(input())
S = input()

r_sum = [0] * N
g_sum = [0] * N
b_sum = [0] * N

if S[0] == "R":
    r_sum[0] = 1
elif S[0] == "G":
    g_sum[0] = 1
else:
    b_sum[0] = 1

c_map = {"R": 1, "G": 2, "B": 3}

for i, c in enumerate(S):
    if i == 0:
        continue
    r_sum[i] = r_sum[i-1]
    g_sum[i] = g_sum[i-1]
    b_sum[i] = b_sum[i-1]
    if c == "R":
        r_sum[i] += 1
    elif c == "G":
        g_sum[i] += 1
    else:
        b_sum[i] += 1

ans = 0
for i in range(N):
    for j in range(i+1, N):
        d = j - i
        if S[i] != S[j]:
            rest = 6 - c_map[S[i]] - c_map[S[j]]
            if rest == 1:
                ans += r_sum[N - 1] - r_sum[j]
                if j + d <= N - 1 and c_map[S[j + d]] == 1:
                    ans -= 1
            elif rest == 2:
                ans += g_sum[N - 1] - g_sum[j]
                if j + d <= N - 1 and c_map[S[j + d]] == 2:
                    ans -= 1
            else:
                ans += b_sum[N - 1] - b_sum[j]
                if j + d <= N - 1 and c_map[S[j + d]] == 3:
                    ans -= 1

print(ans)


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

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;


int main(){

	lli m,d;
	cin>>m>>d;

	lli  cnt=0;

	for(lli i=1;i<=m;i++){
		for(lli j=1;j<=d;j++){
			lli d0 = j%10;
			lli d1 = j/10;
			if(i==d0*d1 && d0>=2 && d1>=2){
				cnt++;
			}
		}
	}

	cout<<cnt<<endl;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    ll N,K; cin >> N >> K;
    vector<ll> p(N+1); p[0] = zero;
    ll tmp;
    for(ll i = 1 ; i <= N; i++){
        cin >> tmp; tmp = 1+tmp;
        p[i] = p[i-1] + tmp;
    }
    ll ma = zero;
    for (ll i = 0; i <= N-K; i++) {
        ma = max(ma, p[i+K] - p[i]);
    }   
    printf("%lf\n", ma/2.0);;

}


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

int main() {
	int N, D; cin >> D >> N;
	if (D == 0) {
		if (N == 100) {
			cout << 101 << endl;
			return 0;
		}
		cout << 1 * N << endl;
		return 0;
	}
	if (D == 1) {
		if (N == 100) {
			cout << 10100 << endl;
			return 0;
		}
		cout << 100 * N << endl;
		return 0;
	}
	if (D == 2) {
		if (N == 100) {
			cout << 1010000 << endl;
			return 0;
		}
		cout << 10000 * N << endl;
		return 0;
	}
}

Measured memory_bytes: 256
tn=list(map(int,list(input())))
for i in range(0,16,2):
  if sum(x*[1,-1][i>>k&1] for k,x in enumerate(tn))==7:
    s=''.join(list(['+','-'][i>>k&1]+str(tn[k]) for k in range(1,4)))
    print(str(tn[0])+s+'=7')
    break


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
#define ANS(s) cout << s << endl


using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}



int main(void) {
    char X,Y;
    cin >> X >> Y;
    if(X == Y){
        cout << '=';
    } else if(X < Y){
        cout << '<';
    } else{
        cout << '>';
    }
    cout << endl;
    return 0;
    
}


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

int main(){
  string s;
  int n;
  cin >> n >> s;
  vector<vector<int>> idx(10);
  rep(i,n) {
    idx[s[i] - '0'].push_back(i);
  }
  int res = 0;
  for (int i = 0; i < 10; i++) {
    if (idx[i].empty()) continue;
    int a = idx[i].front();
    for (int j = 0; j < 10; j++) {
      auto itr1 = upper_bound(idx[j].begin(), idx[j].end(),a);
      if (itr1 == idx[j].end()) continue;
      int b = idx[j][itr1 - idx[j].begin()];
      for (int k = 0; k < 10; k++) {
        auto itr2 = upper_bound(idx[k].begin(), idx[k].end(), b);
        if (itr2 == idx[k].end()) continue;
        res++;
      }
    }
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int main() {
	int x; scanf("%d", &x);
	int cnt = 0, i;
	for (i = 1;; i++) {
		cnt += i;
		if (cnt >= x)break;
	}
	printf("%d\n", i);
}

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

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx")

#define fi first
#define se second

using namespace std;

using ll=long long;
using ld=long double;

int n,m;
vector<vector<int>> gr;
vector<int> dp;

int solve(int r)
{
    if(dp[r]>=0)
        return dp[r];
    int res=0;
    for(auto &i:gr[r])
        res=max(res,solve(i)+1);
    return dp[r]=res;
}

int main()
{
    scanf("%d%d",&n,&m);
    gr.assign(n,{});
    dp.assign(n,-1);
    while(m--)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        gr[b-1].push_back(a-1);
    }
    int res=0;
    for(int i=0;i<n;++i)
        res=max(res,solve(i));
    printf("%d\n",res);
}



Measured memory_bytes: 9344
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
vi G[MAX_N];
bool used[MAX_N];
int bi[MAX_N];
int cnt[MAX_N];

bool loop(int v, int k) {
	used[v] = true;
	bi[v] = k;
	bool ok = true;
	rep(i, 0, sz(G[v])) {
		int n = G[v][i];
		if(!used[n]) {
			if(!loop(n, 1 - k)) {
				ok = false;
			}
		}
		else {
			if(bi[v] == bi[n]) ok = false;
		}
	}
	return ok;
}

void solve() {
	cin >> N >> M;
	rep(i, 0, M) {
		int a, b;
		cin >> a >> b; a--; b--;
		G[a].pb(b); G[b].pb(a);
		cnt[a]++; cnt[b]++;
	}
	ll even = 0, odd = 0, single = 0;
	rep(i, 0, N) {
		if(cnt[i] == 0) {
			single++;
		}
		else {
			if(!used[i]) {
				if(loop(i, 0)) {
					even++;
				}
				else odd++;
			}
		}
	}
	// debug(even, odd, single);
	cout << odd * odd + 2 * even * odd + 2 * even * even + 2 * N * single - single * single << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 14720
#include<bits/stdc++.h>
# define ll long long int
#define mod 1000000007
using namespace std;
int a[100005];
int dp[100005];
/*int fun(int n){
	if (n==0 || n==1){
		return 0;
	}
	if (n==2){
		t[n]=abs(a[1]-a[0]);
		return abs(a[1]-a[0]);
	}
	else{
		if (t[n]!=-1){
			return t[n];
		}
		t[n]= min(abs(a[n-1]-a[n-2])+fun(n-1),abs(a[n-1]-a[n-3])+fun(n-2));
	}
}*/
int main(){
	int n;
	cin>>n;
	
	for (int i=0;i<n;i++){
		cin>>a[i];
	}
	memset(dp,0,sizeof(dp));
	if (n>=2){
		dp[2]=abs(a[1]-a[0]);
	}
	for (int i=3;i<=n;i++){
		dp[i]=min(abs(a[i-1]-a[i-2])+dp[i-1],abs(a[i-1]-a[i-3])+dp[i-2]);
		
	}
	
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <cmath>

int main(void)
{
    std::string s;
    std::cin >> s;
    int i,j;
    int a[4];
    char op[3];
    int sum;
    
    for (i = 0;i < 4;i++){
        a[i] = s[i] - '0';
    }
    
    for (i = 0;i < 8;i++){
        sum = a[0];
        for (j = 0;j < 3;j++){
            if (i & (1 << j)){
                op[j] = '+';
                sum += a[j+1];
            }
            else {
                op[j] = '-';
                sum -= a[j+1];
            }
        }
        if (sum == 7){
            break;
        }
    }
    
    for (i = 0;i < 3;i++){
        std::cout << a[i] << op[i];
    }
    std::cout << a[3] << "=7" << "\n";
    return 0;
}
    
    


Measured memory_bytes: 256
//////////////////////////// ⛎🎱💲♏☢🤘(NOOB 383)
//////////////////////////// 🇨🇸🇪 48
//////////////////////////// 🇯🇦🇭🇦🇳🇬🇮🇷🇳🇦🇬🇦🇷 🇺🇳🇮🇻🇪🇷🇸🇮🇹🇾((JU))

#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    char ch;
    string a;
    cin>>a;
    if(a[2]==a[3] && a[4]==a[5])
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }


    return 0;

}


Measured memory_bytes: 256
#include <climits>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <iostream>

using namespace std;

#define MODULE 1000000007
#define MP make_pair

template<class T, class U>
inline void chmin(T &t, U f) { if (t > f)t = f; }

template<class T, class U>
inline void chmax(T &t, U f) { if (t < f)t = f; }

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9
const int MAXN = 1001;

//------繰り返し二乗法
LL fastPow(LL x,LL n){ // O(logN)
    LL res=1;
    while(n>0){
        if(n&1)res=res*x;
        x=x*x;
        n>>=1;
    }
    return res;
}

LL res=0;

void sumVector(vector<LL> &nums){
    for (int i = 0; i < nums.size(); ++i) {
        res+=nums.at(i);
    }
}

string s;

void rec(int index,LL num, vector<LL> emittedNums){
    if(index!=s.length()) {
        rec(index + 1, num * 10 + s.at(index) - 48, emittedNums);
        emittedNums.push_back(num);
        rec(index + 1, s.at(index) - 48, emittedNums);
    }else{
        sumVector(emittedNums);
        res+=num;
        return;
    }
}

int main() {
    cin>>s;
    vector<LL> v;
    rec(0,0,v);
    cout<<res/2<<endl;
    return 0;
}

Measured memory_bytes: 256
from heapq import heapify, heappush, heappop

X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
rev = lambda x: -int(x)
R = list(map(int, input().split()))
P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)
red = []
green = []
heapify(red)
heapify(green)

red_sum = 0
for i in range(X):
    red_sum += P[i]
    heappush(red, P[i])

green_sum = 0
for i in range(Y):
    green_sum += Q[i]
    heappush(green, Q[i])

min_p = heappop(red)
min_q = heappop(green)
for i in range(C):
    r = R[i]
    if min_p < min_q:
        if r > min_p:
            heappush(red, r)
            red_sum -= min_p
            red_sum += r
            min_p = heappop(red)
    else:
        if r > min_q:
            heappush(green, r)
            green_sum -= min_q
            green_sum += r
            min_q = heappop(green)
print(green_sum + red_sum)

Measured memory_bytes: 114768
import sys
def t(A,p,r):
 x=A[r][1];i=p-1
 for j in range(p,r):
  if A[j][1]<=x:i+=1;A[i],A[j]=A[j],A[i]
 A[i+1],A[r]=A[r],A[i+1]
 return i+1
def k(A,p,r):
 if p<r:q=t(A,p,r);k(A,p,q-1);k(A,q+1,r)
def s(A):
 for i in range(n-1):
  if A[i][1]==A[i+1][1]and A[i][2]>A[i+1][2]:return'Not s'
 return'S'
def m():
 A=[(e[0],int(e[2:]),i)for i,e in enumerate(sys.stdin)]
 k(A,0,n-1)
 print(s(A)+'table')
 print('\n'.join(f'{a} {b}'for a,b,_ in A))
if'__main__'==__name__: n=int(input());m()


Measured memory_bytes: 26988
public class Main {
  private static void solve() {
    int a = ni();
    int b = ni();
    int c = ni();
    
    if (a == b) {
      System.out.println(c);
    } else if (a == c) {
      System.out.println(b);
    } else {
      System.out.println(a);
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




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

using namespace std;

int n;
vector<int> v;

int binary_search(int x)
{
  int l = 0, r = v.size(), mid;
  while (l < r) {
    mid = (l+r)/2;
    if (v[mid] >= x) {
      l = mid + 1;
    } else {
      r = mid;
    }
  }
  return l;
}
  
int main()
{
  cin >> n;
  
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    int id = binary_search(a);
    if (id == v.size()) {
      v.push_back(a);
    } else {
      v[id] = a;
    }
  }
  
  cout << v.size() << endl;
  return 0;
}

Measured memory_bytes: 892
S = input()

N = len(S)
ans = [0] * N
back = front = 0

for i in range(N - 1):
    if not (S[i] == "R" and S[i + 1] == "L"):
        continue
    for j in range(i + 1, N):
        if S[j] == "L":
            front = j
        else:
            break

    for j in range(back, front + 1):
        ans[i + (i - j) % 2] += 1
    back = front + 1

print(*ans)


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

int main(){
    int N;cin>>N;
    double res = 0;
    for(int i = 0; i < N ; i++){
        double a;cin >> a;
        res += 1/a;
    }
    printf("%.15f\n",1/res);
    
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int k,s,su;
int main(){
    scanf("%d%d",&k,&s);
    for(int i=0;i<=k;i++)
        for(int j=0;j<=k;j++){
            int l=s-i-j;
            if(l>=0&&l<=k)
                su++;
        }
    printf("%d\n",su);
    return 0;
}


Measured memory_bytes: 128
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            pass System Test!
*/

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

typedef long long ll;

template <typename T>
std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
  if (!v.empty()) {
    out << '[';
    std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
    out << "\b\b]";
  }
  return out;
}

vector<ll> goods;

ll dfs(ll n, ll cnt, ll k) {
  if (n == 1) return cnt;
  if (n % 2 == 1) return -1;
  for (int i = k; i < goods.size(); i++) {
    ll v = goods[i];
    if (v > n) break;
    if (n % v == 0) {
      ll d = dfs(n / v, cnt + 1, i);
      if (d > 0) return d;
    }
  }
  return -1;
}

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

  ll N;
  cin >> N;
  if (N == 1) {
    cout << -1 << endl;
    return 0;
  }
  queue<ll> que;
  goods.push_back(2);
  goods.push_back(8);
  que.push(2);
  que.push(8);
  ll a = 10;
  while (!que.empty()) {
    ll p = que.front();
    que.pop();
    if (p > N) break;
    while (a < p) a *= 10;
    goods.push_back(a * 2 + p);
    goods.push_back(a * 8 + p);
    que.push(a * 2 + p);
    que.push(a * 8 + p);
  }
  sort(goods.begin(), goods.end());
  // cerr << goods.size() << endl;

  cout << dfs(N, 0, 0) << endl;
}

Measured memory_bytes: 15256