akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int main(){
	cin>>s1;
	s2=s1;
	reverse(s1.begin(),s1.end());
	for(int i=0;i<s1.length();i++){
		if(s1[i]=='b')s1[i]='d';
		else if(s1[i]=='d')s1[i]='b';
		 if(s1[i]=='p')s1[i]='q';
		else if(s1[i]=='q')s1[i]='p';
	}
	for(int i=0;i<s1.length();i++){
		if(s1[i]!=s2[i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <iostream>
#include <math.h>
using namespace std;


int main(){
    int n,a,b,tmp,sum=0;
    cin >> n >> a >> b;
    for(int i=1;i<=n;i++){
        tmp=0;
        for(int j=0; pow(10,j) <=i; j++ ){
            tmp+= (i/int(pow(10,j)))%10;
        }
        if( a<= tmp & tmp <=b) sum +=i;
    }
    cout << sum <<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>

int main(){
    int n, m;
    std::cin >> n >> m;

    std::vector<std::pair<long long, long long>> order(m);
    std::vector<std::vector<long long>> record(n);
    for(int i = 0; i < m; ++i){
        long long p, y;
        std::cin >> order.at(i).first >> order.at(i).second;
        record.at(order.at(i).first - 1).push_back(order.at(i).second);
    }

    for(int i = 0; i < n; ++i){
        auto start = record.at(i).begin();
        auto end = record.at(i).end();
        std::sort(start, end);
    }

    for(int i = 0; i < m; ++i){
        std::stringstream ss;
        long long val = order.at(i).first;
        ss << std::setw(6) << std::setfill('0') << val;
        auto start = record.at(val - 1).begin();
        long long dist = std::distance(start, std::lower_bound(start, record.at(val - 1).end(), order.at(i).second));
        ss << std::setw(6) << dist + 1;

        std::cout << ss.str() << std::endl;
    }

    return 0;
}

Measured memory_bytes: 8576
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    vector<int> coin = {1, 5, 10, 50, 100, 500};
    int sum = 0;
    for(int i=0; i<6; ++i){
        int a;
        cin >> a;
        sum += a * coin[i];
    }

    if(sum < 1000)
        cout << 0 << endl;
    else
        cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 1192
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var k int
	fmt.Scanf("%d", &k)
	answer := createLunlunNumbers(3234566667, k)
	fmt.Println(answer)
}

func findKthLunlun(k int) int {
	if k < 13 {
		return k
	}
	cache = make(map[string]bool)
	nth := 12
	for i := 21; i <= 3234566667; {
		fmt.Println(i, nth)
		strI := strconv.Itoa(i)
		if isLunlun(strI) {
			nth++
			if nth == k {
				return i
			}
			i++
		} else {
			if len(strI) > 2 {
				skip := 8
				for j := 2; j < len(strI); j++ {
					if !isLunlun(strI[0:j]) {
						base := len(strI) - j
						skip = 7 * pow10(base-1)
						break
					}
				}
				i += skip
			} else {
				i += 8
			}
		}
	}
	return -1
}

var cache map[string]bool

func createLunlunNumbers(max, nth int) int {
	if nth < 10 {
		return nth
	}
	digitMap := make([][]int, 20)
	digitMap[0] = []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	digitIndex := 0
	lastNumber := 0
	for counter := 9; counter < nth && max > lastNumber; {
		for _, v := range digitMap[digitIndex] {
			strV := strconv.Itoa(v)
			lastDigit := int(strV[len(strV)-1]) - 48
			if lastDigit != 0 {
				digitMap[digitIndex+1] = append(digitMap[digitIndex+1], v*10+lastDigit-1)
				counter++
				if counter == nth {
					return v*10 + lastDigit - 1
				}
			}
			digitMap[digitIndex+1] = append(digitMap[digitIndex+1], v*10+lastDigit)
			counter++
			if counter == nth {
				return v*10 + lastDigit
			}
			if lastDigit != 9 {
				digitMap[digitIndex+1] = append(digitMap[digitIndex+1], v*10+lastDigit+1)
				counter++
				if counter == nth {
					return v*10 + lastDigit + 1
				}
			}

			lastNumber = v*10 + lastDigit + 1
		}
		digitIndex++
	}
	return -1
}

func isLunlun(strK string) bool {
	if cache[strK] {
		return true
	}

	prev := rune(strK[0])
	for _, v := range strK {
		if abs(int(prev-v)) <= 1 {
			prev = v
		} else {
			return false
		}
	}
	cache[strK] = true
	return true
}

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

func pow10(n int) int {
	x := 10
	for i := 0; i < n; i++ {
		x *= 10
	}
	return x
}


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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  for (ll i = 0; i < n; i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  vector<vector<ll>> cb(m, vector<ll>(2));
  for (ll i = 0; i < m; i++) cin >> cb.at(i).at(1) >> cb.at(i).at(0);
  sort(cb.begin(), cb.end());
  vector<ll> step(0);
  ll cnt = 0;
  for (ll i = m - 1; i >= 0; i--) {
    for (ll j = 0; j < cb.at(i).at(1); j++) {
      step.push_back(cb.at(i).at(0));
      cnt++;
    }
    if (cnt >= n) break;
  }
  for (ll i = 0; i < n - cnt; i++) step.push_back(0);
  ll sum = 0;
  for (ll i = 0; i < n; i++) sum += max(a.at(i), step.at(i));
  cout << sum << endl;
}

Measured memory_bytes: 8692
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
    t = S()
    if t == 'AC':
        ac += 1
    elif t == 'WA':
        wa += 1
    elif t == 'TLE':
        tle += 1
    elif t == 'RE':
        re += 1
print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))

Measured memory_bytes: 68004
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for ( int i=1; i<=int(n); i++ )  
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef long double LD;
const int INF = 0x3f3f3f3f;

template <class T>  
inline bool RD(T &ret) {  
        char c; int sgn;  
		if (c = getchar(), c == EOF) return 0;  
        while (c != '-' && (c<'0' || c>'9')) c = getchar();  
        sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0');  
        while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');  
        ret *= sgn;  
        return 1;  
}  
template <class T>  
inline void PT(T x) {  
        if (x < 0) putchar('-') ,x = -x;  
        if (x > 9) PT(x / 10);  
        putchar(x % 10 + '0');  
}
typedef pair<LL, LL> pii;

const int N = 1e5 + 100;
char s[N];

int main() {
    scanf("%s", s);
    int ans = 0;
    int l = 0, r = strlen(s) - 1;
    while(l <= r) {
        if(s[l] == s[r]) l ++, r --;
        else {
            if(s[l] != 'x' && s[r] != 'x') return puts("-1"), 0;
            ans ++;
            if(s[l] == 'x') l ++;
            else r --;
        }
    }
    printf("%d\n", ans);
}


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

int main(){
	char str[10000]={'\0'};
	int i,n,j;
	
	scanf("%d\n",&n);
	for(j=0;j<n;j++){
	fgets(str,sizeof(str),stdin);
	for(i=0;i<strlen(str);i++)if(str[i]=='H' && str[i+1]=='o' && str[i+2]=='s' && str[i+3]=='h' && str[i+4]=='i' && str[i+5]=='n' && str[i+6]=='o')str[i+6]='a';
	printf("%s",str);
	
	for(i=0;i<strlen(str);i++)str[i]='\0';
	}
return 0;
}

Measured memory_bytes: 612
def main():
    buf = input()
    buflist = list(buf.split())
    N = int(buflist[0])
    M = int(buflist[1])
    edge = dict()
    for i in range(N):
        edge[i] = [] # zero index
    for i in range(M):
        buf = input()
        buflist = list(buf.split())
        X = int(buflist[0])-1 # zero index
        Y = int(buflist[1])-1 # zero index
        Z = int(buflist[2])
        edge[X].append(Y)
        edge[Y].append(X)
    seen = []
    for i in range(N):
        seen.append(False)
    group_num = 0
    for i in range(N):
        if seen[i]:
            continue
        group_num += 1
        seen[i] = True
        stack = []
        for x in edge[i]:
            stack.append(x)
        while stack:
            current = stack.pop()
            if seen[current]:
                continue
            seen[current] = True
            for x in edge[current]:
                if not seen[x]:
                    stack.append(x)
    print(group_num)

if __name__ == '__main__':
    main()


Measured memory_bytes: 32316
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef vector<pii>vip;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 10000000;
ll divcnt[maxn];
void DivisorCount(){
    for(int i = 1; i<=maxn; i++){
        for(int j  = i; j<=maxn; j+=i){
            divcnt[j]++;
        }
    }
}

int main(){
        _
        DivisorCount();
        ll n; cin >> n;
        ll ans = 0;
        for(ll k  = 1; k<=n; k++){
            ans+=(k*divcnt[k]);
        }
        cout << ans << endl;

return 0;
}



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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    ll h;
    int n;
    cin >> h >> n;
    rep (i, n) {
        int a;
        cin >> a;
        h -= a;
    }
    if (h <= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
const int MAX = 2147483647;
int min(int a, int b) {
	return a < b ? a : b;
}
int getSegTreeSize(int len) {
	if (len == 0)
		return 0;
	int ret, cnt = 0, memo = 1;
	while (memo < len) {
		memo *= 2;
		cnt++;
	}
	ret = 1 << (cnt + 1);
	return ret;
}
class RUQ {
  private:
	int size, length;
	std::vector<int> node;
	RUQ() {}
	int find(int return_index, int index, int left, int right) {
		if (node[index] != -1)
			return node[index];
		if ((left + right) / 2 < return_index)
			return find(return_index, index * 2 + 1, (left + right) / 2 + 1, right);
		return find(return_index, index * 2, left, (left + right) / 2);
	}
	void update(int left, int right, int element, int index, int i_left, int i_right) {
		if (element == node[index])
			return;
		if (left <= i_left && i_right <= right) {
			node[index] = element;
			return;
		}
		if (node[index] != -1) {
			node[index * 2] = node[index];
			node[index * 2 + 1] = node[index];
			node[index] = -1;
		}
		int middle = (i_left + i_right) / 2;
		if (middle >= left)
			update(left, right, element, index * 2, i_left, middle);
		if (middle < right)
			update(left, right, element, index * 2 + 1, middle + 1, i_right);
	}

  public:
	RUQ(int size) {
		this->size = getSegTreeSize(size) / 2;
		this->length = getSegTreeSize(size);
		node.resize(this->length);
		fill(node.begin(), node.end(), MAX);
	}
	void update(int left, int right, int element) {
		update(left, right, element, 1, 1, size);
	}
	int find(int index) {
		return find(index, 1, 1, size);
	}
};
int main() {
	int n, q;
	std::cin >> n >> q;
	RUQ segTree(n);
	for (int i = 0; i < q; i++) {
		int com;
		std::cin >> com;
		if (com == 0) {
			int l, r, e;
			std::cin >> l >> r >> e;
			segTree.update(l + 1, r + 1, e);
		}
		else {
			int index;
			std::cin >> index;
			std::cout << segTree.find(index + 1) << std::endl;
		}
	}
}


Measured memory_bytes: 3900
#[allow(unused_macros)]
macro_rules! input {
    ($x:expr) => {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        $x = buf.trim().parse().unwrap();
    };

    ($x:expr, $($y:expr), +) => {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).ok();
        input_iter!(buf.split_whitespace(), $x, $($y), +);
    };

    ($v:expr; $size:expr) => {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).ok();
        for v in buf.split_whitespace() {
            $v.push(v.parse().unwrap());
        }
    };

    ($v:expr; $h_size:expr, $w_size:expr) => {
        for _ in 0..$h_size {
            let mut part_vec = Vec::new();
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).ok();
            for v in buf.split_whitespace() {
                part_vec.push(v.parse().unwrap());
            }
            $v.push(part_vec);
        }
    };
}

#[allow(unused_macros)]
macro_rules! input_iter {
    ($iter:expr, $x:expr) => {
        $x = $iter.next().unwrap().parse().unwrap();
    };

    ($iter:expr, $x:expr, $($y:expr), +) => {
        let mut iter = $iter;
        $x = iter.next().unwrap().parse().unwrap();
        input_iter!(iter, $($y), *);
    };
}

use std::collections::*;

fn main() {
    let (x, y, a, b, c): (usize, usize, usize, usize, usize);
    input!(x, y, a, b, c);
    let (mut p, mut q, mut r): (Vec<usize>, Vec<usize>, Vec<usize>) = (Vec::new(), Vec::new(), Vec::new());
    input!(p; a);
    input!(q; b);
    input!(r; c);
    p.sort_by(|a, b| b.cmp(a));
    p = p[..x].to_vec();
    q.sort_by(|a, b| b.cmp(a));
    q = q[..y].to_vec();
    r = [r, p, q].concat();
    r.sort_by(|a, b| b.cmp(a));
    let mut ans = 0;
    for (i, rr) in r.iter().enumerate() {
        if i >= x + y {
            break;
        }
        ans += *rr;
    }
    println!("{}", ans);
}


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

using namespace std;

int n, f, t;
vector<vector<int> > adjList;
vector<int>vals;
int res[10005];

void BFS()
{
    queue<pair<int, int> >q;
    int curN, par;
    int curIndex = n - 1;
    q.push(make_pair(0, -1));
    while(!q.empty())
    {
        curN = q.front().first;
        par = q.front().second;
        q.pop();
        res[curN] = vals[curIndex];
        curIndex--;
        for(int i = 0; i < adjList[curN].size(); i++)
        {
            if(adjList[curN][i] != par)
            {
                q.push(make_pair(adjList[curN][i],curN ));
            }
        }
    }
}

int main()
{
   while(cin >> n)
   {
       adjList.clear();
       vals.clear();
       adjList.resize(n);
       vals.resize(n);
       for(int i = 0; i < n - 1; i++)
       {
           cin >> f >> t;
           f--, t--;
           adjList[f].push_back(t);
           adjList[t].push_back(f);
       }
       for(int i = 0; i < n; i++)
        cin >> vals[i];
       sort(vals.begin(), vals.end());
       long long sum = 0;
       for(int i = 0; i < n - 1; i++)
        sum += vals[i];
       BFS();
       cout << sum << endl;
       for(int i = 0; i < n; i++)
       {
           if(i)
            cout << ' ';
           cout << res[i];
       }
       cout << endl;
   }

    return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<int> time(n);
    for (int i = 0; i < n; i++){
        cin>>time.at(i);
    }
    
    int m;
    cin>>m;
    for (int i = 0; i < m; i++){
        vector<int> itime(n);
        itime=time;
        int p,x;
        cin>>p>>x;
        itime.at(p-1)=x;
        int sum=0;
        for (int j = 0; j < n; j++){
            sum+=itime.at(j);
        }
        cout<<sum<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifdef LOCAL
#define dbg(...) {cerr << "> "; ZZ(#__VA_ARGS__,__VA_ARGS__);}
template <typename Arg1> void ZZ(const char* val1, Arg1&& arg1) { cerr << val1 << ": " << arg1 << endl; }
template <typename Arg1, typename... Args> void ZZ(const char* vals, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(vals + 1, ',');
    std::cerr.write(vals, comma - vals) << ": " << arg1<<" , ";
    ZZ(comma+1, args...);
}
#else
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int n;
    cin >> n;
    int l = log(n)/log(2);
    cout << (int)pow(2, l+1) - 1 << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;

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

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ll A, B;
    string ans;

    cin >> A >> B;

    if(A == 1) A = 14;
    if(B == 1) B = 14;

    if(A > B)
        ans = "Alice";
    else if(A < B)
        ans = "Bob";
    else
        ans = "Draw";

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            var seg = new [] { 63, 6, 91, 79, 102, 109, 125, 39, 127, 111 };
            for(int count; (count = int.Parse(Console.ReadLine())) != -1;) {
                var prev = 0;
                while(count-- > 0) {
                    int val = int.Parse(Console.ReadLine());
                    Console.WriteLine(Convert.ToString(prev ^ seg[val], 2).PadLeft(7, '0'));
                    prev = seg[val];
                }
            }
        }
    }
}

Measured memory_bytes: 5448
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	    
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int count = 0;
		
		for(int i = a; i <=b; i++){
			if (c % i == 0){
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 17360
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;

int N;
string S;

int main() {
    cin >> S;
  	N = S.length();
    stack<int> last;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (last.empty()) {
            last.push(i);
            continue;
        }
        int l = last.top();
        if (S[l] != S[i]) {
            last.pop();
            ans += 2;
        } else {
            last.push(i);
        }
    }
    cout << ans << endl;
}




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

int main(){
    int N,W;
    cin >> N >>W;
    vector<int> v(N+1),w(N+1);
    for(int i=1;i<=N;i++) cin >> v[i] >> w[i];

    int dp[110][10010] = {};

    for(int i=1;i<=N;i++){
        for(int wei = 0;wei <= W; wei++){
            dp[i][wei] = max(dp[i][wei], dp[i-1][wei]);
            if(wei - w[i] < 0) continue;
            dp[i][wei] = max(dp[i][wei-w[i]]+v[i], dp[i-1][wei]);
        }
    }

    cout << dp[N][W] << endl;
}



Measured memory_bytes: 7408
import math
a, b, x = map(int,input().split())
#水筒に入る水の体積V
V = (a**2) * b
#平面に落とし込むと
S = x / a
#Sが三角形になる場合と台形になる場合に分ける
#三角形になる場合
if S == (a * b):
    ans = 0.0
    print(ans)

elif S < (a*b/2):
    #三角形の高さa_dashを求める
    a_dash = S * 2 / b
    f = a_dash / b
    ans = math.degrees(math.atan(f))
    print(90.0 - ans)
#台形になる場合
else:
    #台形の上辺buの長さを求める
    bu =  (S*2)/a - b
    b_dash = b - bu
    #台形から三角形を切り抜く
    S_dash = S - (a*bu)
    f = a / b_dash
    ans = math.degrees(math.atan(f))
    print(90.0-ans)

Measured memory_bytes: 3188
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Linq.Enumerable;
using static System.Math;

class Program
{
    static void Main()
    {
        var ABC = ReadLine().Split(' ').Select(int.Parse).ToArray();

        var (s, m, l) = ABC.OrderBy(x => x).ToArray();

        var ans = 0;

        ans += l - m;
        s += l - m;
        m = l;
        ans += (m - s + 1) / 2;
        s = (m - s) % 2 == 0 ? m : m + 1;
        ans += s - m;

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 28384
#include <iostream>
#include <string>
#include <vector>
typedef unsigned int UINT;
using namespace std;

int add(int& a, int & b)
{
    return a + b;
}
int sub(int&a, int&b) {
    return a - b;
}

int main(void) {
    int A, B;
    string op;
    cin >> A >> op>> B;
    int (*f)(int&, int&);
    if (op == "+")
        f = add;
    else
        f = sub;
    
    cout << f(A, B) << endl;
    return 0;

}

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

int main() {
	int N, L, i = 1, sum = 0;
	cin >> N >> L;
	while (i<=N)
	{
		sum += L + i - 1;
		i++;
	}

	if (L<0 && -L>N - 1)cout << sum - (L + N - 1);
	else if (L < 0 && -L <= N - 1)cout << sum;
	else cout << sum - L;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n; cin >> n;
    int ans = 0;

    while(ans < n){
        ans += 111;
    }

    if(ans == 1110) ans++;

    dunk(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type& a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	int a,b;
	cin>>a>>b;
	
	int now=1;
	int cnt=0;
	while(now<b){
		cnt++;
		now=now-1+a;
	}
	
	cout<<cnt<<endl;
	return 0;
}

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

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

 typedef long long ll;
 const long long INF = 1LL << 60;



 int main()
 {
    int n, m;
    cin >> n >> m;

    vector<int> a(n);

    for(int i = 0; i<m; i++)
    {
        int k;
        cin >> k;
       for(int j = 0; j < k; j++)
       {
           int s;
           cin >> s; 
           s--;
           a[s] |= 1<<i;
       }
    }

    int p = 0;
    for(int i = 0; i < m; i++)
    {
        int y;
        cin >> y;
        p |= y<<i;
    }

    int ans = 0;

    for(int i = 0; i < (1<<n); i++)
    {
        int y = 0;
        for(int j = 0; j < n; j++)
        {
            if(i&(1<<j)){
                y ^= a[j];
            }
        }
        if(p == y) ans++;
    }
     
    cout << ans << endl;


    return 0;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ar array
#define db double
#define pi 3.14159265358979323846
#define pow pw
int pw(int a,int b){
    int ans=1;
    while(b){
    if (b%2) ans*=a;
    a*=a;
    b/=2;
    }
    return(ans);
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<int> sieve(n+1);
    for (int i=2;i<=sqrt(n);i++)
    if (sieve[i]==0) 
    for (int j=i*i;j<=n;j+=i) sieve[j]=i;
    int ans=0;
    for (int i=1;i<=n;i++)
    {
        int j=i,res=1;
        while(sieve[j])
        {
            int d=sieve[j],c=0;
            while(j%d==0)
            {
                c++;
                j/=d;
            }
            res*=(c+1);
        }
        if (j>1) res*=2;
        ans+=i*res;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 81352
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define inputv(arr,n) for(ll i=0;i<n;i++){ll value;cin>>value;arr.pb(value);}
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define gcd __gcd
#define nl cout<<"\n"
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
//sort in reverse order
bool compare(ll x, ll y){
    return x>y;
}
void solve()
{
  ll n;
  cin>>n;
  map<string,ll>count;
  string s;
  for (ll i = 0; i < n; i++)
  {
      cin>>s;
      count[s]++;
  }
  cout<<count.size()<<endl;
  
}
int main()
{
    IOS;
    int T=1;
   // cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 19408
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) {rep(i,x.size()) cout << x[i] << " "; cout << endl;}
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 2e5;

const double eps = 1e-10;

int main() {
    int N; cin >> N;
    for (int h = 1; h <= 3500; h++) {
        for (int n = 1; n <= 3500; n++) {
            double a = (double)N*h*n;
            double b = (double)4*h*n-N*n-N*h;
            double w = a/b;
            if (w < 1 || w > 3500) continue;
            int tmp = int(w+eps);
            if (abs(w-tmp) < eps) {
                cout << h << " " << n << " " << tmp << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3596
import java.io.IOException;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {

		Scanner scane = new Scanner(System.in);

		double n = scane.nextDouble();

		double[] nums = new double[1000];

		double totala = 0;

		double average = 0;

		double bunsan = 0;

		StringBuilder builder = new StringBuilder();

		while (n != 0) {

			for (int i = 0; i < n; i++) {
				nums[i] = scane.nextDouble();
				totala += nums[i];
			}

			average = totala / n;
			for (int i = 0; i < n; i++) {

				bunsan += Math.pow((nums[i] - average), 2);
			}

			builder.append(Math.sqrt(bunsan / n) + "\n");

			n = scane.nextDouble();

			totala = 0;
			bunsan = 0;

		}

		System.out.print(builder.toString());

	}

}

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

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    string w;
    cin >> w;
    vector<int> abc('z' + 1);

    rep(i, w.size()) {
        abc[w[i]]++;
    }

    for (int i = 'a'; i < 'z' + 1; i++) {
        if (abc[i] % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

int main()
{
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	int now = 0;
	for(auto i:s)
	{
		if(i=='I')now++;
		else now --;
		ans = max(ans,now);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  ll n;
  cin>>n;
  for(int h=1;h<=3500;h++)for(int w=1;w<=3500;w++){
    ll tmp=4*h*w-n*w-n*h;
    if(tmp>0 && (n*h*w)%tmp==0){
      cout<<h<<" "<<(n*h*w)/tmp<<" "<<w<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n, x, t;
  cin >> n >> x >> t;

  int ans = (n + x - 1) / x;

  cout << ans * t << endl;  

  return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <stdlib.h>
#define N 3
#define N1 4
#define N2 9
#define N3 100
int puz[N][N];
int tmp[N][N];
int dx[N1]={0,1,0,-1};
int dy[N1]={1,0,-1,0};
void empty(int x[],int y[]) {
  int i,j;
  for(i=0;i<N;i++) {
    for(j=0;j<N;j++) {
      if(!puz[i][j]) {
        *x = j;
        *y = i;
        return;
      }
    }
  }
}
void swap(int a[],int b[]){
  int tmp;
  tmp=*a;
  *a=*b;
  *b=tmp;
}
int cal(){
  int i,a,sum=0;
  for(i=0; i<N2; i++){
    a = puz[i/N][i%N];
    if(a){
      a--;
      sum+=abs((i/N)-(a/N))+abs((i%N)-(a%N));
    }
  }
  return sum;
}
int dfs(int x,int y,int p,int dep,const int lim){
  int i,h,nx,ny,res;
  h=cal();
  if(h==0) return dep;
  if(dep+h>lim) return -1;
  for(i=0;i<N1;i++){
    nx=x+dx[i];
    ny=y+dy[i];
    if(~p && i==(p+2)%N2) continue;
    if(!(0<=nx && nx<N && 0<=ny && ny<N)) continue;
    swap(&puz[y][x],&puz[ny][nx]);
    res = dfs(nx,ny,i,dep+1,lim);
    if(~res) return res;
    swap(&puz[y][x],&puz[ny][nx]);
  }
  return -1;
}
int main() {
  int i,j,ans,x,y,l;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++) scanf("%d",&puz[i][j]);
  }
  empty(&x,&y);
  for(l=0;l<N3;l++){
    for(i=0;i<N;i++){
      for(j=0;j<N;j++) tmp[i][j] = puz[i][j];
    }
    ans=dfs(x,y,-1,0,l);
    if(ans!=-1){
      printf("%d\n",ans);
      break;
    }
    for(i=0;i<N;i++){
      for(j=0;j<N;j++) puz[i][j] = tmp[i][j];
    }
    ans = -1;
    if(l==N3-1) printf("%d\n",ans);
  }
  return 0;
}



Measured memory_bytes: 2088
// AOJ 2348: Testing Circuits
// 2017.12.15 bal4u@uu

#include <stdio.h>
#include <ctype.h>

#define M  1000000007
#define BASE 100
#define X	 0
#define LP	 20		// (
#define RP   20		// )
#define NOT  10		// ~
#define AND  2		// &
#define OR   1		// |

typedef struct { char s; int a, t; } T;
T stack[1000002]; int top;
char  buf[1000005], *p;

int main()
{
	long long a, t;

	fgets(buf, sizeof(buf), stdin);
	top = 0, stack[top++].s = BASE;
	a = t = 1;
	for (p = buf; ; p++) {
		if      (*p == '(') stack[top++].s = LP;
		else if (*p == '&') stack[top++].s = AND;
		else if (*p == '|') stack[top++].s = OR;
		else if (*p == '~') stack[top++].s = NOT;
		else if (*p == 'x') {
			p++; while (*p >= '0' && *p <= '9') p++; p--;
			a = 2, t = 1;
			while (1) {
				while (stack[top-1].s == NOT) top--;
				if (stack[top-1].s != AND) {
					stack[top].s = X, stack[top].a = (int)a, stack[top++].t = (int)t;
					break;
				}
				top-=2;
				t = (t * stack[top].t) % M; 
				a = (a * stack[top].a) % M;
			}
		} else if (*p == ')' || *p < ' ') {
			a = 0, t = 0;
			while (1) {
				if (*p < ' ' && stack[top-1].s == BASE) goto done;
				if (stack[top-1].s == LP) {
					top--;
					while (1) {
						if (*p < ' ' && stack[top-1].s == BASE) goto done;
						while (stack[top-1].s == NOT) {
							top--;
							t = a - t;
							if (t < 0) t += M;
						}
						if (stack[top-1].s != AND) {
							stack[top].s = X, stack[top].a = (int)a, stack[top++].t = (int)t;
							goto next;
						}
						top -= 2;
						if (!a) a = t = 1;
						t = (t * stack[top].t) % M;
						a = (a * stack[top].a) % M;
					}
				}
				if (stack[top-1].s == X) {
					top--;
					if (!a) a = t = 1;
					t = (t * stack[top].t) % M;
					a = (a * stack[top].a) % M;
				}
				if (stack[top-1].s == OR) {
					long long a2, t2, aa, tt;
					top -= 2;
					t2 = stack[top].t; 
					a2 = stack[top].a;
					aa = (a*a2) % M;
					tt = (aa - (a-t)*(a2-t2)) % M; if (tt < 0) tt += M;
					a = aa,	t = tt;
				}
			}
		}
next:;
	}
done:
	printf("%lld\n", t);
	return 0;
}

Measured memory_bytes: 8620
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int hoge(vector<int> vec) {
	int ret = 12;
	int n = vec.size();
	for (int i = 0; i < n; ++i) {
	   for (int j = i + 1; j < n; ++j) {
		   int diff = abs(vec[i] - vec[j]);
		   ret = min({ ret, diff, 24 - diff });
	   }
	}
	return ret;
}

int main() {
	int N;
	cin >> N;
	vector<int> D(N);
	for (int i = 0; i < N; ++i) { cin >> D[i]; }

	vector<int> cnt(13, 0);
	for (int i = 0; i < N; ++i) { ++cnt[D[i]]; }
	if (cnt[0] > 0 || cnt[12] > 1 || *max_element(cnt.begin(), cnt.end()) > 2) {
		cout << 0 << endl;
		return 0;
	}

	vector<int> d1, d2;
	for (int i = 1; i < 12; ++i) {
		if (cnt[i] == 2) {
			d1.push_back(i);
			d1.push_back(24 - i);
		}
		if (cnt[i] == 1) { d2.push_back(i); }
	}
	d1.push_back(0);
	if (cnt[12] == 1) { d1.push_back(12); }
	int m = d2.size();

	int ans = 0;
	for (int i = 0; i < (1<<m); ++i) {
		vector<int> vec(d1);
		for (int j = 0; j < m; ++j) {
			if ((i>>j) & 1) { vec.push_back(d2[j]); }
			else { vec.push_back(24 - d2[j]); }
		}
		ans = max(ans, hoge(vec));
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
// Author : Mohamed sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
int main()
{
	 int d, t, s;
	 cin >> d >> t >> s;
	 if (t * s >= d)
	 {
		 cout <<"Yes\n"; 
	 }else 
	 cout <<"No\n";
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tii;
#define rep(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

int main(){
  int N; cin >> N;
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  sort(A,A+N);
  int ans = 0;
  for(int i=0;i<N-2;i++){
    for(int j=i+1;j<N-1;j++){
      int num = A[i]+A[j];
      int x = N;
      if(A[N-1]>=num){
        x = lower_bound(A,A+N,num)-A;
      }  
      ans += x-j-1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::pair;
using std::swap;
using std::sort;
using std::lower_bound;
using std::unique;

using int64 = long long int;
using pii   = pair<int, int>;
using pii64 = pair<int64, int64>;

const int NIL = -1;

void init_IO() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}

void solve() {
	string s;
	int64 k;
	cin >> s >> k;

	int equ = 1;

	int64 answ = 0;
	int n = len(s);
	int fl = 0;

	for(int i = 1; i < n; ++i) {
		if(s[i] != s[0]) {
			equ = 0;
			break;
		}
	}

	if(equ) {
		cout << (n * 1LL * k) / 2 << '\n';
		return;
	}

	string between;

	for(int i = 0; i < n;) {
		int j = i;

		while(j + 1 < n && s[j + 1] == s[i])
			++j;

		if(i != 0 && j != n - 1)
			answ += k * 1LL * ((j - i + 1) / 2);
		else
			answ += ((j - i + 1) / 2);

		if(i == 0) {
			for(int k = i; k <= j; ++k) 
				between.push_back(s[k]);
		} 

		if(j == n - 1) {
			for(int k = i; k <= j; ++k)
				between.push_back(s[k]);
		}

		i = j + 1;
	}

	int m = len(between);

	for(int i = 0; i < m;) {
		int j = i;

		while(j + 1 < m && between[j + 1] == between[i])
			++j;

		answ += (k - 1) * 1LL * ((j - i + 1) / 2);
		i = j + 1;
	}

	cout << answ << '\n';
}

int main() {
	init_IO();
	solve();

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat
const int inf = INT_MAX;

int main(int argc, char const *argv[])
{
	sync;
	ll n, m, x, tp;
	cin >> n >> m >> x;
	pair<ll, vector<ll> > book[n];
	rep(i, n)
	{
		cin >> book[i].first;
		rep(j, m)
		{
			cin >> tp;
			book[i].second.pb(tp);
		}
	}
	ll fans = inf, ans = inf;
	ll val[m];
	for (ll i = 0; i < (1<<n); i++)
	{
		ans = 0;
		memset(val,0,sizeof(val));
		for (ll j = 0; j < n; j++)
		{
			if (i&(1<<j))
			{
				ans += book[j].first;
				rep(k, m)
				{
					val[k] += book[j].second[k];
				}
			}
		}
		bool flag = true;
		rep(k, m) 
		{
			if (val[k]<x)
			{
				flag = false;
			}
		}
		if(flag)
		{
			fans = min(ans, fans);
		}
		
	}
	if (fans == inf){
		 cout << -1 << endl;
	}
	else {
		cout << fans << endl;
	}
	return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
//Run with 'Ctrl + Alt + N'


int main(void){


    int X,Y,i,sw = 0;
    int t_asi,k_asi,t,k;

    scanf("%d %d",&X,&Y);



    for(i=0; i<=X; i++){
       k_asi = i*4;
       t_asi =  (X-i)*2;

        //printf("%d\n",i);
       if (k_asi+t_asi == Y){

           printf("Yes");
           sw = 1;
           break;
       }
    }

    if(sw == 0) printf("No");



    return (0);
}

Measured memory_bytes: 1736
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;
namespace lib
{
	template<class T>constexpr T pow(T val, std::uint64_t p)
	{
		auto ret = T(1);
		for (auto i : boost::irange(0, 63))
		{
			if (p & (1ULL << i))
			{
				ret *= val;
			}
			val *= val;
		}
		return ret;
	}
	template<std::uint64_t Mod>class modnum :
		private boost::addable<modnum<Mod>>,
		private boost::subtractable<modnum<Mod>>,
		private boost::multipliable<modnum<Mod>>,
		private boost::dividable<modnum<Mod>>
	{
		std::uint64_t val;
		void clamp()
		{
			val %= Mod;
		}
	public:
		modnum() = default;
		modnum(std::int64_t v) :val()
		{
			if (v < 0)
			{
				v += (std::abs(v) / Mod + 1) * Mod;
			}
			val = v;
			clamp();
		}
		modnum(std::uint64_t v) :val(v)
		{
			clamp();
		}
		modnum(std::int32_t v) :modnum(static_cast<std::int64_t>(v))
		{

		}
		modnum(std::uint32_t v) :modnum(static_cast<std::uint64_t>(v))
		{

		}
		friend std::ostream& operator<<(std::ostream& os, modnum const& num)
		{
			return os << num.val;
		}
		auto& operator+=(modnum const& rhs)
		{
			val += rhs.val;
			clamp();
			return *this;
		}
		auto& operator-=(modnum const& rhs)
		{
			val += Mod - rhs.val;
			clamp();
			return *this;
		}
		auto& operator*=(modnum const& rhs)
		{
			val *= rhs.val;
			clamp();
			return *this;
		}
		auto& operator/=(modnum const& rhs)
		{
			val *= pow(rhs, Mod - 2).val;
			clamp();
			return *this;
		}
		auto const& operator*()const
		{
			return val;
		}
	};
}
using mod_t = lib::modnum<1000000007>;

void Main()
{
	std::size_t N, M;
	std::cin >> N >> M;
	std::vector<int> S(N), T(M);
	for (auto& v : S)
	{
		std::cin >> v;
	}
	for (auto& v : T)
	{
		std::cin >> v;
	}
	boost::multi_array<mod_t, 2> dp(boost::extents[N + 1][M + 1]);
	for (auto i : boost::irange<index_t>(0, N + 1))
	{
		dp[i][0] = 1;
	}
	for (auto j : boost::irange<index_t>(0, M + 1))
	{
		dp[0][j] = 1;
	}
	for (auto i : boost::irange<index_t>(0, N))
	{
		for (auto j : boost::irange<index_t>(0, M))
		{
			dp[i + 1][j + 1] = dp[i + 1][j] + dp[i][j + 1];
			if (S[i] != T[j])
			{
				dp[i + 1][j + 1] -= dp[i][j];
			}
		}
	}
	std::cout << dp[N][M] << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  vector<int> l(n);
  for(auto&& e:l)
  {
    cin>>e;
  }
  sort(l.begin(), l.end());
  int64_t ans = 0;
  for (int i = n-1; i >= 0; --i)
  {
    for (int j = i-1; j >= 0; --j)
    {
      auto itr = upper_bound(l.begin(), l.end(),l[i]-l[j]);
      int k = l.end()-itr;
      ans += max(0,k-(n-j));
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define NIL -1

int n;
int T[252];
void print(){
    for(int i=1;i<n+1;i++){
        cout<<"node "<<i<<": ";
        cout<<"key = "<<T[i]<<", ";
        if(i/2>=1)
            cout<<"parent key = "<<T[i/2]<<", ";
        if(2*i<=n)
            cout<<"left key = "<<T[2*i]<<", ";
        if(2*i+1<=n)
            cout<<"right key = "<<T[2*i+1]<<", ";
        cout<<endl;
    }
}
int main()
{
    for(int i=0;i<252;i++){
        T[i] = NIL;
    }
    cin>>n;
    int key;
    for(int i=1;i<n+1;i++){
        cin>>key;
        T[i] = key;

    }
    print();
    return 0;
}



Measured memory_bytes: 3064