akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
	
ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;
	while (n > 0)
	{
		n /= 10;
		count++;
	}
	return count;
}
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}
int main()
{
	string s;
	cin>>s;
	int n=s.size();
	int cnt=0;
	rep(i,n){
		if(s[i]=='1'){
			cnt++;
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        s:Bytes,
    }
    let mut mp = BTreeMap::new();
    for &x in s.iter() {
        *mp.entry(x).or_insert(0) += 1;
    }
    for (key, value) in mp {
        if value != 2 {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 2204
#include <bits/stdc++.h>
using namespace std;
const int N = 8010;
int a[N], b[N];
char lx[N];

void fail() {
  puts("No");
  exit(0);
}

int f[N];
void gao(int a[], int tot, int flg) {
  int sum = 0;
  if(tot >= 0) {
    for(int i = 1; i <= a[0]; ++i) sum += a[i];
    sum -= tot;
  } else {
    for(int i = 1; i <= a[0]; ++i) {
      if(i == 1) {
        if(flg) sum += a[i];
        else sum -= a[i];
      } else {
        sum -= a[i];
      }
    }
    sum = tot - sum;
  }
  if(sum < 0 || (sum & 1)) fail();
  sum /= 2;
  memset(f, 0, sizeof f);
  f[0] = 1;
  for(int i = 1; i <= a[0]; ++i) {
    if(flg && i == 1) continue;
    for(int j = sum; j >= a[i]; --j) {
      if(f[j - a[i]]) f[j] = 1;
    }
  }
  if(!f[sum]) fail();
}

int main() {
  int x, y;
  scanf("%s%d%d", lx + 1, &x, &y);
  int len = strlen(lx + 1), res = 0;
  int now = 1;
  for(int i = 1; i <= len; ++i) {
    if(lx[i] == 'F') res++;
    else {
      if(now) a[++a[0]] = res;
      else b[++b[0]] = res;
      now ^= 1;
      res = 0;
    }
  }
  if(res) {
    if(now) a[++a[0]] = res;
    else b[++b[0]] = res;
  }
/*  for(int i = 1; i <= a[0]; ++i)
    printf("%d ", a[i]);
  puts("");
  for(int i = 1; i <= b[0]; ++i) 
    printf("%d ", b[i]);
  puts("");*/
  gao(a, x, 1), gao(b, y, 0);
  puts("Yes");
  return 0;
}

Measured memory_bytes: 256
abc = gets.to_i
arc = gets.to_i
agc = gets.to_i
apc = gets.to_i
atc = gets.to_i

abc_a = (abc*0.1).ceil*10
arc_a = (arc*0.1).ceil*10
agc_a = (agc*0.1).ceil*10
apc_a = (apc*0.1).ceil*10
atc_a = (atc*0.1).ceil*10

abc_b = abc_a - abc
arc_b = arc_a - arc
agc_b = agc_a - agc
apc_b = apc_a - apc
atc_b = atc_a - atc

array = [abc_b,arc_b,agc_b,apc_b,atc_b]

b = 0
array.each do |n|
  b = n if n >= b
end


puts abc_a + arc_a + agc_a + apc_a + atc_a - b


Measured memory_bytes: 14292
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

class Main{
	public static void main(String[] a){
		Scanner scanner = new Scanner(System.in);
		int input = scanner.nextInt();
        scanner.close();
		if (input > 100) return;
		long loan = 100000;
		double interest = 0.05;
		for (int i = 0; i < input; i++) {
			loan += (loan*interest);
			loan = new BigDecimal(loan).setScale(-3, RoundingMode.UP).longValue();
		}
		System.out.println(loan);
	}
}

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

int main(){
    int n, sum = 0; cin >> n;
    vector<int>  b(n-1);
    for(int i = 0; i < n-1; i++) cin >> b[i];
    sum += b[0];
    for(int i = 1; i < n-1; i++){
        sum += min(b[i-1], b[i]);
    }
    sum += b[n-2];
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxN = 5e3 + 10;
typedef long long ll;

int n, k;
int a[maxN];
bool dp[2][maxN];
int pre[maxN];

bool ok(int mid) {
  if (k <= a[mid]) return true;
  bitset<5000> bs;
  bs.set(0, 1);

  for (int i = 1; i <= n; ++i) {
    if (i == mid) continue;
    bs = bs | (bs << a[i]);
  }
  int l = k - a[mid], r = k - 1;

  for (int i = l; i <= r; ++i) {
    if (bs.test(i) == 1) return true;
  }
  return false;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//  freopen("abc.inp", "r", stdin); freopen("abc.out", "w", stdout);
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  sort(a+1, a+n+1);
  int l = 1, r = n;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (ok(mid)) r = mid - 1;
    else l = mid + 1;
  }
  cout << r << '\n';
  return 0;
}


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

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

int main(){
  int n,x;
  cin >> n >> x;
  vector<int> a(n+10);
  rep(i,n) cin >> a[i];
  if(n == 1){
    cout << abs(a[0] - x) << endl;
    return 0;
  }
  int ans = gcd(abs(a[1]-x),abs(a[0]-x));
  rep(i,n-1){
    ans = gcd(ans,gcd(abs(a[i+1]-x),abs(a[i]-x)));
  }
  cout << ans << endl;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    string s;
    cin >> s;
    if(s == "SUN") cout << 7;
    if(s == "MON") cout << 6;
    if(s == "TUE") cout << 5;
    if(s == "WED") cout << 4;
    if(s == "THU") cout << 3;
    if(s == "FRI") cout << 2;
    if(s == "SAT") cout << 1;
    return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#ifndef debug_on
#define debug_on 0
#endif

#define dbg \
    if(debug_on) cerr << "DEBUG:"
#define ast(cond)           \
    do {                    \
        if((cond) == false) \
        {                   \
            if(debug_on)    \
            cerr << "ASSERT" << #cond " failed at line:" << __LINE__ << endl;   \
            exit(1);        \
        }                   \
    }while(0)

int V[3];

int main(int, char *[])
{
    cin >> V[0] >> V[1] >> V[2];
    sort(V, V+3);
    V[2] -= V[1];
    V[0] -= V[1];
    V[1] -= V[1];

    int count[2] = {0, 0};
    while(V[0] < 0)
    {
        if(V[0] <=  -2)
        {
            V[0] += 2;
            ++count[0];
        }
        else if(V[0] == -1)
        {
            ++V[0];
            count[0] += 2;
        }
    }
    count[1] = V[2];


    cout << (count[0] + count[1]) << endl;

    return 0;
}


Measured memory_bytes: 256
a, b, c = [int(input()) for _ in range(3)]
for i1 in range(101):
  s = a + b + i1
  i6 = s - a - c
  i3 = s - i1- i6
  i2 = s - c - i3
  i4 = s - a - i2
  i5 = s - b - c
  li = [[a,b,i1],[i2,c,i3],[i4,i5,i6]]
  if all([sum(i) == s for i in li]) and all([sum(i) == s for i in zip(*li)]) and sum([i1,c,i4]) == s:
    for i in li: 
      print(*i)
      

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>

using namespace std;

int N, M;
int P[100001];
int C[100001];
int main(void){
	scanf("%d %d", &N, &M);

	for(int i = 0;i < M;++i){ scanf("%d", P+i); --P[i]; }

	for(int i = 0;i < M-1;++i){
		int L = min(P[i], P[i+1]);
		int R = max(P[i], P[i+1]);
		C[L]++;
		C[R]--;
	}
	for(int i = 1;i < N;++i){
		C[i] += C[i-1];
	}

	long long s = 0;

	for(int i = 0;i < N-1;++i){
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		s += min((long long int)a * C[i], (long long int)b * C[i] + c);
	}

	printf("%lld\n", s);
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

constexpr int MOD = 1000000007;

class mint {
  int n;
public:
  mint(int n_ = 0) : n(n_) {}
  explicit operator int() { return n; }
  friend mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
  friend mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
  friend mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
  friend mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
  friend mint &operator+=(mint &a, mint b) { return a = a + b; }
  friend mint &operator-=(mint &a, mint b) { return a = a - b; }
  friend mint &operator*=(mint &a, mint b) { return a = a * b; }
  friend bool operator==(mint a, mint b) { return a.n == b.n; }
  friend bool operator!=(mint a, mint b) { return a.n != b.n; }
  friend istream &operator>>(istream &i, mint &a) { return i >> a.n; }
  friend ostream &operator<<(ostream &o, mint a) { return o << a.n; }
};

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};

void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(n); return n < 0 ? 0 : I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

mint dp[21][1001];

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int N, K; cin >> N >> K;
  vector<int> A(K); rep(i, K) cin >> A[i];
  dp[0][0] = 1;
  for (int i = 0; i < K; i++) {
    for (int j = 0; j <= N; j++) {
      for (int k = 0; k <= A[i] and j + k <= N; k++) {
        dp[i + 1][j + k] += dp[i][j] * R(k) * C(N - k, A[i] - k);
      }
    }
  }
  cout << dp[K][N] * F(N) << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include <cstdlib>
#include <cstdio>
#include <set>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)


int main(){
    int k,s;
    cin >> k >> s;
    int x,y,z;
    long long ans = 0;
    rep(x,k+1){
        rep(y,k+1){
            if (s-x-y <= k && s-x-y >= 0) ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<set>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF 1000000100
#define rep(i,n) for (int i=0;i<n;i++)

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

Measured memory_bytes: 3452
fun main(args: Array<String>) {
	val w = readLine()!!
	val dic = mutableMapOf<Char, Int>()

	var ans = "Yes"

	for (v in w) {
		dic[v] = (dic[v] ?: 0) + 1
	}

	for (v in dic.values) {
		if (v % 2 != 0) {
			ans = "No"
			break
		}
	}
	println(ans)
}


Measured memory_bytes: 33848
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    vector<string> S = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string s;
    cin >> s;
    rep(i, 7) { S.push_back(S[i]); }
    int now = 0;
    while(S[now] != s)
        now++;
    int p = now;
    while(S[now] != "SUN")
        now++;
    if(now - p == 0)
        now = p + 7;
    cout << now - p << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 
signed main()
{
    SPEED;
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k>a)
    {
        if(k-a>b)
        {
            if(k-a-b>0)
                cout<<a-(k-a-b);
            else
                cout<<a;
        }
        else
            cout<<a;
    }
    else
        cout<<k;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string str; cin >> str;
    ll cntB = 0, cntW = 0;
    ll ans = 0;
    for(ll i=0;i<str.size();i++){
        if(str[i] == 'B'){
            cntB++;
        }else{
            cntW++;
            ans += (i + 1 - cntW);
        }   
    }
    cout << ans << endl;
}

Measured memory_bytes: 720
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final int K = sc.nextInt();

        int[] lock = new int[N];
        final int undef = 0;
        final int tomat = 1;
        final int cream = 2;
        final int basil = 3;
        for(int i = 0; i < K; ++i)
        {
            lock[sc.nextInt() - 1] = sc.nextInt();
        }

        int[][] date = new int[N][];
        final int tomat_1 = 0;
        final int tomat_2 = 1;
        final int cream_1 = 2;
        final int cream_2 = 3;
        final int basil_1 = 4;
        final int basil_2 = 5;

        date[0] = new int[6];
        switch(lock[0])
        {
        case undef:
            date[0][tomat_1] = 1;
            date[0][cream_1] = 1;
            date[0][basil_1] = 1;
            break;
        case tomat:
            date[0][tomat_1] = 1;
            break;
        case cream:
            date[0][cream_1] = 1;
            break;
        case basil:
            date[0][basil_1] = 1;
            break;
        }

        for(int i = 1; i < N; ++i)
        {
            date[i] = new int[6];
            final int sum = date[i - 1][tomat_1] + date[i - 1][tomat_2] + date[i - 1][cream_1] + date[i - 1][cream_2] + date[i - 1][basil_1] + date[i - 1][basil_2];
            switch(lock[i])
            {
            case undef:
                date[i][tomat_1] = (sum - date[i - 1][tomat_1] - date[i - 1][tomat_2]) % 10000;
                date[i][tomat_2] = date[i - 1][tomat_1];
                date[i][cream_1] = (sum - date[i - 1][cream_1] - date[i - 1][cream_2]) % 10000;
                date[i][cream_2] = date[i - 1][cream_1];
                date[i][basil_1] = (sum - date[i - 1][basil_1] - date[i - 1][basil_2]) % 10000;
                date[i][basil_2] = date[i - 1][basil_1];
                break;
            case tomat:
                date[i][tomat_1] = (sum - date[i - 1][tomat_1] - date[i - 1][tomat_2]) % 10000;
                date[i][tomat_2] = date[i - 1][tomat_1];
                break;
            case cream:
                date[i][cream_1] = (sum - date[i - 1][cream_1] - date[i - 1][cream_2]) % 10000;
                date[i][cream_2] = date[i - 1][cream_1];
                break;
            case basil:
                date[i][basil_1] = (sum - date[i - 1][basil_1] - date[i - 1][basil_2]) % 10000;
                date[i][basil_2] = date[i - 1][basil_1];
                break;
            }
        }

        System.out.println(
            (date[N - 1][tomat_1] +
             date[N - 1][tomat_2] +
             date[N - 1][cream_1] +
             date[N - 1][cream_2] +
             date[N - 1][basil_1] +
             date[N - 1][basil_2] )
            % 10000
            );
    }
}

Measured memory_bytes: 19704
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define MAX 1000000007

using namespace std;
int main() {
	lli N, ans=1, d;
	char s[100002];
	cin >> N >> s;
	vector <lli > vec(26, 0);
	for (int i = 0; i < N; i++) vec[(int)(s[i] - 'a')]++;
	
	rep0(i, 26) {
		ans *= (vec[i] + 1) % MAX;
		ans %= MAX;
	}
	cout << (ans - 1);

}

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


int main(){
  int n, m, Q;
  cin >> n >> m >> Q;
  vector<vector<int>> lr(n+1,vector<int>(n+1,0));
  rep(i,m) {
    int l, r;
    cin >> l >> r;
    lr[l][r]++;
  }
  rep(i,n) rep(j,n) lr[i+1][j+1] += lr[i][j+1] + lr[i+1][j] - lr[i][j]; 
  
  rep(i,Q) {
    int p, q;
    cin >> p >> q;
    printf("%d\n", lr[q][q] + lr[p-1][p-1] - lr[p-1][q] - lr[q][p-1]);
  }
  
  return 0;
} 

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

int main(){

    int a,b,c,d;

    cin >> a >> b >> c >> d;
    if(abs(a-c) <= d){
        cout << "Yes" << endl;
    }else if(abs(a-b) <= d && abs(b-c) <= d){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import functools
import os
import sys
import numpy as np


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        ret = fn(*args, **kwargs)
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        print(ret)
        return ret

    return wrapper


sys.setrecursionlimit(10000)
INF = float('inf')

N, Z, W = list(map(int, input().split()))
A = list(map(int, input().split()))

# def xy(x, y, pos, x_turn):
#     if x_turn:
#         return A[pos], y
#     else:
#         return x, A[pos]
#
#
# @debug
# def solve(x, y, pos, x_turn):
#     if pos >= N:
#         return abs(x - y)
#
#     if x_turn:
#         ans = -INF
#         for i in range(pos, N):
#             x, y = xy(x, y, i, x_turn)
#             ans = max(ans, solve(x, y, i + 1, not x_turn))
#     else:
#         ans = INF
#         for i in range(pos, N):
#             x, y = xy(x, y, i, x_turn)
#             ans = min(ans, solve(x, y, i + 1, not x_turn))
#     return ans
#
# print(solve(Z, W, 0, True))


# @lru_cache(maxsize=None)
# def dpx(i):
#     """
#     i 番目から x が最善を尽くしたときのスコア
#     :param i:
#     :return:
#     """
#     if i == 0:
#         y = W
#     else:
#         y = A[i - 1]
#
#     ret = abs(A[-1] - y)
#     for i in range(i + 1, N):
#         ret = max(ret, dpy(i))
#     return ret
#
#
# @lru_cache(maxsize=None)
# def dpy(i):
#     """
#     i 番目から y が最善を尽くしたときのスコア
#     :param i:
#     :return:
#     """
#     if i == 0:
#         x = Z
#     else:
#         x = A[i - 1]
#
#     ret = abs(A[-1] - x)
#     for i in range(i + 1, N):
#         ret = min(ret, dpx(i))
#     return ret


# dpx[i]: i 番目以降から始めて x が最善を尽くしたときの最低スコア
dpx = np.empty(N + 1)
# dpy[i]: i 番目以降から始めて y が最善を尽くしたときの最高スコア
dpy = np.empty(N + 1)

dpx.fill(np.inf)
dpy.fill(-np.inf)
for i in reversed(range(1, N)):
    y = A[i - 1] if i > 0 else W
    dpx[i] = max(abs(A[-1] - A[i - 1]), dpy[i + 1])
    dpx[i] = min(dpx[i], dpx[i + 1])

    dpy[i] = min(abs(A[-1] - A[i - 1]), dpx[i + 1])
    dpy[i] = max(dpy[i], dpy[i + 1])

print(int(max(abs(A[-1] - W), dpy[1])))


Measured memory_bytes: 18692
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int a[100010];
int main()
{
	int n,i,num=0,k=1;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(i=0;i<n-1;i++)
	{
		if(a[i]==a[i+1])
			k=(k+1)%2;
		else
		{
			num+=k;
			k=1;
		}
	}
	if(k%2==1)
	  num+=1;
	cout<<num<<endl;
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication32
{
    class Program
    {  
      static void Main()
      {
		  var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		  int c =0;
		  for (int b=a[0];b<a[1]+1;b++)
		  {
			  if(a[2]%b==0)
			  c++;
		  }
		  Console.WriteLine(c);
		  		}
	 }
 }

      
      

Measured memory_bytes: 9508
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int a[5];string b[4]={"AC","WA","TLE","RE"};
int main()
{
	int n;string s;cin>>n;memset(a,0,sizeof(a));
	rep(i,n){
		cin>>s;
		rep(j,4){
			if(s==b[j]) a[j]++;
		}
	}
	rep(i,4) cout<<b[i]<<" x "<<a[i]<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
string s1, s2;
int dp[3001][3001];

int lcs(int i, int j)
{
	if(i < 0 || j < 0)
		return 0;
	
	if(dp[i][j] != -1)
		return dp[i][j];

	if(s1[i] == s2[j])
		dp[i][j] = 1 + lcs(i - 1, j - 1);
	else
		dp[i][j] = max(lcs(i - 1, j), lcs(i, j - 1));

	return dp[i][j];
}

int main(void)
{
	cin >> s1 >> s2;
	memset(dp, -1, sizeof(dp));
	int l = lcs(s1.length() - 1, s2.length() - 1);

	// for(int i = 0; i < s1.length(); i++)
	// {
	// 	for(int j = 0; j < s2.length(); j++)
	// 		cout << dp[i][j] << " ";
	// 	cout << endl;
	// }

	// cout << "l = " << l << endl;
	vector <char> s;

	int i = s1.length() - 1, j = s2.length() - 1;
	while(i >= 0 && j >= 0 && l)
	{
		if(i > 0 && l == dp[i - 1][j])
			i--;
		else if(j > 0 && l == dp[i][j - 1])
			j--;
		else
		{
			s.pb(s1[i]);
			i--;	j--;	l--;
		}
	}

	for(int i = s.size() - 1; i >= 0; i--)
		cout << s[i];
	cout << endl;



	return 0;
}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int N = 200003, M = N << 1;

int n, k;
int a, b, c;
string s[N];
string ans[N];

void dfs(int now, int a, int b, int c)
{
    if (now > n) 
    {
        puts("Yes");
        for (int i = 1; i <= n; i+=1) cout << ans[i] << endl;
        exit(0);
    }
    if (s[now] == "AB")
    {
        if (b > 0) ans[now] = "A", dfs(now + 1, a + 1, b - 1, c);
        if (a > 0) ans[now] = "B", dfs(now + 1, a - 1, b + 1, c);
    }
    else if (s[now] == "AC")
    {
        if (c > 0) ans[now] = "A", dfs(now + 1, a + 1, b, c - 1);
        if (a > 0) ans[now] = "C", dfs(now + 1, a - 1, b, c + 1);
    }
    else 
    {
        if (c > 0) ans[now] = "B", dfs(now + 1, a, b + 1, c - 1);
        if (b > 0) ans[now] = "C", dfs(now + 1, a, b - 1, c + 1);
    }
}

int main()
{
    n = gi(), a = gi(), b = gi(), c = gi();
    for (int i = 1; i <= n; i+=1) cin >> s[i];
    dfs(1, a, b, c);
    puts("No");
    return 0;
}


Measured memory_bytes: 23912
#include <stdio.h>
#include <string.h>
#define MAX 101
int main(void)
{
	int n, len, len_t, len_h, pt=0, ph=0, i, scale;
	char card[3][MAX];
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%s%s", card[0], card[1]);
		scale = strcmp(card[0], card[1]);
		if(scale == 0){
			pt += 1; ph += 1;
		}else if(scale > 0){
			pt += 3;
		}else if(scale < 0){
			ph += 3;
		}
	}
	printf("%d %d\n", pt, ph);
	return 0;
}

Measured memory_bytes: 604
def get_item(L,i): return L[i] if len(L) > i else -2*10**9-1
def left (i): return i*2
def right(i): return i*2 + 1

def maxHeapify(A,i):
    l = left(i)
    r = right(i)
    largest = i
    if get_item(A,l) > A[largest]: largest = l
    if get_item(A,r) > A[largest]: largest = r
    if largest != i:
        A[i], A[largest] = A[largest], A[i] 
        maxHeapify(A, largest)


def buildMaxHeap(A):
    for i in range(len(A)//2,0,-1): maxHeapify(A,i)


if __name__=='__main__':
    H = int(input())
    hp = [0] + list(map(int,input().split()))
    buildMaxHeap(hp)
    print("",*hp[1:])

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

using namespace std;
using LL = long long;

int main(){
    int A,B;cin >> A >> B;
    if(A >= 13){
        cout<<B<<endl;
    }else if (A >= 6){
        cout<<B/2<<endl;
    }else{
        cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
N=int(input())
M=input().split()
for i in range(N):
    M[i]=int(M[i])
S1=0
S2=sum(M)
t=100000
for i in range(N):
    S1+=M[i]
    S2=S2-M[i]
    if t>abs(S2-S1):
        t=abs(S2-S1)
print(t)

Measured memory_bytes: 3060
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define en '\n'
#define rep(i,n)    for(ll i=0; i<n; i++)
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(1);
#define yes cout<<"YES"<<'\n'
#define no cout<<"NO"<<'\n'
using namespace std;



int main()
{
    godspeed
    //  ll  t,n,i,j;
    ll i,t,n,j,k,d,x,l;
    cin>>n>>x>>t;
      ll ans=(n/x)*t;
      if(n%x) ans+=t;
        cout<<ans<<endl;


    return 0;
}





Measured memory_bytes: 3608
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
      	InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
    	Scanner sc = new Scanner(inputStream);
      	PrintWriter out = new PrintWriter(outputStream);
      	int X = Integer.parseInt(sc.next());
     	int Y = Integer.parseInt(sc.next());
      	char S[][] = new char[50][50];
      
      	for(int x = 0; x < X;  x++){
          	String s = sc.next();
        	for(int y = 0; y < Y; y++){
            	S[x][y] = s.charAt(y);
           	}
        }
      //out.println(Arrays.deepToString(S));
      int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
      int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
      
      for(int i = 0; i < X;  i++){
        	for(int j = 0; j < Y; j++){
            	if(S[i][j] == '.'){
                	int count = 0;
                  	for(int k = 0; k < 8; k++){
                    	int x = i + dx[k];
                      	int y = j + dy[k];
                      	if(0 <= x && x < X && 0 <= y && y < Y && S[x][y] == '#'){
                        	count++;
                        }
                      S[i][j] = (char)('0' + count);
                    }
                }
           	}
      }
        for(int i = 0; i < X; i++){
        	for(int j = 0; j < Y; j++){
            	out.print(S[i][j]);
            }
          out.println();
        }
      out.close();
    }
}

Measured memory_bytes: 25044
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
const int nmax = 40, abmax = 10, inf = 1000000;
int dp[nmax + 1][abmax * nmax + 1][nmax * abmax + 1];

int main() {
  int n, ma, mb;
  cin >> n >> ma >> mb;
  VEC<int> a(n), b(n), c(n);
  REP(i, 0, n) cin >> a[i] >> b[i] >> c[i];
  REPC(i, 0, nmax) {
    REPC(j, 0, nmax * abmax) {
      REPC(k, 0, nmax * abmax) { dp[i][j][k] = inf; }
    }
  }
  dp[0][0][0] = 0;
  //REPC(i, 0, n) {
  //  REPC(j, 0, ma) {
  //    REP(k, 0, mb) { cerr << dp[i][j][k] << " "; }
  //    cerr << endl;
  //  }
  //  cerr << endl;
  //}
  REPC(i, 0, n - 1) {
    REPC(j, 0, nmax * abmax) {
      REP(k, 0, nmax * abmax) {
        // if (dp[i][j][k] == inf)
        //  continue;
        dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
        if (j + a[i] <= nmax * abmax && k + b[i] <= nmax * abmax) {
          dp[i + 1][j + a[i]][k + b[i]] =
              min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
        }
      }
    }
  }
  //REPC(i, 0, n) {
  //  REPC(j, 0, ma*5) {
  //    REP(k, 0, mb*5) { cerr << dp[i][j][k] << " "; }
  //    cerr << endl;
  //  }
  //  cerr << endl;
  //}
  int mi = inf;
  REPC(ca, 1, nmax * abmax) {
    REPC(cb, 1, nmax * abmax) {
      DUMP(mi, ca, cb, dp[n][ca][cb]);
      if (ca * mb == cb * ma) {
        mi = min(mi, dp[n][ca][cb]);
      }
    }
  }
  cout << (mi != inf ? mi : -1) << endl;

  return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;

int main() {
   string s;cin >>s;
   int a=s[0]-'0';
   int b=s[1]-'0';
   int c=s[2]-'0';
   int d=s[3]-'0';
   vector<int>ans;
    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j < 2; ++j) {
            for (int k = 0; k < 2; ++k) {
                int now=a;
                if(i)now+=b;
                else now-=b;
                if(j)now+=c;
                else now-=c;
                if(k)now+=d;
                else now-=d;
                if(now==7){
                    ans.push_back(i);
                    ans.push_back(j);
                    ans.push_back(k);
                }
            }
        }
    }
    cout <<a;
    if(ans[0])cout <<'+';
    else cout <<'-';
    cout <<b;
    if(ans[1])cout <<'+';
    else cout <<'-';
    cout <<c;
    if(ans[2])cout <<'+';
    else cout <<'-';
    cout <<d<<"=7"<<endl;
}


Measured memory_bytes: 3580
import itertools

N, M = [int(x) for x in input().split()]

K = []
S = []

for _ in range(M):
    i = [int(x) for x in input().split()]
    S.append([x-1 for x in i[1:]])

P = [int(x) for x in input().split()]

ans = 0
for pool in itertools.product(range(2), repeat=N):
    t = [0 for _ in range(M)]
    for i in range(M):
        for j in S[i]:
            if pool[j] == 1:
                t[i] += 1
    if all([x%2==P[i] for i, x in enumerate(t)]):
        ans += 1

print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,r;
  int mn=1000000000,mx=-999999999;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>r;
    if(i!=0) mx=max(mx,r-mn);
    mn=min(mn,r);
  }
  cout<<mx<<endl;
  return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h> 
using namespace std; 
#define lld long long int
class Graph 
{ 
    int V; 

    list<int>* adj; 
 
    void DFSUtil(int v, bool visited[]); 
  
public: 
    Graph(int V); 
  
    void addEdge(int v, int w); 
    int NumberOfconnectedComponents(); 
}; 
  
int Graph::NumberOfconnectedComponents() 
{ 
    bool* visited = new bool[V]; 
  
    int count = 0; 
    for (int v = 0; v < V; v++) 
        visited[v] = false; 
  
    for (int v = 0; v < V; v++) { 
        if (visited[v] == false) { 
            DFSUtil(v, visited); 
            count += 1; 
        } 
    } 
  
    return count; 
} 
  
void Graph::DFSUtil(int v, bool visited[]) 
{ 
  
    visited[v] = true; 
  
    list<int>::iterator i; 
  
    for (i = adj[v].begin(); i != adj[v].end(); ++i) 
        if (!visited[*i]) 
            DFSUtil(*i, visited); 
} 
  
Graph::Graph(int V) 
{ 
    this->V = V; 
    adj = new list<int>[V]; 
} 
void Graph::addEdge(int v, int w) 
{ 
    adj[v].push_back(w); 
    adj[w].push_back(v); 
} 

int main() 
{ 
    lld n,m,i,x,y;
    cin>>n>>m;
    Graph g(n); 
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        x--;
        y--;
        g.addEdge(x,y);
    }
    cout << g.NumberOfconnectedComponents()-1; 
  
    return 0; 
} 

Measured memory_bytes: 13564
using System;

namespace Prob0003
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            
            string line;
            while((line = Console.ReadLine()) != null)
            {
                string[] tokens = line.Split(' ');
                
                int[] sides = new int[tokens.Length];
                for(int i = 0; i < tokens.Length; i++)
                {
                    sides[i] = int.Parse(tokens[i]);
                    sides[i] *= sides[i];
                }
                
                bool flag = false;
                for(int i = 0; i < tokens.Length; i++)
                {
                    int sum = 0;
                    for(int j = 0; j < tokens.Length; j++)
                    {
                        if(i != j)
                        {
                            sum += sides[j];
                        }
                    }

                    if(sides[i] == sum)
                    {
                        flag = true;
                    }
                }

                Console.WriteLine((flag ? "YES" : "NO"));
            }
        }
    }
}



Measured memory_bytes: 15948
#include <stdio.h>
#include <string.h>
#include <map>
using namespace std;
int main()
{
    map<int, int> mapx;
    int a,n;
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        scanf("%d",&a);
        if (mapx.find(a) != mapx.end())
            mapx[a]++;
        else
            mapx[a]=1;
    }
    bool possible=true;
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        scanf("%d",&a);
        if (mapx.find(a) == mapx.end()||mapx[a]==0)
            possible=false;
        else
            mapx[a]--;
    }
    if(possible) printf("YES\n");
    else printf("NO\n");
    return 0;
}

Measured memory_bytes: 9728
import sys
INF=1e9
mod=1e9+7
n=int(input())
lit=list(map(int,input().split()))
lit.sort()
ans=0
for i in range(n):
    ans=(ans+lit[i]*(n-i+1)%mod)%mod
for i in range((n-1)):
    ans=ans*4%mod
ans=int(ans)
print(ans)


Measured memory_bytes: 26024
/*
2017_02_25_AC
??????????????????
?????????????????§????????°???????????¨????????????????????§??\??±??????????????¨
???dfs()???????????§grid[y][x]?????¨???return?????????????????¨???
??????????????????????????????????¬????????????????????????¨?????§??????????????£???????????????
????????????
???memset(dp, INF, sizeof(dp));??§?????????????????±
*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

const int INF = 1000000000;
int w, h, cost[4], grid[35][35], dp[35][35][4];

void dfs(int y, int x, int dir, int currentcost){
  if(!CH(y,0,h) || !CH(x,0,w)) return;
  if(dp[y][x][dir] <= currentcost) return;
  dp[y][x][dir] = currentcost;
  if((x == w-1 && y == h-1)/* || grid[y][x] == 4*/) return;
  REP(k,0,5){
    if(k == 0){ //????????????
      int d = grid[y][x];
      if(d == 4) continue;//grid[y][x]==4 (halt) ??????????????????
      dfs(y + dy[(dir + d) % 4], x + dx[(dir + d) % 4], (dir + d) % 4, currentcost);
    }else{  //???????????????tk: 0 ~ 3????????????4(halt)???????????????
      int tk = k - 1; //k=0??????????????????????????????????????????????????´??????
      if(tk == grid[y][x]) continue;
      dfs(y + dy[(dir + tk) % 4], x + dx[(dir + tk) % 4], (dir + tk) % 4, currentcost + cost[tk]);
    }
  }
  return;
}

int main() {

  while(1){
    cin>>w>>h;
    if(w==0 && h==0) break;
    REP(i,0,h){
      REP(j,0,w){
        cin>>grid[i][j];
      }
    }
    REP(k,0,4) cin>>cost[k];
    //memset(dp, INF, sizeof(dp));
    REP(i,0,h)REP(j,0,w)REP(k,0,4) dp[i][j][k] = INF;

    dfs(0, 0, 0, 0);

    cout<<*min_element(dp[h-1][w-1], dp[h-1][w-1]+4)<<endl;
  }

  return 0;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fop(i,m,n) for (int i=(m);i<(n);++i)
#define test(x) cout << #x << ' ' << x << endl;
#define eb emplace_back
#define pb push_back
#define mp make_pair 


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

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  int N,D;
  cin >> N >>D;
  
  //main
  
  // output
  cout << (N+2*D)/(2*D+1) << endl;
  
  return 0;
}

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

#define PI 3.141592653589793238
#define INF 1050000000

using namespace std;



//cout << fixed << setprecision(15) << << endl;
//cout << << endl;

int main() {

	int A, B, C, D;

	cin >> A >> B >> C >> D;

	if (A * B >= C * D) {
		cout << A * B << endl;
	}
	else {
		cout << C*D << endl;
	}



	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int flo[4][3][10];

int main() {
#ifdef TEST
    freopen("input", "r", stdin);
#endif

    int num, num1, num2, num3, num4;
    scanf("%d", &num);
    int tmp;
    for(int i = 0; i < num; ++i) {
            scanf("%d %d %d %d", &num1, &num2, &num3, &num4);
            flo[num1 - 1][num2 - 1][num3 - 1] += num4;
    }

    for(int i = 0; i < 3; ++i) {
        for (int j = 0; j < 10; ++j) {
            printf(" %d", flo[0][i][j]);
        }
        printf("\n");
    }

    for (int k = 1; k <= 3; ++k) {
        printf("####################\n");
        for(int i = 0; i < 3; ++i) {
            for (int j = 0; j < 10; ++j) {
                printf(" %d", flo[k][i][j]);
            }
            printf("\n");
        }
    }

    return 0;
}



Measured memory_bytes: 2052
#define ll long long
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include<bits/stdc++.h>
using namespace std;
int main (){
    int r;
    cin >> r;
    cout << 2* r*PI << endl;
    return 0;
}

Measured memory_bytes: 3784
import java.util.*;

public class Main {
	public static void main(String[] args) {  
  		Scanner sc = new Scanner(System.in);
		int start = sc.nextInt();
      	int addNum = sc.nextInt();
      	int end = sc.nextInt();
		int total = 0;
      	for(int i = start; i <= end; i += start) {
        	total += addNum;  
        }
      	System.out.println(total);
    }
}

Measured memory_bytes: 19796
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int s,w;
  cin >> s >> w;
  if(w>=s) {
    cout << "unsafe" << endl;
  }
  else {
    cout << "safe" << endl;
  }
}

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

int main(){
  int N;
  cin >> N;
  
  int x;
  int tmp=N;
  for(int i=0; i<N; i++){
    x+=tmp%10;
    tmp/=10;
  }
  
  if(N%x==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int n;
string s[100010], t;
int main()
{
	cin >> n;
	for(int i = 1; i <= n; i ++)
		cin >> s[i];
	cin >> t;
	int ansl = 1, ansr = 1;
	for(int i = 1; i <= n; i ++)
	{
		bool L = 0, R = 0;
		string x = s[i];
		for(int j = 0; j < x.size(); j ++)
			if(s[i][j] == '?') x[j] = 'z';
		if(x >= t) R = 1;
		for(int j = 0; j < x.size(); j ++)
			if(s[i][j] == '?') x[j] = 'a';
		if(x <= t) L = 1;
		if(L && R) ansr ++;
		else if(L) ansl ++, ansr ++;
	}
	for(int i = ansl; i <= ansr; i ++)
		cout<<i<<" \n"[i==ansr];
        return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include<algorithm>
using namespace std;
int k,l,m,o,n;
pair <int,int> a[100000000];
int main() {
  cin>>n;
  for(k=1;k<=n;k++){
    cin>>a[k].first;
    a[k].second=k;
  };
  sort(a+1,a+1+n);
  for(k=1;k<=n;k++){
    cout<<a[k].second<<" ";
  }
}

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

int main() {
  string b;
  cin >> b;
  if (b == "A") cout << "T" << endl;
  else if (b == "T") cout << "A" << endl;
  else if (b == "G") cout << "C" << endl;
  else cout << "G" << endl;
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
int main()
{
        int hight[10];
        int c;
        for(c=0;c<10;c++)
        {
                scanf("%d",&hight[c]);
        }

        int i,j,k;

        for(i=0;i<10;i++)
        {

                for(j=0;j<9;j++)
                {
                        if(hight[j]<hight[j+1])
                                {
                                k=hight[j];
                                hight[j]=hight[j+1];
                                hight[j+1]=k;
                                }
                }
        }

        printf("%d\n%d\n%d\n",hight[0],hight[1],hight[2]);

        return 0;

}

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

// ll A, B, C;
// scanf("%ld %ld %ld", &A, &B, &C);
// printf("%ld %ld %ld", A, B, C);

int main()
{

    ll A, B, C;
    scanf("%ld %ld %ld", &A, &B, &C);

    printf("%ld %ld %ld", C, A, B);

    return 0;
}


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

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

signed main() {
  long long A,B,C,D; cin >> A >> B >> C >> D;

  long long BB = B - ((B / C) + (B / D) - (B / lcm(C,D)));
  long long AA = A-1 - (((A-1) / C) + ((A-1) / D) - ((A-1) / lcm(C,D)));
  cout <<  BB - AA << endl;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,x,y=map(int,input().split())
    x-=1
    y-=1
    ans=[0]*n
    for i in range(n-1):
        for j in range(i+1,n):
            ans[min(j-i,abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i))]+=1
    for a in ans[1:]:
        print(a)


if __name__=='__main__':
    main()

Measured memory_bytes: 3444
#include <iostream>

using namespace std;

long long N, A, B;

int main(void) {
  cin >> N >> A >> B;
  long long X = (N - 2) * A + A + B;
  long long Y = (N - 2) * B + A + B;
  if (Y - X + 1 <= 0) cout << 0 << endl;
  else cout << Y - X + 1 << endl;
}


Measured memory_bytes: 256