akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    map<string, int> word_count;
    ll m;
    cin >> m;
    REP(i, m) {
        string word;
        cin >> word;
        word_count[word]++;
    }
    ll n;
    cin >> n;
    REP(i, n) {
        string word;
        cin >> word;
        word_count[word]--;
    }

    set<pair<string, int>, function<bool(pair<string, int>, pair<string, int>)>> setOfWords(ALL(word_count), [](pair<string, int> elem1, pair<string, int> elem2) {
        return elem1.second > elem2.second;
    });
    ll max_value = (*setOfWords.begin()).second;
    if (max_value < 0) max_value = 0;
    cout << max_value << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        string[] ab = Console.ReadLine().Split(' ');
        int a = int.Parse(ab[0]);
        int b = int.Parse(ab[1]);
        
        int d = a / b;
        int r = a % b;
        double f = (double)a / (double)b;

        Console.WriteLine("{0} {1} {2:f5}", d, r, f); 
    }
}

Measured memory_bytes: 9168
package main

import (
	"fmt"
	"os"
)

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

func main() {
	var a, b, num, k int
	fmt.Scan(&a, &b, &k)
	lim := min(a, b)
	for i := lim; i >= 1; i-- {
		if a%i == 0 && b%i == 0 {
			num++
			if num == k {
				fmt.Println(i)
				os.Exit(0)
			}
		}
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=998244353;
const ll inf=1e16;
const ll ms=(2e5) +5;


int ar[ms];



int main()
{
    idfc;


    int k;
    int n;
    cin>>k>>n;
    int i;

    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
    }
    int ans=ar[n]-ar[1];

    int pp;
    for(i=2;i<=n;i++)
    {
        pp=ar[i]-ar[i-1];
        pp=k-pp;
        ans=min(ans,pp);
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 1024
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn divisions(x: i64) -> std::collections::HashSet<i64> {
    let mut r = std::collections::HashSet::new();
    for y in 1..x+1 {
        if y * y > x { break }
        if x % y == 0 {
            r.insert(y);
            r.insert(x / y);
        }
    }
    r
}

fn main() {
    let mut sc = Scanner::new();
    let n: i64 = sc.cin();

    let mut ans = 0;

    // n % k == 0
    for &k in divisions(n).iter() {
        if k == 1 { continue }
        let mut n = n;
        while n % k == 0 { n /= k }
        if n % k == 1 {
            ans += 1;
        }
    }

    // n % k != 0 <=> (n - 1) % k == 0
    for &k in divisions(n - 1).iter() {
        if k == 1 { continue }
        if n % k == 1 {
            ans += 1;
        }
    }

    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


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


int main() {
  string s; cin >> s;
  int ans = 0;
  int cnt = 0;
  for(int i = 0;i < s.size();i++){
    if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G'){
      cnt++;
      ans = max(ans,cnt);
    } else cnt = 0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int N; string s; cin>>N>>s;

    int b = 0; int r = 0;
    rep(i,N) {
      if(s[i] == 'R') r++;
      else b++;
    }
    if(r>b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}




Measured memory_bytes: 256
from collections import deque

H, W = [int(i) for i in input().split()]

S = []
white = 0
for _ in range(H):
    s = input()
    white += s.count(".")
    S.append(list(s))

S[0][0] = ""
Q = deque([(0, 0, 1)])
while Q:
    h, w, count = Q.popleft()
    if (h, w) == (H - 1, W - 1):
        print(white - count)
        quit()

    for nh, nw in [(h, w + 1), (h, w - 1), (h + 1, w), (h - 1, w)]:
        if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == ".":
            S[nh][nw] = ""
            Q.append((nh, nw, count + 1))
print(-1)

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    double START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    i32 n; cin >> n;
    vi x(n), y(n);
    rep(i,n) cin >> x[i] >> y[i];

    ld sum = 0;
    vi id(n);
    rep(i,n) id[i] = i;
    do {
        ld tmp = 0;
        for(i32 i = 0; i < n-1; ++i) {
            i32 idx1 = id[i], idx2 = id[i+1];

            tmp += sqrt((x[idx1]-x[idx2]) * (x[idx1]-x[idx2]) + (y[idx1]-y[idx2]) * (y[idx1]-y[idx2]));
        }
        sum += tmp;
    } while(next_permutation(all(id)));

    rep1(i,n) {
        sum /= i;
    }

    cout << sum << '\n';

//     printf("ElapsedTime: %5.3f ms\n",1000*((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3820
local mma, mmi = math.max, math.min
local mfl, mce = math.floor, math.ceil
local function comp(a, b)
  return a < b
end
local function upper_bound(ary, x)
  local num = #ary
  if num == 0 then return 1 end
  if comp(x, ary[1]) then return 1 end
  if not comp(x, ary[num]) then return num + 1 end
  local min, max = 1, num
  while 1 < max - min do
    local mid = mfl((min + max) / 2)
    if not comp(x, ary[mid]) then
      min = mid
    else
      max = mid
    end
  end
  return max
end

local n, W = io.read("*n", "*n")
local v, w = {}, {}
local low_w = true
for i = 1, n do
  w[i], v[i] = io.read("*n", "*n")
end

local function solve_low_w()
  local t = {}
  for i = 1, W do t[i] = 0 end
  for i = 1, n do
    for j = W - w[i], 1, -1 do
      if 0 < t[j] then
        t[j + w[i]] = mma(t[j + w[i]], t[j] + v[i])
      end
    end
    t[w[i]] = mma(t[w[i]], v[i])
  end
  local ret = 0
  for i = 1, W do ret = mma(ret, t[i]) end
  return ret
end

local function solve_low_v()
  local t = {}
  for i = 1, 200000 do t[i] = 0 end
  local v_cursum = 0
  for i = 1, n do
    local vlim = mmi(v_cursum, 200000 - v[i])
    for j = vlim, 1, -1 do
      if 0 < t[j] then
        if t[j + v[i]] == 0 then
          t[j + v[i]] = t[j] + w[i]
        else
          t[j + v[i]] = mmi(t[j + v[i]], t[j] + w[i])
        end
      end
    end
    if t[v[i]] == 0 then
      t[v[i]] = w[i]
    else
      t[v[i]] = mmi(t[v[i]], w[i])
    end
    v_cursum = v_cursum + v[i]
  end
  local ret = 0
  for i = 200000, 1, -1 do
    if 0 < t[i] and t[i] <= W then ret = i break end
  end
  return ret
end
print(solve_low_w())


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
// #ifndef ONLINE_JUDGE
// #include "debug.cpp"
// #endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  string s1,s2; cin >> s1 >> s2;
  cout << s2+s1;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
int main(){
    int n;
    int a[100010];
    cin >> n;
    for(int i = 0; i < 100010; i++){
        a[i] = 0;
    }
    for(int i = 0; i < n; i++){
        int temp;
        cin >> temp;
        //a[i] = temp;
        a[temp]++;
    }
    vector<int> hoge;
    for(int i = 1; i <= 100000;i++){
        if(a[i] > 1){
            for(int j = 0; j < a[i]-1; j++){
                hoge.push_back(i);
            }
        }
    }
    int ans;
    int huga = hoge.size();
    if(huga % 2 == 0){
        ans = n - huga ;
    }
    else{
        ans = n - huga - 1;
    }
    cout << ans << endl;

}

Measured memory_bytes: 4240
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from bisect import bisect_left as bisect
    n,m=map(int,input().split())
    A=list(map(int,input().split()))
    A.sort()
    BC=[tuple(map(int,input().split())) for _ in range(m)]
    BC.sort(lambda x:-x[1])

    now=0
    ans=0
    for b,c in BC:
        i=bisect(A,c)
        if(i<=now): continue
        next=min(i,now+b)
        ans+=c*(next-now)
        now=next
    print(ans+sum(A[now:]))
resolve()

Measured memory_bytes: 72448
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

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

	std::cin >> n >> a >> b;

	if (a == 0) {
		std::cout << 0 << std::endl;
		return 0;
	}

	if (n / (a + b) == 0) {
		std::cout << std::min(n, a) << std::endl;
		return 0;
	}

	std::cout << n / (a + b) * a + std::min(n % (a + b), a) << std::endl;

	return 0;
}

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

int main()
{
	int N;
	cin >> N;
	vector<double> v(N);
	for (int i = 0; i < N; i++)
	{
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	double ans = v[0];
	for (int i = 1; i < v.size(); i++)
	{
		ans = (ans + v[i]) / 2;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){

    int A,B,C,N,M,H,W,K;
    int i,j,k;
    int min = 1000000000;
    int max = 0;
    int a,b,c,d;
    int ans = 0;
    int count=0,count_two=0,v;
    string moji[50];

    cin >> A >> B >> C >> K;

    for(i=K;i>=0;i--){
        for(j=0;j<=K-i;j++){
            a = i;
            b = j;
            c = K - (i + j);
            ans = pow(2,a)*A + pow(2,b)*B + pow(2,c)*C;
            if(ans > max)max = ans;
        }
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	int p[n], s[n];
	for (int i = 0; i < n; i++) {
		int c;
		cin >> c;
		p[i] = c;
		s[i] = c;
	}
	
	sort(s, &s[n]);
	
	int diff = 0;
	for (int i = 0; i < n; i++) {
		if (p[i] != s[i]) diff++;
	}
	
	if (diff <= 2) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
#define dwn(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	string s;
	cin >> s;
	int f = 0;
	if (s == "KIHBR")f = 1;
	if (s == "KIHBRA")f = 1;
	if (s == "KIHBAR")f = 1;
	if (s == "KIHBARA")f = 1;
	if (s == "KIHABR")f = 1;
	if (s == "KIHABRA")f = 1;
	if (s == "KIHABAR")f = 1;
	if (s == "KIHABARA")f = 1;
	if (s == "AKIHBR")f = 1;
	if (s == "AKIHBRA")f = 1;
	if (s == "AKIHBAR")f = 1;
	if (s == "AKIHBARA")f = 1;
	if (s == "AKIHABR")f = 1;
	if (s == "AKIHABRA")f = 1;
	if (s == "AKIHABAR")f = 1;
	if (s == "AKIHABARA")f = 1;
	if (f) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<list>
#define INF 100000000
using namespace std;
int N;
int distA[100000];//先手側からの距離
int distB[100000];
list<int> map[100000];//どのマスとつながっているか
void Asearch(int x,int count);//N番目からの距離を入れる
void Bsearch(int x,int count);
main(){
    scanf("%d",&N);
    for(int i = 0;i < N-1;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        map[a-1].push_back(b-1);
        map[b-1].push_back(a-1);
    }
    for(int i = 0;i < N;i++){
        distA[i] = INF;
        distB[i] = INF;
    }
/*    for(int i = 0;i < N;i++){
        printf("%d:",i+1);
        for(list<int>::iterator itr = map[i].begin();itr!=map[i].end();itr++){
            printf("%d ",*itr+1);
        }
        printf("\n");
    }
*/    
    Asearch(0,0);
    Bsearch(N-1,0);
/*  for(int i = 0;i < N;i++){
        printf("%d%c",distA[i],i==N-1?'\n':' ');
    }
    for(int i = 0;i < N;i++){
        printf("%d%c",distB[i],i==N-1?'\n':' ');
    }
*/
    int Acount = 0;
    int Bcount = 0;
    for(int i = 0;i < N;i++){
        if(distA[i]==INF && distA[i]==distB[i]){continue;}
        if(distA[i]<=distB[i]){
            Acount++;
        }else{
            Bcount++;
        }
    }
    printf("%s\n",Acount>Bcount?"Fennec":"Snuke");
}
void Asearch(int x,int count){
    if(distA[x]!=INF){return;}
    if(x==N-1){return;}
    distA[x] = count;
    for(list<int>::iterator itr = map[x].begin();itr!=map[x].end();itr++){
        Asearch(*itr,count+1);
    }
}
void Bsearch(int x,int count){
    if(distB[x]!=INF){return;}
    if(x==0){return;}
    distB[x] = count;
    for(list<int>::iterator itr = map[x].begin();itr!=map[x].end();itr++){
        Bsearch(*itr,count+1);
    }
}


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

namespace ITP1_6_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] _input = Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray();
            int n = _input[0];
            int m = _input[1];

            List<int[]> arr1 = new List<int[]>();
            List<int> arr2 = new List<int>();

            for(int i = 0; i < n; i++)
                arr1.Add(Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray());

            for(int j = 0; j < m; j++)
                arr2.Add(int.Parse(Console.ReadLine()));

            foreach(int[] arr in arr1)
            {
                int _num = 0;
                for(int k = 0; k < arr.Length; k++)
                    _num += arr[k] * arr2[k];
                Console.WriteLine("{0}", _num);
            }
        }
    }
}

Measured memory_bytes: 9896
// 2013/11/05 Tazoe

#include <iostream>
#include <queue>
using namespace std;

struct state{
	int p[8];
	int t;
};

int main()
{
	while(true){
		int P[8];

		cin >> P[0];

		if(cin.eof())
			break;

		for(int i=1; i<8; i++){
			cin >> P[i];
		}

		if(P[0]==0 && P[1]==1 && P[2]==2 && P[3]==3 && P[4]==4 && P[5]==5 && P[6]==6 && P[7]==7){
			cout << 0 << endl;
			continue;
		}

		struct state s;
		for(int i=0; i<8; i++){
			s.p[i] = P[i];
		}
		s.t = 0;

		queue<struct state> q;
		q.push(s);

		bool memo[8][8][8][8][8][8][8];
		for(int i0=0; i0<8; i0++){
		for(int i1=0; i1<8; i1++){
		for(int i2=0; i2<8; i2++){
		for(int i3=0; i3<8; i3++){
		for(int i4=0; i4<8; i4++){
		for(int i5=0; i5<8; i5++){
		for(int i6=0; i6<8; i6++){
			memo[i0][i1][i2][i3][i4][i5][i6] = false;
		}
		}
		}
		}
		}
		}
		}
		memo[s.p[0]][s.p[1]][s.p[2]][s.p[3]][s.p[4]][s.p[5]][s.p[6]] = true;

		bool flg = true;

		while(true){
			if(q.empty())
				break;

			struct state t = q.front();
			t.t++;

			for(int i=0; i<8; i++){
				if(t.p[i]==0){
					if(0<=i && i<=3){
						t.p[i] = t.p[i+4];
						t.p[i+4] = 0;

						if(t.p[0]==0 && t.p[1]==1 && t.p[2]==2 && t.p[3]==3 && t.p[4]==4 && t.p[5]==5 && t.p[6]==6 && t.p[7]==7){
							cout << t.t << endl;
							flg = false;
							break;
						}

						if(!memo[t.p[0]][t.p[1]][t.p[2]][t.p[3]][t.p[4]][t.p[5]][t.p[6]]){
							q.push(t);
							memo[t.p[0]][t.p[1]][t.p[2]][t.p[3]][t.p[4]][t.p[5]][t.p[6]] = true;
						}

						t.p[i+4] = t.p[i];
						t.p[i] = 0;
					}

					if(4<=i && i<=7){
						t.p[i] = t.p[i-4];
						t.p[i-4] = 0;

						if(t.p[0]==0 && t.p[1]==1 && t.p[2]==2 && t.p[3]==3 && t.p[4]==4 && t.p[5]==5 && t.p[6]==6 && t.p[7]==7){
							cout << t.t << endl;
							flg = false;
							break;
						}

						if(!memo[t.p[0]][t.p[1]][t.p[2]][t.p[3]][t.p[4]][t.p[5]][t.p[6]]){
							q.push(t);
							memo[t.p[0]][t.p[1]][t.p[2]][t.p[3]][t.p[4]][t.p[5]][t.p[6]] = true;
						}

						t.p[i-4] = t.p[i];
						t.p[i] = 0;
					}

					if(i!=0 && i!=4){
						t.p[i] = t.p[i-1];
						t.p[i-1] = 0;

						if(t.p[0]==0 && t.p[1]==1 && t.p[2]==2 && t.p[3]==3 && t.p[4]==4 && t.p[5]==5 && t.p[6]==6 && t.p[7]==7){
							cout << t.t << endl;
							flg = false;
							break;
						}

						if(!memo[t.p[0]][t.p[1]][t.p[2]][t.p[3]][t.p[4]][t.p[5]][t.p[6]]){
							q.push(t);
							memo[t.p[0]][t.p[1]][t.p[2]][t.p[3]][t.p[4]][t.p[5]][t.p[6]] = true;
						}

						t.p[i-1] = t.p[i];
						t.p[i] = 0;
					}

					if(i!=3 && i!=7){
						t.p[i] = t.p[i+1];
						t.p[i+1] = 0;

						if(t.p[0]==0 && t.p[1]==1 && t.p[2]==2 && t.p[3]==3 && t.p[4]==4 && t.p[5]==5 && t.p[6]==6 && t.p[7]==7){
							cout << t.t << endl;
							flg = false;
							break;
						}

						if(!memo[t.p[0]][t.p[1]][t.p[2]][t.p[3]][t.p[4]][t.p[5]][t.p[6]]){
							q.push(t);
							memo[t.p[0]][t.p[1]][t.p[2]][t.p[3]][t.p[4]][t.p[5]][t.p[6]] = true;
						}

						t.p[i+1] = t.p[i];
						t.p[i] = 0;
					}

					break;
				}
			}

			if(!flg)
				break;

			q.pop();
		}
	}

	return 0;
}

Measured memory_bytes: 3348
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)t


int w;
int a,b;

int main()
{
    cin >> w >> a >> b;

    if(a + w < b)
    {
        cout << b - (a + w) << endl;
    }
    else if(b + w < a)
    {
        cout << a - (b + w) << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long int
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(),v.rend() //reverse
#define vl vector<long long>v(n);
#define mii unordered_map<ll,ll>
#define pb push_back
double pi = 2*acos(0.0);
ll power(ll a,ll b){ ll res=1;while(b){if(b&1)res=res*a;b=b/2; a=(a*a); }return res;}



 int main()
 {
       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
       ll tst;
       tst=1;
       //cin>>tst;
    
       while(tst--)
       {
        ull a,b;
        cin>>a>>b;
        cout<<a*b<<endl;
        
       }
 
 }

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

using namespace std;

int max(int num, int size, int arr[]);
int isFound(int num ,int size, int arr[]);

int main(){
    string n , out;
    int  k , var = -8 , d[]={0,1,2,3,4,5,6,7,8,9};
    cin >> n;
    cin >> k;
    int dislike[k], like[10-k] , myarray[n.length()];
    
    for(int i=0; i<k;i++)
        cin>>dislike[i];
        
    sort(dislike, dislike+k); 
    set_difference(d,d+10,dislike,dislike+k ,like); 
    
    for(int i=0;i<n.length();i++){
        myarray[i] = n[i] - '0';
    }   
    
    for(int i=0 ; i<n.length();i++){
        if(isFound(myarray[i], 10-k,like) == 1){
            out += to_string(myarray[i]);
        }else if(max(myarray[i],10-k,like) != -1){
            out += to_string(max(myarray[i],10-k , like));
            var = i ;
            break;
        }else{
            if(i==0 && like[0]!=0){
                out = to_string(like[0]);
                var = -1 ;
                break;
            }else if(i==0 && like[0]==0){
                out = to_string(like[1]);
                var = -1 ;
                break;
            }else{
                myarray[i] = like[0] ;
                myarray[i-1] = myarray[i-1] + 1 ; 
                i-=2;
                if (!out.empty()) {
    		            out.pop_back();
    	        }
            }
        }
    }

    if(var != -8){
      for(int i=0 ;i<(n.length()-(1+var));i++){
        out += to_string(like[0]);
        }  
    }
    
    cout<< out ; 
    return 0;
}

int max(int num, int size, int like[]) {
    int result = -1;
    sort(like, like+size); 

 for(int i=0 ; i<size ; i++){
    if (like[i] > num){
        result = like[i];
        break;
    }
 }
    return result; 
}

int isFound(int num ,int size, int arr[]){
    int found = -1 ;
    for(int i=0; i<size ; i++){
        if(arr[i] == num){
            found = 1 ;
            break;
        }
    }
    return found ;
}




   

Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
	using u64 = std::int_fast64_t;
public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
#pragma endregion

int main() {
	string s;
	cin >> s;
	bool flag = true;
	bool flag2 = false;
	flag &= s[0] == 'A';
	rep(i, s.size() - 3) {
		if (s[i + 2] == 'C') {
			if (flag2) flag = false;
			flag2 = true;
		}
	}
	flag &= flag2;
	flag &= s[1] != 'C';
	int cnt = 0;
	rep(i, s.size()) {
		if ('A' <= s[i] && s[i] <= 'Z') cnt++;
	}
	flag &= cnt == 2;
	cout << (flag ? "AC" : "WA");
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    // Your code here!
    
    int m1,d1,m2,d2;
    bool result = false;
    scanf("%d %d", &m1, &d1);
    scanf("%d %d", &m2, &d2);

    if (m1 == (m2 - 1))
    {
        result = true;
    }
    else
    {
        result = false;
    }
    printf("%d\n",result);

    return 0;
}


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

int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll point = 1 * min(a, k);
    k -= a;
    k -= b;
    if (k <= 0){
        cout << point << endl;
    }
    else cout << point -1 * k << endl;
   return 0;    
}

Measured memory_bytes: 3600
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static ConsoleApp.Util;
using static System.Math;
 
namespace ConsoleApp
{
    class Program
    {
       
        static void Main(string[] args)
        {
            var arr = ReadLine().Split().Select(long.Parse).ToArray();
            long n = arr[0];
            long k = arr[1];
 
            long[] p = ReadLine().Split().Select(long.Parse).ToArray();
 
            long maxExp2 = 0;
            //0-K-1までの期待値の合計を出す
 
            for (long i = 0; i < k;i++)
            {
                maxExp2 += p[i] + 1;
            }
            var sum = maxExp2;
            for (long i = 0; i < n-k;i++)
            {
               
                sum -= p[i] + 1;
                sum += p[i+k] + 1;
                if(sum > maxExp2)
                    maxExp2 = sum;
            }
 
            WriteLine((double)(maxExp2/2.0));
        }
 
        
    }
 
 
    static class Util{
        public static void ChMin(ref long a,long b){
            
            if(a > b){
                a = b;
            }
        }
 
        public static void ChMax(ref long a,long b){
            if(a < b){
                a = b;
            }
        }
 
 
 
		
    }
}

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


int main(){
    int A,B;
    cin >> A >> B;
    int Atax,Btax;
    int ans=1001;
    for(int i=13;i<1001;i++){
        Atax=int(i*0.08);
        Btax=int(i*0.1);
        if(Atax == A && Btax == B ){
            if(ans > i){
                ans = i;
            }
        }
    }
  if(ans != 1001){
  cout << ans;
  }else{
    cout << -1;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std; 
int R,C;
int ** a;
int Max;
int count;
bool flag=true;
void dfs(int r){
  if(r==R){
    count=0;
    for( int j=0; j<C; j++){
      int p=0,q=0;
    for( int i=0; i<R; i++){ 
      if(a[i][j]==1){p++;}
      if(a[i][j]==0){q++;}
      }
      if(p>=q){count+=p;}
      else if(p<q){count+=q;}
      }
      if(count>Max){Max=count;}
  return;
  }
  dfs(r+1);
  for(int i=0; i<C; i++){
    if(a[r][i]==0){
    a[r][i]=1;
    }else if(a[r][i]==1){
    a[r][i]=0;
    }
  }
  dfs(r+1);
  return;
}
int main() {
  while(flag){
    cin>>R>>C;
    if(R==0&&C==0){break;}
    Max=0;
    a = new int*[R];
  for( int i=0; i<R; i++ ) {
    a[i] = new int[C];
  }
  for( int i=0; i<R; i++){
    for( int j=0; j<C; j++){
      cin>>a[i][j];
    }
   }
   dfs(0);
   for( int i=0; i<R; i++ ) {
    delete[] a[i];
    }
   delete[] a;
   cout<<Max<<endl;
   }
}

Measured memory_bytes: 1324
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

ll mod=998244353;
int N;
string X;

ll calc(int num){
    int cyc=N/num;
    string g=X.substr(0, cyc), h;
    ll res=0, now=1;
    for(int i=cyc-1; i>=0; --i){
        if(g[i]=='1') res=(res+now)%mod;
        now=(now*2)%mod;
    }
    if(num==1){
        res=(res+1)%mod;
        return res;
    }
    for(int i=0; i<cyc; ++i){
        if(g[i]=='0') h += '1';
        else h += '0';
    }
    for(int i=1; i<num; ++i){
        string subs=X.substr(i*cyc, cyc);
        if(i%2==1){
            if(h!=subs){
                if(h<subs) res=(res+1)%mod;
                break;
            }
        }else{
            if(g!=subs){
                if(g<subs) res=(res+1)%mod;
                break;
            }
            if(i+1==num) res=(res+1)%mod;
        }
    }
    return res;
}

int main() {
	cin >> N >> X;
	vector<int> odd_div, corr;
	for(int i=1; i<=N; i += 2){
	    if(N%i==0){
	        odd_div.push_back(i);
	        corr.push_back(N/i);
	    }
	}
	vector<ll> benz(odd_div.size(), 0);
	for(int i=odd_div.size()-1; i>=0; --i){
	    benz[i]=calc(odd_div[i]);
	    for(int j=i+1; j<odd_div.size(); ++j){
	        if(odd_div[j]%odd_div[i]==0){
	            benz[i]=(benz[i]+mod-benz[j])%mod;
	        }
	    }
	}
	ll ans=0;
	for(int i=0; i<benz.size(); ++i){
	    ans=(ans+(benz[i]*2*corr[i])%mod)%mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 784
L, R = map(int, input().split())
mod = 2019

if R - L >= mod:
    print(0)
else:
    s = []
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            s.append((i * j) % mod)
    s.sort()
    print(s[0])

Measured memory_bytes: 81392
X = int(input())
if 400 <= X <= 599:
    print(8)
elif 600 <= X <= 799:
    print(7)
elif 800 <= X <= 999:
    print(6)
elif 1000 <= X <= 1199:
    print(5)
elif 1200 <= X <= 1399:
    print(4)
elif 1400 <= X <= 1599:
    print(3)
elif 1600 <= X <= 1799:
    print(2)
elif 1800 <= X <= 1999:
    print(1)


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

int main() {
    int a,b,c,x,y,total=0;
    scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
    if (x*y != 0){
        if (2*c<a+b){
            int minval = min(x,y);
            x-=minval;
            y-=minval;
            total += 2*c * minval;
        }
    }
    if (x!=0){
        if (2*c<a){
            total += 2*c*x;
            x=0;
        }else
            total += a*x;
    }
    if (y!=0){
        if (2*c<b){
            total += 2*c*y;
        }else
            total += b*y;
    }
    printf("%d",total);
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll a[100010];
int main(){
    ll n, m;
    while(cin>>n>>m){
        ll ans=0, sm=0;
        for(int i=0; i<n; ++i){
            scanf("%lld",a+i);
            sm+=a[i];
        }
        sort(a, a+n);
        reverse(a, a+n);
        bool l=1;
        for(ll i=0; i<m; ++i){
        	if(a[i]*4*m<sm){
        		l=0;
        		break;
        	}
        }
        if(l){
        	printf("Yes\n");
        }
        else{
        	printf("No\n");
        }
    }
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int N;
    cin >> N;
    vector<int> P(N);
    vector<int> ind(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
        P[i]--;
        ind[P[i]] = i;
    }
    multiset<int> S;
    S.insert(-1);
    S.insert(-1);
    S.insert(N);
    S.insert(N);
    S.insert(ind[N-1]);

    ll a,b,c,d;
    ll ans = 0;
    for (int i = N-2; i >= 0; i--) {
        S.insert(ind[i]);
        auto itr = S.lower_bound(ind[i]);
        itr--;
        b = *itr;
        itr--;
        a = *itr;
        itr++; itr++; itr++;
        c = *itr;
        itr++;
        d = *itr;

        ans += (b-a) * (c - ind[i]) * (i+1);
        //printf("%lld %d\n", (b-a) * (c - ind[i])+(d-c) * (ind[i] - b) * i, i);
        ans += (d-c) * (ind[i] - b) * (i+1);
    }

    printf("%lld\n", ans);
    


}

Measured memory_bytes: 8672
#include <iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>

using namespace std;

int main(){
    
    string S;
    cin >> S;
    if(S[5]=='1'||S[6]-'4'>0){
        cout << "TBD" << endl;
    }
    else{
        cout << "Heisei" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>

using namespace std;

const int N = 1e5+5;
int n,m;
int fa[N],r[N];

void init()
{
    for(int i=1; i<=n; i++)
    {
        fa[i] = i;
    }
    memset(r,0,sizeof(r));
}

int Find(int x)
{
    if(fa[x]==x) return x;
    int root = Find(fa[x]);
    r[x] += r[fa[x]];
    return fa[x] = root;
}

bool Merge(int x, int y, int d)
{
    int fx = Find(x);
    int fy = Find(y);
    if(fx==fy)
    {
        return d == r[y]-r[x];
    }
    fa[fy] = fx;
    r[fy] = r[x] + d - r[y];
    return 1;
}

int main()
{
    while(scanf("%d%d",&n,&m) != EOF)
    {
        int ok = 1;
        int L,R,D;
        init();
        for(int i=0; i<m; i++)
        {
            scanf("%d%d%d",&L,&R,&D);
            if(ok && !Merge(L,R,D))
            {
                ok = 0;
            }
        }
        if(ok) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


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



int N, M;

vector<int> path[600];
double p[600]; // p[j] = p(0,j)  0からjに到達する確率
double pe[600]; // pe[j] = pe(0,j) = p(0,j) * e(0,j) // 通路数期待値e(0,j)
double re[600]; // re[j] = 通路期待値e(j,N-1)


/*
	A と排他的な部屋 B を仮定する。AかBのどちらかを必ず通る。
	e(0,N-1) = p(0,A)*(e(0,A)+e(A,N-1)) + p(0,B)*(e(0,B)+e(B,N-1))
	         = pe(0,A)+p(0,A)*e(A,N-1) + (定数)
	         
	         pe(0,A) と p(0,A) と e(A,N-1) の変化がEにどう影響するかはこの式で
	
	         pe(0,A) と p(0,A) は全てのAに対して最初に計算する
	         e(A,N-1) 全てのAに対してゴールから逆に計算する 
	
	j から k0, k1, k2 への3本の通路が出ていたとする
	通路 j->k0 を削除すると、e(0,N-1) はどう変化するか?
	  変化するのは pe(0,k) と p(0,k)
	  e(k,N-1) は変化しない
	
	pjk = 1/3
	pjk2 = 1/2
	new_p(0,k0)  = p(0,k0) - p[j]*pjk
	new_pe(0,k0) = pe(0,k0) - pjk*(pe[j]+p[j])
	new_p(0,k1)  = p(0,k1) - pjk*p[j] + pjk2*p[j]
	new_pe(0,k1) = pe(0,k1) - pjk*(pe[j]+p[j]) + pjk2*(pe[j]+p[j])
	
	
*/

int main(){
	cin >> N >> M;
	
	for ( int i = 0; i < M; i++ ){
		int s, t;
		cin >> s >> t;
		s--;
		t--;
		path[s].push_back(t);
	}
	
	
	// 部屋0から開始したときの、部屋kの到達率と通路数の期待値を調べる
	for ( int j = 0; j < N; j++ ){
		p[j] = pe[j] = 0.0;
	}
	p[0] = 1.0;
	pe[0] = 0.0;
	
	for ( int j = 0; j < N-1; j++ ){
		if ( p[j] == 0.0 || path[j].size() == 0 )
			continue;
		
		double pjk = 1.0 / (path[j].size());
		for ( auto k : path[j] ){
			p[k] += p[j]*pjk;
			pe[k] += pjk*(pe[j]+p[j]); // pe[k] += (jkを通ってkに到達する確率)*(jの通路数期待値+1) // == (p[j]*pjk)*(pe[j]/p[j]+1)
		}
	}
	
	// 部屋iから開始したときの、部屋N-1の通路数の期待値を調べる
	re[N-1] = 0.0;
	for ( int i = N-2; i >= 0; i-- ){
		double n = path[i].size();
		double ee = 0.0;
		for ( auto k : path[i] ){
			ee += (re[k]+1.0) / n;
		}
		re[i] = ee;
	}
	
//	for ( int j = 0; j < N; j++ ){
//		cout << j << " : p=" << p[j] << " pe=" << pe[j] << " e=" << (pe[j]/p[j]) << " : re=" << re[j] << endl;
//	}
	
	//
	double min_newE = pe[N-1];
	for ( int j = 0; j < N; j++ ){
		double n = path[j].size();
		for ( auto k : path[j] ){
			// j->kの道を削除するとどうなるか?
			double e_mod = 0.0; // eの変化分
			double newE = 0.0;
			if ( n == 1.0 ){
				// このpathは削除可能でない
				continue;
			}
			else {
				double pjk = 1.0 / n;
				double pjk2 = 1.0 / (n-1.0);
				for ( auto l : path[j] ){
					// p->new_p, pe->new_pe になったときのEの変化は
					// e_mod = - ( pe + p*re ) + (new_pe + new_p*re )
					//       = + (new_pe-pe) + (new_p-p)*re
					if ( l == k ){
						e_mod = e_mod + ( -pjk*(pe[j]+p[j]) ) + ( -pjk*p[j] )*re[l];
					}
					else {
						e_mod = e_mod + ( (pjk2-pjk)*(pe[j]+p[j]) ) + ( (pjk2-pjk)*p[j] )*re[l];
					}
				}
				newE = pe[N-1] + e_mod;
			}
			
			//cout << " path " << j << "-" << k << " newE=" << newE << "  e_mod=" << e_mod << endl;
			min_newE = min( min_newE, newE );
		}
		
	}
	cout << std::setprecision(10) << min_newE << endl;

	
	return 0;
}



Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define sz 100005
#define faster_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;

int main()
{
    faster_io
    int n,x,y;
    cin>>n>>x;
    x = 2*x + 1;
    cout<<ceil((n+.0)/x)<<endl;

    return 0;
}


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

int main() {

  int A = 0;
  int B = 0;
  string op = "a";
  cin >> A >> op >> B;

  if(op == "+"){
    cout << A + B << endl;
  }

  else if(op == "-"){
    cout << A - B << endl;
  }
  
  else{
    cout << "error" << endl;
  }
}


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

int main(){
  int n,l ;
  cin >> n >> l ;
  vector<string> a(n) ;
  for(int i=0;i<n;i++) cin >> a.at(i) ;
  sort(a.begin(),a.end()) ;
  for(auto i:a) cout << i ;
  cout << endl ;
}

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

using namespace std;

int main() {
    int A, P;
    cin >> A >> P;
    cout << (3 * A + P) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
/*
      author  : nishi5451
      created : 14.08.2020 14:52:40
*/

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


int main(){
    string s;
    cin >> s;
    string ans;
    rep(i,int(s.size())){
        if(!(i&1)){
            ans+=s[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
N,W = map(int,input().split())
WV = [tuple(map(int,input().split())) for i in range(N)]

wvs = [[] for i in range(4)]
w0 = WV[0][0]
for w,v in WV:
    wvs[w-w0].append(v)

cumwvs = []
for vs in wvs:
    cums = [0]
    for v in sorted(vs, reverse=True):
        cums.append(cums[-1] + v)
    cumwvs.append(cums)

ans = 0
for i,a in enumerate(cumwvs[0]):
    if i*w0 > W: break
    for j,b in enumerate(cumwvs[1]):
        if i*w0 + j*(w0+1) > W: break
        for k,c in enumerate(cumwvs[2]):
            if i*w0 + j*(w0+1) + k*(w0+2) > W: break
            for l,d in enumerate(cumwvs[3]):
                if i*w0 + j*(w0+1) + k*(w0+2) + l*(w0+3) > W: break
                ans = max(ans, a+b+c+d)
print(ans)

Measured memory_bytes: 3192
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {
    const int R = 3;
    const int NG = INT_MIN / 2;

    int N;
    cin >> N;
    vector<array<int, R>> dp(N + 1);
    rep(i, N + 1)rep(j, R)dp[i][j] = NG;
    rep(j, R)dp[0][j] = 0;

    rep(i, N) {
        rep(j, R) {
            int a;
            cin >> a;
            rep(k, R)if (j != k || i == 0) {
                smax(dp[i + 1][k], dp[i][j] + a);
            }
        }
    }

    int ans = NG;
    rep(j, R)smax(ans, dp[N][j]);
    cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 1408
def selection_sort(array):
    A = array[:]
    count = 0
    for i in range(len(A)):
        mini = i
        for j in range(i, len(A)):
            if int(A[j]) < int(A[mini]):
                mini = j
        if i != mini:
            A[i], A[mini] = A[mini], A[i]
            count += 1

    return A, count

_, array = input(), input().split()

result, count = selection_sort(array)

print(' '.join(result))
print(count)


Measured memory_bytes: 5600
#include<iostream>
using namespace std;
int main(){
	int a[10];
	int b[10];
	int c[10];
	int x[2];
	int y[2];
	int z[2];
	int m[3];
	int ans[10];
	int i=0;
	
	for(i=0;i<6;i++){
		cin>>a[i];
	}
	x[0]=a[0]*3600+a[1]*60+a[2];
	x[1]=a[3]*3600+a[4]*60+a[5];
	m[0]=x[1]-x[0];
	for(i=0;i<6;i++){
		cin>>b[i];
	}
	y[0]=b[0]*3600+b[1]*60+b[2];
	y[1]=b[3]*3600+b[4]*60+b[5];
	m[1]=y[1]-y[0];
	for(i=0;i<6;i++){
		cin>>c[i];
	}
	z[0]=c[0]*3600+c[1]*60+c[2];
	z[1]=c[3]*3600+c[4]*60+c[5];
	m[2]=z[1]-z[0];
	
	ans[0]=m[0]/3600;
	m[0]-=ans[0]*3600;
	ans[1]=m[0]/60;
	ans[2]=m[0]%60;
	
	ans[3]=m[1]/3600;
	m[1]-=ans[3]*3600;
	ans[4]=m[1]/60;
	ans[5]=m[1]%60;
	
	ans[6]=m[2]/3600;
	m[2]-=ans[6]*3600;
	ans[7]=m[2]/60;
	ans[8]=m[2]%60;
	
	cout<<ans[0]<<" "<<ans[1]<<" "<<ans[2]<<endl;
	cout<<ans[3]<<" "<<ans[4]<<" "<<ans[5]<<endl;
	cout<<ans[6]<<" "<<ans[7]<<" "<<ans[8]<<endl;
	
	return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>

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

using namespace std;

int main(){
    string s[]={"mon","tue","wed","thu","fri","sat","sun"};
    int index=3;
    int x; cin>>x;
    rep(i,0,x){
        index++;
        if(index==7)index=0;
    }
    cout<<s[index]<<endl;

    return 0;
}



Measured memory_bytes: 3188
N=int(input())
b=list(map(int,input().split()))
cnt=0
wa=0
while cnt<N-1:
    if cnt==0:
        wa+=b[0]
    
    
    else:
        wa+=min(b[cnt-1:cnt+1])
       
    cnt+=1
print(wa+b[N-2])

Measured memory_bytes: 3060
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();
        long aMinusOne = a - 1;
        System.out.println(count(b, c, d) - count(aMinusOne, c, d));
    }
    public static long count(long num, long c, long d) {
      long lcm = lcm(c, d);
      long count = num / c + num / d - num / lcm;
      return num - count;
    }
    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
}


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

int main(){
  int s;
  cin >> s;
  for (int i = 1; ; i++){
    if (s == 1 || s == 2){
      cout << 4 << endl;
      break;
    }
    if (s & 1) s = s*3+1;
    else s = s/2;
    if (s == 4){
      cout << i+4 << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld double
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pll pair <ll,ll>
#define nl "\n"
 
int main()
{
	ios_base::sync_with_stdio(false);
	ll n,i;
	cin>>n;
	ll h[n+2];
	ll ans[n+2];
	for(i=0;i<n;i++)
		cin>>h[i];
	ans[0]=0;
	ans[1]=abs(h[0]-h[1]);
	for(i=2;i<n;i++)
	{
		ans[i] = min(ans[i-1]+abs(h[i]-h[i-1]), ans[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<ans[n-1]<<nl;
	return 0;
}

Measured memory_bytes: 5164