akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int s_int(string s){
    return atoi(s.c_str());
}
vector<int> v(4,0);
bool ok = 0;
void solve(int now, int cnt, vector<bool> ope){
    if(cnt == 4){
        if(now == 7 && ok == 0){
            rep(i,4){
                if(i < 3){
                    if(ope[i] == 0) cout << v[i] << "+";
                    else cout << v[i] << "-";
                }else cout << v[i] << "=7" << endl;
            }
            ok = 1;
            return ;
        }
    }else{
        vector<bool> ope1,ope2;
        ope1 = ope;
        ope2 = ope;
        ope1.push_back(0);
        ope2.push_back(1);
        solve(now + v[cnt], cnt + 1, ope1);
        solve(now - v[cnt], cnt + 1, ope2);
    }
}
int main(){
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    rep(i,4) v[i] = s_int(s.substr(i,1));
    vector<bool> ope;
    solve(v[0],1, ope);
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#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 MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;

const int MOD = 1e9 + 7;

int fac[200005];
int power(int x, int t)
{
	int ret = 1;
	while(t > 0) {
		if(t & 1) ret = 1LL * ret * x % MOD;
		x = 1LL * x * x % MOD;
		t >>= 1;
	}
	return ret;
}

int C(int n, int m)
{
	if(n < m) return 0;
	return 1LL * fac[n] * power(1LL * fac[m] * fac[n - m] % MOD, MOD - 2) % MOD;
}

void gen_fac()
{
	fac[0] = 1;
	rep1(i, 200000) fac[i] = 1LL * fac[i - 1] * i % MOD;
}

int main()
{
	gen_fac();
	
	int n, a, b, c;
	scanf("%d%d%d%d", &n, &a, &b, &c);
	
	a = 1LL * a * power(100 - c, MOD - 2) % MOD;
	b = 1LL * b * power(100 - c, MOD - 2) % MOD;
	c = 1LL * c * power(100, MOD - 2) % MOD;
	
	int ans = 0;
	for(int i = n; i <= 2 * n - 1; i ++) {
		ans = (ans + 1LL * power(a, n) * power(b, i - n) % MOD * C(i - 1, n - 1) % MOD * i) % MOD;
		ans = (ans + 1LL * power(b, n) * power(a, i - n) % MOD * C(i - 1, n - 1) % MOD * i) % MOD;
	}
	
	ans = 1LL * ans * power(1 - c + MOD, MOD - 2) % MOD;
	printf("%d\n", ans);
	return 0;
}

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

int main() {
	ll n;
	scanf("%lld", &n);
	int k = sqrt(n+0.5);
	int ans = 0;
	for(int i=2; i<=k; i++) {
		if(n%i==0) {
			int cnt = 0;
			while(n%i==0) {
				cnt++;
				n /= i;
			}
			int j;
			for(j=1; j<=cnt; j++) {
				cnt -= j;
			}
			ans += j-1;
		}
	}
	if(n>1)
		ans++;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3816
use std::io;
use std::str::FromStr;
use std::cmp::*;
use std::collections::BinaryHeap;

fn input_tuple() -> (i64, i64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<i64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input_vec() -> Vec<i64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let (n, k) = input_tuple();
    let mut a_vec = input_vec();

    if k * n > 100_000_000 {
        for _ in 0..n {
            print!("{} ", n);
        }
        println!();
        return;
    }
    // let mut a_vec = vec![0; n as usize];
    for _ in 0..k {
        let mut queue: BinaryHeap<i64> = BinaryHeap::new();
        let mut count = 0;
        let mut next = vec![1; n as usize];
        for j in 0..n {
            // println!("j = {}", j);
            // println!("{:?}", queue);
            while !queue.is_empty() {
                if j == -queue.peek().unwrap() {
                    count -= 1;
                    queue.pop();
                } else {
                    break;
                }
            }
            next[j as usize] += count;
            // println!("{}", j+a_vec[j as usize]+1);
            queue.push(-(j+a_vec[j as usize]+1));
            count += 1;
        }

        let mut queue: BinaryHeap<i64> = BinaryHeap::new();
        let mut count = 0;
        for j in (0..n).rev() {
            while !queue.is_empty() {
                if j == *queue.peek().unwrap() {
                    count -= 1;
                    queue.pop();
                } else {
                    break;
                }
            }
            next[j as usize] += count;
            // println!("{}", j-a_vec[j as usize]-1);
            queue.push(j-a_vec[j as usize]-1);
            count += 1;
        }
        a_vec = next;
    }
    for a in a_vec {
        print!("{} ", a);
    }
    println!();
}


Measured memory_bytes: 8108
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>

using namespace std;


/*--- Macro ---*/
#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 mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;


// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

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

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

  // 変形させる個数
  ll k = ((m - 2*n) / 4);
  k = (k > 0 ? k : 0);

  n = n+k;
  m = m-2*k;
 
  cout << min(n, m/2) << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		if(N % 10 == 3)
		System.out.println("bon");

		if(N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9)
		System.out.println("hon");

		if(N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8)
		System.out.println("pon");
	}
}

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

using namespace std;

typedef long long ll;

#define newline cout<<"\n"
#define deb(x) cout<<#x<<" "<<x<<endl;

template<typename... T>
void read(T&... args){
    ((cin>>args), ...);
}

template<typename... T>
void write(T... args){
    ((cout<<args<<" "), ...);
}

void printarr(vector<int> &v){
    for(int x: v){
        cout<<x<<" ";
    }
    newline;
}

const int MOD = 1e9+7;
const int nax = 1e7+7;

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

    int v[m];

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

    sort(v, v+m);

    vector<int> dists;

    for(int i=0; i<m-1; i++){
        dists.push_back(v[i+1]-v[i]);
    }

    sort(dists.begin(), dists.end());

    reverse(dists.begin(), dists.end());

    int ans = 0;

    for(int i=n-1; i<dists.size(); i++){
        ans += dists[i];
    }

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

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

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> correct(N, 0);
  for(int i = 0; i < Q; i++) {
    int a;
    cin >> a;
    correct.at(a - 1)++;
  }
  for(int i = 0; i < N; i++) {
    if(K - Q + correct.at(i) > 0) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

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

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
#define DRT() int t; si(t); while(t--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//# define M_PI           3.14159265358979323846264338327950288
// DSU
void IO(){
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
}

int main(){
	IO();
	LL w,h,x,y;
	cin>>w>>h>>x>>y;
	double area = (w*h)/2.0;
	cout<<area<<" ";
	LL a = w/2;
	LL b = h/2;
	LL r1 = w%2;
	LL r2 = h%2;
	if(!r1 && !r2 && a == x && b == y)
		cout<<1;
	else
		cout<<0;
	return 0;
}

Measured memory_bytes: 3720
#include<iostream>

#define REP(i, a) for(int i=0;i<(int)a;++i)
using namespace std;

void solver() {
    int N;
    cin >> N;
    REP(i, N) {
        int a, b, c;
        cin >> a >> b >> c;
        bool isTri = a * a == b * b + c * c || b * b == a * a + c * c || c * c == a * a + b * b;
        cout<<(isTri?"YES":"NO")<<endl;
    }
}

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

Measured memory_bytes: 2964
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
 template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
using namespace std;

const long long INF=9000000000000000;
int main(){
  int n,s,x=0,ans=0;
  cin>>n;
  string nn[n];
  for(int i=0;i<n;i++){
    cin>>nn[i];
  }
  cin>>s;
  string ss[s];
  string y;
  for(int i=0;i<s;i++){
    cin>>ss[i];
  }
  for(int j=0;j<n;j++){
    for(int i=0;i<n+s;i++){
      if(i==0)
        y=nn[j];
      if(i<n){
        if(y==nn[i])
          x++;
      }
      if(i>=n){
        if(y==ss[i-n])
          x--;
      }
    }
    ans=max(ans,x);
    x=0;
  }
  cout<<ans<<endl;
}

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

const ll MOD = 1e+9+7;
const int INF = 1e+9+7;
int main(){
    int N;
    cin >> N;
    vector<vector<int>> A(N,vector<int>(N,0));
    vector<vector<int>> dp(N,vector<int>(N,INF));
    vector<vector<bool>> bri(N,vector<bool>(N,true));
    rep(i,N){
        rep(j,N){
            cin >> A[i][j];
        }
    }

    rep(i,N){
        rep(j,N){
            dp[i][j]=A[i][j];
        }
    }

    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                if(i==j||i==k||j==k) continue;
                if(dp[i][j]==dp[i][k]+dp[k][j]){
                    bri[i][j]=false;
                }
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
            }
        }
    }

    ll ans=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(dp[i][j]!=A[i][j]){
                ans=-1;
                cout << ans << endl;
                return 0;
            }
        }
    }

    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(bri[i][j]) ans+=dp[i][j];
        }
    }


    cout << ans/2 << endl;

    
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int D = sc.nextInt();
        
        double X = (double) N / ( D * 2 + 1);
        X = Math.ceil(X);
        
        System.out.println((int)X);
    }
}


Measured memory_bytes: 23764
import math

Q = int(input())
lr = []
for _ in range(Q):
    lr.append(tuple(map(int, input().split())))

prime=[]
for n in range(2, 10**5+1):
    for i in range(2, math.floor(math.sqrt(n)) + 1):
        if n % i == 0:
            break
    else:
        prime.append(n)
#print(prime)



like2017=[0]*(10**5+1)
for p in prime:
    if (p+1)//2 in prime:
        like2017[p]=1
#print(like2017)

cumulative=[0]
for i in range(10**5):
    cumulative.append(like2017[i]+cumulative[i])
#print(cumulative)

for q in lr:
    l, r = q
    print(cumulative[r+1]-cumulative[l])


Measured memory_bytes: 68568
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

  int A=in(),B=in();
  if(A==B){
    cout << A+B << endl;
  }
  else{
    int M = max(A,B);
    cout << 2*M-1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

fun main(args: Array<String>) {
  val scanner = Scanner(System.`in`)
  val N = scanner.nextLong()
  var min = Long.MAX_VALUE
  for (i in 0..4) {
    val input = scanner.nextLong()
    min = if (min < input) min else input
  }
  println(N / min + (if (N % min == 0.toLong()) 4 else 5))
  scanner.close()
}

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

int main(){
  string S;
  cin >> S;
  
  string str[4]={"dream","dreamer","erase","eraser"};
  
  reverse(S.begin(),S.end());
  for(int i=0; i<4; i++) reverse(str[i].begin(),str[i].end());
  
  bool ans = false;
  for(int i=0; i<S.size();){
    for(int j=0; j<4; j++){
      if(S.substr(i,str[j].size())==str[j]){
        i += str[j].size();
        ans = false;
        break;
      }
      else ans = true;
    }
    if(ans){
      cout << "NO" << endl;
      break;
    }
  }
  if(!(ans)) cout << "YES" << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool check(const vector<int> &arr, int ans, int k) {
  int n = arr.size();
  vector<int> minus(n), plus(n);
  for (int i = 0; i < n; i++) {
    minus[i] = arr[i] % ans;
  }
  sort(minus.begin(), minus.end());
  for (int i = 0; i < n; i++) {
    plus[i] = (ans - minus[i]) % ans;
  }
  int i = 0;
  int sum = 0;
  while (i < n - 1) {
    if (k >= minus[i]) {
      k -= minus[i];
      sum += minus[i];
      i++;
    } else {
      break;
    }
  }
  while (i < n) {
    if (sum >= plus[i]) {
      sum -= plus[i];
      i++;
    } else {
      break;
    }
  }
  return i == n;
}

int main() {
  int n, k; cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  int sum = 0;
  for (int i : a) {
    sum += i;
  }

  vector<int> candidates;

  for (int i = 1; i * i <= sum; i++) {
    if (sum % i == 0) {
      candidates.push_back(i);
      candidates.push_back(sum / i);
    }
  }

  int ans = 1;

  for (int c : candidates) {
    if (check(a, c, k)) {
      if (c > ans) {
        ans = c;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

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

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll n;
    cin>>n;
    ll ans = (n/2) + ((n%2)?1:0);
	cout<<ans<<'\n';
}
// Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


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

string s; int K;
set<string> substrings;

int main() {
    cin >> s >> K;
    int N = s.size();
    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= K; j++) {
            substrings.insert(s.substr(i,j));
        }
    }
    auto ansiter = substrings.begin();
    for (int i = 0; i < K-1; i++) {
        ansiter++;
    }
    cout << *ansiter << endl;
}


Measured memory_bytes: 1664
//In the name of ALLAH
#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<fstream>
#define sc(x) scanf("%d",&x)
#define ll long long
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORd(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define reset(x) memset(x,0,sizeof x)
#define sz(x) x.size()
#define pb push_back
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);


using namespace std;

typedef pair<int,int> pii;
typedef vector<pii> vii;
const int con = 1e5+7;
static const int INF = 0x3f3f3f3f;
static const int MOD = 1e9+7;

int main(){

    ll k,a,b;cin >> k >> a >> b;
    ll yen=0,curr_b=1;
    if(b > a+1){

        FOR(i,0,k){

            if(yen > 0) {
                curr_b += b;
                yen--;
            }

            else if(curr_b >= a && i < k-1){

                yen++;
                curr_b -= a;
            }
            else curr_b++;
        }
    }else{

        curr_b += k;
    }
    cout << curr_b;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  for(int i=0; i<N; i++){
    cin >> X.at(i);
  }
  sort(X.begin(),X.end());
  int answer=0,en=0;
  for(int i=X.at(0); i<X.at(N-1); i++){
    for(int j=0; j<N; j++){
      en+=(i-X.at(j))*(i-X.at(j));
    }
    if(i==X.at(0)){
      answer=en;
      continue;
    }
    answer=min(answer,en);
    en=0;
  }
  cout << answer << endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<deque>
#include<iomanip>

using namespace std;
typedef long long ll;

int main(void)
{
    double W, H, x, y;
    cin >> W >> H >> x >> y;

    cout << setprecision(7) << W * H / 2 << " ";

    if((y == H * x / W) && (y == -H * x / W + H))
    {
        cout << "1" << endl;
    }
    else
    {
        cout << "0" << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e12;
using Graph = vector<vector<int>>;

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

  bool zero = 0;
  int M = 0;
  vector<int> A(N);
  int t = 0;
  for( int i = 0; i < N; i++ ){
    cin >> A[i];
    if( A[i] < 0 ) M++;
    else if( A[i] == 0 ) zero = 1;
    A[i] = abs(A[i]);
    t += A[i];
  }

  sort(A.begin(), A.end());
  if( M%2 == 0 || zero == 1 ){
    cout << t << endl;
  }else{
    cout << t-2*A[0] << endl;
  }



}


Measured memory_bytes: 4048
#include <math.h>
#include <stdio.h>
#include <string.h>
int n;
int main(void) {
    scanf("%d", &n);
    if (n / 100 == 7) {
        printf("Yes\n");
    } else if ((n % 100) / 10 == 7) {
        printf("Yes\n");
    } else if (n % 10 == 7) {
        printf("Yes\n");

    } else {
        printf("No\n");
    }
}

Measured memory_bytes: 1652
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int q,a,b,c,d;
int main()
{
    scanf("%d",&q);
    while(q--){
        scanf("%d%d%d%d",&a,&b,&c,&d);
        long long l=0,r=a,mid,k=(max(a,b)-1)/(min(a,b)+1)+1;
        while(l<=r){
            mid=(l+r)>>1;
            long long A=mid,B=max((mid-1),0ll)/k;
            if((a-A)*k>=b-B)l=mid+1;
            else r=mid-1;
        }
        long long pos=l+max((l-1),0ll)/k;
        for(int i=c;i<=min(d,(int)pos);++i)
            printf("%c",(i%(k+1))==0?'B':'A');
        for(int i=max((long long)c,pos+1);i<=d;++i)
            printf("%c",(a+b-i+1)%(k+1)==0?'A':'B');
        puts("");
    }
    return 0;
}

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

#define int long long int

constexpr int INF = std::numeric_limits<int>::max();

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B, C;
    cin >> N >> A >> B >> C;

    vector<int> L(N);

    for (int &l : L) {
        cin >> l;
    }

    int ans = INF;
    int ABC[] = {0, A, B, C};
    const int lim = 0b01 << (2 * N);
    for (int i = 0; i < lim; i++) {
        int cnt[4] = {0, 0, 0, 0};
        int len[4] = {0, 0, 0, 0};
        for (int z = i, idx = 0; z > 0; z = z >> 2, idx++) {
            int y = z & 0b11;
            cnt[y]++;
            len[y] += L[idx];
        }

        if (cnt[1] == 0 || cnt[2] == 0 || cnt[3] == 0) {
            continue;
        }

        int ret = 0;
        for (int p = 1; p < 4; p++) {
            ret += (cnt[p] - 1) * 10 + abs(len[p] - ABC[p]);
        }
        ans = min(ans, ret);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;

namespace _168_b
{
    internal class TripleDots
    {
        private static void Main(string[] args)
        {
            var k = int.Parse(Console.ReadLine() ?? throw new InvalidOperationException());
            var s = Console.ReadLine();
            if (s == null) return;

            if (s.Length > k)
            {
                var subString = s.Substring(0, k);
                Console.WriteLine(subString + "...");
            }
            else
            {
                Console.WriteLine(s);
            }
        }
    }
}

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

ll n;

void dfs(ll max_c, string s){
    if(s.size()==n){
        cout<<s<<endl;
    }else{
        rep(i,max_c){
            dfs(max_c,s+(char)('a'+i));
        }
        dfs(max_c+1,s+(char)('a'+max_c));
    }
}

int main(){
    cin>>n;
  	if(n==1){
      	cout<<"a"<<endl;
    }else{
    	dfs(1,"a");
    }
}



Measured memory_bytes: 1536
n = int(input())
x = [(ind, int(i)) for ind, i in enumerate(input().split())]
x.sort(key=lambda x:x[1])
ans = [None]*n
l = x[n//2-1][1]
r = x[n//2][1]
for ind, (i, _) in enumerate(x):
    if ind<n//2:
        ans[i] = r
    else:
        ans[i] = l
for i in ans:
    print(i)

Measured memory_bytes: 45444
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main(){
    int ans = 0;
    string s;
    
    while( cin >> s ){
    	string s_ = s;
    	reverse(s.begin(), s.end());
        if( s == s_ ) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1196
H, W, D = map(int, input().split())
m = [None] * (H * W + 1)
for i in range(H):
    l = map(int, input().split())
    for j, a in enumerate(l):
        m[a] = (i, j)
Q = int(input())
LR = []
for _ in range(Q):
    l, r = map(int, input().split())
    LR.append((l, r))

S = [0] * (H * W + 1)
for k in range(D + 1, H * W + 1):
    x, y = m[k]
    i, j = m[k - D]
    S[k] = S[k - D] + abs(x - i) + abs(y - j)

for l, r in LR:
    print(S[r] - S[l])


Measured memory_bytes: 27676
require 'set'
require 'prime'

n, m, s, t = gets.split.map(&:to_i)
g = Hash[(1..n).map {|i| [i, []] }]
m.times do
  i, j = gets.split.map(&:to_i)
  g[i] << j
  g[j] << i
end

if g[s].any? {|i| g[i].include?(t) }
  p 2
  exit
end

dist = { t => 0 }
color = { t => 0 }
queue = [t]
has_odd_cycle = false
until queue.empty?
  i = queue.shift
  g[i].each do |j|
    if color[j] && (color[j] == color[i])
      has_odd_cycle = true
    end
    next if dist[j]
    dist[j] = dist[i] + 1
    color[j] = 1 - color[i]
    queue << j
  end
end

if Prime.prime?(dist[s])
  p dist[s]
elsif dist[s].odd?
  d = dist[s]
  d += 2 until Prime.prime?(d)
  p d
elsif !has_odd_cycle
  p -1
else
  dist2 = { s => 0 }
  queue = [s]
  d = nil
  until queue.empty?
    i = queue.shift
    g[i].each do |j|
      d = dist2[i] + 1 + dist[j]
      if d.odd?
        queue = []
        break
      end
      next if dist2[j]
      dist2[j] = dist2[i] + 1
      queue << j
    end
  end
  d += 2 until Prime.prime?(d)
  p d
end



Measured memory_bytes: 37880
N = int(input())

list1 = [i for i in range(1, 14)]

S = []
H = []
C = []
D = []

mylist = []


for n in range(N):
    a, b = input().split()
    b = int(b)
    if a == 'S':
        S.append(b)
    elif a == 'H':
        H.append(b)
    elif a == 'C':
        C.append(b)
    elif a == 'D':
        D.append(b)

for i in list1:
    if i not in S:
        mylist.append("S {}".format(i))

for i in list1:
    if i not in H:
        mylist.append("H {}".format(i))

for i in list1:
    if i not in C:
        mylist.append("C {}".format(i))

for i in list1:
    if i not in D:
        mylist.append("D {}".format(i))

for q in mylist:
    print(q)


Measured memory_bytes: 5600
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("fma,avx,avx2")

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ld long double
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

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


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                if (a[i] == a[j] || a[j] == a[k] || a[k] == a[i]) continue;
                if (2 * max({a[i], a[j], a[k]}) < a[i] + a[j] + a[k]) {
                    ans++;
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#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 show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    string s;
    cin >> s;
    int n = s.size();

    int zero = 0;
    int one = 0;
    rep(i, n){
        if (s[i] == '0'){
            zero++;
        } else {
            one++;
        }
    }
    cout << 2 * min(zero, one) << endl;
    
}



Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>

using namespace std;

const int mod = 1000000007;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

    while (true)
    {
        int first = n % 10;
        int second = n / 10 % 10;
        int third = n / 100 % 10;
        if (first == second && second == third)
        {
            break;
        }
        
        n++;
    }
    
    cout << n << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [int(i) for i in input()]

def myindex(l,x,ind):

    global n
    if ind == n:
        return -1
    for i in range(ind,n):
        if l[i] == x:
            return i
    return -1

c=0

for i in range(10):
    x1 = myindex(s,i,0)
    if x1 != -1:
        for j in range(10):
            x2 = myindex(s,j,x1+1)
            if x2 != -1:
                for k in range(10):
                    x3 = myindex(s,k,x2+1)
                    if x3 != -1:
                        c+=1

print(c)

Measured memory_bytes: 9572
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#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 pair<int,int> P;
const int maxk = 10;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int n,m; cin >>n >> m;
    vector<vector<int> > light;
    REP(i,m){
        int k; cin >> k;
        vector<int> ss;
        light.push_back(ss);
        REP(l,k){
            int s; cin >> s; s--;
            light[i].push_back(s);
        }
        sort(ALL(light[i]));
    }
    vector<int> p; 
    REP(i,m){
        int pp; cin >> pp;
        p.push_back(pp);
    }
    int ans = 0;
    for(int bit = 0; bit < (1<<n); bit++){
        bool flag = true;
        REP(i,m){
            int on = 0;
            REP(k,n){
                if(bit & (1<<k)){
                    if(binary_search(ALL(light[i]), k)){
                        on++;
                    }
                }
            }
            if (on % 2 != p[i]) {
                flag = false; 
                break;
            }

        }
        if(flag) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    byte n = sc.nextByte();
    byte m = sc.nextByte();
    if(n==m){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
  
}

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


int gcd(int a, int b){ return a%b ? gcd(b, a%b) : b; }
int lcm(int a, int b){ return a/gcd(a,b)*b; }

int main(){
int a,b;
while(cin>>a>>b){
cout<<gcd(a,b)<<" "<<lcm(a,b)<<endl;
}
return 0;
}

Measured memory_bytes: 0
n, m = gets.chomp.split.map(&:to_i)
s = gets.chomp.split.map(&:to_i)
t = gets.chomp.split.map(&:to_i)
a = []
d = 1
a[0] = []
m.times do |j|
  if s[0] == t[j]
    d += 1
  end
  a[0][j] = d
end
1.upto(n-1) do |i|
  a[i] = []
  if s[i] == t[0]
    a[i][0] = a[i-1][0] + 1
  else
    a[i][0] = a[i-1][0]
  end
  1.upto(m-1) do |j|
    if s[i] == t[j]
      a[i][j] = a[i-1][j] + a[i][j-1]
    else
      a[i][j] = a[i-1][j] + a[i][j-1] - a[i-1][j-1]
    end
    a[i][j] %= 1000000007
  end
end
puts a[-1][-1]


Measured memory_bytes: 41212
#include <bits/stdc++.h>
using namespace std;
#define fori(i,n) for(int i =0;i<n;i++)
#define pb push_back
#define ll long long
#define int long long
#define F first
#define S second
#define mp make_pair
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout.precision(15);
 
 
int mod = 1e9+7;
 
int pow(int a, int b) {
    int ans = 1;
    a %= mod;
    while(b) {
        if(b%2) {
            ans *= a;
            ans %= mod;
        }
        b /= 2;
        a *= a;
        a %= mod;
    }
    return ans;
}

int inv(int a) {
    return pow(a,mod-2);
}

int mul (int a,int b) {
    return ((a%mod)*(b%mod))% mod;
}

struct cmp {
    bool operator() (pair<int,int> a, pair<int,int> b) const {
        int x = a.F;
        int y = b.F;
        return x>=y;
    }
};


int32_t main() {
    FAST;
    int t;
    // cin>>t;
    t = 1;
    while(t--) {
        int n;
        cin>>n;
        int ans = 0;
        fori(i,n) {
            int x;
            cin>>x;
            int j = i+1;
            ans += (j&1)&(x&1);
        }
        cout<<ans;
    }
    
    return 0;
}

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

int main(){
    int w,h,n;
    cin >> w >> h >> n;
    int x[n] = {},y[n] = {},a[n] = {};
    bool isBlack[w+1][h+1] = {false};
    for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> a[i];
    for(int i = 0; i < n; i++){
        if(a[i] == 1){
            for(int j = 1; j <= x[i]; j++)for(int k = 1; k <= h; k++) isBlack[j][k] = true;
        }
        else if(a[i] == 2){
            for(int j = x[i]+1; j <= w; j++)for(int k = 1; k <= h; k++) isBlack[j][k] = true;
        }
        else if(a[i] == 3){
            for(int j = 1; j <= w; j++)for(int k = 1; k <= y[i]; k++) isBlack[j][k] = true;
            }
        else if(a[i] == 4){
            for(int j = 1; j <= w; j++)for(int k = y[i]+1; k <= h; k++) isBlack[j][k] = true;
            }
    }
    int square = 0;
    for(int i = 1; i <= w; i++){
        for(int j = 1; j <= h; j++){
            if(!isBlack[i][j]){ square++;}
        }
    }
    cout << square << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int N = 1e5 + 10;
long long ans;
int a[N];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int n;
    cin >> n;
    for(int i = 0;i < n; ++i)
        cin >> a[i];
    for(int i = 1;i < n; ++i)
        if(a[i] < a[i-1]) a[i]++;
    for(int i = 1;i < n; ++i){
        if(a[i] < a[i-1]){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int sdkys(int a,int b){
    if(b==0) return a;
    return sdkys(b,a%b);
}
int sskbs(int a,int b){
    return a*b/sdkys(a,b);
}
int sosu(int a){
    if(a==2){
        return 1;
    }
    for(int i=2;i<sqrt(a)+1;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}
vector<int> v;
int n,m,cnt=0,ans=0,aa[220000];
pair<int,int> pp[220000];
string s,ss[220000];
char ch[220000];
queue<int> que;
signed main(){
    cin>>n>>s;
    rep(i,n){
        if(s[i]=='R'){
            cnt++;
        }
    }
    rep(i,n){
        if(s[i]=='W'&&i<cnt){
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = new int[NM[1]];
            var b = new int[NM[1]];

            for (var i = 0; i < NM[1]; i++)
            {
                var tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                a[i] = tmp[0];
                b[i] = tmp[1];
            }

            var ans = 0;
            for (var i = 0; i < NM[1]; i++)
            {
                var uf = new UnionFind(NM[0]+1);

                for (var j = 0; j < NM[1]; j++)
                {
                    if (i == j) continue;
                    uf.Unite(a[j], b[j]);
                }
                if (uf.GetSize(a[i]) != NM[0]) ans++;
            }
            Console.WriteLine(ans);
        }
    }


    class UnionFind
    {
        public int Size { get; set; } = 0;
        List<int> parent;
        List<int> sizes;

        public UnionFind(int count)
        {
            parent = new List<int>(count);
            sizes = new List<int>(count);
            ExtendSize(count);
        }

        public bool Unite(int x, int y)
        {
            var xp = Find(x);
            var yp = Find(y);
            if (yp == xp) return false;
            if (sizes[xp] < sizes[yp])
            {
                var tmp = xp;
                xp = yp;
                yp = tmp;
            }
            parent[yp] = xp;
            sizes[xp] += sizes[yp];
            return true;
        }

        public IEnumerable<int> AllParents => parent.Where(x => x == parent[x]);
        public int GetSize(int x) => sizes[Find(x)];
        public int Find(int x) => parent[x] == parent[parent[x]] ? parent[x] : parent[x] = Find(parent[x]);
        public void ExtendSize(int treeSize)
        {
            if (treeSize <= Size) return;
            parent.Capacity = treeSize;
            sizes.Capacity = treeSize;
            while (Size < treeSize)
            {
                parent.Add(Size);
                sizes.Add(1);
                Size++;
            }
        }
    }
}


Measured memory_bytes: 13268
N = int( input())
A = list( map( int, input().split()))
C = [0]*8
col = 0
for a in A:
    for i in range(8):
        if a < (i+1)*400:
            C[i] = 1
            break
    else:
        col += 1
if sum(C) == 0:
    print("{} {}".format( 1, col))
else:
    print("{} {}".format( sum(C), sum(C)+col))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return n != 1; // 1の場合は例外
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll ans;
    for(ll i = 6; ; i += 5){
        if(is_prime(i)){
            ans.emplace_back(i);
        }
        if(SZ(ans) == n) break;
    }
    rep(i, SZ(ans)){
        cout << ans[i] << " \n"[i==SZ(ans)-1];
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	H := make([]int, N)
	for i := range H {
		fmt.Scan(&H[i])
	}
	sort.Ints(H)
	sum := 0
	if len(H) < K {
		fmt.Println(0)
		return
	}
	for i := range H[:len(H)-K] {
		sum += H[i]
	}
	fmt.Println(sum)
}


Measured memory_bytes: 6784
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.numeric, std.typecons;

void main()
{
    auto N = readln.chomp.to!int;

    int[][] AAS;
    AAS.length = N;
    foreach (ref AA; AAS) AA = readln.split.to!(int[]);

    foreach (k; 0..N)
        foreach (i; 0..N)
            foreach (j; 0..N)
                if (AAS[i][k] + AAS[k][j] < AAS[i][j])
                    goto not;
    
    if (false) {
        not:
        writeln("-1");
        return;
    }

    long sum_l = 0;
    foreach (i; 0..N) {
        foreach (j; 0..N) {
            auto flg = true;
            foreach (k; 0..N) if (k != i && k != j && AAS[i][j] == AAS[i][k] + AAS[k][j]) {
                flg = false;
                break;
            }
            if (flg) sum_l += AAS[i][j];
        }
    }
    writeln(sum_l / 2);
}

Measured memory_bytes: 5628
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <iomanip>
#include <set>
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define SORT(s) sort((s).begin(),(s).end())

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

    set<ll> a;
    ll count = 1;
    while(a.find(s) == a.end()){
        a.insert(s);
        if(s%2 == 0){
            s /= 2;
        }else{
            s = 3*s + 1;
        }
        count += 1;
    }
    cout << count << endl;

}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
typedef pair<ll,mp> mmp;
ll inf =  1e9;

vector<vector<bool> > go;
ll dx[] = {1,-1,0,0};
ll dy[] = {0,0,1,-1};
ll h,w;

ll solve( ll si, ll sj  ){
   // if( !go[si][sj] ) return inf;
    vector<vector<ll> > cost( h+2, vector<ll>(w+2,inf) );
    queue<mmp> q;
    q.push( mmp( 0, mp( si , sj ) ) );
    while( !q.empty() ){
	mmp now = q.front();
	ll c = now.first;
	ll x = now.second.first;
	ll y = now.second.second;
	q.pop();
	if( cost[x][y] != inf ) continue;
	cost[x][y] = c;
	for(ll i=0;i<4;i++){
	    ll nx = x + dx[i];
	    ll ny = y + dy[i];
	    if( cost[nx][ny] == inf && go[nx][ny] ){
		q.push( mmp( c+1 , mp(nx,ny) ) );
	    }
	}
    }
    ll res = 0;
    /*for(ll i=1;i<=h;i++){
	for(ll j=1;j<=w;j++)cout<<cost[i][j]<<' ';
	cout<<endl;
    }*/
    for(ll i=1;i<=h;i++){
	for(ll j=1;j<=w;j++){
	    if( go[i][j] ) res = max( res , cost[i][j]) ;
	}
    }
    return res;
}

int main(){
    cin>>h>>w;
    go = vector<vector<bool> >( h+2 , vector<bool>(w+2,false) );
    for(ll i=1;i<=h;i++){
	for(ll j=1;j<=w;j++){
	    char c;
	    cin>>c;
	    if( c == '.' ){
		go[i][j] = true;
	    }
	}
    }
    ll res  = 0;
    for(ll i=1;i<=h;i++){
	for(ll j=1;j<=w;j++){
	    if( go[i][j] ) res = max( res , solve(i,j) );
	}
    }
    cout<<res<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>
#include <functional>

using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL
#define rep(i,a,n) for (int i=a ; i<n ; i++)
#define per(i,a,n) for (int i=n-1 ; i>=a ; i--)
#define LLINF 100000000000000005LL
#define INF (int)1e9+1
#define endl '\n'
#define pb push_back

// debug 도구

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto& x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}\n";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)

// debug 도구 end

using llong = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VPII = vector<pair<int, int>>;
using VLL = vector<long long>;
using PII = pair<int, int>;

int main() {
    int n, d;
    cin >> n >> d;
    cout << (n + 2 * d) / (2 * d + 1);
    return 0;
}

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

int main() {
	int a, b, n;
	while(cin >> a >> b >> n){
		int ans = 0;
		a %= b;
		for(int i = 1; i <= n; ++i){
			a *= 10;
			ans += a / b;
			a %= b;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<n;++i)

typedef long long ll;
using namespace std;
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int res = (min(b, d)-max(a, c));
    if(min(b, d)-max(a, c)<0) res = 0;
    cout << res << "\n";
    return 0;
}

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

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

    vector<int> d(n);
    for(int i=0; i<n; i++){
        cin>>d[i];
    }
    
    sort(d.begin(),d.end());
   
    int count=0;
    
    /*for(int i=d[n]; i<d[n-1]+1; i++){
        int arc=0,abc=0;
        for(int j=0; j<n; j++){
            if(d[j]>=i){
                arc++;
            }else{
                abc++;
            }
        }
        if(arc==abc){
            count++;
        }
    }*/

    for(int i=d[(n-2)/2]; i<d[n/2]; i++){
        count++;
    }

    cout<<count<<endl;
}

Measured memory_bytes: 768
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999
#define ALL(x) (x).begin(), (x).end()
#define LBi(x, n) lower_bound(ALL(x), n) - (x).begin()
#define ZIP(x) (x).erase(unique(ALL(x)), (x).end())
#define Pi pair<int, int>
#define Vi vector<int>

#define rep(n) for(int i = 0; i < n; i++)

string s = "";
char ch[10];
int n, a, b, c, d, x, m[5];

int main() {
	rep(4) cin >> ch[i];
	if ((ch[0] == ch[1] && ch[1] == ch[2]) || (ch[1] == ch[2] && ch[2] == ch[3]))
		cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

#ifdef __GNUC__
#define popcount __builtin_popcount
#elif _MSC_VER >= 1400
#include <intrin.h>
#define popcount __popcnt
#else
static inline int popcount(unsigned int b) {
	b = (b & 0x55555555) + (b >> 1 & 0x55555555);
	b = (b & 0x33333333) + (b >> 2 & 0x33333333);
	b = (b & 0x0F0F0F0F) + (b >> 4 & 0x0F0F0F0F);
	b += b >> 8;
	return (b + (b >> 16)) & 0x3F;
}
#endif

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		int n = 0;
		cin >> n;
		if (n <= 0) return 0;
		vector<int> a[2];
		for (int j = 0; j < 2; ++j) {
			a[j] = vector<int>(n);
			for (int i = 0; i < n; ++i) {
				cin >> a[j][i];
			}
		}
		int dp[1 << 18][18];
		memset(dp, 0x7f, sizeof(dp));
		for (int c = 0; c < n; ++c) {
			dp[1 << c][c] = 0;
		}
		for (int b = 1; b < (1 << n); ++b) {
			int digits = popcount(b);
			for (int c = 0; c < n; ++c) {
				if (dp[b][c] >= (1 << 30)) continue;
				int p = a[(digits + c - 1) & 1][c];
				for (int d = 0; d < n; ++d) {
					int q = a[(digits + d) & 1][d];
					if (p > q) continue;
					if (b & (1 << d)) continue;
					int cost = dp[b][c] + popcount(b & ~((1 << d) - 1));
					int e = b | (1 << d);
					dp[e][d] = min(dp[e][d], cost);
				}
			}
		}
		int ans = 1 << 30;
		for (int c = 0; c < n; ++c) {
			ans = min(ans, dp[(1 << n) - 1][c]);
		}
		cout << (ans < (1 << 30) ? ans : -1) << endl;
	}
	return 0;
}


Measured memory_bytes: 18688