akhauriyash/Code-Regression huggingface dataset:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


h,w = map(int, input().split())
a = [None]*h
for i in range(h):
    a[i] = input()
dp = [[0]*(w+1) for _ in range(h+1)]
dp[1][1] = 1
M = 10**9+7
for i in range(1,h+1):
    for j in range(1,w+1):
        if i==1 and j==1:
            continue
        if a[i-1][j-1]==".":
            dp[i][j] = dp[i-1][j] + dp[i][j-1]
            dp[i][j] %= M
print(dp[h][w])

Measured memory_bytes: 76352
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

using namespace std;

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++)

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int> > VVi;
typedef vector<vector<ll> > VVl;

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

const ll MAX_A = 1e6;
const int MAX_N = 2e5;
Vl F, A;
ll K;
int N;

void init()
{
	cin >> N >> K;
	A.resize(N);
	F.resize(N);

	REP(i, N) cin >> A[i];
	REP(i, N) cin >> F[i];

	sort(ALL(A));
	sort(ALL(F));
}

bool check(ll t)
{
	Vl tmpA(N);
	REP(i, N)
	{
		tmpA[i] = t / F[i];
	}

	sort(ALL(tmpA));

	ll x = 0;
	REP(i, N)
		x += max((ll)0, A[i] - tmpA[i]);

	return x <= K;
}

int main()
{
	init();
	ll ng = -1, ok = MAX_A * MAX_A * 2+ 1;
	while (ok - ng > 1)
	{
		auto mid = (ng + ok) / 2;

		if (check(mid))
			ok = mid;
		else
			ng = mid;
	}

	cout << ok << endl;
}


Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int cur;
    int ans = 1;
    cin >> cur;
    int curmin = cur;
    for (int i = 1; i < n; ++i)
    {
       cin >> cur;
       if (cur <= curmin)
       {
           ans++;
           curmin = cur;
       }
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
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; }
ll gcd (ll a, ll b){ return b == 0? a : gcd(b, a % b); }
ll lcm (ll a, ll b){ return a * (b / gcd(a, b));}

void solve(long long X){
    ll R = lcm(X, 360);
    cout<<R/X<<endl;
}
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll Mod=1e9+7;
int w[61][61];
ll dp[61][61];
ll lth[61][61];
ll edge[61][61];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	ll len;
	cin>>n>>len;
	for(int i=1;i<=n;++i){
		dp[i][i]=1;
		for(int j=1;j<=n;++j){
			cin>>edge[i][j];
		}
	}
	while(len){
		if(len&1){
			memset(lth,0,sizeof(lth));
			for(int i=1;i<=n;++i){
				for(int j=1;j<=n;++j){
					for(int k=1;k<=n;++k){
						(lth[i][k]+=dp[i][j]*edge[j][k])%=Mod;
					}
				}
			}
			memcpy(dp,lth,sizeof(dp));
		}
		memset(lth,0,sizeof(lth));
		for(int i=1;i<=n;++i){
			for(int j=1;j<=n;++j){
				for(int k=1;k<=n;k++){
					(lth[i][k]+=edge[i][j]*edge[j][k])%=Mod;
				}
			}
		}
		memcpy(edge,lth,sizeof(edge));
		len>>=1;
	}
	ll s=0;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			(s+=dp[i][j])%=Mod;
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 384
def josushi(N):
  h_set = ("2","4","5","7","9")
  p_set = ("0","1","6","8")
  b_set = ("3")
  
  if N[-1] in h_set:
    return "hon"
  elif N[-1] in p_set:
    return "pon"
  else:
    return "bon"


N = input()
ans = josushi(N)
print(ans)

Measured memory_bytes: 9024
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var S string
	fmt.Scan(&S)
	A, _ := strconv.Atoi(S[:2])
	B, _ := strconv.Atoi(S[2:])

	if 1 <= A && A <= 12 && 1 <= B && B <= 12 {
		fmt.Println("AMBIGUOUS")
	} else if A > 12 || A == 0 {
		// A must be a year
		if 1 <= B && B <= 12 {
			fmt.Println("YYMM")
		} else {
			fmt.Println("NA")
		}
	} else { // 1 <= A <= 12
		if B > 12 || B == 0 {
			fmt.Println("MMYY")
		} else {
			fmt.Println("NA")
		}
	}
}


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

using namespace std;

const int N = 3030, mod = 1e9 + 7;

int a[N][N];
int b[N][N];
int s[N];

long long powmod(long long b, long long p) {
  long long r = 1;
  for (; p; p >>= 1, b = b * b % mod)
    if (p & 1)
      r = r * b % mod;
  return r;
}

int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  for (int i = 0; i < n; ++i)
    scanf("%d", s+i);
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      if (s[i] < s[j])
        b[i][j] = 1;
      if (s[i] > s[j])
        a[i][j] = 1;
    }
  }
  int inv2 = (mod + 1) / 2;
  for (int it = 0; it < q; ++it) {
    int l, r;
    scanf("%d %d", &l, &r);
    --l, --r;
    if (l > r)
      swap(l, r);
    for (int i = 0; i < l; ++i) {
      a[i][l] = a[i][r] = 1LL * (a[i][l] + a[i][r]) * inv2 % mod;
      b[i][l] = b[i][r] = 1LL * (b[i][l] + b[i][r]) * inv2 % mod;
    }
    for (int i = l+1; i < r; ++i) {
      a[l][i] = b[i][r] = 1LL * (a[l][i] + b[i][r]) * inv2 % mod;
      a[i][r] = b[l][i] = 1LL * (b[l][i] + a[i][r]) * inv2 % mod;
    }
    for (int i = r+1; i < n; ++i) {
      a[l][i] = a[r][i] = 1LL * (a[l][i] + a[r][i]) * inv2 % mod;
      b[l][i] = b[r][i] = 1LL * (b[l][i] + b[r][i]) * inv2 % mod;
    }
    a[l][r] = b[l][r] = 1LL * (a[l][r] + b[l][r]) * inv2 % mod;
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      ans = (ans + a[i][j]) % mod;
    }
  }
  ans = ans * powmod(2, q) % mod;
  if (ans < 0) ans += mod;
  printf("%lld\n", ans);
  return 0;
}

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

int main(){

    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];
    for(int i = 0; i < N; i++) cin >> C[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    long long ans = 0;
    for(int i = 0; i < N; i++){
        long long num_a = distance(A.begin(), lower_bound(A.begin(), A.end(), B[i]));
        long long num_c = distance(upper_bound(C.begin(), C.end(), B[i]), C.end());
        ans += num_a * num_c;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
module mod_black_or_white
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer(8) :: f(0:200000), invf(0:200000), invp(0:200000)
contains
  subroutine init(n)
    implicit none
    integer, intent(in) :: n
    integer :: i
    integer(8) :: p
    f = 0_8
    invf = 0_8
    f(0) = 1_8
    p = 1_8
    do i = 1, n
      f(i) = mod(f(i-1)*int(i,8),md)
      p = mod(p*2_8,md)
    end do
    invf(n) = inv(f(n))
    invp(n) = inv(p)
    do i = n, 1, -1
      invf(i-1) = mod(invf(i)*int(i,8),md)
      invp(i-1) = mod(invp(i)*2_8,md)
    end do
    return
  end subroutine init
  integer(8) function perm(n,k)
    implicit none
    integer, intent(in) :: n, k
    perm = 0_8
    if (n.lt.0.or.k.gt.n) return
    perm = mod(f(n)*invf(n-k),md)
    return
  end function perm
  integer(8) function comb(n,k)
    implicit none
    integer, intent(in) :: n, k
    comb = mod(perm(n,k)*invf(k),md)
    return
  end function comb
  function inv(n) result(y)
    implicit none
    integer(8), intent(in) :: n
    integer(8) :: a, b, x, y, t, q
    a = mod(n,md)
    b = md
    x = 0
    y = 1
    do while(b.ne.0_8)
      q = a/b
      t = b
      b = mod(a,b)
      a = t
      t = y
      y = x
      x = t-q*x
    end do
    do while (y.lt.0_8)
      y = y+md
    end do
    y = mod(y,md)
    return
  end function inv
end module mod_black_or_white
program black_or_white
  use mod_black_or_white
  implicit none
  integer :: b, w, i
  integer(8) :: x = 0_8, y = 0_8
  read(*,*) b, w
  call init(b+w)
  do i = 1, b+w
    write(*,'(i0)') mod(mod(md+1_8-x+y,md)*invp(1),md)
    x = mod(x+comb(i-1,b-1)*invp(i),md)
    y = mod(y+comb(i-1,w-1)*invp(i),md)
  end do
  stop
end program black_or_white

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

typedef long long ll;
using namespace std;

ll Mod = 1e9 + 7;
int main()
{
    int N, M;
    bool isPossible = false;
    cin >> N >> M;
    vector <int> a(N, 0), b(N, 0);
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        if (x == 1) a[y] = 1;
        if (y == N) b[x] = 1;
    }
    for (int i = 0; i < N; i++) {
        if (a[i] * b[i]) isPossible = true;
    }

    if (isPossible) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  int n, a;
  cin >> n >> a;
  vi x(n);
  rep(i,n) cin >> x[i];

  vector<vl> dp(n + 1, vl(n*50+1, 0));
  dp[0][0] = 1;

  rep(i, n) {
    rrep(k, n) {
      rep(j, n*50) {
	if (j + x[i] > n*50) {
	  break;
	}
	dp[k+1][j + x[i]] += dp[k][j];
      }
    }
  }

  ll ans = 0;
  rep(i, n){
    ans += dp[i+1][(i+1) * a];
  }
  cout << ans << endl;
}


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

using namespace std;

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

    vector<bool> ac = vector<bool>(n, false);
    vector<int> wa_count = vector<int>(n, 0);

    int penalty = 0;
    for (int i = 0; i < m; i++) {
        int pi;
        string si;
        cin >> pi >> si;
        if (ac[pi-1]) continue;
        if (si == "AC") {
            ac[pi-1] = true;
            penalty += wa_count[pi-1];
        }
        if (si == "WA")
            wa_count[pi-1]++;
    }

    int sum_ac = 0;
    int sum_wa = 0;
    for (int i = 0; i < n; i++) {
        if (ac[i]) sum_ac++;
        sum_wa += wa_count[i];
    }

    cout << sum_ac << " " << penalty << endl;

    return 0;
}


Measured memory_bytes: 640
import math
N, M = map(int, input().split())

if abs(N - M) >= 2:
    print(0)
elif abs(N - M) == 1:
    print((math.factorial(N) * math.factorial(M)) % (10 ** 9 + 7))
else:
    print(2 * math.factorial(N) * math.factorial(M) % (10 ** 9 + 7))

Measured memory_bytes: 5176
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int h, n;
  cin >> h >> n;
  int as = 0;
  F0R(i, n) {
    int a; cin >> a;
    as += a;
  }

  cout << ((as >= h) ? "Yes" : "No");
}
#endif


Measured memory_bytes: 256
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef long long ll;
const int MYINF = 1e9+7;

#define HSIZE 10009

typedef enum {
	NEXT_A,
	NEXT_C,
	NEXT_G,
	NEXT_T,
	NEXT_NUL, // NUL
} next_e;

int getidx(char c) {
	switch (c) {
	case 'A': return NEXT_A; break;
	case 'C': return NEXT_C; break;
	case 'G': return NEXT_G; break;
	case 'T': return NEXT_T; break;
	default:
		  fprintf(stderr, "Invalid char %c\n", c);
		  exit(1);
	}
}

typedef struct node_st {
	struct node_st *next[sizeof(next_e)];
} node_t;

void *xmalloc(size_t s) {
	void *p = malloc(s);
	if (p == NULL) {
		fprintf(stderr, "malloc failed\n");
		exit(1);
	}
	return p;
}

node_t *node_new() {
	node_t *p = xmalloc(sizeof(node_t));
	memset(p, 0, sizeof(node_t));
	return p;
}

node_t root_node, term_node;
node_t *dict = &root_node;
node_t *nul = &term_node;

void node_insert(node_t *n, const char *s) {
	char c = s[0];
	int i;
	if (c == '\0') {
		n->next[NEXT_NUL] = nul;
		return;
	}
	i = getidx(c);
	if (!n->next[i]) n->next[i] = node_new();
	node_insert(n->next[i], s + 1);
}

int node_search(node_t *n, const char *s) {
	char c = s[0];
	int i;
	if (c == '\0') {
		return n->next[NEXT_NUL] == nul;
	}
	i = getidx(c);
	if (n->next[i]) return node_search(n->next[i], s + 1);
	else return 0;
}

void insert(const char *s) {
	node_insert(dict, s);
}

int search(const char *s) {
	return node_search(dict, s);
}

int main(int argc, char **argv)
{
	int i, n;
	char cmd[8], s[16];

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %s", cmd, s);
		if (strcmp(cmd, "insert") == 0) {
			insert(s);
		} else {
			if (search(s)) puts("yes");
			else puts("no");
		}
	}
		
	return 0;
}

Measured memory_bytes: 16888
/*Author : Hrishi*/

/*When I wrote this, only God and I understood what I was doing.
Now, only God knows.*/

#include <bits/stdc++.h>

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int,int>
#define pl pair<ll,ll> 
#define ff first
#define ss second
#define PB push_back
#define F(i,L,R) for(auto i=L; i<R ;i++)
#define FR(i,R,L) for(auto i=R;i>L;i--)
#define all(x) (x).begin(),(x).end()
#define show(x) cout<<(#x)<<" = "<<(x)<<"\n";
#define show2(x,y) cout<<(#x)<<" = "<<(x)<<" & "<<(#y)<<" = "<<(y)<<"\n";
#define show3(x,y,z) cout<<(#x)<<" = "<<(x)<<" & "<<(#y)<<" = "<<(y)<<" & "<<(#z)<<" = "<<(z)<<"\n";
#define endln "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define M 1000000007

using namespace std;

bool dp[105][100010];// dp(i,j) = True if first i numbers of arr are considered and Player playing first can win if no of stones(k) is j
int arr[105];

int n,k;

int main() 
{
	fastio;
	cin>>n>>k;
	
    F(i,0,n)
        cin>>arr[i+1];
    
    F(i,0,n+1)
        dp[i][0] = false;
    
    F(j,0,k+1)
    {
        dp[0][j] = false;
    }
    
    F(i,1,n+1)
    {
        F(j,1,k+1)
        {
            F(x,1,i+1)
            {
                
                if(j-arr[x] < 0)
                {
                    dp[i][j] = dp[i-1][j];
                    break;
                }
                else if(dp[i][j-arr[x]] == false)
                {
                    dp[i][j] = true;
                    break;
                }
                else dp[i][j] = false;
            }
        }
    }
    
    if(dp[n][k]) cout<<"First";
    else cout<<"Second";
}




Measured memory_bytes: 10496
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <stack>
#include <queue>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
// static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

// template <class T> inline void chadd(T &a, const T &b) {
//   a += b, a %= MOD;
//   // TODO minus case
// }

template <class T>
std::ostream &operator<<(std::ostream &stream, const std::vector<T> &vec) {
  for (auto val : vec) {
    if (std::is_fundamental<T>::value)
      stream << " " << val;
    else
      stream << std::endl << val;
  }
  return stream;
}

using namespace std;
const int MOD = 1e9 + 7;

vector<long long> fact_inv, inv;

/*  init_nCk :二項係数のための前処理
    計算量:O(k)
*/
void init_nCk(int SIZE) {
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
}

/*  nCk :MODでの二項係数を求める(前処理 int_nCk が必要)
    計算量:O(k)
*/
long long nCk(int n, int k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    long long ans = 1;
    for (int i = n; i >= n - k + 1; i--) {
        ans *= i;
        ans %= MOD;
    }
    return ans * fact_inv[k] % MOD;
}

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

  init_nCk(1000000);
  // std::cout << nCk(n, a) << std::endl;

  long long res = 0;
  res += modpow(2, n, MOD) - 1;
  res -= nCk(n, a);
  if (res < 0)
    res += MOD;
  res -= nCk(n, b);
  if (res < 0)
    res += MOD;
  std::cout << res << std::endl;

  return 0;
}


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

#define x first
#define y second
#define pb push_back
#define mp make_pair

#define all(a) (a).begin(), (a).end()

#define ll long long
#define ld long double

bool check(vector<int> & seq, vector<int> & start) {
    for (int i=0; i<seq.size(); i++) {
        if ((seq[i] ^ seq[(i + 1) % seq.size()] ^ seq[(i + 2) % seq.size()]) != 0) return 0;
    }
    sort(all(seq));
    sort(all(start));
    return start == seq;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    map<int,int> cnt;
    vector<int> start(n);
    for (int i=0; i<n; i++) {
        cin >> start[i];
        cnt[start[i]]++;
    }
    if(cnt.size()>4){
        cout<<"No\n";
        return 0;
    }
    for (auto x:cnt) {
        for (auto y:cnt) {
            for (auto z:cnt) {
                vector<int> seq;
                for (int i=0; i<n; i++) {
                    if (i%3 == 0) seq.pb(x.x);
                    if (i%3 == 1) seq.pb(y.x);
                    if (i%3 == 2) seq.pb(z.x);
                }
                if (check(seq, start)) {
                    cout << "Yes\n";
                    return 0;
                }
            }
        }
    }
    cout << "No\n";
    return 0;
}


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

int main() {

    int n;cin>>n;
    int ac,wa,tle,re;
    ac=wa=tle=re=0;
    string* verdicts = new string[n];
    for (int i = 0; i < n; i++)
    {
        cin>>verdicts[i];
        if(verdicts[i]=="AC")
        {
            ac++;
        }
        if(verdicts[i]=="WA")
        {
            wa++;
        }
        if(verdicts[i]=="TLE")
        {
            tle++;
        }
        if(verdicts[i]=="RE")
        {
            re++;
        }
        
    }

    cout<<"AC "<<"x "<<ac<<endl;
    cout<<"WA "<<"x "<<wa<<endl;
    cout<<"TLE "<<"x "<<tle<<endl;
    cout<<"RE "<<"x "<<re<<endl;

    
    return 0;
}

Measured memory_bytes: 6688
#include<stdio.h>

typedef struct {
	char m_aLetter[4];
}Squares_t;

void DisplayLetter(Squares_t* a_pstSquares);

int main(void) {
	//構造体変数の定義
	Squares_t astSquares[3];

	//変数に文字を入力
	scanf("%s", &astSquares[0].m_aLetter);
	scanf("%s", &astSquares[1].m_aLetter);
	scanf("%s", &astSquares[2].m_aLetter);
	
	DisplayLetter(astSquares);

	return 0;
}

/**********
*3行3列に並んだアルファベットの中で左上、中央、右下の3つを順番に表示する関数
*　Squares_t* a_pstSquares　入力される文字の構造体
*/
void DisplayLetter(Squares_t* a_pstSquares) {
	int i;
	printf("\n");
	//並んだアルファベットの中で左上、中央、右下の3つを順番に表示
	for (i = 0; i < 3; i++) {
		printf("%c", a_pstSquares[i].m_aLetter[i]);
	}
	printf("\n");

	return ;
}

Measured memory_bytes: 2060
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
typedef pair<int,int> pr;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

//kruskal  use Union_find


vector<int> i2g;          // i2g[i] := アイテム i の所属するグループの番号(find)
vector<vector<int>> g2i;  // g2i[g] := グループ g に所属するアイテムたち

void union_init(int n) {
  i2g.resize(n);
  g2i.resize(n);
  for (int i = 0; i < n; ++i) {
    // 最初はアイテム i はグループ i に所属
    i2g[i] = i;
    g2i[i].assign(1, i);
  }
}

// アイテム ia の所属するグループとアイテム ib の所属するグループを 1 つにする
void merge(int ia, int ib) {
  if(i2g[ia]==i2g[ib])return;
  // ia の所属するグループが ib の所属するグループより小さくならないようにする
  if (g2i[i2g[ia]].size() < g2i[i2g[ib]].size()) {
    swap(ia, ib);
  }
  int ga = i2g[ia], gb = i2g[ib];
  // グループ gb に所属する全てのアイテムをグループ ga に移す
  for (int j : g2i[gb]) i2g[j] = ga;
  g2i[ga].insert(g2i[ga].end(), g2i[gb].begin(), g2i[gb].end());
  g2i[gb].clear();
}

// アイテム ia とアイテム ib は同じグループに所属しているか？
bool is_same_group(int ia, int ib) {
  return i2g[ia] == i2g[ib];
}


typedef pair<int,pair<int,int>> edge; //<cost,<from,to>>
priority_queue<edge,vector<edge>,greater<edge>> eque;
/*
//input example
int sptreefrom,sptreeto,sptreecost
cin>>sptreefrom>>sptreeto>>sptreecost;
eque.push(make_pair(sptreecost,make_pair(sptreefrom,sptreeto)));
//*/

LL kruskal(int v){//頂点数(番号のmax)
  LL cost=0;
  union_init(v);
  while(!eque.empty()){
    edge ed=eque.top();
    eque.pop();
    if(!is_same_group(ed.ND.ST,ed.ND.ND)){
      merge(ed.ND.ST,ed.ND.ND);
      cost+=ed.ST;
			//cout<<"merge... cost:"<<ed.ST<<" /"<<ed.ND.ST<<"&"<<ed.ND.ND<<endl;
    }
}
  return cost;
}


int main(){
	int n;
	pr a[100011]={},b[100011]={};
	cin>>n;
	FOR(i,0,n){
		int p,q;
		cin>>p>>q;
		a[i]=make_pair(p,i+1);
		b[i]=make_pair(q,i+1);
	}
	sort(a,a+n);
	sort(b,b+n);
	FOR(i,0,n-1){
		int dd=a[i+1].ST-a[i].ST;
		eque.push(make_pair(dd,make_pair(a[i+1].ND,a[i].ND)));
		int dd2=b[i+1].ST-b[i].ST;
		eque.push(make_pair(dd2,make_pair(b[i+1].ND,b[i].ND)));
	}//*/

	cout<<kruskal(n+1)<<endl;
	//for (int j : g2i[i2g[1]])cout<<j<<" ";

    return 0;
}


Measured memory_bytes: 14192
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
char s[105],ans[105];
int main()
{
	cin>>s;
	int len=strlen(s),tot=0;
	for(int i=0;i<len;i++)
	{
		if(s[i]=='0')	ans[++tot]='0';
		if(s[i]=='B'&&tot>0)	tot--;
		if(s[i]=='1')	ans[++tot]='1';
	}
	for(int i=1;i<=tot;i++)
	{
		cout<<ans[i];
	}
	return 0;
}

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

const int INF = 1001001001;
//const ll INF = 1000000000000000000;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i,n) cin >> a[i];

	int le = 0, ri = k;
	rep(i, n - k) {
		if (a[le] < a[ri]) cout << "Yes" << endl;
		else cout << "No" << endl;
		le++; ri++;
	}
	return 0;
}


Measured memory_bytes: 4056
import math 
X  = int(input())
lis = [1]*(10**6+1)
lim = int(10**3)+1
for i in range(2,lim):
    if lis[i] == 1:
        for j in range(2,10**6+1):
            if i*j > 10**6:
                break
            else:
                lis[i*j] = 0

for i in range(X,len(lis)):
    if lis[i] == 1:
        print(i)
        break        

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

#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second

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

const int MOD = 1e9+7;

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);

	string s,t;
	cin >> s >> t;
	int a = s.length(),b=t.length(),ans=10057269;

	for (int i=0;i<=(a-b);++i) {
		int cnt = 0;
		for (int j=0;j<b;j++) {
			if (s[i+j]!=t[j]) cnt++;
		}
		ans = min(cnt,ans);
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 9e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

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

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
	if(y<=0) return 1;
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);

	ll a, b;
	cin>>a>>b;
	cout<<a*b;


    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <utility>
#include <vector>
#define llint long long

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint c[105][105];

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			cin >> c[i][j];
		}
	}
	llint ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(i < j) ans += min(c[i][j], c[j][i]);
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3180
#include <iostream>
using namespace std;
   
int main() {
  int h, w;
  while (true) {
    cin >> h >> w;
    if (h == 0 && w == 0) break;
       
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if ( i == 0 || i == h - 1 || j == 0 || j == w - 1) {
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
int main(){
  int R;
  scanf("%d", &R);
  double pi=3.1415926535897931386;
  printf("%.4lf\n", pi*2*R);
  return 0;
}


Measured memory_bytes: 3236
import sys
input = sys.stdin.readline
import heapq
def main():
    N, M = map( int, input().split())
    d = dict()
    E = [[] for _ in range(N)]
    for i in range(N-1):
        E[i+1].append((0,i))
    for _ in range(M):
        l, r, c = map( int, input().split())
        l -= 1
        r -= 1
        E[l].append((c,r))
    q = [(0,0)]
    heapq.heapify(q)
    path = [-1]*N
    while q:
        c, v = heapq.heappop(q)
        if path[v] >= 0:
            continue
        path[v] = c
        for cost, e in E[v]:
            if path[e] == -1:
                heapq.heappush(q, (c+cost, e))
    print(path[-1])
if __name__ == '__main__':
    main()


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

int main() {

long N,M;
cin>>N>>M;
vector<long> h(N);
vector<long> a(M);
vector<long> b(M);
for(int i=0;i<N;i++) cin>>h[i];
for(int i=0;i<M;i++) cin>>a[i]>>b[i];

long ans=0;
vector<vector<long>> t(N);
for(int i=0;i<M;i++){
  t[a[i]-1].push_back(b[i]-1);
  t[b[i]-1].push_back(a[i]-1);
}

for(int i=0;i<N;i++){
  long H=h[i];
  long tmp=0;
  for(int j=0;j<t[i].size();j++){

    tmp=max(h[t[i][j]],tmp);
  }
  if(tmp<H) {
    ans++;
    //cout<<tmp<<H<<endl;
  }
}

cout<<ans<<endl;
}


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

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;

    vector<int> h(N);
    for (int i = 0; i < N; i++) cin >> h[i];

    vector<bool> isOK(N, true);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if (h[a] <= h[b]) isOK[a] = false;
        if (h[b] <= h[a]) isOK[b] = false;
    }

    int ans = 0;
    for (int i = 0; i < N; i++){
        if (isOK[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    ll X;
    cin >> X;
    ll ans = 0;
    while(ans*(ans+1)/2 < X) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int g[n][n] = {};
	for(int i = 0; i < n; i++){
		int u,k;
		cin >> u >> k;
		int v;
		for(int j = 0; j < k; j++){
			cin >> v;
			g[u-1][v-1] = 1;
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cout << g[i][j];
			if(j != n-1)
				cout << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll arr[100100],n,ans,temp,a,b,c,k,m,p,l,temp1,temp2;
vector<ll> v[200200];
int main()
{
    cin>>n>>m;
    while(m--)
    {
        cin>>a>>b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(int i=0;i<v[0].size();i++)
    {
        if(v[0][i]==(n-1))
        {
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    for(int i=0;i<v[0].size();i++)
    {
        for(int j=0;j<v[v[0][i]].size();j++)
        {
            if(v[v[0][i]][j]==n-1)
            {
                cout<<"POSSIBLE"<<endl;
                return 0;
            }
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
return 0;
}


Measured memory_bytes: 12776
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[200010];
int main(){
    int n, k;
    while(cin>>k>>n){
        ll ans=0;
        int mx=0;
        for(int i=0; i<n; ++i){
        	scanf("%d",&a[i]);
        	if(i>0)
        	mx=max(mx, abs(a[i]-a[i-1]));
        }
        a[n]=k-a[n-1]+a[0];
        mx=max(mx, a[n]);
        ++n;
        ans=k-mx;
        printf("%lld\n",ans);
    }
  return 0;
}




Measured memory_bytes: 1024
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, i = LI()
    print(n-i+1)
    return

#B
def B():
    h, w = LI()
    a = SR(h)
    dy = defaultdict(int)
    dx = defaultdict(int)
    for y in range(h):
        for x in range(w):
            if a[y][x] == "#":
                dx[x] = 1
                dy[y] = 1
    dy = list(sorted(dy.items(), key=lambda x: x[0]))
    dx = list(sorted(dx.items(), key=lambda x: x[0]))
    for y,_ in dy:
        for x,_ in dx:
            print(a[y][x], end="")
        print()
    return

#C
def C():
    n, k = LI()
    x = LI()
    ans = inf
    for i in range(n - k + 1):
        if x[i] * x[i + k - 1] > 0:
            ans = min(ans, max(abs(x[i]), abs(x[i + k - 1])))
            continue
        ans = min(ans, min(abs(x[i]), abs(x[i + k - 1])) * 2 + max(abs(x[i]), abs(x[i + k - 1])))
    print(ans)
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 59120
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  int a,b;
  cin >>a>>b;
  
  if(1<=a && a<=9 && 1<=b && b<=9) {
  cout << a*b << endl; 
  }
  
  else {
  cout << -1 <<endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        if(X < 30){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 35692
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

constexpr ll mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

class combination{
public:
    vector<mint> fact,inv,finv;
    combination(int N){
        fact = inv = finv = vector<mint>(N+1);
        fact[0] = fact[1] = 1;
        inv[0] = inv[1] = 1;
        finv[0] = finv[1] = 1;
        for(ll i=2;i<=N;i++){
            fact[i] = fact[i-1]*i;
            inv[i] = (mint) mod - inv[mod%i]*(mod/i);
            finv[i] = finv[i-1]*inv[i];
        }
    }
    mint f(int i){
        return fact[i];
    }
    mint comb(int n,int k){
        if(n<k) return 0;
        if(n<0 || k<0) return 0;
        return fact[n]*finv[k]*finv[n-k];
    }
    mint hcomb(int n,int k){
        if(n==0 && k==0) return 1;
        return comb(n+k-1,k);
    }
};

mint dp[310][310][610] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    int K;
    cin >> S >> K;
    K = min(K,(int) count(S.begin(),S.end(),'1'));
    int N = S.size();
    vec<int> C;
    C.push_back(0);
    for(int l=0;l<N;l++){
        if(S[l]=='1') continue;
        int r = l+1;
        while(r<N && S[r]=='1') r++;
        C.push_back(r-l-1);
        l = r-1;
    }
    int n = C.size();
    dp[n][0][0] = 1;
    for(int i=n-1;i>=0;i--) for(int j=0;j<=K;j++) for(int k=0;k<=K;k++){
        for(int l=0;l<=j+C[i];l++) dp[i][l][k+max(0,l-j)] += dp[i+1][j][k];
    }
    mint ans = 0;
    for(int k=0;k<=K;k++) ans += dp[0][0][k];
    cout << ans << "\n";
}

Measured memory_bytes: 461572
#include<stdio.h>

int main(){
  long long n,cnt=1,i;
  char s[100001];
  scanf("%lld %s",&n,s);
  for(i=1;i<n;i++){
    if(s[i-1]!=s[i]) cnt++;
  }
  printf("%lld",cnt);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int vis[123456];

int main()
{
   int n, k;
   cin >> n >> k;
   vector <int> vec(n);
   for(int i = 0; i < n; i++) cin >> vec[i];
   for(int i = k; i >= 0; i--){
       for(int j = 0; j < n; j++){
          if(!vis[i] && vec[j] <= i){
           vis[i-vec[j]] = 1;
          }
       }
   }

   if(vis[0]) cout << "First";
   else cout << "Second";

}


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

int main(void){
    
    string S;
    cin >> S;

    vector<int> numChildren(100000, 0);

    int bufR = 0;
    int bufL = 0;
    int gatherR = 0;
    int indexC = 0;
    char bufC = 'R';

    for(char C: S){
        if((C == 'R')&&(bufC == 'R')){
            bufR++;
        }
        if((C == 'L')&&(bufC == 'L')){
            bufL++;
        }
        if((C == 'L')&&(bufC == 'R')){
            gatherR = indexC-1;
            bufL = 1;
        }
        if((C == 'R')&&(bufC == 'L')){
            numChildren[gatherR] = (bufR+1)/2+(bufL)/2;
            numChildren[gatherR+1] = (bufR)/2+(bufL+1)/2;
            bufR = 1;
        }
        indexC++;
        bufC = C;
    }
    numChildren[gatherR] = (bufR+1)/2+(bufL)/2;
    numChildren[gatherR+1] = (bufR)/2+(bufL+1)/2;

    bool firstoutput = true;

    for(int i=0; i<indexC; i++){
        if(firstoutput){
            firstoutput = false;
        }else{
            cout << " ";
        }
        cout << numChildren[i];
    }

    return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
 
public class Main {
    private static class Solver {
        private void solve(InputReader inp, PrintWriter out) {
            int n = inp.nextInt();
            int[] a = inp.nextArrayInt(n);
 
            Integer[] b = new Integer[n];
            for (int i = 0; i < n; ++i) {
                b[i] = a[i] - (i + 1);
            }
            Arrays.sort(b);
 
            int median = b[n / 2];
            long ans = 0;
            for (int i = 0; i < n; ++i) {
                ans += Math.abs(b[i] - median);
            }
            out.println(ans);
        }
    }
 
    private static class Misc {
        static int[] ArrayFilled(int size, int value) {
            int[] a = new int[size];
            for (int i = 0; i < size; ++i) {
                a[i] = value;
            }
            return a;
        }
        static int[] UnitArray(int size) {
            int[] a = new int[size];
            for (int i = 0; i < size; ++i) {
                a[i] = i;
            }
            return a;
        }
        static long ArraySum(int[] a) {
            long ans = 0;
            for (int x: a) {
                ans += x;
            }
            return ans;
        }
        static int ArrayMin(int[] a) {
            int ans = a[0];
            for (int x: a) {
                ans = Math.min(ans, x);
            }
            return ans;
        }
        static int ArrayMax(int[] a) {
            int ans = a[0];
            for (int x: a) {
                ans = Math.max(ans, x);
            }
            return ans;
        }
    }
    private static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;
 
        private InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
 
        private String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
 
        private int nextInt() {
            return Integer.parseInt(next());
        }
        private long nextLong() {
            return Long.parseLong(next());
        }
        private int[] nextArrayInt(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) {
                a[i] = nextInt();
            }
            return a;
        }
    }
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader inp = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(inp, out);
        out.close();
    }
}

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

int main()
{
  int a, b, count = 0;
  cin >> a >> b;

  int str[a];

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

  while (a > 0)
  {
    count++;

    a -= b;

    if (a > 0)
      a++;
  }

  cout << count << endl;

}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<double, int> P;
typedef tuple<double, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int n, m, p, a, b;

double dijkstra(int s, int g, vector<int> &t, vector<vector<P>> &G){
    vector<vector<double>> dist(35, vector<double>(1000, INF));
    priority_queue<T, vector<T>, greater<T>> que;
    dist[s][0] = 0;
    que.push(T(0, s, 0));

    while(!que.empty()){
        double ccost;
        int cv, cbit;
        tie(ccost, cv, cbit) = que.top();
        que.pop();

        if(dist[cv][cbit] < ccost) continue;

        for(auto x : G[cv]){
            int nv = x.first;
            int ncost = x.second;

            for(int bit=0; bit<(1<<n); bit++){
                if(dist[cv][bit] == INF) continue;

                for(int i=0; i<n; i++){
                    if(!((1<<i) & bit)){
                        int nbit = bit | (1<<i);
                        if(dist[cv][bit] + 1.*ncost / t[i] < dist[nv][nbit]){
                            dist[nv][nbit] = dist[cv][bit] + 1.*ncost / t[i];
                            que.push(T(dist[nv][nbit], nv, nbit));
                        }
                    }
                }
            }
        }
    }

    double ans=INF;
    for(int bit=0; bit<(1<<n); bit++){
        chmin(ans, dist[g][bit]);
    }

    return ans;
}

int main(){
    while(1){
        cin>>n>>m>>p>>a>>b;
        a--, b--;
        if(n == 0) return 0;
        vector<int> t(n);
        for(int i=0; i<n; i++) cin>>t[i];

        vector<vector<P>> G(35);
        for(int i=0; i<p; i++){
            int x, y, z; cin>>x>>y>>z;
            x--, y--;
            G[x].eb(P(y, z));
            G[y].eb(P(x, z));
        }

        double ans = dijkstra(a, b, t, G);

        if(ans == INF){
            cout << "Impossible" << endl;
        }
        else{
            cout << fixed << setprecision(6) << ans << endl;
        }
    }
}


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

using namespace std;

int main() {
  int a, b;
  char op = 0;
  cin >> a >> op >> b;
  if (op == '+') {
    cout << a+b << endl;
  } else if (op == '-') {
    cout << a-b << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
    // Your code here!
    int a,b,k;
    
    scanf("%d %d %d",&a,&b,&k);
    int n=0;
    
    for(int i=a;i>0;i--){
        if(a%i==0 & b%i==0)n++;
        if(n==k){
            printf("%d\n",i);
            return 0;
        }
    }
    
    //printf("%d\n",c);
    
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void){
    int k,a,b;
    scanf("%d%d%d",&k,&a,&b);
    if(k==a||k==b||b%k==0||a%k==0)
    printf("OK");
    else if((a/k+1)*k>=a&&(a/k+1)*k<=b)
    printf("OK");
    else
    {
        printf("NG");
    }
    return 0;
}

Measured memory_bytes: 1732