akhauriyash/Code-Regression huggingface dataset:
<?php
while (true) {
    list($height, $width) = getSpacesByExplodeTrimInput();
    $lines = array();

    if ($height == 0 && $width == 0) {
        break;
    }
   
    for ($i = 0; $i < $height; $i++) {
        if ($i % 2) {
                $lines[] = setEvenNumLine($width);
        } else {
                $lines[] = setOddNumLine($width);
        }
    }

    echo implode($lines), PHP_EOL;
}

function getSpacesByExplodeTrimInput()
{
    return explode(' ', trim(fgets(STDIN)));
}

function setEvenNumLine($width)
{
    for ($i = 0; $i < $width; $i++) {
        $symbol[] = $i % 2 ? "#" : ".";
    }
    return implode($symbol).PHP_EOL;
}
   
function setOddNumLine($width)
{
    for ($i = 0; $i < $width; $i++) {
        $symbol[] = $i % 2 ? "." : "#";
    }
    return implode($symbol).PHP_EOL;
}

Measured memory_bytes: 15432
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)
#define INF 10000000

using namespace std;

void solve(void){
    int x, a, b;
    cin >> x >> a >> b;
    if (a >= b) cout << "delicious" << endl;
    else if (a + x >= b) cout << "safe" << endl;
    else cout << "dangerous" << endl;
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 256
#define George_Plover
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <iostream>
#include <iomanip>
#include <algorithm>
#define MAXN 200001
#define MAXM 200001
#define MOD 100000007
#define EPS (1e-8)
#define LL long long
using namespace std;
map<int,int>s;
int n,m;
int h[MAXN];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&h[i]);
        s[i+h[i]]+=1;
    }
    LL ans=0;
    for(int i=1;i<=n;i++)
    {
        auto tmp=s.find(i-h[i]);
        if(tmp==s.end())
            continue;
        else
            ans+=s[i-h[i]];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 13324
import sys


def input():
    return sys.stdin.readline()[:-1]


if __name__ == "__main__":
    N = int(input())
    al = [chr(ord('a') + i) for i in range(26)]

    def dfs(s, mx):
        if (len(s) == N):
            print(s)
        else:
            for c in al:
                if c == chr(ord(mx) + 1):
                    break
                nmx = chr(ord(mx) + 1) if (c == mx) else mx  # 次のmx
                dfs(s + c, nmx)

    dfs('', 'a')


Measured memory_bytes: 4340
#include <stdio.h>

int main()
{
	int N;
	scanf("%d", &N);
	long long int array[N], max = 1e18, x = 1, y = 0, z = 0;
	
	for(int i = 0; i < N; i++)
	{
		scanf("%lld", &array[i]);
		y = (array[i] > max) ? 1 : y;
		x = x*array[i];
		(array[i]) ? max = max/array[i] : z = 1;
	}
	(z) ? printf("0") : ((y) ? printf("-1") : printf("%lld\n", x));
	return 0;
}

Measured memory_bytes: 2460
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a = I()
    s = input()
    if a >= 3200:
        print(s)
    else:
        print("red")
    return

#B
def B():
    n = I()
    a = LI()
    ans = 0
    for i in a:
        ans += 1/i
    print(1/ans)
    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 39152
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        c: usize,
        a: [usize; n],
        b: [usize; n]
    }
    let d = 1000000007;
    let mut p = vec![vec![0; 401]; c + 1];
    for i in 0..c + 1 {
        for j in 1..401 {
            p[i][j] = (p[i][j - 1] + pow_m(j, i, d)) % d;
        }
    }
    let mut tab = vec![vec![0; c + 1]; n + 1];
    tab[n][0] = 1;
    for i in (0..n).rev() {
        for j in 0..c + 1 {
            for k in 0..j + 1 {
                tab[i][j] += (p[k][b[i]] + d - p[k][a[i] - 1]) * tab[i + 1][j - k] % d
            }
            tab[i][j] %= d;
        }
    }
    println!("{}", tab[0][c]);
}

fn pow_m(n: usize, mut p: usize, d: usize) -> usize {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r % d;
            p /= 2;
        } else {
            ret = ret * r % d;
            p -= 1;
        }
    }
    ret
}


Measured memory_bytes: 6396
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int a, b;

int main() {
	cin >> a >> b;
	int cnt = 0;
	for (int i = a; i <= b; i++) {
		string s = to_string(i);
		if (s[0] == s[4] && s[1] == s[3])cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <cstring>
#include <cassert>
#include <list>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <limits>
using namespace std;
typedef long long          ll;
typedef unsigned long long ull;
typedef long double        ld;
typedef pair<int,int>      pii;
typedef pair<ll,ll>        pll;
typedef vector<int>        vi;
typedef vector<long long>  vll;
#define left(x)		   (x << 1)
#define right(x) 	   (x << 1) + 1
#define mid(l, r) 	   ((l + r) >> 1)
#define mp                 make_pair
#define pb                 push_back
#define all(a)             a.begin(),a.end()
#define debug(x)	   {cerr <<#x<<" = " <<x<<"\n"; }
#define debug2(x, y)       {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<"\n";}
#define debug3(x, y, z)    {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<"\n";}
#define debug4(x, y, z, w) {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<", "<<#w << " = " <<w <<"\n";}
#define ss                 second
#define ff                 first
#define m0(x) 		   memset(x,0,sizeof(x))

template<typename T >T min_ ( T a , T b ) { return a > b ? b : a ; }
template < typename T ,  typename... Ts > T min_( T first , Ts... last ){ return  min_(first, min_(last...)); }
template<typename T >T max_ ( T a , T b ) { return a > b ? a : b ; }
template < typename T ,  typename... Ts > T max_( T first , Ts... last ){ return  max_(first, min_(last...)); }

template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<typename T> ostream& operator<< (ostream& out, const vector<T>& v) {
    out << "["; size_t last = v.size() - 1; for(size_t i = 0; i < v.size(); ++i) {
    out << v[i]; if (i != last) out << ", "; } out << "]"; return out;
}

ll pwr(ll base, ll p, ll mod){
ll ans = 1; while(p) { if(p&1) ans=(ans*base)%mod; base=(base*base)%mod; p/=2; } return ans;
}
ll gcd(ll a, ll b) {  return b == 0 ? a : gcd(b,a%b); }
ll lcm(ll a, ll b) {  return a*(b/gcd(a,b)); }

const long double PI = (long double)(3.1415926535897932384626433832795);
const ll  mx_ll   = numeric_limits<ll> :: max();
const int mx_int  = numeric_limits<int> :: max();
const int mod = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef __APPLE__
    freopen("test.in", "rb", stdin);
    //freopen("  .out", "wb", stdout);
#endif

   int a, b, c; cin >>  a >> b >> c;
   if(c >= a && c <= b)
   {
       cout << "Yes";
       return 0;
   }
   if(c >= b && c <= a)
   {
       cout << "Yes";
       return 0;
   }
   cout << "No";
    return 0;
}



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

int main()
{
    int N, H, W;
    cin >> N >> H >> W;
    int count = 0;
    for(int n = 0; n < N; n++) {
        int A, B;
        cin >> A >> B;
        if(A >= H && B >= W) {
            count += 1;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3600
#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>;

int main(){
	int a, b;
	cin >> a >> b;
	if((a+b)%2 == 0){
		cout << (a+b)/2 << endl;
    }else{
		cout << "IMPOSSIBLE" << endl;
	}
}

Measured memory_bytes: 256
def solve(n, a):
    from itertools import accumulate

    inf = (400 ** 2) * (10 ** 9) + 10

    acc = (0,) + tuple(accumulate(a))
    cost = [[inf] * (n + 1) for _ in range(n + 1)]
    for i in range(n):
        cost[i][i + 1] = 0

    for l in range(n - 1, -1, -1):
        for r in range(l + 2, n + 1):
            for c in range(l + 1, r):
                cost[l][r] = min(cost[l][r], cost[l][c] + cost[c][r])
            cost[l][r] += acc[r] - acc[l]

    return cost[0][n]


if __name__ == '__main__':
    n = int(input())
    a = tuple(map(int, input().split()))
    print(solve(n, a))


Measured memory_bytes: 41328
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    int d;
    cin >> d;
    const int n = 26;
    vector<int> c(n,0);
    rep(i,n)cin >> c[i];
    vector<vector<int>> s(365,vector<int>(n,0));
    rep(i,d)rep(j,n)cin >> s[i][j];
    rep(i,d){
        cout << 15 << endl;
    }
    return 0;
}

Measured memory_bytes: 3680
parseInt(x) = parse(Int, x)
parseFloat(x) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n,m=parseMap(split(readline()))
    x=sort(parseMap(split(readline())))
    if n>=m
        println(0)
    else
        dif=[0 for i in 1:m-1]
        for i in 1:m-1
            dif[i]=x[i+1]-x[i]
        end
        sort!(dif,rev=true,by=x->x[1])
        ans=0
        for i in 1:m-1
            if i>=n
                ans+=dif[i]
            end
        end
        println(ans)
    end
end
main()

Measured memory_bytes: 122632
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF = 1e18;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    map<ll,ll> mp1;
    rep(i,n){
        ll x;
        cin>>x;
        mp1[x]++;
    }
    ll k;
    cin>>k;
    map<ll,ll> mp2;
    rep(i,k){
        ll x;
        cin>>x;
        mp2[x]++;
    }
    for(auto i=mp2.begin();i!=mp2.end();i++){
        if(mp1[i->first]<i->second){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  double t, x ;
  cin >> t >> x ;
  cout << t/x << endl ;
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end
def debug(k,v) puts "#{k}: #{v}" end
def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end


n = gi #10**3
as = gsmi

now = 1000
kabu = 0

as.each_cons(2) do |a,a2|
  if a2>a
    kabu, now = kabu+now/a, now%a
  else
    kabu, now = 0, now+a*kabu
  end
end
kabu, now = 0, now+as[-1]*kabu
puts now


Measured memory_bytes: 14416
n = int(input())

d = input().split(" ")
ans = 0

for i in range(1,n-1):
	if(d[i] == d[i-1] and d[i] == d[i+1]):
		ans += 1
		d[i] = -i;

	elif(d[i] == d[i-1]):
		ans += 1
		d[i-1] = -i

	elif(d[i] == d[i+1]):
		ans += 1
		d[i+1] = -i

if(n == 2):
	if(d[0] == d[1]):
		ans += 1
# print(d)
print(ans)

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

int main()
{
    string s,ans="Yes";
    cin >> s;
    if(s[0]==s[1]&&s[1]==s[2]) ans ="No";
    cout << ans << endl;
}


Measured memory_bytes: 256
r,g,b,n = list(map(int,input().split(" ")))
c = 0
rl = n//r + 1
bl = n//b + 1


for i in range(rl):
    for j in range(bl):
        if n-(i*r + b*j) >=0 and (n-(i*r + b*j)) % g == 0:
            c += 1
print(c)

Measured memory_bytes: 40556
/*
    JAI JAGANNATH!
*/
//@Author : zanj0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<lli>
#define mii             map<lli,lli>
#define pqb             priority_queue<lli>
#define pqs             priority_queue<lli,vi,greater<lli> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            lli x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void zanj0()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void solve() {
	lli n;
	cin >> n;
	set <string> s;
	string x;
	while (n--) {
		cin >> x;
		s.insert(x);
	}
	cout << s.size() << endl;
}
int main()
{
	zanj0();
	solve();
	return 0;
}

Measured memory_bytes: 19208
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(lambda x:int(x)-1, input().split())
    G[a].append(b)
    G[b].append(a)

from itertools import permutations
c = 0
for p in permutations(range(1, N)):
    pi = 0
    for pj in p:
        if not pj in G[pi]:
            break
        pi = pj
    else:
        c += 1
print(c)

Measured memory_bytes: 3064
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n; cin >> n;
    vector<ll> a(n), b(n), c(n);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];
    REP(i, n) cin >> c[i];
    sort(ALL_OF(a));
    sort(ALL_OF(b));
    sort(ALL_OF(c));

    ll ans = 0;
    REP(i, n) {
        ll j = lower_bound(ALL_OF(a), b[i]) - a.begin();
        ll k = upper_bound(ALL_OF(c), b[i]) - c.begin();
        ans += j * (n - k);
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 2560
n, m, l = map(int, input().split())
a = [[0 for j in range(m)] for i in range(n)]
b = [[0 for k in range(l)] for j in range(m)]
c = [[0 for k in range(l)] for i in range(n)]
 
for i in range(n):
  a[i] = list(map(int, input().split()))
for i in range(m):
  b[i] = list(map(int, input().split()))
for i in range(n):
  for k in range(l):
    sum = 0
    for j in range(m):
      sum += a[i][j] * b[j][k]
    c[i][k] = sum
    if k == 0:
      print(c[i][k], end = "")
    else:
      print("", c[i][k], end = "")
  print()


Measured memory_bytes: 7160
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << endl; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;

using Graph = vector<vector<int>>;
Graph G;

int main() {
  int n; cin >> n;
  V ans(n);
  for (int i = 0; i < n-1; ++i) {
    int a;
    cin >> a;
    a--;
    ans[a]++;
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 3988
#include <iostream>

int main()
{
  long K, S;
  std::cin >> K >> S;

  long c = 0;
  for(long x = 0; x <= K; ++x)
  {
    for(long y = 0; y <= K; ++y)
    {
      long z = S - (x + y);
      if(0 <= z && z <= K) ++c;
    }
  }
  std::cout << c << std::endl;

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;
const ll MOD=1e9+7;
const int INF=1<<30;

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

double dp[3000][3000];

void add(double &a,double b){
  a=a+b;
}
           
         
int main(){
  int N; cin >> N;
  vector<double> p(N);
  rep(i,N){
    cin >> p[i];
  }
  dp[0][0]=1;
  rep(i,N){
    rep(j,i+1){
      add(dp[i+1][j+1],dp[i][j]*p[i]);
      add(dp[i+1][j],dp[i][j]*(1-p[i]) );
    }
  }
  double ans=0;
  for (int j=(N+1)/2;j<=N;j++){
    ans+=dp[N][j];
  }
  /*
  rep(i,N+1){
    rep(j,N+1){
      if(j==N){
        cout << dp[i][j] << endl;
        continue;
      }
      cout << dp[i][j] << " ";
    }
  }
  */
  cout << fixed << setprecision(10) << ans << endl;  
  
}

Measured memory_bytes: 68864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
const ld pi = acos(-1);
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

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

int main() {
    init();

    int n; ll a; cin >> n >> a;
    VL x(n);
    FOR(i, 0, n) {
        cin >> x[i];
        x[i] = abs(a - x[i]);
    }

    ll ans = x[0];
    FOR(i, 1, n)ans = gcd(ans, x[i]);
    cout << ans << "\n";
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}

#define MAX_N (4000)
bool is_candidate[MAX_N + 1];

int main() {

	ll N;
	cin >> N;

	ll ans = 0;
	for (ll i = 1; i < N + 1; i++) {
		ll fact_num = N / i;
		ll fact_sum = fact_num * (fact_num + 1) / 2 * i;
		ans += fact_sum;
	}

	cout << ans << endl;

	return 0;

}


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

using namespace std;

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
vector<long long> divisor(long long n){//nの約数列挙
    vector<long long> res;
    for(long long i = 1; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            if(i != n / i) res.push_back(n / i);
        }
    }
    return res;
}
int main(){
    long long N;
    cin >> N;
    vector<long long> d = divisor(N);
    long long ans = 1e18;
    for(int i = 0; i < d.size(); i++){
        long long t = d[i];
        long long temp = (t - 1) + N / t - 1;
        if(temp < ans) ans = temp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int n= sc.nextInt();
      String s = sc.next();
      for(int i=0;i<s.length();i++){
        int x = s.charAt(i)+n;
        if(x>90){
          x-=26;
        }
        System.out.print((char)x);
      }
      System.out.println();
    }
}

Measured memory_bytes: 39560
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

public class Main{
	
	public static void main(String[] args) {
		new Main().run();
	}
	
	double dist(double x0,double y0,double x1,double y1) {
		double dx=x0-x1;
		double dy=y0-y1;
		return Math.sqrt(dx*dx+dy*dy);
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		int A=sc.nextInt();
		int B=sc.nextInt();
		int H=sc.nextInt();
		int M=sc.nextInt();
		double a0=1.*(H+M/60.)/12*2*Math.PI;
		double a1=1.*M/60*2*Math.PI;
		double x0=A*Math.cos(a0);
		double y0=A*Math.sin(a0);
		double x1=B*Math.cos(a1);
		double y1=B*Math.sin(a1);
		System.out.println(dist(x0,y0,x1,y1));
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 33228
#!/usr/bin/env python3
H, W = map(int, input().split())
s = [0 for i in range(H)]
for i in range(H):
    s[i] = str(input())

l = [[0 for i in range(W)] for j in range(H)]

for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            l[i][j] = 1

dp = [[0 for i in range(W)] for j in range(H)]

dp[0][0] = l[0][0]

for i in range(1, W):
    dp[0][i]  = dp[0][i-1]
    if l[0][i] != l[0][i-1]:
        dp[0][i] += 1
for i in range(1, H):
    dp[i][0] = dp[i-1][0]
    if l[i][0] != l[i-1][0]:
        dp[i][0] += 1

for i in range(1, H):
    for j in range(1, W):
        a, b = dp[i-1][j], dp[i][j-1]
        if l[i-1][j] != l[i][j]:
            a += 1
        if l[i][j-1] != l[i][j]:
            b += 1
        dp[i][j] = min(a, b)
if l[0][0] == l[H-1][W-1] == 0:
    print(dp[H-1][W-1] // 2)

else:
    print(max(1, (dp[H-1][W-1] + 1)//2))

Measured memory_bytes: 3316
using System;

namespace ABC044A
{
    class Program
    {
        static void Main(string[] args)
        {
            int N, K, X, Y, A;
            N = int.Parse(Console.ReadLine());
            K = int.Parse(Console.ReadLine());
            X = int.Parse(Console.ReadLine());
            Y = int.Parse(Console.ReadLine());
            if (N <= K) { A = N * X; }
            else { A = K * X + (N - K) * Y; }
            Console.WriteLine(A);
            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const int INF = 1<<30;

int main(){
  int n;cin>>n;
  string ans="";
  if(n==0)ans="0";
  else{
    while(n!=0){
      if(n>0){
        ans.insert(0, string(1, char(int(n%2)+'0')));
        n = -n/2;
      }else{
        ans.insert(0, string(1, char(int(-n%2)+'0')));
        n = (-n)/2+(-n)%2;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1e9 + 7;
typedef pair<int,int> P;// pair型は２つの値の組を表せる

int main(){
    int A,B; cin >> A >> B;
    for (int i=1; i<=1009; i++){
        if (floor(i*0.08)==A && floor(i*0.1)==B){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N, K;
cin >> N >> K;
int ball[110];
for(int i = 0; i < N; i++){
cin >> ball[i];
}
int ans = 0;
for(int i = 0; i < N; i++){
int a = ball[i];
int b = K - ball[i];

ans += min(a, b);
}
cout << ans*2 << endl;


}

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

int main() {
  int n, k, ans, maxi; cin >> n >> k; ans = maxi = --n;
  string s; cin >> s;
  while(n){ if (s[n-1] != s[n]) ans--;  n--;}
  cout << min(ans + 2*k, maxi) << endl;
}

Measured memory_bytes: 3744
#include<cstdio>
#define RI register int
#define CI const int&
const int N=5005;
int n,m,mod,f[N][N][2],ans; // f[x][y] x:sum y:last delta
inline void inc(int& x,CI y)
{
	if ((x+=y)>=mod) x-=mod;
}
inline int sum(CI x,CI y)
{
	int t=x+y; return t>=mod?t-mod:t;
}
int main()
{
	RI i,j; scanf("%d%d",&n,&mod); m=(n-1)/2;
	for (f[0][0][0]=i=1;i<=m;++i) for (j=0;j<=n;++j)
	{
		f[i][j][1]=f[i-1][j][0];
		if (i<=j) inc(f[i][j][1],f[i][j-i][1]);
		f[i][j][0]=f[i][j][1];
		if (i<=j) inc(f[i][j][0],f[i][j-i][0]);
	}
	if (n&1)
	{
		for (i=1;i<=n;++i) for (j=0;n-i-j*(m+1)>=0;++j)
		inc(ans,f[m][n-i-j*(m+1)][0]);
	} else
	{
		for (i=1;i<=n;++i) for (j=0;n-i-j*(m+1)>=0;++j)
		inc(ans,1LL*f[m][n-i-j*(m+1)][0]*(j+1)%mod);
	}
	return printf("%d",ans),0;
}


Measured memory_bytes: 98560
#include <algorithm>
#include <iostream>
#include <vector>
 
using namespace std;
 
int main() {
  int h, w; cin >> h >> w;
 
  vector<vector<int> > T(h+1, vector<int>(w+1, 0));
  vector<vector<int> > A(h+1, vector<int>(w+1, 0));
 
  for (int i = 1; i <= h; i++)
    for (int j = 1; j <= w; j++)
      cin >> T[i][j];
 
  int max_side = 0;
 
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (T[i][j]) {
        A[i][j] = 0;
      } else {
        A[i][j] = min(A[i-1][j-1], min(A[i-1][j], A[i][j-1])) + 1;
        max_side = max(max_side, A[i][j]);
      }
    }
  }
 
  cout << max_side * max_side << endl;
}

Measured memory_bytes: 16580
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        x: u64,
    }

    if x <= 599 {
        println!("8");
    } else if x <= 799 {
        println!("7")
    } else if x <= 999 {
        println!("6")
    } else if x <= 1199 {
        println!("5")
    } else if x <= 1399 {
        println!("4")
    } else if x <= 1599 {
        println!("3")
    } else if x <= 1799 {
        println!("2")
    } else if x <= 1999 {
        println!("1")
    }
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(ll, n, m);
  map<ll, ll> as;
  rep(i, n) {
    in(ll, a);
    ++as[a];
  }
  rep(i, m) {
    in(ll, b, c);
    ll changed = 0;
    while (changed < n && b > 0) {
      auto [k, v] = *as.begin();
      if (k >= c) {
        break;
      }
      ll change = min(b, v);
      if (change == v) {
        as.erase(as.begin());
      } else {
        as[k] -= change;
      }
      changed += change;
      b -= change;
    }
    as[c] += changed;
  }
  ll ans = 0;
  for (auto [k, v] : as) ans += k * v;
  out(ans);
}


Measured memory_bytes: 9840
program cc
  implicit none
  integer :: n, k, i,point,sum
  integer,allocatable :: div(:)
  double precision :: prob, ans
  read *, n, k
  allocate(div(n))
  ans = 0
  div = 0
  point = 1
  prob = 1
  do i = 1, n
    point = i
    prob = 1
    do while (point < k)
      point = point * 2
      div(i) = div(i) + 1
    end do
  end do
  sum = 0
  do i = 1, n 
    sum = sum + 2**(div(1)-div(i))
  end do 
  ans = dble(sum)/(2.0**dble(div(1))*dble(n))
  print '(f15.13)', ans
  stop
end program cc


Measured memory_bytes: 640
#include <cstdio>
#define MAXH 105
#define MAXW 10
using namespace std;

const long long M=1000000007LL;

int h,w,k;bool f;
long long dp[MAXH][MAXW];

int main()
{
	scanf("%d %d %d",&h,&w,&k);dp[1][1]=1LL;
	for (int i=1;i<=h;i++)
		for (int j=1;j<=w;j++)
			for (int p=0,q=1<<(w-1);p<q;p++)
			{
				f=false;
				for (int r=1;r<w&&!f;r++) if ((p&(1<<r))&&(p&(1<<(r-1)))) f=true;
				if (f) continue;
				if (j>=2&&((p>>(j-2))&1)) (dp[i+1][j-1]+=dp[i][j])%=M;
				else if (j<=w-1&&((p>>(j-1))&1)) (dp[i+1][j+1]+=dp[i][j])%=M;
				else (dp[i+1][j]+=dp[i][j])%=M;
			}
	printf("%lld\n",dp[h+1][k]);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;

ll extgcd(ll a, ll b, ll& x, ll& y) {
    ll d = a;
    if(b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else {
        x = 1;
        y = 0;
    }
    return d;
}
 
unordered_map<ll, ll> memo;

ll inv(ll a) {
    if(memo.find(a) != memo.end()) return memo[a];
    ll x, y;
    extgcd(a, MOD, x, y);
    return memo[a] = (x + MOD) % MOD;
}

int main(){
    ll n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    ll f[1001];
    f[0]=1;
    rep(i,n) f[i+1]=f[i]*(i+1)%MOD;
    vector<vector<ll>> s(n+1,vector<ll>(n+1,0));
    rep(i,n+1) s.at(0).at(i)=1;
    for (ll i=a;i<=b;i++){
        rep(k,n+1){
        s.at(k).at(i)=s.at(k).at(i-1);
        ll in=1;
        ll invf=inv(f[i]);
        rep(j,c) in=in*invf%MOD;
        for (int j=c;j<=min(d,k/i);j++){
            ll tmp=f[n-k+i*j]*inv(f[n-k])%MOD;
            tmp=tmp*in%MOD;
            in=in*invf%MOD;
            tmp=tmp*inv(f[j])%MOD;
            (s.at(k).at(i)+=s.at(k-i*j).at(i-1)*tmp%MOD)%=MOD;
        }
        }
        
    }
    cout << s.at(n).at(b)%MOD << endl;
}


Measured memory_bytes: 8192
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	int n,k,x,y;
	int sum=0;
	cin >> n >> k >> x >> y;
	REP(i,n){
		if(i<k)
			sum+=x;
		else
			sum+=y;
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, u, v, k, l;
int edge[10001];
int start[101];
int goal[101];
int c;
int bfs[101];
queue<int> Q;
int main()
{
	cin >> n;
	c=0;
	for(int i=1; i<=n; i++)
	{
		cin >> u;
		start[i]=c;
		cin >> k;
		c+=k;
		goal[i]=c;
		for(int j=start[i]; j<goal[i]; j++)
		{
			cin >> edge[j];
		}
	}
	for(int i=1; i<=n; i++)
	{
		bfs[i]=-1;
	}
	bfs[1]=0;
	Q.push(1);
	while(!Q.empty())
	{
		v=Q.front();
		Q.pop();
		for(int j=start[v]; j<goal[v]; j++)
		{
			l=edge[j];
			if(bfs[l]==-1)
			{
				bfs[l]=bfs[v]+1;
				Q.push(l);
			}
		}
	}
	for(int i=1; i<=n; i++)
	{
		cout << i << ' ' << bfs[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL x,y,z,k;
    cin >> x >> y >> z >> k;
    VLL a(x), b(y), c(z);
    REP(i,0,x) cin >> a[i];
    REP(i,0,y) cin >> b[i];
    REP(i,0,z) cin >> c[i];
    VLL sum2;
    REP(i,0,y) REP(j,0,z) sum2.push_back(b[i] + c[j]);
    sort(all(sum2));
    reverse(all(sum2));
    VLL sum(x * k);
    REP(i,0,x) {
        REP(j,0,min(k, (LL)sum2.size())) {
            sum[i * k + j] = a[i] + sum2[j];
        }
    }
    sort(all(sum));
    reverse(all(sum));
    REP(i,0,k) cout << sum[i] << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 31980
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
#define MOD 1000000007
using namespace std;
typedef pair<int,int>pii;
int n,m;
char a[1010][1010];
int dp[1010][1010];
signed main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>a[i][j];
	dp[1][1]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)if(a[i][j]=='.'&&(i!=1||j!=1)){
			dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
		}
	cout<<dp[n][m]<<endl;
	return 0;
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(void){
	cin>>a>>b;
	if(a>0&&b>0){
		cout<<"Positive"<<endl;
		return 0;
	}
	if((a<=0&&b>=0)||(a>=0&&b<=0)){
		cout<<"Zero"<<endl;
		return 0;
	}
	if(a<0&&b<0){
		if((abs(a-b)+1)%2==0){
			cout<<"Positive"<<endl;
			return 0;
		}
		else{
			cout<<"Negative"<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main()
{
  int n,q;

  int S[10001];
  
  std::cin>>n;

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


  std::cin>>q;
  
  int T[501];
  int count=0;

  for(int i=0; i<q; i++)
    {
      std::cin>>T[i];
    }
  
  for(int i=0; i<q; i++)
    {
      for(int j=0; j<n; j++)
	{
	  if(T[i]==S[j])
	    {
	      count++;
	      break;
	    }
	}
    }

  std::cout<<count<<'\n';

  return 0;
}



Measured memory_bytes: 3088
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    int k=0,l;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='A')
        {
            k=i;
            break;
        }
    }
    for(int i=s.size()-1;i>=0;i--)
    {
        if(s[i]=='Z')
        {
            l=i;
            break;
        }
    }
    cout<<l-k+1<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d)cout << "Left" << endl;
	else if (a + b < c + d)cout << "Right" << endl;
	else cout << "Balanced" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int N,K,Q; cin >> N >> K >> Q;
    vector<int>v(N,0);
    for(int i = 0; i < Q; ++i){
        int t; cin >> t; --t;
        v[t]++;
    }
    for(auto e : v){
        cout << (K - (Q - e) > 0  ? "Yes" : "No") << endl;
    }
}


Measured memory_bytes: 1408