akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T> void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod) { a %= _mod; b %= _mod; ll res = 1; switch(op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break; } if (res < 0) res += _mod; return res; }


int main()
{
        ll X, Y;
        cin >> X >> Y;
        map<ll, ll> mp;
        mp[3] = 100000;
        mp[2] = 200000;
        mp[1] = 300000;

        ll ans = mp[X] + mp[Y];
        if (X == 1 and Y == 1) ans += 400000;

        cout << ans << endl;
}


Measured memory_bytes: 3616
import java.util.*;
import java.util.TreeMap;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Map<Integer, Integer> list = new TreeMap<Integer, Integer>();
    for (int i = 1; i <= N; i++) {
      list.put(sc.nextInt(), i);
    }
    for (Integer key : list.keySet()) {
      System.out.print(list.get(key) + " ");
    }
  }
}


Measured memory_bytes: 71356
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N >> M;
    vi x(N + 1, -1);
    bool flag = 0;
    REP(i, M) {
        int s, c;
        cin >> s >> c;
        if (x[s] == -1) {
            x[s] = c;
        } else {
            if (x[s] == c) {
                continue;
            } else {
                flag = 1;
                break;
            }
        }
    }
    if (x[1] == 0 && N != 1) {
        flag = 1;
    }
    if (x[1] == -1) {
        if (N != 1)
            x[1] = 1;
        else {
            x[1] = 0;
        }
    }
    dump(x);
    if (flag) {
        cout << -1 << endl;
    } else {
        REP(i, N + 1) {
            if (x[i] != -1) {
                ans += x[i] * pow(10, N - i);
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
    char ara[1000];
    char ara1[1000];
    gets(ara);
    gets(ara1);
    if(strcmp(ara,ara1)==0){
            //f=0;
            printf("Yes\n");
            return 0;
        }
    int n=strlen(ara1);
    int f=0;
    for(int i=n-1;i>=0;i-- ){
        char x=ara1[n-1];
        for(int j=n-2;j>=0;j--){
            ara1[j+1]=ara1[j];
        }
        ara1[0]=x;
        if(strcmp(ara,ara1)==0){
            f=0;
            break;
        }
        else f=1;
    }
    if(f==0) printf("Yes\n");
    else printf("No\n");
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <string>

using namespace std;

int main()
{
    string s;
    cin >> s;
    vector<int> v(30,0);
    for (auto& c : s)
    {
        v[c - 'a']++;
    }
    for (int i = 0; i < v.size(); i++) if (v[i] % 2 != 0)
    {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  vll a(3);
  rep(i,3) cin>>a[i];
  vsort(a);
  cout<<a[0]*a[1]/2<<endl;
}

Measured memory_bytes: 256
tails []     = [[]]
tails (x:xs) = [x:xs] ++ tails(xs)

putListLn :: Show a => [a] -> IO ()
putListLn = putStrLn . unwords . map show

getList :: Read a => IO [a]
getList = fmap (map read . words) getLine

insert x [] = [x]
insert x (y:ys)
   | x <= y     = x:y:ys
   | otherwise = y:(insert x ys)

isortStates :: Ord a => [a] -> [[a]]
isortStates l = tail $ zipWith (++) (scanl (flip insert) [] l) (tails l)

main :: IO ()
main = do
  _ <- getLine
  ns <- getList :: IO [Int]
  mapM_ putListLn $ isortStates ns

Measured memory_bytes: 4036
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << a[qwq];\
		else cerr << ", " << a[qwq];\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#endif
template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }

int main() {
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	cout << (n - k + 1) << endl;
	return 0;
}


Measured memory_bytes: 256
#ifndef Local
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:1024000000,1024000000")
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define popCnt(x) (__builtin_popcountll(x))
typedef long long Long;

// gp_hash_table<int, int> table;

const int N = 2e5 + 5;

bool arr[N];

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  int n;
  cin >> n;

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

  vector <int> vec;

  for (int i = n; i >= 1; --i) {
    bool res = arr[i];
    for (int j = 2 * i; j <= n; j += i) {
      res ^= arr[j];
    }
    arr[i] = res;
    if (res) {
      vec.push_back(i);
    }
  }

  cout << vec.size() << endl;
  for (int x : vec) {
    cout << x << endl;
  }



}


Measured memory_bytes: 1912
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int f(const vector<int>& v, int n) {
    if (v.size() == 0 || v[0] > n) return 0;
    int b = 0, e = v.size() - 1;
    while (b < e) {
        int m = (b + e) / 2 + 1;
        if (v[m] > n) {
            e = m - 1;
        } else {
            b = m;
        }
    }
    return b + 1;
}

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    vector<pair<int, int>> vp(m, make_pair(0, 0));
    for (int i = 0; i < m; i++) {
        scanf("%d%d", &vp[i].first, &vp[i].second);
    }
    sort(vp.begin(), vp.end());
    vector<vector<int>> v(n + 1, vector<int>(0));
    for (int i = 0; i < m; i++) {
        v[vp[i].first].push_back(vp[i].second);
    }
    vector<vector<int>> res(n + 1, vector<int>(n + 1, 0));
    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j++) {
            int c = 0;
            for (int k = i; k <= j; k++) {
                c += f(v[k], j);
            }
            res[i][j] = c;
        }
    }
    for (int i = 0; i < q; i++) {
        int l, r;
        scanf("%d%d", &l, &r);
        printf("%d\n", res[l][r]);
    }
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

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

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main()
{
	string s, t;
	cin >> s >> t;

	int n = s.size();
	int m = t.size();

	vi sa(n+1), sb(n+1);
	vi ta(n+1), tb(n+1);

	rep(i, 0, n){
		sa[i+1] = sa[i] + (s[i] == 'A');
		sb[i+1] = sb[i] + (s[i] == 'B');
	}
	rep(i, 0, m){
		ta[i+1] = ta[i] + (t[i] == 'A');
		tb[i+1] = tb[i] + (t[i] == 'B');
	}

	int q;
	cin >> q;
	while(q--){
		int a, b, c, d;
		cin >> a >> b >> c >> d;

		int x = sa[b]-sa[a-1];
		int y = sb[b]-sb[a-1];
		int v = ta[d]-ta[c-1];
		int u = tb[d]-tb[c-1];

		if(x > v or y > u){
			int t = max(x-v, y-u);	
			x -= t;
			y -= t;
		}else{
			int t = min(v-x, u-y);	
			x += t;
			y += t;
		}

		if((v-x)%3 == 0 and (u-y)%3 == 0){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 4096
n,k=map(int,input().split())
a=list(map(int,input().split()))
import numpy as np
a=np.array(a)
temp=np.argmin(a)
import math
if n==k:
  print(1)
else:
  print(math.ceil(temp/(k-1))+math.ceil((n-temp-1-(k-temp-1)%(k-1))/(k-1)))


Measured memory_bytes: 17196
let () = Scanf.scanf "%d\n" @@ fun n ->
  let xys = Array.to_list @@ Array.init n @@ fun _ -> Scanf.scanf "%d %d\n" @@ fun x y -> x, y in
  try
    let odd =
      match
        List.for_all (fun (x, y) -> (x land 1) = (y land 1)) xys,
        List.for_all (fun (x, y) -> (x land 1) <> (y land 1)) xys
      with
      | false, true -> true
      | true, false -> false
      | _, _ -> raise Not_found in
    print_string (if odd then "39\n" else "40\n1 ");
    for i = 38 downto 0 do
      Printf.printf "%d " @@ 1 lsl i
    done;
    print_newline ();
    let solve =
      Array.fold_right (fun d (x, y) ->
        match 0 <= x + y, 0 <= x - y with
        | true, true -> 
            print_char 'R'; (x - d, y)
        | true, false -> 
            print_char 'U'; (x, y - d)
        | false, true -> 
            print_char 'D'; (x, y + d)
        | false, false -> 
            print_char 'L'; (x + d, y)
            ) @@
      Array.init 39 @@ ( lsl ) 1 in
    List.iter (fun (x, y) ->
      ignore (solve
        ( if odd
          then (x, y)
          else (print_char 'L'; (x + 1, y)) ));
      print_newline ()) xys
  with Not_found -> print_endline "-1"


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int n,k,a[10212],sum;
int main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    
	for(int i=1;i<=n-1;i++)
        for(int j=i+1;j<=n;j++){
            if(a[i]<a[j]) swap(a[i],a[j]);
        }
    for(int i=1;i<=k;i++) sum+=a[i];
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<long long> c(100001, 0);
  int a, b;
  rep(i, N) {
    cin >> a >> b;
    c[a] += b;
  }

  rep(i, c.size()) {
    K -= c[i];
    if (K <= 0) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}


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

int main() {
  
  double n, m;
  cin >> n >> m;
  vector <int> vi;
  for (int i = 0, x; i < m; ++i) {
  	cin >> x;
  	vi.push_back(x);
  }

  int s = accumulate(vi.begin(), vi.end(), 0);
  if (s >= n) puts("Yes");
  else puts("No");
  // cout << ceil(n / m) << '\n';
  return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
typedef complex<double> P;
typedef vector<P> G;

double cross(const P& a, const P& b) { return imag(conj(a)*b); }
double dot(const P& a, const P& b) { return real(conj(a)*b); }

enum { OUT, ON, IN };
int contains(const G &g, const P &p) {
  bool in = false;
  for (int i = 0; i < g.size(); ++i) {
    P a = curr(g,i) - p, b = next(g,i) - p;
    if (imag(a) > imag(b)) swap(a, b);
    if (imag(a) <= 0 && 0 < imag(b))
      if (cross(a, b) < 0) in = !in;
    if (cross(a, b) == 0 && dot(a, b) <= 0) return ON;
  }
  return in ? IN : OUT;
}

void input(P &p){
  int x, y; cin >>x >>y;
  p = P(x, y);
}

int main() {
  int N; cin >>N;
  while(N--){
    G g(3);
    REP(i, 3) input(g[i]);
    P a, b;
    input(a); input(b);
    int ac = contains(g, a), bc = contains(g, b);
    cout <<(ac == bc ? "NG" : "OK") <<endl;
  }
  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, 0, n) cin >> d[i];
    bool f = true;
    int now = 0;
    rep(i, 0, n - 1){
        if(now >= i){
            now = max(now, i + d[i] / 10);
        }
    }
    if(now < n - 1) f = false;
    now = n - 1;
    repb(i, n - 1, 1){
        if(now <= i){
            now = min(now, i - d[i] / 10);
        }
    }
    if(now > 0) f = false;
    cout << (f ? "yes" : "no") << endl;
}

Measured memory_bytes: 5204
#include <stdio.h>
#include <stdlib.h>

void s(int *, int *);
void maxheap(int*, int, int);
void buildmaxheap(int*, int);

main(){
int h, i, *A;

scanf("%d", &h);
A = malloc(sizeof(int)*(h+1));
for(i=1; i<=h; i++){
scanf("%d", A+i);
}

buildmaxheap(A, h);
for(i=1; i<=h; i++){
printf(" %d", *(A+i));
}
printf("\n");

free(A);
return 0;
}

void s(int *a, int *b){
int tmp;

tmp = *a;
*a = *b;
*b = tmp;
}

void maxheap(int *A, int h, int i){
int largest = i;
int l = i*2;
int r = i*2 + 1;

if(l<=h && A[l] > A[i]) largest = l;
if(r<=h && A[r] > A[largest]) largest = r;

if(largest != i){
s(A+largest, A+i);
maxheap(A, h, largest);
}
}

void buildmaxheap(int *A, int h){
int i;

for(i=h/2; i >= 1; i--){
maxheap(A, h, i);
}
}

Measured memory_bytes: 2472
import numpy as np
a,b,c=map(int, input().split())
d=[list(map(int,input().split())) for s in range(c)]
e=np.zeros((a,b),dtype=int)
for i in d:
    if i[2]==1:
        for j in range(i[0]):
            for k in range(b):
                e[j][k]=1
    if i[2]==2:
        for j in range(i[0],a):
            for k in range(b):
                e[j][k]=1
    if i[2]==3:
        for j in range(i[1]):
            for k in range(a):
                e[k][j]=1
    if i[2]==4:
        for j in range(i[1],b):
            for k in range(a):
                e[k][j]=1
f=[a]*b-sum(e)
print(sum(f))

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

//#include "rubo.h"
//#define mp make_pair
//#define pb push_back
#define in int
#define ll long long
#define vc vector
#define SQ(j) (j)*(j)
//#define x first
//#define y second

//#define ld long double
#define dbl  long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

#define db(x) cout << #x << " = " << x << endl
#define dbCont(x) cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout << endl;

typedef long double ld;

using namespace std;


const int N = 100 + 5;
const int K = 100*1000 + 5;
const int MOD = 1000*1000*1000+7;
int n,k;
vector<int> a;

int dp[N][K];
int ps[K];


int main() {
    cin >> n >> k;
    loop(i,n){
        int e;
        cin >> e;
        a.push_back(e);
    }


    for(int j = 0; j < K; j++){
        dp[0][j] = (j <= a[0] ? 1 : 0);
    }


    for(int j = 0; j < K; j++){
        ps[j] = (j-1 >= 0 ? ps[j-1] : 0 ) + dp[0][j];
    }


    for(int lastChild = 1; lastChild < n; lastChild++){
        for(int candies = 0; candies <= k; candies++) {

            // O(1)
            int l = max(0,candies - a[lastChild]);
            int r = candies;

            dp[lastChild][candies] =  ps[r] - (l-1 >= 0 ? ps[l-1] : 0);

            dp[lastChild][candies] += MOD;
            dp[lastChild][candies] %= MOD;
        }


        ps[0] = 0;
        for(int j = 0; j < K; j++){
            ps[j] = (j-1 >= 0 ? ps[j-1] : 0 ) + dp[lastChild][j];
            ps[j] %= MOD;
        }
    }

    int res = dp[n-1][k];
    cout << res << endl;

    return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

int main(){
    ll x, y;
    scanf("%lld%lld", &x, &y);
    if(abs(x-y) <= 1) printf("Brown\n");
    else printf("Alice\n");
}

Measured memory_bytes: 256
a = input()
n = int(a)
p = list(map(int,input().split()))
count = 0

for i in range(1,n-1):
    if (p[i-1] < p[i] and p[i] <= p[i+1]) or (p[i+1] < p[i] and p[i] <= p[i-1]):
        count = count + 1
print(count)

Measured memory_bytes: 9176
#include <stdio.h>

main()
{
	int a,b,c,d,M,S;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	M = (a + b + c + d)/60;
	S = (a + b + c + d)%60;
	printf("%d\n",M);
	printf("%d\n",S);
}

Measured memory_bytes: 1024
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if X == 500*a + 100*b + 50*c:
                cnt += 1
print(cnt)

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
int n;
ll calcu(ll x)
{
	ll ans = 0;
	while(x>=10)
	{
		ans += x/10;
		x = x/10 + x%10;
	}
	return ans;
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n;
	ll len = 0, cur = 0;
 	for(int i=1;i<=n;i++)
 	{
 		int d1;
		ll c1;
 		cin >> d1 >> c1;
 		len += c1;
 		cur += c1*d1;
 	}
 	len += calcu(cur) - 1;
 	cout << len;
	return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  // 0のかたまりの数
  int count = 0;
  for(int i = 0; i < N; i++) {
    if(i == 0){
      if(S.at(i) == '0') {
        count++;
      }
    }
    else if(S.at(i) == '0' && S.at(i - 1) == '1') {
      count++;
    }
  }
  if(count <= K) {
    cout << N << endl;
  }
  else {
    // 0のかたまりの右端と左端の位置
    vector<int> L, R;
    for(int i = 0; i < N; i++) {
      if(i == 0) {
        if(S.at(0) == '0') {
          L.push_back(i);
        }
      }
      else if(S.at(i) == '0' && S.at(i - 1) == '1') {
        L.push_back(i);
      }
      if(i == N - 1) {
        if(S.at(i) == '0') {
          R.push_back(i);
        }
      }
      else if(S.at(i) == '0' && S.at(i + 1) == '1') {
        R.push_back(i);
      }
    }
    reverse(L.begin(), L.end());
    //残す0の塊の数
    int a = count - K;
    int ans = 0;
    for(int i = 0; i <= a; i++) {
      //左にi個残す
      int total;
      if(i == 0) {
        total = L.at(a - i - 1);
      }
      else if(i == a) {
        total = N - R.at(i - 1) - 1;
      }
      else {
        total = L.at(a - i - 1) - R.at(i - 1) - 1;
      }
      if(total > ans) {
        ans = total;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3948
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9
#define common cout << "Case #" << w+1 << ": "


int main()
{
    int x;
    cin >> x;
    if(x>=400 and x<600)
        cout << "8" << endl;
    if(x>=600 and x<800)
        cout << "7" << endl;
    if(x>=800 and x<1000)
        cout << "6" << endl;
    if(x>=1000 and x<1200)
        cout << "5" << endl;
    if(x>=1200 and x<1400)
        cout << "4" << endl;
    if(x>=1400 and x<1600)
        cout << "3" << endl;
    if(x>=1600 and x<1800)
        cout << "2" << endl;
    if(x>=1800 and x<2000)
        cout << "1" << endl;
}

Measured memory_bytes: 3628
N=int(input())
arr=[]
for a in range(N):
    a=int(input())
    if a in arr:
        continue
    arr.append(a)

def gcf(a,b):
    if b==0:return a
    return gcf(b,a%b)
def lcm(a,b):
    return a*b//gcf(a,b)

temp=1
for i in range(len(arr)):
    temp=lcm(temp,arr[i])
print(temp)

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

struct land{
    char form;
    int  height;
};
vector<land> map;
vector<int> tamari;

int calc_slash_index(int back_index)
{
    for (int i = back_index + 1; i < map.size(); i++) {
        if (map[i].form == '/' && map[i].height == map[back_index].height) {
            return i;
        }
    }
    return -1;
}

int calc(int back_index, int slash_index)
{
    int ret = slash_index - back_index;
    for (int i = back_index + 1; i < slash_index; i++) {
        if (map[i].form == '\\') {
            int s = calc_slash_index(i);
            ret += s - i;
        }
    }
    return ret;
}

int main()
{
    char c;
    land land_in;
    cin >> land_in.form;
    land_in.height = 0;
    map.push_back(land_in);
    while (cin >> land_in.form) {
        int height_param1;
        int height_param2;
        if (map.back().form == '/') {
            height_param1 = 0;
        } else {
            height_param1 = -1;
        }
        if (land_in.form == '\\') {
            height_param2 = 0;
        } else {
            height_param2 = 1;
        }
        land_in.height = map.back().height + height_param1 + height_param2;
        map.push_back(land_in);
    }

    int total = 0;
    for (int i = 0; i < map.size(); i++) {
        if (map[i].form == '\\') {
            int slash = calc_slash_index(i);
            if (slash == -1) continue;
            int rain = calc(i, slash);
            tamari.push_back(rain);
            total += rain;
            i = slash;
        }
    }
    cout << total << endl;
    cout << tamari.size();
    for (int i = 0; i < tamari.size(); i++) {
        cout << " " << tamari[i];
    }
    cout << endl;
    return 0;
}

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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    string S;
    cin >> S;
    int mi = MOD, ma = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] == 'A')
            mi = min(mi, i);
        if (S[i] == 'Z')
            ma = max(ma, i);
    }
    cout << ma - mi + 1;
}

Measured memory_bytes: 3756
//😄😄😄😄😄😄😄😄😄😄😄😄😄
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define For(i,a,b) for(int i=a;i<b;i++)
#define debug(x) cout<<"DEBUG------> "<<#x<<" -> "<<x<<endl
#define endl "\n"
#define all(x) x.begin(),x.end()

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	int ac = 0, r = 0, t = 0, w = 0;
	string s;
	while (n--) {
		cin >> s;
		if (s[0] == 'A')
			ac++;
		else if (s[0] == 'R')
			r++;
		else if (s[0] == 'T')
			t++;
		else if (s[0] == 'W')
			w++;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << w << endl;
	cout << "TLE x " << t << endl;
	cout << "RE x " << r << endl;

	return 0;
}



Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  string s;
  cin >> s;
  char a,b;
  a=s[0],b=s[1];
  bool ok=false;
  if(a==b)ok=1;
  ll p=1,q=2;
  for(ll i=2;i<s.size();i++){
    char c=s[i];
    if(b==c){
      ok=1;
      p=i;
      q=i+1;
      break;
    }
    if(a==c){
      ok=1;
      p=i-1;
      q=i+1;
      break;
    }
    a=b;
    b=c;
  }

  if(!ok)cout << -1 << " " << -1 << endl;
  else cout << p << " " << q << endl;

}

Measured memory_bytes: 3760
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;

char field[501][501];
// wèµ½ê©çãº¶EÌ}XÉÅÉ»êéL
void solve(){
    int h,w;
    cin>>h>>w;
    for(int i = 0; i < h; i++)
        for(int j = 0; j < w; j++)
            cin>>field[i][j];
    const int dy[]={-1,0,0,1};
    const int dx[]={0,1,-1,0};
    bool update=true;
    int score=0;
    while(update){
        update=false;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(field[i][j]=='.'){
                    map<char,vector<pair<int,int> > > m; 
                    // eûüÖTõ
                    for(int k = 0; k < 4; k++){
                        int x = j + dx[k];
                        int y = i + dy[k];
                        while(1){
                            if(!(x>=0&&y>=0&&y<h&&x<w))
                                break;
                            if(field[y][x]!='.'){
                                m[field[y][x]].push_back(make_pair(y,x));
                                break;
                            }
                            x+=dx[k];y+=dy[k];
                        }
                    }
                    // ñÂÈãÌÀWªüÁÄ¢éêª êÎAí
                    for(map<char,vector<pair<int,int> > >::iterator it = m.begin();it!=m.end();it++){
                        if(it->second.size()>=2){
                            update=true;
                            for(int k = 0; k < it->second.size(); k++){
                                field[it->second[k].first][it->second[k].second]='.';
                                score++;
                            }
                        }
                    }
                }
            }
        }
    }
    cout<<score<<endl;
}
int main(){
    solve();
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
//#include "../cxx-prettyprint/prettyprint.hpp"

int main() {
    int N;
    std::cin >> N;

    std::vector<std::string> cards(N);
    for (int i = 0; i < N; i ++) {
        std::cin >> cards[i];
    }

    // バブルソート
    auto cards_B = cards;
    for (int i = 0; i < N; i ++) {
        for (int j = N - 1; j > i; j --) {
            if (cards_B[j][1] < cards_B[j-1][1]) {
                std::swap(cards_B[j], cards_B[j-1]);
            }
        }
    }
    for (int i = 0; i < N; i ++) {
        if (i > 0) std::cout << " ";
        std::cout << cards_B[i];
    }
    std::cout << std::endl;
    std::cout << "Stable" << std::endl;

    // 選択ソート
    auto cards_S = cards;
    for (int i = 0; i < N; i ++) {
        int minj = i;
        for (int j = i; j < N; j ++) {
            if (cards_S[j][1] < cards_S[minj][1]) {
                minj = j;
            }
        }
        std::swap(cards_S[i], cards_S[minj]);
    }
    for (int i = 0; i < N; i ++) {
        if (i > 0) std::cout << " ";
        std::cout << cards_S[i];
    }
    std::cout << std::endl;
    std::cout << (cards_S == cards_B ? "Stable" : "Not stable") << std::endl;
}



Measured memory_bytes: 3220
#include<stdio.h>

int main(void){
	
	int W,H,x,y,r;
	int ue,sita,migi,hidari;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	
	ue = y+r;
	sita = y-r;
	migi = x+r;
	hidari = x-r;
	
	if((ue>H)||(sita<0)||(migi>W)||(hidari<0)){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	
	
	
	
	return 0;
	
}

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

#define BIG 2000000007

#define MOD 1000000007
typedef unsigned long long ull;
typedef   signed long long sll;


#define N_MAX 200000
#define M_MAX 200000

ull n, m;
ull a[N_MAX];
ull b[N_MAX];

void swap_adj(ull *a, ull *b){
	ull tmp = *b;
	*b = *a;
	*a = tmp;
	return;
}

int comp(const void *a, const void *b){
	if (*(ull*)a < *(ull*)b) {
		return -1;
	} else if (*(ull*)a > *(ull*)b) {
		return +1;
	} else {
		return 0;
	}
}

ull divide(ull a, ull b){
	ull x = MOD - 2;
	ull ans = 1;
	while (x) {
		if (x & 1) ans = (ans * b) % MOD;
		b = (b * b) % MOD;
		x /= 2;
	}
	return (a * ans) % MOD;
}

int digits(ull x){
	int i = 1;
	while (x >= 10) {
		x /= 10;
		i++;
	}
	return i;
}

int nibutan(ull x, int begin, int end){
	while (begin + 1 < end) {
		int med = (begin + end) / 2;
		if (b[med] < x) {
			begin = med;
		} else {
			end = med;
		}
	}
	if (b[begin] < x) {
		return begin;
	} else {
		return begin - 1;
	}
}

int solve(){
	int i, j;
	ull x = 0;

	for (i = 0; i < n; i++) {
		b[i] = BIG;
	}
	
	for (i = 0; i < n; i++) {
		if (!i) {
			b[0] = a[0];
			x++;
			continue;
		}
		int index = nibutan(a[i], 0, x);
		b[index + 1] = a[i];
		if (index + 1 == x) x++;

	}

	printf("%llu\n", x);

	return 0;
}

int main(void){
	ull i;

	scanf("%llu%llu", &n, &m);

	for (i = 0; i < m; i++) {
		ull x, y;
		scanf("%llu%llu", &x, &y);
		if (x == 1) {
			a[y - 1] = 1;
		}
		if (y == n) {
			b[x - 1] = 1;
		}
	}

	for (i = 0; i < n; i++) {
		if (a[i] && b[i]) {
			goto poss;
		}
	}
	printf("IM");
	poss:
	puts("POSSIBLE");

	// solve();

	return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>
char p[101000], q[5][10]={"dream","dreamer","erase","eraser"};
int D[101000], L[5]={5,7,5,6};
int main(){
    int i, j, k;
    scanf("%s",p+1);
    D[0]=1;
    for(i=1;p[i];i++){
        for(j=0;j<4;j++){
            if(i < L[j])continue;
            for(k=0;k<L[j];k++){
                if(p[i-L[j]+k+1] != q[j][k])break;
            }
            if(k==L[j]){
                D[i] |= D[i-L[j]];
            }
        }
    }
    puts(D[i-1]?"YES":"NO");
}


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

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

    vector<int> ans(n);
    int a, b;
    for (auto i = 0; i < m; i++) {
        cin >> a >> b;
        ans[a - 1]++;
        ans[b - 1]++;
    }

    for (auto i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define INF 1<<64
#define sf(a) scanf("%d",&a)
using namespace std;
int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
typedef pair<int,int> pii;
vector<pii> vii;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    str s;
    cin >> s;
    int S=0,N=0,E=0,W=0;
    bool yes=false;
    for(int i=0;i<s.size();i++){
        if(s[i]=='S')S=1;
        else if(s[i]=='N')N=1;
        else if(s[i]=='E')E=1;
        else if(s[i]=='W')W=1;
    }
    if(S==N&&E==W)yes=true;
    if(yes){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int r[200];

int main() {
	int N;
	scanf("%d", &N);
	rep(i, N * (N - 1) / 2) {
		int a, b, c, d;
		scanf("%d %d %d %d", &a, &b, &c, &d);
		if(c == d) {
			++r[a]; ++r[b];
		}
		else if(c > d) r[a] += 3;
		else if(c < d) r[b] += 3;
	}
	FOR(i, 1, N + 1) {
		int cnt = 1;
		FOR(j, 1, N + 1) if(i != j && r[i] < r[j]) ++cnt;
		printf("%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 3220
K = int(input())
As = list(map(int, input().split()))

# answer will be "{lo} {hi}"
lo = 2
hi = 2
for A in reversed(As):
    if (hi // A) - ((lo - 1) // A) == 0:
        print(-1)
        exit()
    lo = (lo + A - 1) // A * A
    hi = (hi // A + 1) * A - 1 

print(lo, hi)

Measured memory_bytes: 20476
#include<iostream>
#include<string>
using namespace std;
 
int main(void){
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  int *sum_W = new int[N+1];
  int *sum_E = new int[N+1];
  for(int i=0;i<=N;i++){
  	sum_W[i]=0;
    sum_W[i]=0;
  }
  
  //累積和を計算
  for(int i=0;i<N;i++){
    if(S.at(i)=='E'){
      sum_E[i+1]=sum_E[i]+1;
      sum_W[i+1]=sum_W[i];
    }else{
      sum_E[i+1]=sum_E[i];
      sum_W[i+1]=sum_W[i]+1;
    }
  }
  
  int min=N;
  for(int i=1;i<=N;i++){
    int sum= sum_W[i-1]+sum_E[N]-sum_E[i];
    if(min>sum) min=sum;
  }
  cout << min <<endl;
  return 0;
}

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

using namespace std;

using ll = long long;

int main() {

	ll N;
	cin>>N;
	vector<double> p(N+1);
	for (int i = 1;i <= N;++i) {
		cin>>p[i];
	}

	vector<vector<double>> dp(3000, vector<double>(3000, 0));
	dp[0][0] = 1;
	for (int i = 1;i <= N;++i) {
		dp[i][0] = dp[i-1][0] * (1-p[i]);
		dp[i][i] = dp[i-1][i-1] * p[i];
		for (int j = 1;j < i;++j) {
			dp[i][j] = dp[i-1][j] * (1-p[i]) + dp[i-1][j-1] * p[i];
		}
	}

	double ans = 0;
	for (int i = N/2 + 1;i <= N;++i) {
		ans += dp[N][i];
	}

	cout<<setprecision(10);
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 70784
n = int(input())
a = input().split()
b = [str(i) for i in range(1, n+1)]
d = {}

for s in a:
  if s in d:
    d[s] = d[s] + 1
  else:
    d[s] = 1

for i in b:
  if i in d:
    print(d[i])
  else:
    print(0)


Measured memory_bytes: 53680
#include <stdio.h>
#include <string.h>

int main(){
  int a,b,c;
  char s[10];
  while(scanf("%d%d",&a,&b) != EOF){
    c = a+b;
    sprintf(s,"%d",c);
    printf("%d\n",(int)strlen(s));
  }
  return 0;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------

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

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

  string s; cin >> s;
  int w; cin >> w;
  rep(i,s.size()){
    if(i%w==0) cout << s[i];
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 256
/*

#      #      #####   ##   ##  #####      ##     #  #      #   #  #####
#      #      #   #  #  ###  # #          # ##   #  #      #   #  #   #
#      #      #   #  #   #   # #          #  ##  #  #      #   #  #   #
#      #      #   #   #     #  #####      #   #  #  #       ###   #####
#      #      #   #    #   #   #          #  ##  #  #        #    #   #
#      #      #   #     ###    #          # ##   #  #        #    #   #
#      #####  #####      #     #####      ##     #  #####    #    #   #

*/

#include <bits/stdc++.h>

using namespace std;

#define f first
#define s second
#define pb push_back
#define np next_permutation
#define bs binary_search
#define mp make_pair
#define all(x) x.begin(), x.end()
#define bp __builtin_popcountll
#define sqr(x) ((llong)sqrt (x))
#define b_ctz __builtin_ctzll
#define b_clz __builtin_clzll

#define y1 road_to_respa_top_6
#define prev road_to_respa_top_6
#define Abdrakhman abcdefghijklmnopqrstuvwxyzRakhman
#define left kotoriy_levee_chem_right
#define right kotoriy_pravee_chem_left

#define android ios_base::sync_with_stdio(0), cin.tie (0), cout.tie (0)
#define fn ""

typedef long long llong;
typedef long double ldouble;
typedef unsigned long long ullong;

typedef vector <int> vi;
typedef vector <string> vs;
typedef vector <vector <llong> > matrix;

typedef pair <llong, llong> pll;

typedef map <int, int> mii;

typedef set <llong> sl;

const llong MXN = 1e6 + 1;
const llong MNN = 1e3 + 1;
const llong MOD = 1e9 + 7;
const llong INF = 1e18;
const llong MAGIC = 1000;
const ldouble EPS = 1e-9;
const ldouble PI = 3.1415926536;
const string TIME = "rovno_ushten_push_ketti";

inline llong log2 (llong x) {return 64 - b_clz (x) - 1;};
inline llong __lcm (llong a, llong b) {return a / __gcd (a, b) * b;};

int n, sum, mx = -1;

int main () {
    android;
    //freopen ("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i ++) {
        int x;
        cin >> x;
        sum += x;
        mx = max (mx, x);
    }
    cout << sum - mx + (mx / 2);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	string s;
	cin >> s;
	cout << s.substr(0, 3) << endl;
}


Measured memory_bytes: 3012
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
//#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  bitset<64> bit(0);
  int n;
  cin>>n;
  vector<bitset<64>> mask(n,bitset<64>(0));
  rep(i,n){
    int m;
    cin>>m;
    while(m--){
      int k;
      cin>>k;
      mask[i].set(k);
    }
  }

  int q;
  cin>>q;
  while(q--){
    int c;
    cin>>c;
    if(c==0){
      int i;
      cin>>i;
      cout<<bit[i]<<endl;
    }if(c==1){
      int m;
      cin>>m;
      bit|=mask[m];
    }if(c==2){
      int m;
      cin>>m;
      bit&=(~mask[m]);
    }if(c==3){
      int m;
      cin>>m;
      bit=bit^mask[m];
    }if(c==4){
      int m;
      cin>>m;
      cout<<((bit&mask[m])==mask[m])<<endl;
    }if(c==5){
      int m;
      cin>>m;
      cout<<(bit&mask[m]).any()<<endl;
    }if(c==6){
      int m;
      cin>>m;
      cout<<(((~bit)&mask[m])==mask[m])<<endl;
    }if(c==7){
      int m;
      cin>>m;
      cout<<(bit&mask[m]).count()<<endl;
    }if(c==8){
      int m;
      cin>>m;
      cout<<(bit&mask[m]).to_ullong()<<endl;
    }

  }



}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
typedef v(string) vs;

vs s3 = {
  "aab",
  "c.b",
  "cdd"};
vs s4 = {
  "aacd",
  "bbcd",
  "efgg",
  "efhh"};
vs s5 = {
  "abc..",
  "abc..",
  "gghdd",
  "i.hee",
  "ijjff"};
vs s7 = {
  "abc....",
  "abc....",
  "...deff",
  "...degg",
  "kkl..hh",
  "m.lii..",
  "mnnjj.."};

int main() {
  int n;
  scanf("%d",&n);
  if (n <= 2) dame;
  vs ans(n,string(n,'.'));
  int ni = 0;
  auto add = [&](vs& s) {
    int m = sz(s);
    rep(i,m)rep(j,m) {
      ans[ni+i][ni+j] = s[i][j];
    }
    ni += m;
  };
  if (n%3 == 0) {
    while (ni < n) add(s3);
  } else if (n == 7) {
    add(s7);
  } else if (n == 11) {
    add(s7);
    add(s4);
  } else {
    int n5 = 0;
    while ((n-n5*5)%4) ++n5;
    rep(i,n5) add(s5);
    while (ni < n) add(s4);
  }
  rep(i,n) {
    cout<<ans[i]<<endl;
  }
  return 0;
}






















Measured memory_bytes: 2304
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n, k; rd(n, k);
  auto a=readln.split.to!(long[]);

  long[] b, c;
  foreach(x; a){
    if(x<0) b~=-x;
    else if(x==0) k--;
    else c~=x;
  }
  b.sort!"a<b";
  if(k==0){
    writeln(0);
    return;
  }

  long f(){
    if(b.length==0 && c.length==0){
      return 0;
    }
    if(b.length==0){
      return c[k-1];
    }
    long ret=1_000_000_000_000_000_000;
    if(k-1<c.length){
      ret=min(ret, c[k-1]);
    }
    foreach(i; 0..k){
      if(i<b.length && 0<=k-i-2 && k-i-2<c.length){
        ret=min(ret, b[i]*2+c[k-i-2]);
      }
    }
    return ret;
  }

  auto ans=f();
  swap(b, c);
  ans=min(ans, f());
  writeln(ans);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


Measured memory_bytes: 7220
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
    public void run() throws Exception {
    	//StringBuilder sb = new StringBuilder();

    	int n1 = sc.nextInt();
    	int n2 = sc.nextInt();
    	int n3 = sc.nextInt();
    	long anw = 0;
    	if(n2 > n3){
    		System.out.println(anw);
    		return;
    	}

    	if(n1 == 1){
    		if (n2 == n3){
            	anw = 1;
    		}else {
    			anw = 0;
    		}
    	}else if (n1 == 2){
    		anw = 1;
    	}else {
        	long min = (long) n2*(n1-1) + (long) n3;
        	long max = (long) n3*(n1-1) + (long) n2;
        	anw = max - min + 1;
    	}
    	System.out.println(anw);
    }
    public static void main(String[] args) throws Exception {
        new Main().run();
    }
}

Measured memory_bytes: 23764