akhauriyash/Code-Regression huggingface dataset:
import Control.Monad

main :: IO ()
main = do
  l1 <- replicateM 8 getLine
  l2 <- replicateM 8 getLine
  l3 <- replicateM 8 getLine
  let l1' = map words l1
      t1 = choiceTop' l1'
      r1 = rest l1' t1

      l2' = map words l2
      t2 = choiceTop' l2'
      r2 = rest l2' t2

      l3' = map words l3
      t3 = choiceTop' l3'
      r3 = rest l3' t3

      l4 = r1 ++ r2 ++ r3
      t4 = choiceTop' l4
      ans = t1 ++ t2 ++ t3 ++ t4
  mapM_ putStrLn (map format ans)
name :: [String] -> String
name [n,t] = n

time :: [String] -> Float
time [n,t] = (read :: String -> Float) t

choiceTop :: [[String]] -> [[String]] -> [[String]]
choiceTop sss [] = sss
choiceTop [] (s:ss) = choiceTop [s] ss
choiceTop (a:[]) (s:ss)
  |(time a) < (time s) = choiceTop (a:s:[]) ss
  | otherwise = choiceTop [s,a] ss
choiceTop [a,b] (s:ss)
  |(time a) >= (time s) = choiceTop [s,a] ss
  |(time b) >= (time s) = choiceTop [a,s] ss
  | otherwise = choiceTop [a,b] ss

choiceTop' :: [[String]] -> [[String]]
choiceTop' sss = choiceTop [] sss

rest :: [[String]] -> [[String]] -> [[String]]
rest all top = [s | s <- all , not (elem s top)]

format :: [String] -> String
format [n,t] = n ++ " " ++ t

Measured memory_bytes: 4208
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int count = 0;
    for(int i=a;i<=b;i++){
      String n = Integer.toString(i);
      boolean flag = true;
      for(int j=0;j<n.length()/2;j++){
        char c1 = n.charAt(j);
        char c2 = n.charAt(n.length() - j -1);
        if(c1 != c2){
          flag = false;
          break;
        }
      }
      if(flag) count++;
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 26196
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
//#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,k;

int main(){
	cin>>n>>k;
	ll ans=0;
	for(int b=1;b<=n;b++){
		ans+=(n/b)*max(0,b-k);
		ans+=max(0,n%b-k+1);
	}
	if(k==0)
		ans-=n;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func nextFloat64() (float64, error) {
	return strconv.ParseFloat(nextString(), 64)
}

var infty = math.MaxFloat64

func optimalBst(p []float64, q []float64, n int) ([][]float64, [][]int) {
	e := make([][]float64, n+2)
	for i := 0; i <= n+1; i++ {
		e[i] = make([]float64, n+1)
	}
	w := make([][]float64, n+2)
	for i := 0; i <= n+1; i++ {
		w[i] = make([]float64, n+1)
	}
	root := make([][]int, n+1)
	for i := 0; i <= n; i++ {
		root[i] = make([]int, n+1)
	}

	for i := 1; i <= n+1; i++ {
		e[i][i-1] = q[i-1]
		w[i][i-1] = q[i-1]
	}
	for l := 1; l <= n; l++ {
		for i := 1; i <= n-l+1; i++ {
			j := i + l - 1
			e[i][j] = infty
			w[i][j] = w[i][j-1] + p[j] + q[j]
			for r := i; r <= j; r++ {
				t := e[i][r-1] + e[r+1][j] + w[i][j]
				if t < e[i][j] {
					e[i][j] = t
					root[i][j] = r
				}
			}
		}
	}

	return e, root
}

func main() {
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	p := make([]float64, n+1)
	q := make([]float64, n+1)
	for i := 1; i <= n; i++ {
		p[i], _ = nextFloat64()
	}
	for i := 0; i <= n; i++ {
		q[i], _ = nextFloat64()
	}

	// fmt.Println(p)
	// fmt.Println(q)

	e, _ := optimalBst(p, q, n)

	// fmt.Println(root)
	fmt.Println(e[1][n])
}



Measured memory_bytes: 7704
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define repeat(i,a,b) for(int i=(a),i##__end=(b);i<i##__end;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,i##__end=(a);i>=i##__end;i--)
#define mst(a,x) memset((a),(x),sizeof(a))
#define pii pair<int,int>
#define N 100010
#define mod 1000000007
//#define int ll
#define inf mod
vector<pii> a[N];
int ansco[N];
void dfs(int x,int fa,int faco){
	int co=1;
	for(auto i:a[x])
	if(i.first!=fa){
		if(faco==co)co++;
		ansco[i.second]=co;
		dfs(i.first,x,co);
		co++;
	}
}
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin>>n;
	repeat(i,0,n-1){
		int x,y;cin>>x>>y;x--,y--;
		a[x].push_back({y,i});
		a[y].push_back({x,i});
	}
	int ans=0;
	repeat(i,0,n)
		ans=max(ans,(int)a[i].size());
	dfs(0,-1,-1);
	cout<<ans<<endl;
	repeat(i,0,n-1)
		cout<<ansco[i]<<endl;
	return 0;
}

Measured memory_bytes: 9344
#include <stdio.h>
#include<iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
	int n, k, a[100003], ans;

	cin >> n >> k;

	for (int i = 0; i < n; i++)
		cin >> a[i];

	if (n < k)
		ans = 1;
	else{
		if ((n - k) % (k - 1))
			ans = 2 + (n - k) / (k - 1);
		else
			ans = 1 + (n - k) / (k - 1);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {

	int K;
	cin >> K;
	if (K % 2 == 0) {
		cout << pow((K / 2), 2);
	}
	else {
		cout << K / 2 * (K / 2 + 1);
	}
	return 0;
}

Measured memory_bytes: 256
W, H, x, y = map(int,input().split())

# 範囲内なら必ず等分できるので問題なし
square = 1.0 * W * H / 2

# ちょうど真ん中なら2パターンの切り分けがある
patt = 0
if 1.0 * W / 2 == x and 1.0 * H / 2 == y:
    patt = 1

print(square, patt)
    

Measured memory_bytes: 2940
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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;}

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=INF,z=INF;
  string s="",t="";
  //

  // ここから
  IN2(n,m);
  Vi A(n);
  Vi B(n);
  Vi C(m);
  Vi D(m);
  REP(i,n){
    IN2(A[i],B[i]);
  }
  REP(i,m){
    IN2(C[i],D[i]);
  }
  REP(i,n){
    z = INF;
    REP(j,m){
      int distance = abs(A[i]-C[j]) + abs(B[i]-D[j]);
      if(z > distance){
        z = distance;
        y = j+1;
      }
    }
    OUT(y);
  }
}

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

int main(){
	int n;
  cin >> n;
	
  map<ll, pair<ll, ll>> mp;
  rep(i, n){
    int a;
    cin >> a;
    mp[a+i].first++; mp[-a+i].second++;
  }
  
  ll ans = 0;
  for(auto p : mp){
    ll u, v;
    u = p.second.first;
    v = p.second.second;
    ans += u*v;
  }
  
  cout << ans << endl;
    
    return 0;
  }

Measured memory_bytes: 26220
n = int(input())
a = list(map(int, input().split()))
num = 10000
for i in range(n):
    rec = 0
    j = 2
    while a[i] % j == 0:
        j *= 2
        rec += 1
        if rec >= num:
            break

    num = min(rec, num)

print(num)

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

using namespace std;

typedef long long ll;

ll getkey(ll x){
	if(x % 10 == 0) return 0;
	if(x <= 9) return x;
	ll a = x % 10;
	ll b = 0;
	while(x > 0){
		b = x % 10;
		x /= 10;
	}

	if(a == b) return a;
	return a * 10 + b;
}

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

	ll n;
	cin >> n;

	map<ll, ll> mp;
	for(ll i = 1; i <= n; i++){
		ll key = getkey(i);
		if(mp.count(key) == 0) mp[key] = 0;
		mp[key]++;
	} 

	ll ans = 0;
	for(auto p : mp){
		ll k = p.first;
		ll v = p.second;
		if(k == 0) continue;
		if(k <= 9){
			ans += v * v;
		}else{
			int l = (k % 10) * 10 + k / 10;
			ans += v * mp[l];
		}		
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int K, A, B; cin >> K >> A >> B;
  for(int i=A; i<=B; i++){
    if(i%K==0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <inttypes.h>
#include <stdint.h>

#define MIN(a, b) ((a) > (b) ? (b) : (a))

static uint32_t costForLeft(const uint32_t numMasses, const uint32_t numGates, const uint32_t * const gatePos, const uint32_t origin)
{
	uint32_t cost = 0;

	for (uint32_t idx = 0; idx < numGates; idx++) {
		if (gatePos[idx] < origin) {
			cost++;
		}
	}

	return cost;
}

static uint32_t costForRight(const uint32_t numMasses, const uint32_t numGates, const uint32_t * const gatePos, const uint32_t origin)
{
	uint32_t cost = 0;

	for (uint32_t idx = 0; idx < numGates; idx++) {
		if (gatePos[idx] > origin) {
			cost++;
		}
	}

	return cost;
}

int main(void)
{
	uint32_t numMasses, numGates, origin;
	uint32_t gatePos[100];

	scanf("%I32u %I32u %I32u\n", &numMasses, &numGates, &origin);

	for (uint32_t idx = 0; idx < numGates - 1; idx++) {
		scanf("%I32u ", &(gatePos[idx]));
	}
	scanf("%I32u", &(gatePos[numGates - 1]));

	printf("%I32u", MIN(costForLeft(numMasses, numGates, gatePos, origin), costForRight(numMasses, numGates, gatePos, origin)));

	return 0;
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	A, B, C := getInt(), getInt(), getInt()
	x := getInt()
	ans := 0
	for a := 0; a <= A; a++ {
		for b := 0; b <= B; b++ {
			for c := 0; c <= C; c++ {
				if a*500+b*100+c*50 == x {
					ans++
				}
			}
		}
	}
	out(ans)
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define fin(x) cout << x << endl;

using namespace std;
using ll = long long;

int main(void) {
  int a, b, m;
  cin >> a >> b >> m;
  vector<int> v1(a);
  vector<int> v2(b);
  rep(i, a) cin >> v1[i];
  rep(i, b) cin >> v2[i];
  int ans = *min_element(all(v1)) + *min_element(all(v2));
  rep(i, m) {
    int c, d, e;
    cin >> c >> d >> e;
    ans = min(ans, v1[c - 1] + v2[d - 1] - e);
  }
  fin(ans);
  return 0;
}

Measured memory_bytes: 1024
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}


#[allow(unused_macros)]
macro_rules! invec {
    ( $ t : ty ) => {{
        let mut s = String::new();
        match std::io::stdin().read_line(&mut s) {
            Ok(0) => Vec::<$t>::new(),
            Ok(n) => s
                .trim()
                .split_whitespace()
                .map(|s| s.parse::<$t>().unwrap())
                .collect::<Vec<$t>>(),
            Err(_) => Vec::<$t>::new(),
        }
    }};
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (n, t) = input!(usize, u64);
    let a = invec!(u64);

    let total = n as u64 * t;
    
    let mut overlap = 0;
    for i in 0..(n-1) {
        let diff = a[i + 1] - a[i];
        if diff < t {
            overlap += t - diff;
        }
    }

    println!("{}", total - overlap);
}

fn main() {
    solve();
}


Measured memory_bytes: 10492
# -*- coding: utf-8 -*-


class DisjointSets:
    '''
    Implementing disjoint sets using disjoint sets forests structure.
    '''

    def __init__(self, size):
        self.ranks = [0] * size
        self.roots = [0] * size
        for x in range(size):
            self.make_set(x)

    def make_set(self, x):
        self.roots[x] = x
        self.ranks[x] = 0

    def link(self, x, y):
        if self.ranks[x] > self.ranks[y]:
            self.roots[y] = x
        else:
            self.roots[x] = y
            if self.ranks[x] == self.ranks[y]:
                self.ranks[y] += 1

    def find_set(self, x):
        # compression of the path
        if x != self.roots[x]:
            self.roots[x] = self.find_set(self.roots[x])

        return self.roots[x]

    def unite(self, x, y):
        self.link(self.find_set(x), self.find_set(y))

    def in_same_set(self, x, y):
        return self.find_set(x) == self.find_set(y)


if __name__ == '__main__':
    import sys
    n, q = map(int, input().split())
    ds = DisjointSets(n)

    for line in sys.stdin.readlines():
        query, x, y = map(int, line.strip().split())
        if query == 0:
            ds.unite(x, y)
        elif query == 1:
            if ds.in_same_set(x, y):
                print(1)
            else:
                print(0)



Measured memory_bytes: 13864
import math


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return data

primes = set(get_sieve_of_eratosthenes(10**5))
A = []
for i in range(1, 10**5+1):
  if i % 2 == 1:
    if i in primes and (i+1) // 2 in primes:
      A.append(1)
    else:
      A.append(0)
  else:
    A.append(0)

for i in range(1, len(A)):
  A[i] += A[i-1]

q = int(input())
for _ in range(q):
  l, r = map(int, input().split())
  if l == 1:
    l = 2
  ans = A[r-1] - A[l-2]
  print(ans)


Measured memory_bytes: 84924
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX 200000
#define INFTY 2000000000

long long s[MAX],m[MAX];
long long n,k,ans=INFTY;;

void candles(long long A[],long long B[],long long ha,long long hb){
  for(long long i=0;i<=k;i++){
    if(i>ha) break;
    if(k-i>hb) continue;
    ans=min(ans,A[i]*2+B[k-i]);
  }
  return;
}

int main(){
  s[0]=0; m[0]=0;
  long long counts=0,countm=0,count0=0,data;
  cin>>n>>k;
  for(long long i=0;i<n;i++){
    cin>>data;
    if(data>0) s[++counts]=data;
    else if(data<0) m[++countm]=-data;
    else count0++;
  }
  k-=count0;
  reverse(m+1,m+countm+1);
  candles(s,m,counts,countm);
  candles(m,s,countm,counts);
  cout<<ans<<endl;


}


Measured memory_bytes: 1024
#include<cstdio>
#include<vector>

using namespace std;

int main() {
	int n;
	vector<int> a;
	vector<int> b;
	vector<int> c;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int tmp;
		scanf("%d", &tmp);
		a.push_back(tmp - 1);
	}
	for (int i = 0; i < n; i++) {
		int tmp;
		scanf("%d", &tmp);
		b.push_back(tmp);
	}
	for (int i = 0; i < n - 1; i++) {
		int tmp;
		scanf("%d", &tmp);
		c.push_back(tmp);
	}
	int score = 0;
	int prev = -10;
	for (int i = 0; i < n; i++) {
		score += b[a[i]];
		if (prev + 1 == a[i]) {
			score += c[prev];
		}
		prev = a[i];
	}
	printf("%d\n", score);
	return 0;
}


Measured memory_bytes: 888
N, A, B, C, D = map(int, input().split())


MOD = 10 ** 9 + 7
M = 1005
fact = [0] * M
fact[0] = 1
for i in range(1, M):
    fact[i] = fact[i - 1] * i
    fact[i] %= MOD

rfact = [0] * M
rfact[M - 1] = pow(fact[M - 1], MOD - 2, MOD)
for i in range(M - 2, -1, -1):
    rfact[i] = rfact[i + 1] * (i + 1)
    rfact[i] %= MOD

dp = [[0] * (N + 1) for i in range(N + 1)]
dp[A - 1][0] = 1
for i in range(A, B + 1):
    for j in range(N + 1):
        dp[i][j] += dp[i - 1][j]
        k = C
        while k <= D and j - k * i >= 0:
            dp[i][j] += dp[i - 1][j - k * i] * fact[N - (j - k * i)] * pow(rfact[i], k, MOD) * rfact[k] * rfact[N - j]
            dp[i][j] %= MOD
            k += 1

print(dp[B][N])


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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

    // 入力
    int n, a, b;
    cin >> n >> a >> b;

    // 処理
    int ans = 0;
    for (int i = 0; i <= n; i++) {
        int n   = i;
        int sum = 0;
        while (n > 0) {
            sum += n % 10;
            n /= 10;
        }
        if (a <= sum && sum <= b) ans += i;
    }

    // 出力
    cout << ans << endl;

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> h(n);

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

  bool flg = true;
  int maxi=h[0];
  for (int i = 0; i < n-1; i++)
  {
    if(h[i]<h[i+1]){
      maxi=h[i+1];
    }
    if(h[i]>h[i+1]){
      if(maxi-h[i+1]>1) flg = false;
    }
  }
  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cerr << #v << " = "; array_out(v , __VA_ARGS__ );} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
 
using P = pair<ll,ll>; using vp = vector<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
/////////////////
void solve(){
  inl(N);
  trc(N % 11);
  if(N % 11 == 0) out((N / 11) * 2);
  else if(N % 11 <= 6) out((N / 11) * 2 + 1);
  else out((N / 11) * 2 + 2);
}



Measured memory_bytes: 256
// E.

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

using namespace std;

typedef long long LL;
typedef long double LD;
const LL MOD = 1000000007;
const LD EPS = 1e-10;
static const size_t MAX_N = 1000001;

struct modll {
	long long x;
	modll() { }
	modll(int _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(int y) { return (x + y + MOD) % MOD; }
	modll operator+=(int y) { x = (x + y + MOD) % MOD; return *this; }
	modll operator-(int y) { return (x - y + MOD) % MOD; }
	modll operator-=(int y) { x = (x - y + MOD) % MOD; return *this; }
	modll operator*(int y) { return (x * y) % MOD; }
	modll operator*=(int y) { x = (x * y) % MOD; return *this; }
	modll operator/(int y) { return (x * modpow(y, MOD - 2)) % MOD; }
	modll operator/=(int y) { x = (x * modpow(y, MOD - 2)) % MOD; return *this; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

modll combination(LL n, LL r) {
	static modll fact[MAX_N + 1], inv[MAX_N + 1];
	if (!fact[0]) {
		fact[0] = 1;
		for (int i = 1; i <= MAX_N; ++i) {
			fact[i] = fact[i - 1] * i;
		}
		inv[MAX_N] = modll::modinv(fact[MAX_N]);
		for (int i = MAX_N; i >= 1; --i) {
			inv[i - 1] = inv[i] * i;
		}
	}
	if (r > n) {
		return 0;
	}
	return (fact[n] * inv[r]) * inv[n - r];
}

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		int n = -1, k;
		cin >> n >> k;
		if (n < 0) return 0;
		vector<int> a(n);
		for (int i = 0; i < n; ++i) {
			cin >> a[i];
		}

		modll ans = 0;
		sort(a.rbegin(), a.rend());
		for (int i = 0; i <= n - k; ++i) {
			modll x = a[i] + MOD;
			ans += x * combination(n - i - 1, k - 1);
		}

		sort(a.begin(), a.end());
		for (int i = 0; i <= n - k; ++i) {
			modll x = a[i] + MOD;
			ans -= x * combination(n - i - 1, k - 1);
		}

		cout << ans << endl;

	}
	return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define rep(i,n) for(int i = 0; i < (n); i++)

template<class T, class U>
using umap = unordered_map<T, U>;
using ll = long long;

ll n;
vector<vector<ll>> a;
umap<ll, vector<ll>> to;
int main(){
  cin >> n;
  const ll MAXN = 1010;
  const ll MAXV = MAXN*MAXN*0.5;
  a.resize(n, vector<ll>(n-1));
  ll tbl[MAXN][MAXN] = {};
  ll v = 0;
  rep(i,n){
    rep(j,n){
      if(i < j)tbl[i][j] = v++;
    }
  }
  auto id = [&](ll i, ll j){
	   if(i > j) swap(i, j);
	   return tbl[i][j];
	 };
  rep(i, n){
    rep(j, n-1){
      cin >> a[i][j];a[i][j]--;
      if(j)to[id(i,a[i][j-1])].push_back(id(i,a[i][j]));
    }
  }
  
  ll dist[MAXV] = {};
  set<ll> vst, fin;
  auto dfs = [&](ll i, auto func) -> ll{
	       if(vst.count(i) == 1) {
		 if(fin.count(i) == 0) return -1;
		 return dist[i];
	       }
	       vst.insert(i);
	       ll ret = 1;
	       for(auto&e : to[i]){
		 ll d = func(e, func);
		 if(d == -1) return -1;
		 else ret = max(ret, d + 1);
	       }
	       fin.insert(i);
	       dist[i] = ret;
	       return dist[i];
	     };
  ll ans = 1;
  rep(i,MAXV){
    ll val = dfs(i, dfs);
    if(val == -1){
      ans = -1; break;
    }
    ans = max(ans, val);
  }
  cout << ans << endl;
  return 0;
}













Measured memory_bytes: 111476
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
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;}

int main() {
    string s;
    cin >> s;
    char c1 = '-', c2 = '_';
    ll bgn = -1, end = -1;
    rep(i, 0, (ll)s.size()) {
        if (c2 == s[i]) {
            bgn = i;
            end = i+1;
            break;
        }
        else if (c1 == s[i]) {
            bgn = i-1;
            end = i+1;
            break;
        }
        else {
            c1 = c2;
            c2 = s[i];
        }
    }
    cout << bgn << " " << end << endl;
}

Measured memory_bytes: 512
class Hand:

    def __init__(self):
        self.flag_r = False
        self.flag_s = False
        self.flag_p = False

    def set_flag(self,str,bool):

        if str == "r":
            self.flag_r = bool

        elif str == "s":
            self.flag_s = bool

        elif str == "p":
            self.flag_p = bool

    def get_flag(self,str):

        if str == "r":
            return self.flag_r

        elif str == "s":
            return self.flag_s

        elif str == "p":
            return self.flag_p

class Point:

    def __init__(self,r,s,p):
        self._R = r#ぐ
        self._S = s#ch
        self._P = p#pa

    def get_point(self,str):

        if str == "r":
            return self._P

        elif str == "s":
            return self._R

        elif str == "p":
            return self._S


if __name__ == '__main__':

    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = list(input())
    #print(T)


    Hands = [Hand() for i in range(len(T))]
    Point = Point(R,S,P)
    ans = 0

    for i in range(len(T)):

        #じゃんけん
        if Hands[i].get_flag(T[i]) == False:
            #print(Point.get_point(T[i]))
            ans += Point.get_point(T[i])

            #k回目のflagがtrue
            try:
                Hands[i+K].set_flag(T[i],True)
            except:
                pass

        else:
            continue


    print(ans)


Measured memory_bytes: 57096
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int F[150000];
vector<int> G[150000], B[150000];
vector<double> dp[150000];


double dfs(int x, int p) {
  if (dp[x][p] != -1) return dp[x][p];
  int c = G[x].size();
  if (p != G[x].size()) c--;

  if (c == 0) return dp[x][p] = 0;
  double r = 0;
  for (int i=0; i<G[x].size(); i++) {
    if (i == p) continue;
    int t = G[x][i];
    r += dfs(t, lower_bound(all(G[t]), x)-G[t].begin())/c;
  }
  return dp[x][p] = r+1;
}

double dfs2(int x, int p) {
  if (dp[x][p] != -1) return dp[x][p];
  int c = G[x].size();
  if (p != G[x].size()) c--;

  if (c == 0) return dp[x][p] = 0;
  double r = 0;
  if (F[x] == -1) {
    for (int i=0; i<G[x].size(); i++) {
      if (i == p) continue;
      r += dfs2(G[x][i], B[x][i]);
    }
    dp[x][p] = (r/c)+1;
    F[x] = r;
    if (p < G[x].size()) F[x] += dfs2(G[x][p], B[x][p]);
    return dp[x][p];
  }
  else {
    r = F[x];
    if (p < G[x].size()) r -= dfs2(G[x][p], B[x][p]);
  }
  return dp[x][p] = (r/c)+1;
}


signed main() {
  scanf("%d", &N);
  rep(i, N-1) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--, b--;
    G[a].pb(b);
    G[b].pb(a);
  }
  bool f = false;
  rep(x, N) {
    F[x] = -1;
    sort(all(G[x]));
    B[x].resize(G[x].size());
    dp[x].resize(G[x].size()+1, -1);
    if (G[x].size() > 1000) f = true;
  }

  rep(x, N) {
    for (int i=0; i<G[x].size(); i++) {
      int t = G[x][i];
      B[x][i] = lower_bound(all(G[t]), x) - G[t].begin();
    }
  }
  rep(i, N) {
    if (f)
    printf("%.15f\n", dfs2(i, G[i].size()));
    else
    printf("%.15f\n", dfs(i, G[i].size()));
  }
  return 0;
}


Measured memory_bytes: 36224
#include<stdio.h>
int main(){
    int r, c, table[105][105], i, j;
    scanf("%d %d", &r, &c);

    for(i=0;i<=r;i++){
        table[i][c] = 0;
    }
    for(j=0;j<=c;j++){
        table[r][j] = 0;
    }
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            scanf("%d",&table[i][j]);
            table[i][c] += table[i][j];
            table[r][j] += table[i][j];
        }
        table[r][c] += table[i][c];
    }
    for(i=0;i<=r;i++){
        for(j=0;j<c;j++){
            printf("%d ", table[i][j]);
        }printf("%d\n", table[i][j]);
    }

return 0;
}



Measured memory_bytes: 2108
#include <stdio.h>


int main()
{

    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int ans=a+b;
    if (a+c<ans) ans=a+c;
    if (b+c<ans) ans=b+c;
    printf("%d\n",ans);

}


Measured memory_bytes: 128
fun main(args:Array<String>){
    var (n,k) = readLine()!!.split(" ").map(String::toInt)
    var sum = 0.0
    for (x in 1 until (n+1)) {
        var tmp = 1.0/n
        var y = x
        while (y<k) {
            tmp *= 0.5
            y *= 2
        }
        sum+=tmp
    }

    println(sum)
}


Measured memory_bytes: 36484
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n, l;
    cin >> n >> l;

    pair<ll, ll> p[n];
    rep(i, 0, n){
        cin >> p[i].first >> p[i].second;
    }

    ll ans = 9000000000000000000;
    rep(i, 0, n){
        rep(j, i + 1, n){
            rep(k, 0, n){
                rep(m, k + 1, n){
                    ll count = 0;
                    rep(o, 0, n){
                        if(min(p[i].first, p[j].first) <= p[o].first &&
                                max(p[i].first, p[j].first) >= p[o].first &&
                                min(p[k].second, p[m].second) <= p[o].second &&
                                max(p[k].second, p[m].second) >= p[o].second){
                            count++;
                        }
                    }
                    if(count >= l){
                        ans = min(ans, ll(abs(p[i].first - p[j].first)) * ll(abs(p[k].second - p[m].second)));
                    }
                }
            }
        }
    }

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


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv){vprint(v)};

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

    ll N, Q;
    cin >> N >> Q;

    ll h = N-2;
    ll w = N-2;
    ll total = h * w;

    vll hs(N-2, -1), ws(N-2, -1);
    hs[N-3] = ws[N-3] = N-2;

    vll qs(Q), xs(Q);
    rep(i, Q){
        ll q, x;
        cin >> q >> x;
        qs[i] = q;
        xs[i] = x;
        if(q==1){
            w = min(w, x-2);
            if(h>0) ws[h-1] = w;
        }
        else{
            h = min(h, x-2);
            if(w>0) hs[w-1] = h;
        }
    }
    ll idx = N-3;
    while(idx>0){
        if(hs[idx-1]<0) hs[idx-1] = hs[idx];
        if(ws[idx-1]<0) ws[idx-1] = ws[idx];
        --idx;
    }

    rep(i, Q){
        if(qs[i]==1){
            total -= hs[xs[i]-2];
        }
        else{
            total -= ws[xs[i]-2];
        }
    }
    cout << total << endl;
}


Measured memory_bytes: 9496
#include <bits/stdc++.h>
#define rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)


#define SZ(x) ((int)(x).size())


typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
struct Vec{
    double x, y;
};

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;
}

template<class T>
T min(T a, T b)
{
    if (a < b) return a;
    return b;
}

template<class T>
T max(T a, T b)
{
    if (a > b) return a;
    return b;
}

using namespace std;

int main()
{
    string S;
    cin >> S;
    int cnt;
    rep(i, 3) {
        if (S[i] == 'A') cnt++;
    }
    if (cnt > 0 && cnt < 3) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

#define foreach(i,v) for(auto&& i: v)
#define all(x) (x).begin(), (x).end()

typedef std::vector< std::string > VS;
typedef std::vector<int> VI;
typedef long long ll;

template <class C> C& mini(C& a, C b) { if (b < a) a = b; return a; }
template <class C> C& maxi(C& a, C b) { if (a < b) a = b; return a; }


using namespace std;

map<pair<int, string>, int> sleft, sright;

void doleft(const char *s, int N) {
	string ss;
	ss.resize(N);

	for (int m = 0; m < (1 << N); m++) {
		int l = 0, r = N-1;
		for (int i = 0; i < N; i++)
			if (m & (1 << i))
				ss[l++] = s[i];
			else
				ss[r--] = s[i];
		sleft[make_pair(__builtin_popcount(m), ss)]++;
	}
}

void doright(const char *s, int N) {
	string ss;
	ss.resize(N);

	for (int m = 0; m < (1 << N); m++) {
		int l = 0, r = N-1;
		for (int i = 0; i < N; i++)
			if (m & (1 << i))
				ss[l++] = s[N-i-1];
			else
				ss[r--] = s[N-i-1];
		sright[make_pair(__builtin_popcount(m), ss)]++;
	}
}

int main(int argc, const char* argv[]) {
	int N;
	char A[64];
	scanf("%d\n", &N);
	scanf("%s\n", &A);
	doleft(&A[0], N);
	doright(&A[N], N);
	ll ret = 0;
	auto itl = sleft.begin();
	auto itr = sright.begin();
	while (itl != sleft.end() && itr != sright.end()) {
		if (itl->first < itr->first)
			itl++;
		else if (itl->first > itr->first)
			itr++;
		else {
			ret += (ll)itl->second * itr->second;
			itl++;
			itr++;
		}
	}

	printf("%lld\n", ret);
	return 0;
}


Measured memory_bytes: 65792
#include<bits/stdc++.h>
int a[123456];
int main()
{
	long long ans1=1,ans2=1;
	int n;
	scanf("%d",&n);
	for (int i=0;i<n;i++){
		scanf("%d",a+i);
		if ((a[i]&1)==0)ans2*=2;
		ans1*=3;
	}
	printf("%lld",ans1-ans2);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char str[20];
	int i;
	
	scanf("%s", str);
	
	for (i = 0; i < 20; i++){
		if (str[i] == '\0'){
			break;
		}
	}
	
	for (i--; i >= 0; i--){
		printf("%c", str[i]);
	}
	printf("\n");
	
	return (0);
}

Measured memory_bytes: 520
import numpy as np
H, W = map(int, input().split())
lines = [input() for i in range(H)]
grid = np.zeros([H, W])
for i in range(H):
    for ii in range(W):
        if lines[i][ii] == '#':
            grid[i, ii] = 1
flag = True
for i in range(H):
    for ii in range(W):
        if grid[i, ii] == 1:
            if i == 0:
                if ii == 0:
                    a = grid[i, ii+1] + grid[i+1, ii]
                elif ii == W-1:
                    a = grid[i, ii-1] + grid[i+1, ii]
                else:
                    a = grid[i, ii-1] + grid[i, ii+1] + grid[i+1, ii]
            elif i == H-1:
                if ii == 0:
                    a = grid[i, ii+1] + grid[i-1, ii]
                elif ii == W-1:
                    a = grid[i, ii-1] + grid[i-1, ii]
                else:
                    a = grid[i, ii-1] + grid[i, ii+1] + grid[i-1, ii]
            else:                
                if ii == 0:
                    a = grid[i, ii+1] + grid[i+1, ii] + grid[i-1, ii]
                elif ii == W-1:
                    a = grid[i, ii-1] + grid[i+1, ii] + grid[i-1, ii]
                else:
                    a = grid[i, ii-1] + grid[i, ii+1] + grid[i+1, ii] + grid[i-1, ii]
            if a == 0:
                flag = False
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 21536
A,B,C,X,Y = map(int,input().split())

if A+B <= 2*C:
	print(A*X+B*Y)
elif X <= Y:
	if B <= 2*C:
		print(2*C*X+B*(Y-X))
	else:
		print(2*C*Y)
elif X >= Y:
	if A <= 2*C:
		print(2*C*Y+A*(X-Y))
	else:
		print(2*C*X)

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

int main()
{
    ll t = 1;
    //cin >> t;
    while (t--)
    {
        char s[5];
        scanf("%s",s);
        if(s[0] >= 'a' && s[0] <= 'z')
        {
            printf("a\n");
        }
        else
        {
            printf("A\n");
        }
    }
}


Measured memory_bytes: 3688
import sys

readline = sys.stdin.buffer.readline


def main():
    N, K = map(int, readline().split())
    H = list(map(int, readline().split()))
    for i in range(K):
        H.append(10**10)

    dp = [10**10] * (N+K)
    dp[0] = 0

    for i in range(N):
        for k in range(1, K+1):
            dp[i+k] = min(dp[i+k], dp[i] + abs(H[i+k]-H[i]))

    print(dp[N-1])


main()


Measured memory_bytes: 52464
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let A = cin.getInt(), B = cin.getInt(), C = cin.getInt();
    let ans = (A < C && C < B) || (B < C && C < A);
    console.log(ans ? "Yes" : "No");
}
class Inputer{constructor(t){this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

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

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector <int> a(n);
    int s = 0;
    for (auto &i : a) {
        cin >> i;
        s += i;
    }
    s = (s + 4 * m - 1) / (4 * m);
    for (int i = 0; i < n; i++) {
        if (a[i] >= s) --m;
    }
    if (m <= 0) {
        cout << "Yes\n";
    }
    else cout << "No\n";
}


Measured memory_bytes: 3656
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var N, M int
	con.Scan(&N)
	T := make([]int, N)
	var S int
	for i := range T {
		con.Scan(&T[i])
		S += T[i]
	}
	con.Scan(&M)
	for i := 0; i < M; i++ {
		var p, x int
		con.Scan(&p, &x)
		con.Println(S - T[p-1] + x)
	}
	return nil
}


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

using namespace std;

int main(){

    int n[3], k, i, j, l = 0, m = 2, temp, maxim;

    cin >> n[0] >> n[1] >> n[2] >> k;

    int sum[k*3];

    for(i = 0; i < k; i++){
        for(j = 0; j < 3; j++){
            temp = n[j];
            n[j] *= m;
            sum[l] = n[0] + n[1] + n[2];
            l++;
            n[j] = temp;
        }
        m *= 2;
    }

    maxim = sum[0];

    for(i = 0; i < l; i++){
        if(maxim < sum[i]){
            maxim = sum[i];
        }
    }

    cout << maxim << endl;

    return 0;
}





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

int main(){
  int n;
  cin>>n;
  int h[n];
  rep(i,0,n) cin>>h[i];
  int dp[n];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  rep(i,2,n){
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
fun main() {
  val (n, k) = readLine()!!.split(' ').map { it.toInt() }
  if(k >= n) {
    println(0)
    return
  }
  val sum = readLine()!!.split(' ').map { it.toLong() }.sortedDescending().subList(k,n).sum()
  println(sum)
}

Measured memory_bytes: 65404
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000
struct duilie {
    char name[10];
    int time;
} Q[MAX];

int head;
int tail;
int max;

void initialize(){
    head = tail = 0;
}

int isEmpty(){
    return head == tail;
}

int isFull(){
    return (head == tail+1) || (tail+1 == MAX && head == 0);
    //return head == (tail+1)%MAX
}

void enqueue(struct duilie x){
    if (isFull()){
        printf("Full, error\n");
        exit(-1);
    }
    Q[tail] = x;
    if (tail+1 == MAX)
        tail = 0;
    else
        tail++;
}

struct duilie dequeue(){
    if (isEmpty()){
        printf("Empty, error\n");
        exit(-1);
    }
    struct duilie tmp = Q[head];
    if (head+1 == MAX)
        head = 0;
    else
        head++;    

    return tmp;
}

int main (){
    initialize();
    int n, split;
    scanf("%d", &max);
    scanf("%d", &split);
    for (int i = 0; i < max; i++){
        scanf("%s", &Q[i].name);
        scanf("%d", &Q[i].time);
		tail++;
    }
    int totalTime = 0;
	while (!isEmpty()){
		if (Q[head].time <= split){
			totalTime += Q[head].time;
			printf("%s %d\n", Q[head].name, totalTime);
			dequeue();
		}
		else {
			totalTime += split;
            Q[head].time -= split;
			enqueue(dequeue());
		}
	}
    return 0;
}


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

int main(int argc, char const *argv[])
{
    int m,f,r,sum;
    while(1) {
        cin >> m >> f >> r;
        sum = m + f;
        if(m==-1 && f==-1 && r==-1) break;
        else if(m==-1 || f==-1) cout << 'F' << endl;
        else if(sum>=80) cout << 'A' << endl;
        else if(80>sum && sum>=65) cout << 'B' << endl;
        else if(65>sum && sum>=50) cout << 'C' << endl;
        else if(50>sum && sum>=30 && r>=50) cout << 'C' << endl;
        else if(50>sum && sum>=30 && r<50) cout << 'D' << endl;
        else if(sum<30) cout << 'F' << endl;
    }

    return 0;
}

Measured memory_bytes: 1152