akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <bitset>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

int n;
vvi c;

int dp[16][1<<16];

int solve(int v, int S){
    int& res=dp[v][S];
    if(res!=-1) return res;
    int t=c[v][0];
    rep(i,n){
        if(S>>i&1){
            t = min(t, c[v][i+1]);
        }
    }
    S|=(1<<v);
    if(S==(1<<n)-1) return t;

    int u=1<<29;
    rep(i,n){
        if(!(S>>i&1)){
            u = min(u,solve(i,S));
        }
    }
    return res=t+u;
}

int main(){
    while(cin>>n && n){
        rep(i,1<<16)rep(j,16)dp[j][i]=-1;
        c.assign(n,vi(n+1));
        rep(i,n)rep(j,n+1){
            cin>>c[i][j];
        }
        int ans = 1<<29;
        rep(i,n)ans=min(ans,solve(i,0));
        cout << ans << endl;
    }
}

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

int main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;

    int ans = 0;
    rep(i, a+1){
        rep(j, b+1){
            rep(k, c+1){
                if (500*i + 100*j + 50*k == x) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//--- pA ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	public Solution () {
		reader = new Reader();
		while (reader.hasNext()) {
			run_case();
		}
	}
	private void run_case() {
		int N = ni();
		// System.out.println("N = " + N);
		int res = (int)Math.ceil(1.0 * N / 2);
		System.out.println(res);
		return;
	}
	private int ni() {return Integer.parseInt(reader.next());}
	private String ns() {return reader.next();}
}

class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			return st.hasMoreTokens();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
}


Measured memory_bytes: 23380
class Dice:
     
    def __init__(self,ls):
        self.a = ls[1-1] # top
        self.b = ls[2-1] # front
        self.c = ls[3-1] # right
        self.d = ls[4-1] # left
        self.e = ls[5-1] # back
        self.f = ls[6-1] # bottom
     
    def E(self):
        self.a, self.c, self.f, self.d = self.d, self.a, self.c, self.f
    def W(self):
        self.a, self.c, self.f, self.d = self.c, self.f, self.d, self.a
    def S(self):
        self.a, self.b, self.f, self.e = self.e, self.a, self.b, self.f
    def N(self):
        self.a, self.b, self.f, self.e = self.b, self.f, self.e, self.a   
                         
import random
ls = map(int,raw_input().split())
q = int(raw_input())
for i in range(q):
    dice = Dice(ls)
    a,b = map(int,raw_input().split())
    while dice.a != a or dice.b != b:
        i = random.choice([1,2,3,4])
        if i == 1: dice.E()
        elif i == 2: dice.W()
        elif i == 3 : dice.S()
        elif i == 4 : dice.N()
    print dice.c


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll N,K,X,Y,ans;
  IN(N,K,X,Y);
  if(N<=K) ans=N*X;
  else     ans=K*X+(N-K)*Y;
  OUT(ans);

  return 0;
}

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

using namespace std;

struct Data {
	int data;
	int user;
};

bool checkLock(int data, Data lock[], Data wait[], int lockNum, int waitNum, bool check[]);


bool checkWait(int user, Data lock[], Data wait[], int lockNum, int waitNum, bool check[]) {

	if (check[user]) {
		return false;
	}

	check[user] = true;

	for (int i = 0; i < waitNum; i++) {

		if (user == wait[i].user) {
			if (!checkLock(wait[i].data, lock, wait, lockNum, waitNum, check)) {
				return false;
			}
		}
	}
	check[user] = false;
	return true;
}
bool checkLock(int data, Data lock[], Data wait[], int lockNum, int waitNum, bool check[]) {

	for (int i = 0; i < lockNum; i++) {

		if (data == lock[i].data) {
			if (!checkWait(lock[i].user, lock, wait, lockNum, waitNum, check)) {
				return false;
			}
		}
	}
	return true;
}


int main() {
	int N;
	int lockNum = 0;
	int waitNum = 0;
	bool check[101];
	Data lock[1000];
	Data wait[1000];

	int user;
	int data;
	string str;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> user >> str >> data;
		if (str == "lock") {
			lock[lockNum].data = data;
			lock[lockNum].user = user;
			lockNum++;
		}
		else {
			wait[waitNum].data = data;
			wait[waitNum].user = user;
			waitNum++;
		}
	}

	for (int i = 0; i < waitNum; i++) {
		for (int j = 0; j < 101; j++) {
			check[j] = false;
		}
		if (!checkWait(wait[i].user,lock,wait,lockNum,waitNum,check)) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 1236
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e2 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int x = tx - sx, y = ty - sy;
	cout << string(y, 'U');
	cout << string(x, 'R');
	cout << string(y, 'D');
	cout << string(x + 1, 'L');
	cout << string(y + 1, 'U');
	cout << string(x + 1, 'R');
	cout << string(1, 'D');
	cout << string(1, 'R');
	cout << string(y + 1, 'D');
	cout << string(x + 1, 'L');
	cout << string(1, 'U') << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
	for (;;)
	{
		int a,b;
		char d,e;
		int f;
		char g;
		int h;
		char c[2][100000]={0};
		char C[2][100000]={0};
		cin>>a;
		if (a==0)
		{
			break;
		}
		for (b=0;b<a;b++)
		{
			cin>>d>>e;
			c[0][b]=d;
			c[1][b]=e;
		}
		cin>>f;
		for (h=0;h<f;h++)
		{
			cin>>g;
			C[0][h]=g;
			for (b=0;b<a;b++)
			{
				if (C[0][h]==c[0][b])
				{
					C[1][h]=c[1][b];
					break;
				
				}
				else if (C[0][h]!=c[0][b])
				{
					C[1][h]=C[0][h];
				}
			}
		}
		for (h=0;h<f;h++)
		{
			cout<<C[1][h];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3388
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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 x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  ll n,m;
  cin>>n>>m;

  vector<ll> p(n);
  rep(i,n){
    cin>>p[i];
  }

  sort(all(p));

//ok以上の握手がm個以上ある
//————————————————二分探索——————————————————————————

  ll ng = INF;
  ll ok = 0;
  while (abs(ok - ng) > 1) {
    ll mid = (ng + ok) / 2;

    ll cnt=0;
    rep(i,n){
      int x = lb(p,mid-p[i]);
      if(x<n) cnt+=n-x;
    }
    (cnt>=m? ok : ng) = mid;
  }

//——————————————————————————————————————————

  auto rui=p;
  for(int i=n-2;i>=0;i--){
    rui[i]+=rui[i+1];
  }

  ll cnt=0;
  ll ans=0;
  rep(i,n){
    int x = lb(p,ok-p[i]);
    if(x<n) {
      cnt+=n-x;
      ans+=p[i]*(n-x)+rui[x];
    }
  }
  if(cnt>m) ans-=(cnt-m)*ok;

  cout << ans << endl;
}

Measured memory_bytes: 4760
# frozen_string_literal: true

n, m = gets.split.map(&:to_i)
uv = m.times.map { gets.split.map(&:to_i) }
s, t = gets.split.map(&:to_i)

d = Array.new(n + 1) { -1 }

ts = Array.new(n + 1) { [] }

uv.each do |e|
  u = e[0]
  v = e[1]
  ts[u].push v
end

$v0 = {}
$v1 = {}
$v2 = {}

def kenken(s, ts, d, count, dest)
  return if $v0[s]

  $v0[s] = true
  ts[s].each do |t1|
    next if $v1[t1]

    $v1[t1] = true
    ts[t1].each do |t2|
      next if $v2[t2]

      $v2[t2] = true
      ts[t2].each do |t3|
        if d[t3].negative?
          d[t3] = count
          dest.push t3
        end
      end
    end
  end
  dest
end

count = 1
dest = [s]
loop do
  break if dest.empty?

  ndest = []
  dest.each do |ss|
    kenken(ss, ts, d, count, ndest)
  end
  if d[t].positive?
    puts d[t]
    exit
  end
  count += 1
  dest = ndest
end
puts '-1'


Measured memory_bytes: 36092
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solveC();
	}

	private void solveC() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int time = N * 100 + M * 1800;
		int pi = 1;
		for (int i = 0; i < M; i++) {
			pi *= 2;
		}
		double prev = -1.0;
		double current = 0.0;
		int k = 1;
		while (Math.ceil(prev) != Math.ceil(current)) {
			prev = current;
			double tmp = 1.0 * k * time / pi;
			for (int d = 1; d < k; d++) {
				tmp *= (1.0 - 1.0 / pi);
			}
			current += tmp;
			k++;
		}
		System.out.println(100*Math.round(Math.ceil(current/100)));
	}
}

Measured memory_bytes: 21844
//0014 Integral

//vñFy=x^2Ay=0Ax=600ÉÍÜê½ÊÏðAÏªÁÛ­ßé
//ßIÈÊÏðoÍµÈ³¢
//üÍÍ¡sÅ^¦çêA1sÉÍ600Ìñd¾¯ªÜÜêé@üÍÌI¹ÍEOFÅ\³êé
//»ê¼êÌüÍdÉÎµAßIÈÊÏð1s²ÆÉoÍ¹æ

//¿ÈÝÉdð¬³­·êÎ·éÙÇA72000000ÉßÃ­

#include<iostream>
using namespace std;

int main(void)
{
	int d;
	const int LIMIT_X = 600;
	while(cin >> d)
	{
		int sum = 0;
		for(int i = d; i < LIMIT_X; i+=d)
		{
			sum += (i*i)*d;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#define N 100000
int main(void) {
  int i,j,n,ans=0,prime[N+1];
  prime[0]=0;prime[1]=0;
  for(i=2;i<=N;i++)
    prime[i]=1;
  for(i=2;i*i<=N;i++){
    if(prime[i]==1){
      for(j=i*i;j<=N;j+=i)
        prime[j]=0;
    }
  }
  int cnt=0;
  for (i=0;i<=N;i++)
    if (prime[i]==1)
      prime[cnt++]=i;

  while (true){
    int m,a,b;
    scanf("%d %d %d",&m,&a,&b);
    if (m==0) return 0;
    int maxInt=0;
    int ansp=0,ansq=0;
    for (int p=0;p<cnt;p++){
      if (prime[p]>m) break;
      for (int q=p;q<cnt;q++){
        unsigned long mul=prime[p]*prime[q];
        if (mul>m) break;
        if ((mul<=m) && (a*prime[q]<=prime[p]*b && prime[p]*b<=b*prime[q]))
          if (mul>maxInt){
            maxInt=mul;
            ansp=prime[p];
            ansq=prime[q];
          }
      }
    }
    printf("%d %d\n",ansp,ansq);
  }
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (int)(n); ++i)
#define fj(st,n) for (int j = (st); j <= (int)(n); ++j)
#define fk(st,n) for (int k = (st); k <= (int)(n); ++k)
#define fq(st,n) for (int q = (st); q <= (int)(n); ++q)
#define fw(st,n) for (int w = (st); w <= (int)(n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (int)(n); ++(i))
#define ei(st,n) for (int i = (st); i >= (int)(n); --i)
#define ej(st,n) for (int j = (st); j >= (int)(n); --j)
#define ek(st,n) for (int k = (st); k >= (int)(n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (int)(n); --(i))
#define ri(st,n) for (int i = (st); i < (int)(n); ++i)
#define rj(st,n) for (int j = (st); j < (int)(n); ++j)
#define rk(st,n) for (int k = (st); k < (int)(n); ++k)
#define rq(st,n) for (int q = (st); q < (int)(n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (int)(n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 1e9 + 7;
const int maxn = (int) 1e5 + 5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(10);
//srand(time(0));

ll n, a, b, c, d, l, r;

int main()
{
//    fin("t.in");
    sync;
    cin >> n >> a >> b >> c >> d;
    if (a > b)
    	swap(a, b);
    l = a;
    r = a;
    fi(1, n - 1)
    {
    	if (r < b || (l <= b && r >= b && r - b <= b - l))
    	{
    		l += c;
    		r += d;
    		continue;
    	}
    	else
    	{
    		l -= d;
    		r -= c;
    		continue;
    	}
    }
	if (l <= b && r >= b)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef int64_t intl;

int main(){
  intl mod = 1000000007;
  intl N,K;
  cin >> N >> K;
  intl count = 0;
  for ( intl J = K;  J <=  N+1 ; J++){
    count += N*(N+1)/2 - (N-J)*(N-J+1)/2 - (J-1)*J/2 + 1;
    count %= mod;
  }
  cout << count;
}

Measured memory_bytes: 3620
use proconio::fastout;
use whiteread::parse_line;

fn solve() -> usize {
    let (mut a, mut b): (usize, usize) = parse_line().unwrap();
    if a > b {
        let tmp = b;
        b = a;
        a = tmp;
    }

    if a == b || a + 1 == b {
        2 * a - 2
    } else {
        let mut c = ((a * b) as f64).sqrt() as usize;
        if c * c == a * b {
            c -= 1;
        }

        if c * (c + 1) >= a * b {
            2 * c - 2
        } else {
            2 * c - 1
        }
    }
}

#[fastout]
fn main() {
    let q: usize = parse_line().unwrap();

    for _ in 0..q {
        println!("{}", solve());
    }
}


Measured memory_bytes: 2208
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int main()
{
	int a, b, c, min, min2;
	std::cin >> a >> b >> c;
	min = a; min2 = b;
	if (b < min) { min2 = min; min = b; }
	if (c < min) { min2 = min; min = c; }
	else if (c < min2) { min2 = c; }
	std::cout << min + min2 << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n,m;
    std::cin >> n>>m;
    
    vector<ll> a(n);
    vector<ll> b(m);
    
    map<ll,pair<ll,ll>> ma;
    
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        ma[a[i]].first = i+1;
    }
    
    for (int i = 0; i < m; i++) {
        std::cin >> b[i];
        ma[b[i]].second = i+1;
    }
    
    
    
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    
    for (int i = 0; i < n-1; i++) {
        if(a[i]==a[i+1]){
            std::cout << 0 << std::endl;
            return 0;
        }
    }
    for (int i = 0; i < m-1; i++) {
        if(b[i]==b[i+1]){
            std::cout << 0 << std::endl;
            return 0;
        }
    }
    
    ll res = 1;
    
    for (ll i = 1; i <= n*m; i++) {
        if(ma[i].first!=0 && ma[i].second!=0){
            continue;
        }
        if(ma[i].first == 0 && ma[i].second ==0){
            ll t1 = n-distance(a.begin(),lower_bound(a.begin(),a.end(),i));
            ll t2 = m-distance(b.begin(),lower_bound(b.begin(),b.end(),i));
            res *= t1*t2-(n*m-i);
            res %= MOD;
        }else{
            if(ma[i].first==0){
                ll t1 = n-distance(a.begin(),lower_bound(a.begin(),a.end(),i));
                res *= t1;
                res %= MOD;
            }else{
                ll t2 = m-distance(b.begin(),lower_bound(b.begin(),b.end(),i));
                res *= t2;
                res %= MOD;
            }
        }
    }
    
    std::cout << res%MOD << std::endl;
    
}


Measured memory_bytes: 62720
#include <iostream>
#include <map>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

const int MOD = 1000000007;

int main(){
  ll n;
  cin >> n;
  ll ans = 1;
  repd(i, 1, n+1){
    ans = (ans*i) % MOD;
  }
  cout << ans << endl;
}



Measured memory_bytes: 632
#include<iostream>
#include<cstring>
#include<cstdio>

#define SIZE 200

using namespace std;
int main()
{
    char text[SIZE];
    int y,m,d;
    
    scanf("%d/%d/%d",&y,&m,&d);
    
    if(y == 2019){
        if( m < 5 ){
            if( m == 4 ){
                if( d <= 30){
                    cout << "Heisei";
                }else{
                    cout << "TBD";
                }
            }else{
                cout << "Heisei";
            }
        }else{
            cout << "TBD";
        }
    }else if( y < 2019){
        cout << "Heisei";
    }else{
        cout << "TBD";
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
// Author : Mohamed Sameh
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
typedef long long ll ;
using namespace std ;
int n;
const int N = 4e2+9;
int a[N];
ll dp[N][N];
ll pre[N];
ll sum (int l, int r)
{
  return pre[r] - (l - 1 >= 0 ? pre[l-1] : 0);
}
void test ()
{
   cin >> n;
   for (int i = 0; i < n; i++)
    cin >> a[i];
   pre[0] = a[0];
   for (int i = 1; i < n; i++)pre[i] = pre[i-1] + a[i];
   for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      dp[i][j] = (i != j ? 1e18 : 0);
   for (int i = 0; i + 1 < n; i++) dp[i][i+1] = a[i]  + a[i+1];
   for (int k = 2; k < n; k++)
   {
     for (int i = 0; i + k < n; i++)
     {
       for (int j = i; j < i + k; j++)
       {
          ll cst = dp[i][j] + dp[j+1][i+k];
          dp[i][i+k] = min(dp[i][i+k] , cst + sum(i, i+k));
       }
    }
   }
   cout << dp[0][n-1] <<"\n";
}
int main()
{
  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  test();
}


Measured memory_bytes: 1664
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)

score = b[a[0] - 1]
for i in 1.upto(n - 1)
    score += b[a[i] - 1]
    if a[i - 1] + 1 == a[i] then
        score += c[a[i - 1] - 1]
    end
end

puts score


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;


int main()
{
    int ans;
    rep(i,5)
    {
        int a;
        cin>>a;
        if(a==0)ans=i+1;
    }
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;
vector<i64> a;

int main(){
  cin >> N;
  a.resize(N);
  for(auto & x : a) cin >> x;
  i64 S = 0;
  i64 r = 0;
  i64 ans = 0;
  for(i64 l = 0;l < N;l++){
    while(r < N && !(S & a[r])){
      S |= a[r];
      r++;
    }
    ans += r - l;
    if(l == r) r++;
    else S = S & ~a[l];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N >> M >> K >> R;
	int ans = 0;
	ans += min(N, R);
	R -= min(N, R);
	R -= min(M, R);
	ans -= min(K, R);
	cout << ans << endl;
}

Measured memory_bytes: 3648
n = input()
num = input().split()

tmp=[0]*int(n)
count=0

for i in range(int(n)) :
    l = int(num[i]) 
    if l % 2 == 0 :
        tmp[i]=1
        if l % 3 == 0 or l % 5 == 0 :
            count=count+1

if sum(tmp) == count :
    print('APPROVED')
else :
    print('DENIED')

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    vi v(3);
    rep(i,3) {
        cin>>v.at(i);
    }
    int K;
    cin>>K;
    sort(all(v));
    rep(i,K) {
        v.at(2)*=2;
    }
    cout<<v.at(0)+v.at(1)+v.at(2)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  int n;
  cin >> n;
  char s[n];
  cin >> s;
  map<char,int> m;
  REP(i,n) {
    m[s[i]]++;
  }
  int ans=0,temp=0;
  set<char> c;
  REP(i,n) {
    if(m[s[i]]>1) {
      auto it=c.find(s[i]);
      if(it!=c.end()) {
        m[s[i]]--;
      } else {
        temp++;
        m[s[i]]--;
        c.insert(s[i]);
      }
    } else if(m[s[i]]==1) {
      auto it=c.find(s[i]);
      if(it!=c.end()) {
        temp--;
        m[s[i]]--;
      }
    }
    ans=max(ans,temp);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long a, b;
    cin >> a >> b;
    long long d = __gcd(a, b);
    vector<long long> ps;
    for (long long i = 2; i * i <= d; ++i) {
        if (d % i == 0) {
            ps.push_back(i);
            while (d % i == 0) {
                d /= i;
            }
        }
    }
    if (d > 1) {
        ps.push_back(d);
    }
    cout << ps.size() + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
const LL mods=1000000007LL;
const int MAXN=1000000;
struct M{
	LL x;
	M(){
		x=0;
	}
	M(LL angka){
		if(angka>=mods||angka<=-mods)
			angka%=mods;
		if(angka<0)
			angka+=mods;
		x=angka;
	}
	
	M operator + (const M &other) const{
		return M(x+other.x);
	}
	M operator - (const M &other) const{
		return M(x-other.x);
	}
	M operator * (const M &other) const{
		return M(x*other.x);
	}
	M operator - () const{
		return M(-x);
	}
};
int n;
M fakt[MAXN+5],invfakt[MAXN+5],pways[MAXN+5],ans;
M DnC(M angka,LL pangkat){
	if(pangkat==0)
		return 1;
	M ret=DnC(angka,pangkat>>1);
	ret=ret*ret;
	if(pangkat&1)
		ret=ret*angka;
	return ret;
}
M inv(int n,int k){
	//cout<<"ngeinv "<<n<<" "<<k<<endl;
	M ret;
	int i,j;
	for(int ulang=0;ulang<2;ulang++)
	{
		if(ulang==0)
			i=n-2*k,j=k;
		else
			i=n-2*k+1,j=k-1;
		if(!(i>=0&&j>=0))
			continue;
		ret=ret+fakt[i+j]*invfakt[i]*invfakt[j];
	}
	return ret;
}
M ways(int i){
	return inv(n-3,(n-1)-i);
}
void isipways(){
	M substract;
	for(int i=2;i<=n-1;i++)
	{
		//cout<<"untuk "<<i<<" caranya "<<ways(i).x<<endl;
		pways[i]=ways(i)*fakt[i]-substract;
		substract=substract+pways[i];
		substract=substract*(n-i-1);
		//cout<<"pways "<<i<<" "<<pways[i].x<<endl;
	}
}
int main()
{
	cin>>n;
	if(n==2)
	{
		cout<<1<<endl;
		return 0;
	}
	if(n==3)
	{
		cout<<4<<endl;
		return 0;
	}
	fakt[0]=1;
	invfakt[0]=1;
	for(int i=1;i<=n;i++)
	{
		fakt[i]=fakt[i-1]*i;
		invfakt[i]=DnC(fakt[i],mods-2);
	}
	isipways();
	for(int i=2;i<=n-1;i++)
		ans=ans+pways[i]*fakt[n-1-i]*i;
	printf("%lld\n",ans.x);
}

Measured memory_bytes: 23680
#include<iostream>
#include<vector>
#include<string>
#include<cstdio>
#include<algorithm>
#include<unordered_map>
using namespace std;

int main() {
	unordered_map<char, int>a;
	string b;
	cin >> b;
	for (char c : b)a[c]++;
	cout << min(min(min(a['U'], a['K']), a['P']), a['C']) << endl;
}

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

int main()
{
    int A,B,C,D;
	scanf ("%d%d%d%d",&A,&B,&C,&D);
	if (A<=C&&B>=C&&D>=B)
	printf ("%d\n",B-C);
	else if (A<=C&&D<=B)
	printf("%d\n",D-C);
	else if (C<=A&&B<=D&&B>=C)
	printf("%d\n",B-A);
	else if (A>=C&&B>=D&&D>=A)
	printf("%d\n",D-A);
	else
	printf ("0\n");
}


Measured memory_bytes: 128
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

#include <atcoder/math>
using namespace atcoder;

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
//#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

void solve() {
    cini(n);
    cini(m);
    cini(a);
    cini(b);

    cout<<floor_sum(n,m,a,b)<<endl;
}

signed main() {
    cini(t);
    while(t--)
        solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
ll n,a[100005][5],k;
ll dp[100005][3];

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

    cin>>n;
    for (int i=0;i<n;i++)
    {
        cin>>a[i][0];
        cin>>a[i][1];
        cin>>a[i][2];
        dp[i][0]=a[i][0];
        dp[i][1]=a[i][1];
        dp[i][2]=a[i][2];
    }

    for (int i=1;i<n;i++)
    {
        dp[i][0]+=max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]+=max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]+=max(dp[i-1][1],dp[i-1][0]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;


    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;



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

Measured memory_bytes: 3916
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] a = new int[n];

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }

    // find already k-length ordered segment
    Set<Integer> ordered = new HashSet<>();
//    int ordered = 0;
    int l = 0;
    int r = 1;
    for (l = 0; l < n; l++) {
      if (l == r) r++;
      while (r < n && a[r - 1] < a[r]) r++;
      if (k <= r - l) ordered.add(l);
    }

    SortedSet<Integer> set = new TreeSet<>();

    for (int i = 0; i < k; i++) {
      set.add(a[i]);
    }

    int res = n - k + 1;

    for (int i = 0; i < n - k; i++) {
      int min = set.first();
      int max = set.last();
      set.remove(a[i]);
      set.add(a[i + k]);
      if (min == a[i] && max < a[i + k] && !ordered.contains(i)) res--;
    }

    if (ordered.size() > 1) {
      res -= ordered.size() - 1;
    }
    os.println(res);

  }

}

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

int main(){
    string s;
    string ans;
    cin >> s;

    for(int i = 0; i < s.size(); i++){
        if(s[i] == '0'){
            ans = ans + '0';
        }
        else if(s[i] == '1'){
            ans = ans + '1';
        }
        else if(s[i] == 'B' and ans.size() == 0){
            continue;
        }
        else if(s[i] == 'B' and ans.size() != 0){
            ans.erase(ans.size()-1);
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

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

  if((s[0] == s[s.length() - 1]) ^ (s.length() % 2)) {
    cout << "First" << endl;
  }else {
    cout << "Second" << endl;
  }
  return 0;
}



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

signed main() {
	int n;
	cin >> n;
	int cnt = 0, sum = 0;
	bool zero = false;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		if (a[i] < 0) cnt++;
		if (a[i] == 0) zero = true;
		a[i] = abs(a[i]);
		sum += a[i];
	}

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

	if (zero or cnt % 2 == 0) {
		cout << sum << endl;
	}
	else {
		cout << sum - 2 * a[0] << endl;
	}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main(){
  string s;
  cin>>s;
  int k=0,l=s.size()-1;
  for(int i=0;i<s.size();i++){if(s[i]=='A'){k=i;break;}}
  for(int j=s.size()-1;j>=0;j--){if(s[j]=='Z'){l=j;break;}}
  cout<<l-k+1<<endl;
}

Measured memory_bytes: 768
// abc128_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 30)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int N, K;
    cin >> N >> K;
    vector<int> V(N);
    REP(i, N) cin >> V[i];

    int ans = 0;
    REP(k, min(N+1, K+1)){

        REP(p, k+1){
            int q = k - p;

            multiset<int> st{};

            REP(i, p) st.insert(V[i]);
            REP(i, q) st.insert(V[N-1-i]);

            int res = K - k;

            int tmp = accumulate(ALL(st), 0);
            for (auto v: st){
                if (res-- > 0 && v < 0) tmp -= v;
            }

            ans = max(ans, tmp);
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
def func(x,y):
    return x**5-y**5

x = int(input())
a = -200
b = 200
flag = False

for i in range(-199,200):
    for j in range(-200,199):
        if(func(i,j)==x):
            print(i,j)
            flag = True
            break
    if(flag):
        break


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

int main(void){
  int b, r, g, c, s, t;
  while(cin >> b >> r >> g >> c >> s >> t, b | r | g | c | s | t){
    cout << 100+ b*12 + b*13*5 + r*12 + r*13*3 + g*4 + c*(-1) + s*(-3) +(-3)*(t-(b+b*5+r+r*3+g+c+s+s)) << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
a, b, c = map(int, input().split())
tmp = 0
if a > b :
    tmp = a
    a = b
    b = tmp
if b > c :
    tmp = b
    b = c
    c = tmp
if a > b :
    tmp = a
    a = b
    b = tmp

print(a, b, c)


Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
 int a,b;
 cin >> a >> b;
 for (int i = 1;i < 10000;i++){
   if (a==i*8/100 && b==i/10 ){
     cout << i << endl;
     return 0;
   }
 }
 cout << -1 << endl;
 return 0; 
}


Measured memory_bytes: 256
import sys
import itertools
input = sys.stdin.readline

N = int(input())
S = input()
cc = [0]*1000
ans = [0]*1000
for j in range(len(S)-1):
	p = int(S[j])
	for i in range(1000):
		if(p==i%10 and cc[i]==2):
			cc[i]+=1
			ans[i]=1
		elif(p==(i//10)%10 and cc[i]==1):
			cc[i]+=1
		elif(p==i//100 and cc[i]==0):
			cc[i]+=1
print(sum(ans))

Measured memory_bytes: 45660
using System;
using System.Linq;
public class main{
    static public void Main(){
        int n,k;
        n=int.Parse(Console.ReadLine());
        k=int.Parse(Console.ReadLine());
        int show = 1;
        for(int i=0;i<n;i++){
            if(show<k){
                show=show*2;
            }else{
                show+=k;
            }
            
        }
        Console.WriteLine(show);
    }
}

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

const int N = 200005;
const int MOD = 1e9 + 7;

int n, k;

vector<int> mf(N, -1);

int modfact(int n) {
  if (mf[n] != -1) return mf[n];
  if (n == 0) return mf[0] = 1;
  return mf[n] = (ll)n * modfact(n-1) % MOD;
}

int modinv(int a) {
  int b = MOD, u = 1, v = 0;
  while (b) {
    int t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= MOD;
  if (u < 0) u += MOD;
  return u;
}

vector<int> mif(N, -1);

int modinvfact(int n) {
  if (mif[n] != -1) return mif[n];
  if (n == 0) return mif[0] = 1;
  return mif[n] = (ll)modinv(n) * modinvfact(n-1) % MOD;
}

int modcomb(int n, int k) {
  return (ll)modfact(n) * modinvfact(k) % MOD * modinvfact(n-k) % MOD;
}

int f(int k) {
  if (k >= n) return f(n-1);
  if (k == 0) return 1;
  int res = (ll)modcomb(n, k) * modcomb(n-1, k) % MOD;
  res = (res + f(k-1)) % MOD;
  return res;
}

int main() {
  cin >> n >> k;
  cout << f(k) << endl;
  return 0;
}

Measured memory_bytes: 11088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b;
  
  c = a*b;
  d = c % 2;

  if (d == 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000000
#define f(i,a,b) for(long long i=a;i<b;i++)
#define tc long long t;cin>>t;while(t--)
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define input(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define output(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" ";
#define up upper_bound
#define lo lower_bound
#define endl "\n"
#define mem(a) memset(a,-1,sizeof(a))
#define ll long long
#define umap unordered_map


ll a[200010];
ll n,k;
bool solve(ll x){
    ll sum=0;
    f(i,0,n){
        sum+=(a[i]-1)/x;
    }
    return sum<=k;
}

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    cin>>n>>k;

    input(a,n);

    ll l=1,r=1e9+10,mid;

    while(l<r){
        mid=(l+r)/2;
        if(solve(mid)) r=mid;
        else l=mid+1;
    }
    cout<<r;

    return 0;
}

Measured memory_bytes: 5140
import collections, itertools
N = int(input())
A = [int(_) for _ in input().split()]
C = sorted(collections.Counter(A).most_common(), key=lambda xs: -xs[1])
f = 0
if len(C) == 1:
    a, la = C[0]
    #a^a^a^
    if a ^ a == a:
        f = 1
elif len(C) == 2:
    a, la = C[0]
    b, lb = C[1]
    #a^b^a^b^a^b^
    if la == lb and a ^ b == a and b ^ a == b:
        f = 1
    #b^a^a^b^a^a^
    if la == lb * 2 and b ^ a == a and a ^ a == b:
        f = 1
elif len(C) == 3:
    a, la = C[0]
    b, lb = C[1]
    c, lc = C[2]
    #x^y^(x^y)^x^y^(x^y)^
    if la == lb == lc and any(
            x ^ y == z for x, y, z in itertools.permutations((a, b, c))):
        f = 1
    #x^y^(x^y)^x^y^
    if la == lb == lc + 1:
        if any(x ^ y == c == x and y ^ c == x and c ^ x == y
               for x, y in ((a, b), (b, a))):
            f = 1
    #(y^z)^y^z^(y^z)^y^z^(y^z)^
    if lb == lc == la - 1:
        if any(a ^ y == z and y ^ z == a and z ^ a == y == a
               for y, z in ((b, c), (c, b))):
            f = 1
if f:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 15512
<?php
    fscanf(STDIN, "%d", $d);
    switch ($d) {
    case 22:
        echo "Christmas Eve Eve Eve"."\n";
        break;
    case 23:
        echo "Christmas Eve Eve"."\n";
        break;
    case 24:
        echo "Christmas Eve"."\n";
        break;
    case 25:
        echo "Christmas"."\n";
        break;
}
    ?>

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

using namespace std;

const int INF = 100;

int n;

int mn[50];
int freq[50];

int main()
{
	scanf("%d",&n);

	for(int i = 0 ; i < 50 ; i++)
		mn[i] = INF;

	for(int i = 1 ; i <= n ; i++)
	{
		string s;
		cin >> s;

		memset( freq , 0 , sizeof(freq) );

		for(int j = 0 ; j < s.size() ; j++)
			freq[ s[j] - 'a' ]++;

		for(int j = 0 ; j < 50 ; j++)
			mn[j] = min( mn[j] , freq[j] );
	}

	for(int i = 0 ; i < 50 ; i++)
		for(int j = 1 ; j <= mn[i] ; j++) printf("%c",'a' + i);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    ll a[n];
    vector<pair<ll,int>> v;
    rep(i,n){
        cin >> a[i];
        pair<ll,int> p;
        p.first = a[i];
        p.second = i;
        v.push_back(p);
    }
    sort(v.begin(), v.end(), greater<pair<ll,int>>());
    ll ans[n] = {};

    ll ite = 0;
    int head = 1001001001;
    ll ma = -1;

    while(true){
        if(ite==0){
            head = v[ite].second;
            ma = v[ite].first;
            ite++;
            while(ite<n){
                if(v[ite].first==ma){
                    head = min(head,v[ite].second);
                    ite++;
                }else{
                    break;
                }
            }
        }else{
            ma = v[ite].first;
            head = min(head,v[ite].second);
            ite++;
            while(ite<n){
                if(v[ite].first==ma){
                    head = min(head,v[ite].second);
                    ite++;
                }else{
                    break;
                }
            }
        }

        if(ite==n){
            ans[head] += n * ma;
        }else{
            ans[head] += (ma-v[ite].first) * ite;
        }
        if(ite==n)break;
    }

    rep(i,n){
        cout << ans[i] << endl;
    }

    return 0;
}
 
 


Measured memory_bytes: 4336
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define p1d(a,n)                for(int ix=0;ix<n;ix++) out<<a[ix]<<" "; out<<endl
#define p2d(a,n,m)              for(int ix=0;ix<n;ix++){ for(int jx=0;jx<m;jx++) out<<a[ix][jx]<<" "; out<<endl;}
#define range(v)                v.begin(),v.end()
#define w(x)                    while(x--)
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

void ssolve(std::istream& in, std::ostream& out){
int a,b;
s2(a,b);
int sa = ceil(a*12.5);
int ga = ceil((a+1)*12.5);

    int sb = ceil(b*10);
    int gb = ceil((b+1)*10);

    ga--;
    gb--;

    int c = max(sa,sb);
    if(c<= ga && c<=gb) out<<c<<endl;
    else out<<-1<<endl;

}

class CTaxIncrease {
public:
	void solve(std::istream& in, std::ostream& out) {
        int t;
        int READ = 0;
        if(READ) s(t);
        else t = 1;
        while(t--){
            ssolve(in, out);
        }
	}
};


integer main() {
	CTaxIncrease solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int a[3];
int main(void){
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]==5&&a[1]==5&&a[2]==7){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    
}


Measured memory_bytes: 3628
/*
[ ( ^ _ ^ ) ]
*/
// problem: atc/abc167_a
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000000



int main() {
    char s[100], t[100];
    scanf("%s", s);
    scanf("%s", t);
    int n = strlen(s);
    int m = strlen(t);
    if(n+1==m) {
        bool ok = true;
        for(int i=0; i<n; i++) {
            ok &= s[i]==t[i];
        }
        if(ok) {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
}


Measured memory_bytes: 3652
S = input()
l = []
for s in S:
  l.append(s)

cnt = 0
for i in range(len(l)):
  if i != 0 and l[i - 1] == l[i]:
    if l[i] == "0":
      l[i] = "1"
    else:
      l[i] = "0"
    cnt += 1
print(cnt)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;

	cin >> n;
	vector<int> m(n);
	int a;
	int mx=0;
	int sum=0;
	for (int i=0;i<n;i++){
		cin >> a;
		if (a>mx){
			mx =a;
		}
		sum+=a;
	}
	if (mx < sum -mx){
		cout << "Yes" <<endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
def lcm(a, b):
    ab = a * b
    while b != 0:
        a, b = b, a % b
    return ab // a


def s(n, c, d):
    return n - n//c - n//d + n//lcm(c, d)


a, b, c, d = map(int, input().split())
print(s(b, c, d) - s(a-1, c, d))

Measured memory_bytes: 3060