akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n);
	REP(i, n)cin >> v[i];
	ll ans = 0;
	FOR(a,1, n) {
		int i = 1;
		ll tmp = 0;
		while (i * a < n) {
			if ((n - 1 - i * a) % a == 0 && (n - 1 - i * a) / a <= i)break;
			
			tmp += v[i * a];
			tmp += v[n - 1 - i * a];

			if (n - 1 - i * a > a)chmax(ans, tmp);
			i++;
		}

	}
	cout << ans << endl;
}

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

int main(){
	int n;
	cin >> n;
	int sisa=n%10;
	if(sisa==2 || sisa==4 || sisa==5 || sisa==7 || sisa==9) cout << "hon\n";
	else if(sisa==0 || sisa==1 || sisa==6 || sisa==8) cout << "pon\n";
	else cout << "bon\n";
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w,k;
    cin >> h >> w >> k;
    char c[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> c[i][j];
        }
    }
    int ans = 0;
    for(int i=0;i<(1<<h);i++){
        for(int j=0;j<(1<<w);j++){
            int cnt = 0;

            for(int ii=0;ii<h;ii++){
                if((1<<ii) & i)continue;
                for(int jj=0;jj<w;jj++){
                    if((1<<jj) & j)continue;

                    if(c[ii][jj] == '#')cnt++;

                }
            }

            if(cnt == k)ans++;

        }
    }
    cout << ans<<endl;

}

Measured memory_bytes: 3576
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
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; }
typedef pair<int, int>P;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;
set<string>ans;
int N;
void dfs(string s, int c, char mx) {

	if (c >= N) {
		ans.insert(s); return;
	}
	for (char i = 'a'; i <= mx; i++) {
		dfs(s + i, c + 1, mx);
	}
	dfs(s + char(mx + 1), c + 1, mx + 1);
}
void solve() {
	cin >> N;
	string s = "a";
	dfs(s, 1,'a');
	for (auto x : ans)print(x);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 12416
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

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

const ll MOD = ll(1e9) + 7;
const ll INF = LLONG_MAX;
const ll MAX_N = ll(1e5) + 5;
const double EPS = 10e-8;
const double PI = 3.14159265359;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

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

vector<int> g[101];
bool visited[101]{};
int n, ans[101]{};

void bfs() {
    fill(ans, ans + n + 1, -1);
    ans[1] = 0;
    queue<P> que;
    que.push({1, 0});
    visited[1] = true;
    while (!que.empty()) {
        int u, d;
        u = que.front().first;
        d = que.front().second;
        que.pop();
        REP(i, g[u].size()) {
            if (visited[g[u][i]]) continue;
            que.push({g[u][i], d + 1});
            visited[g[u][i]] = true;
            ans[g[u][i]] = d + 1;
        }
    }
}

int main() {
    cin >> n;
    REP(i, n) {
        int u, m;
        cin >> u >> m;
        REP(j, m) {
            int v;
            cin >> v;
            g[u].push_back(v);
        }
    }
    bfs();
    for(int i=1;i<=n;i++){
        cout << i << " " << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3128
N = int(input())
H = list(map(int,input().split()))

for i in range(N-1,0,-1):
    if H[i] + 1 == H[i-1]:
        H[i-1] -= 1
    elif H[i] < H[i-1]:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 20596
k = int(input())


t =[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]


print(t[k-1])

Measured memory_bytes: 3060
package main

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

func main() {
	sc := newScanner()
	var n = sc.readInt()
	var a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = sc.readInt()
	}

	var pre = 0
	var now = 0
	var cnt = 0
	for i := 0; i < n; i++ {
		if i == 0 {
			pre = a[i]
			continue
		}
		now = a[i]
		if pre > now {
			cnt += pre - now
			now = pre
		}
		pre = now
	}
	fmt.Println(cnt)
}

//////////////////
//////////////////
//////////////////

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

func min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func reverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func reverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type scanner struct {
	bufScanner *bufio.Scanner
}

func newScanner() *scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &scanner{bufSc}
}

func (sc *scanner) readString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *scanner) readInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *scanner) readInt64() int64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseInt(text, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define mp make_pair
typedef long long ll;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll p)
{
    if (p == 0)
        return 1;
    if (!(p % 2))
    {
        ll halfP = p / 2;
        ll half = modpow(a, halfP);
        return half * half % mod;
    }
    else
    {
        return a * modpow(a, p - 1) % mod;
    }
}

ll comb(int a, int b)
{
    if (b > a - b)
        return comb(a, a - b);
    ll ansMul = 1;
    ll ansDiv = 1;
    for (int i = 0; i < b; i++)
    {
        ansMul *= a - i;
        ansDiv *= i + 1;
        ansMul %= mod;
        ansDiv %= mod;
    }
    ll ans = ansMul * modpow(ansDiv, mod - 2) % mod;
    return ans;
}

/*
int num = 200010;
vector<ll> fact(num), ifact(num);
fact[0] = 1;
fact[1] = 1;
for (int i = 2; i < num; i++) {
    fact[i] = fact[i-1] * i;
    fact[i] %= mod;
}
for (int i = 0; i < num; i++) {
    ifact[i] = modpow(ifact[i], mod-2);
    ifact[i] %= mod;
}
*/

using Edge = pair<int, ll>;
using Graph = vector<vector<Edge>>;

Graph G(101010);
vector<ll> dist(101010);

void dfs(int v,int p, ll sum)
{
    dist[v] = sum;
    for (auto e : G[v])
    {
        if (p == e.first) continue;
        dfs(e.first, v, sum + e.second);
    }
}

int main()
{
    int N;
    cin >> N;
    rep(i, N - 1)
    {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--;
        b--;
        G[a].pb({b, c});
        G[b].pb({a, c});
    }
    int Q, K;
    cin >> Q >> K;
    K--;
    dfs(K, -1, 0);
    rep(i, Q)
    {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        cout << dist[x] + dist[y] << endl;
    }

    return 0;
}


Measured memory_bytes: 14336
#include<iostream>
using namespace std;
int main(void){
    int R;
    cin>>R;
    if(R<1200){
        cout<<"ABC"<<endl;
    }else if(R<2800){
        cout<<"ARC"<<endl;
    }else{
        cout<<"AGC"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<map>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<cstring>
using namespace std;
typedef long long ll;
ll gcc(ll a,ll b)
{
	return b==0?a:(gcc(b,a%b));
}
ll gc(ll a,ll b,ll c)
{
	ll ans=gcc(a,b);
	ans=gcc(ans,c);
	return ans;
}
int main()
{
	ll n;
	scanf("%lld",&n);
	ll sum=0;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=n;j++)
		{
			for(ll k=1;k<=n;k++)
			{
				sum+=gc(i,j,k);
			}
		}
	}
	printf("%lld",sum);
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

/*
    if you have any question about any part of my code,
    please don't shy to ask anytime :)
*/



void solve()
{
    ll n;
    cin>>n;
    vector<ll>x(n);
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>x[i];
        sum^=x[i];
    }

    for(int i=0;i<n;i++)
    {
        cout<<(sum^x[i])<<" ";
    }
    cout<<endl;
}


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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 4712
n, k = map(int, input().split())
td = [list(map(int, input().split())) for i in range(n)]
td = sorted(td, key=lambda x: x[1], reverse=True)
sushi = [[] for i in range(2)]
used = set()
for t, d in td:
    if t in used:
        sushi[0].append(d)
    else:
        sushi[1].append(d)
        used.add(t)
y = k - min(k, len(sushi[0]))
sushi = list(reversed(sushi[0][:k])) + sushi[1][:k]
sum = sum(sushi[:k])
ans = sum + y ** 2
for i in range(len(sushi) - k):
    sum += sushi[k + i] - sushi[i]
    ans = max(ans, sum + (y + i + 1) ** 2)
print(ans)

Measured memory_bytes: 34260
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: u32,
        b: u32,
        c: u32,
        x: u32,
        y: u32,
    }
    if a+b < c*2 {
        println!("{}", a*x + b*y);
    } else {
        if x > y {
            println!("{}",
                std::cmp::min(y*c*2 + (x-y)*a, x*c*2));
        } else if x < y {
            println!("{}",
                std::cmp::min(x*c*2 + (y-x)*b, y*c*2));
        } else {
            println!("{}", x*c*2);
        }
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

int main()
{
    ll n, x;
    cin >> n >> x;
    vll a(n);
    rep(i, n) cin >> a[i];
    vvll dp(n, vll(n, infl));
    rep(start,n){
        ll now = infl;
        rep(k,n){
            now = min(now, a[(start + k) % n]);
            dp[k][(start + k) % n] = now;
        }
    }
    ll ans = infl;
    rep(k,n){
        ll now = k * x;
        rep(i,n){
            now += dp[k][i];
        }
        ans = min(ans, now);
    }
    cout << ans << endl;
}

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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int N = 2e5+5;

struct SegT{
	int node[4*N];

	void modify(int pos, int val, int ind = 1, int l = 0, int r = N-1){
		if(l==r){
			node[ind] = val;
		}else{
			int mid = (l+r)/2;
			if(pos<=mid) modify(pos,val,ind<<1,l,mid);
			else modify(pos,val,ind<<1|1,mid+1,r);
			node[ind] = max(node[ind<<1],node[ind<<1|1]);
		}
	}

	int range_query(int ql, int qr, int ind = 1, int l = 0, int r = N-1){
		if(ql>r||qr<l) return INT_MIN;
		if(ql<=l&&qr>=r) return node[ind];
		int mid = (l+r)/2;
		return max(range_query(ql,qr,ind<<1,l,mid),range_query(ql,qr,ind<<1|1,mid+1,r));
	}
} st;

void solve(){
	int n;
	cin >> n;
	int h[n], a[n];
	for(auto &x : h) cin >> x;
	for(auto &x : a) cin >> x;
	for(int i = 0;i < n;i++){
		//cout << i << " " << h[i] << " " << st.range_query(0,h[i]) << " " << a[i] << "\n";
		st.modify(h[i],st.range_query(0,h[i]) + a[i]);
	}
	cout << st.range_query(0,N-1) << "\n"; 
}

signed main(){
	fastio
	int t = 1;
	//cin >> t;
	while(t--) solve();
}

Measured memory_bytes: 10840
/*
  与えられる数は10^8以下->10^4(10000)までの素数を持っていれば良い
 */

#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

#define PB push_back

void Input();
void Make_Table();
void Calc();

int n,ans,x;
vector<int> ivs;
vector<int> ivin;

int main(int argc,char* argv[]){
  ivs.clear();
  ans=0;

  Input();
  Make_Table();
  Calc();

  printf("%d\n",ans);
  return 0;
}

void Input(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x;
    ivin.PB(x);
  }
}

void Make_Table(){
  bool flag;
  for(int i=2;i<=10000;i++){
    if(ivs.empty())
      ivs.PB(i);
    else{
      flag=true;
      vector<int>::iterator itivs;
      for(itivs=ivs.begin();itivs!=ivs.end();itivs++){
	if(i%(*itivs)==0){
	  flag=false;
	  break;
	}
      }
      if(flag)
	ivs.PB(i);
    }
  }
}

void Calc(){
  bool flag;
  vector<int>::iterator itivin;
  for(itivin=ivin.begin();itivin!=ivin.end();itivin++){

    flag=true;
    vector<int>::iterator itivs;
    for(itivs=ivs.begin();itivs!=ivs.end();itivs++){
      
      if(*itivin%*itivs==0 && *itivin!=*itivs){
	flag=false;
	break;
      }

      else if(*itivin<=*itivs) break;
    }
    if(flag) ans++;
  }
}

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

int main() {
    int N,Y;
    cin >> N >> Y;
    for(int i=0;i<=N;i++) {
        for(int j=0;j<=N-i;j++) {
            if(10000*i+5000*j+1000*(N-i-j)==Y) {
                cout << i << " " << j << " " << N - i - j << endl;
                exit(0);
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 3640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

int main()
{
    ll A,B,H,M;

    cin >> A >> B >> H >> M;

    double c = 2 * M_PI * (H / 12.0 + M / (12.0 * 60) );
    double t = 2 * M_PI * M / 60.0;

    double theta = c-t;


    double ans = sqrt(A * A + B * B - 2 * A * B * cos(theta));

    cout << fixed << setprecision(11);
    cout << ans << endl;
}


Measured memory_bytes: 4196
N,W = map(int,input().split())
wv = []
base_w = float('inf')
for _ in range(N):
    w, v = (int(x) for x in input().split())
    wv.append([w, v])
    base_w = min(base_w, w)

dp = [[-10000000000 for i in range(100*3+1)] for j in range(N+1)]

dp[0][0] = 0

#横軸はお重さの合計、縦軸は何個選ぶか
for ws ,vs in wv:
    ws -= base_w
    for h in range(N+1, 0, -1):
        for w in range(100*3, -1, -1):
            if 0 <= w-ws:
                if dp[h-1][w-ws] != -10000000000:
                    dp[h][w] = max(dp[h][w], dp[h-1][w-ws]+vs)

ans = 0
for i in range(0,N+1):
    tmp_W = W-i*base_w
    #print(tmp_W, i)
    if 0 <= tmp_W:
        #print(dp[i][:tmp_W+1])
        tmp_max_V = max(dp[i][:tmp_W+1])
        ans = max(ans, tmp_max_V)
print(ans)   


Measured memory_bytes: 74136
#include <bits/stdc++.h>
using namespace std;
const long long BASE1 = 1234567;
const long long BASE2 = 7654321;
const long long MOD = 1000000007;
long long modpow(long long a, long long b){
  long long ans = 1;
  while (b > 0){
    if (b % 2 == 1){
      ans *= a;
      ans %= MOD;
    }
    a *= a;
    a %= MOD;
    b /= 2;
  }
  return ans;
}
long long modinv(long long a){
  return modpow(a, MOD - 2);
}
int main(){
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  long long hash1 = s[0];
  long long hash2 = s[0];
  int L = 0;
  int R = 1;
  set<pair<long long, long long>> st;
  for (int i = 0; i < m; i++){
    string q;
    cin >> q;
    if (q == "R++"){
      hash1 = (hash1 * BASE1 + s[R]) % MOD;
      hash2 = (hash2 * BASE2 + s[R]) % MOD;
      R++;
    }
    if (q == "R--"){
      R--;
      hash1 = ((hash1 - s[R] + MOD) * modinv(BASE1)) % MOD;
      hash2 = ((hash2 - s[R] + MOD) * modinv(BASE2)) % MOD;
    }
    if (q == "L++"){
      hash1 = (hash1 - s[L] * modpow(BASE1, R - L - 1) % MOD + MOD) % MOD;
      hash2 = (hash2 - s[L] * modpow(BASE2, R - L - 1) % MOD + MOD) % MOD;
      L++;
    }
    if (q == "L--"){
      L--;
      hash1 = (hash1 + s[L] * modpow(BASE1, R - L - 1)) % MOD;
      hash2 = (hash2 + s[L] * modpow(BASE2, R - L - 1)) % MOD;
    }
    st.insert(make_pair(hash1, hash2));
  }
  cout << st.size() << endl;
}


Measured memory_bytes: 21880
#include <iostream>
using namespace std;
int main(){
    int k;
    string s;
    cin >> k >> s;
    if(k>=s.length()){
        cout << s << endl;
        return 0;
    }
    string temp="";
    for(int i=0; i<k; i++){
        temp+=s[i];
    }
    temp+="...";
    cout << temp << endl;
    return 0;
}


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

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e15;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

int n;
ll a[3005];
ll dp[3005][3005];

ll rec(int i, int j){
  if(dp[i][j] != -1) return dp[i][j];
  int turn = n-(j-i);
  
  ll d;
  if(turn%2 == 0){
    d=max(a[i]+rec(i+1,j), a[j-1]+rec(i,j-1));
  }else{
    d=min(-a[i]+rec(i+1,j), -a[j-1]+rec(i,j-1));
  }
  return dp[i][j]=d;
}

int main(){
  cin>>n;
  rep(i,n) cin>>a[i];
  
  rep(i,n+1) rep(j,n+1) dp[i][j]=-1;
  rep(i,n+1) dp[i][i]=0;
  
  rec(0, n);
  
  cout<<dp[0][n]<<endl;
}

Measured memory_bytes: 70912
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
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; }

//Roling Hash
//RollingHash RH(s,base) base:[2,MOD)?????±??°
//RH.set(s,base): vector???????§???????????????????????????§????????????????????????????????????
//RH.get(l,r): [l,r)??????????????\ O(1)
//1000000007, 1000000009, 1000000021
template<long long MOD>
class RollingHash {
public:
	int n;
	long long base;
	vector<long long> pow, hash;
	RollingHash() {}
	RollingHash(const string &s, long long base_ = 10007) { init(s, base_); }
	void init(const string &s, long long base_ = 10007) {
		n = s.size();
		base = base_;
		calc(s.c_str());
	}
	long long get(int x)const { return hash[x]; }
	long long get(int l, int r)const { return (get(r) - get(l)*pow[r - l] % MOD + MOD) % MOD; }
	void calc(const char *s) {
		pow.resize(n + 1);
		pow[0] = 1;
		hash.resize(n + 1);
		hash[0] = 0;
		for (int i = 0; i < n; i++) {
			pow[i + 1] = pow[i] * base % MOD;
			hash[i + 1] = (s[i] + hash[i] * base) % MOD;
		}
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	RollingHash<1000000007> RH(s);
	int n = s.size(); //???????????¨Runtime Error
	for (int a = (n - 2) / 3, b; a >= 1; a--) {
		b = (n - a * 3) / 2;
		if (3 * a + 2 * b != n)continue;
		if (RH.get(0, a) == RH.get(a + b, a + b + a)
			&& RH.get(0, a) == RH.get(a + b + a + b, a + b + a + b + a)
			&& RH.get(a, a + b) == RH.get(a + b + a, a + b + a + b)) {
			cout << "Love " << s.substr(0, a + b) << "!" << endl;
			return 0;
		}
	}
	cout << "mitomerarenaiWA" << endl;
	return 0;
}

Measured memory_bytes: 19948
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef long double ld;
typedef vector<int> vt;
typedef vector<vt> vtt;
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};

const lld mod = 1e9 + 7;
lld dp[2222];
lld recur(int n){
	if(n<3) return 0;
	if(dp[n]!=-1) return dp[n];
	dp[n] = 1;
	for(int p=3;p<=n-3;p++){
		dp[n] = (dp[n] + recur(n-p))%mod;
	}
	return dp[n];
}
int main(void){
	memset(dp,-1,sizeof(dp));
	int n;
	scanf("%d",&n);
	printf("%lld\n",recur(n));
	return 0;
}


Measured memory_bytes: 3844
package main

import (
  "fmt"
  "strings"
  "strconv"
)

func main() {
  var a, b int
  fmt.Scan(&a, &b)
  var res string
  if a <= b {
    res = strings.Repeat(strconv.Itoa(a), b)
  } else {
    res = strings.Repeat(strconv.Itoa(b), a)
  }

  fmt.Println(res)

}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i > 0; i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t int64;

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

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


class B {
	int rows, cols;
	vector<string> input;
	vector<string> res;
	vector<bool> printCol;
public:
	B()
	{
		cin >> rows >> cols;
		input.resize(rows);
		printCol.resize(cols, false);

		REP(y, rows)
			cin >> input[y];


	}
	void solve()
	{

		REP(y, rows)
		{
			bool flag{ false };
			for (char c : input[y])
			{
				if (c == '#')
				{
					flag = true;
					break;
				}
			}
			if (flag)
				res.PB(input[y]);
		}

		REP(x, cols)
		{
			bool flag{ false };

			REP(y, SZ(res))
			{
				if (res[y][x] == '#')
				{
					flag = true;
					break;
				}
			}

			printCol[x] = flag;
		}

		REP(y, SZ(res))
		{
			REP(x, cols)
				if (printCol[x])
					cout << res[y][x];
			cout << endl;
		}

	}

	void debug()
	{
		REP(y, SZ(res))
		{
			REP(x, cols)
				cout << res[y][x] << " ";
			cout << endl;
		}
	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		long sum = 0;

		for(int i = 1; i <= n; i++) {
			if(i%3!=0 && i%5!=0) sum += i;
		}

		System.out.println(sum);
	}
}

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

int main() {
    int N;
    cin >> N;
    vector<int> word(26, 50);
    for(int i = 0; i < N; i++) {
        string S;
        cin >> S;
        vector<int> word_tmp(26, 0);
        for(int j = 0; j < S.size(); j++) {
            word_tmp[S[j] - 'a']++;
        }
        for(int j = 0; j < 26; j++) {
            word[j] = min(word[j], word_tmp[j]);
        }
    }
    string result = "";
    for(int i = 0; i < 26; i++) {
        string str = string(word[i], 'a' + i);
        result += str;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v = sorted(v,reverse=True)

# (合計, 個数)
max_avg = (sum(v[:A]), A)

t = v[A-1]
num1 = v[:A].count(t)
num2 = v[A:].count(t)

fact = [0]*(N+1)
ifact = [0]*(N+1)
inv = [0]*(N+1)
p=170141183460469231731687303715884105727

def combination(n,fact,ifact):
    fact[0] = 1
    fact[1] = 1
    ifact[0] = 1
    ifact[1] = 1
    inv[1] = 1
    for i in range(2,n+1):
        fact[i] = (fact[i-1]*i)%p
        inv[i] = p - inv[p%i]*(p//i)%p
        ifact[i] = (ifact[i-1]*inv[i])%p
def op(n,k):
    if k<0 or k>n or n<0:
        return 0
    return (fact[n]*ifact[k]*ifact[n-k])%p

combination(N,fact,ifact)

res = int(op(num1+num2, num1))
if v[0]==v[-1]:
    res = 0
    for i in range(A,B+1):
        res += int(op(N, i))
elif v[0] == v[B-1]:
    res = 0
    for i in range(A, B+1):
        res += int(op(num1+num2,i))
elif v[0] == v[A-1]:
    res = 0
    for i in range(A, min(B, A+num2)+1):
        res += int(op(num1+num2, i))
print(max_avg[0]/max_avg[1])
print(res)




Measured memory_bytes: 3188
#pragma region Macros
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define IN(x, a, b) x >= a and x < b

using namespace std;
using ll = long long;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;
#pragma endregion

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

  int a, b, x;
  cin >> a >> b >> x;

  constexpr double pi = 3.141592653589793;
  double ok = 0;
  double ng = pi / 2;
  REP(i, 10000000) {
    double mid = (ok + ng) / 2;

    double h = a * tan(mid);
    double V = 0;
    if (h < b) {
      V += a * a * h / 2;
      double h2 = b - h;
      V += h2 * a * a;
    } else {
      double a2 = b * tan(pi / 2 - mid);
      V += a * a2 * b / 2;
    }
    if (V > x) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  cout<<fixed<<setprecision(10)<<ok*180/pi<<endl;
  // printf("%.10lf\n", ok * 180 / pi);

  return 0;
}

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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979323846

template<class T>bool ch1000000(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; }





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

  int ans = 0;

  rep(i, 1, N+1){
    int ai;
    cin >> ai;

    if(ai % 2 == 1 && i % 2 == 1) ans++;
  }

  cout << ans << endl;



  // cout << setprecision(8) << ans << endl;  // For double
}



Measured memory_bytes: 3592
package main

import (
	"fmt"
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	m1 := make(map[byte]map[byte]bool)
	m2 := make(map[byte]map[byte]bool)
	for i := byte('a'); i <= byte('z'); i++ {
		m1[i] = make(map[byte]bool)
		m2[i] = make(map[byte]bool)
	}
	for i := range s {
		m1[s[i]][t[i]] = true
		m2[t[i]][s[i]] = true
	}
	for _, v := range m1 {
		if len(v) > 1 {
			fmt.Println("No")
			return
		}
	}
	for _, v := range m2 {
		if len(v) > 1 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  for (auto &a : A)
    cin >> a;
  int ans = K - (A[N - 1] - A[0]);
  for (int i = 0; i < N - 1; i++)
  {
    ans = max(ans, A[i + 1] - A[i]);
  }
  cout << K - ans << endl;
  return 0;
}

// N軒全て回るということは移動開始地点と移動終点地点の間だけ歩かなくてよいということなのでそれが最大になるところを探索


Measured memory_bytes: 1152
#include<stdio.h>
#include<string.h>
int main()
{
	int i,sm=0;
	char s[1000000];
	scanf("%s",s);
	for(i=0;i<strlen(s);i++)
		sm+=s[i]-'0';
		if(sm%9==0)
		printf("Yes\n");
		else
		printf("No\n");
}

Measured memory_bytes: 1808
#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 n;
    cin >> n;
    set<string> s;
    for (int i=0; i<n; ++i) {
        string str;
        cin >> str;
        s.insert(str);
    }
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 19212
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  map<ll, ll> mp;
  rep(i, n) {
    ll a;
    cin >> a;
    mp[a]++;
  }
  bool ng = false;
  if(mp.size() > 2) ng = true;
  ll k = (*mp.begin()).first;
  if((*mp.rbegin()).first - k > 1) ng = true;
  if(mp.size() == 1) {
    if(k != n - 1 && n / k < 2) ng = true;
  } else {
    ll x = (*mp.begin()).second;
    if(n - k < k - x + 2) ng = true;
    if(x > k) ng = true;
  }
  cout << (ng ? "No" : "Yes") << endl;
}

Measured memory_bytes: 9836
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp;

#[fastout]
fn main() {
  input! {
    n: usize,
    k: usize,
    a: [[Usize1]; k],
  }
  let mut target = vec![true; n];
  for t in a {
    for i in t {
      target[i] = false;
    }
  }

  println!("{}", target.iter().filter(|&&t| t).count());
}


Measured memory_bytes: 2164
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, A, B = map(int, readline().split())
H = list(map(int,read().split()))
H = sorted(H,reverse = True)
t = A-B

def solve(x):
    cnt = 0
    for i in range(N):
        rem = H[i]-x*B
        if rem <= 0:
            break
        else:
            cnt += -(-rem // t)
    if cnt <= x:
        return True
    else:
        return False 
    

left = 0
right = 10**9
while right - left > 1:
    x = (left + right) // 2
    flag = solve(x)
    if flag:
        right = x
    else:
        left = x
        
print(right)

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

// 組み合わせ
long nCr(int n, int r) {
	long ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}

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

	int ans = 0;

	if (n == 0)	// 奇奇
	{
		ans += nCr(m, 2);
	}
	else if (m == 0)	// 偶偶
	{
		ans += nCr(n, 2);
	}
	else
	{
		ans += nCr(m, 2);
		ans += nCr(n, 2);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
/*---------------------------------- NEVER GIVE UP --------------------------------------------*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef double ld;
typedef pair<ll,ll> pii;
typedef tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define debug1(x) cerr<<#x<<" : "<<(x)<<endl
#define debug2(x,y) cerr<<#x<<" : "<<(x)<<" "<<#y<<" : "<<(y)<<endl
#define debug3(x,y,z) cerr<<#x<<" : "<<(x)<<" "<<#y<<" : "<<(y)<<" "<<#z<<" : "<<(z)<<endl
#define fastt ios_base::sync_with_stdio(false); cin.tie(NULL) ; cout.tie(NULL)

const ll modd=998244353;
const ll inff=1e18;

ll poww(ll a,ll b){
  ll ans=1;
  while(b){
    if(b&1LL) ans=(ans*a);
    a=(a*a);
    b=b>>1LL;
  }
  return ans;
}

/*-----------------------------------------------------------------------------------------------*/

const ll N = 3e3+5;

ll dp[N][N];

int main(){
  fastt;

  ll a , b , c , d;
  cin >> a >> b >> c >> d;

  dp[a][b] = 1;

  for(ll i = a; i < N; i++)
      for(ll j = b; j < N; j++){
          if(i == a && j == b) continue;
          dp[i][j] = (dp[i-1][j] * (j) % modd + dp[i][j-1] * (i) % modd - dp[i-1][j-1]*((i-1)*(j-1)) % modd + 3 * modd) % modd;
      }


  cout << dp[c][d] << endl; 
  return 0;
}


Measured memory_bytes: 74120
import sys
import math
N,M = map(int, sys.stdin.readline().strip().split())
def combinations(n, r):
    return math.factorial(n) // (math.factorial(r) * math.factorial(n - r))
if (N > 1):
    count_even = combinations(N, 2)
else:
    count_even = 0
if (M > 1):
    count_odd = combinations(M, 2)
else:
    count_odd = 0
print(count_even + count_odd)


Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>    
#include <cstring>
#include <array>
#include <cctype>
#include <string.h>
#include <vector>
#include <limits.h>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cassert>
#include <algorithm>
#include <functional>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <stdio.h>
#include <bitset>
using namespace std;
#define PI 3.14159265359
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) FOR(i,0,n)
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const int INF = 1<<29;
typedef long long ll;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int n;

int main(){
	ios_base::sync_with_stdio(false); //Fast I/O
	cin.tie(NULL);
	//freopen("in.txt","r",stdin);
	//freopen("output.txt","w",stdout);	

	cin >> n;

	if(n>999)	cout << "ABD\n";
	else	cout << "ABC\n";

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

long calc(int max, int count) {
  int i;
  long mx = 0, mn = 0;
  for(i = 0;i < count;i++) {
    mn += i;
    mx += max - i;
  }
  mx = max * count - mn;
  return mx - mn + 1;
}

int main(void) {
  int n, k;
  
  scanf("%d %d", &n, &k);
  if(k > n) {
    printf("1\n");
    return 0;
  }
  int i;
  long ret = 0;
  for(i = k;i <= n + 1;i++) {
    ret += calc(n, i);
  }
  ret %= 1000000007;
  printf("%ld\n", ret);
  return 0;
}
  


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string S;
  cin >> N >> S;
  int r = 0, w = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'R') {
      r++;
    }
    else {
      w++; 
    }
  }
  int answer = min(N - w, N - r);
  int rock=0;
  for(int i=0;i<r;i++){
    if(S.at(i)=='W'){
      rock++;
    }
  }
  answer=min(answer,rock);
  rock=0;
  for(int i=r;i<N;i++){
    if(S.at(i)=='R'){
      rock++;
    }
  }
  answer=min(answer,rock);
  cout<<answer<<endl;
}



Measured memory_bytes: 3644
S = input()
ans = 'NO'

n = len(S)
if S == 'keyence':
  ans = 'YES'
for i in range(n):
  for j in range(i,n):
    T = S[:i]+S[j:]
    if T == 'keyence':
      ans = 'YES'
print(ans)
  
  

Measured memory_bytes: 2940
char s[72],r[72];
R(){
	int x,y;
	memcpy(s,r,71);
	for(y=0;y<8;y++)
		for(x=0;x<8;x++)
			r[x+y*9]=s[y+(7-x)*9];
	puts(r);
}
main(i){
	read(0,r,71);
	for(i=1;i<=3;i++){
		printf("%d\n",90*i);
		R();
	}
	exit(0);
}

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

using namespace std;


#ifdef zxc

#include <sys/resource.h>
#include "debug.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = int64_t;
using ld = long double;
const ld EPS = 1e-9;
//const ll MOD = 924844033;
const ld PI = 3.141592653589793;
const int maxn = 300001;
const ll MOD = 998244353;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

signed main() {
#ifdef zxc
    struct rlimit rl;
    const rlim_t kStackSize = 512L * 1024L * 1024L;
    assert(!getrlimit(RLIMIT_STACK, &rl));
    rl.rlim_cur = kStackSize;
    assert(!setrlimit(RLIMIT_STACK, &rl));
    freopen("../kolya_input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    //    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
    //            freopen("", "r", stdin);
    //        freopen("hack.out", "w", stdout);
#endif


    function<void(int)> solve = [](int t) {
        int n;
        cin >> n;
        vector<int> a(n + 10);

        for (int i = 0; i <= n; ++i) {
            cin >> a[i];
        }
        if (n == 0) {
            if (a[0] == 1) {
                cout << 1;
            } else {
                cout << -1;
            }
            return;
        }
        if (a[0] > 0) {
            cout << -1;
            return;
        }
        vector<ll> l(n + 1);
        vector<ll> r(n + 1);

        for (int i = n - 1; i >= 0; --i) {
            r[i] = a[i + 1] + r[i + 1];
            if (i <= 60) {
                r[i] = min<ll>(r[i], (1ll << i) - a[i]);
            }
            l[i] = (a[i + 1] + l[i + 1] + 1) / 2;
            if (l[i] > r[i]) {
                cout << -1 << "\n";
                return;
            }
        }
        ll cur_l = 1;
        ll cur_r = 1;ll ans = a[n]+1;
        for (int i = 1; i < n; ++i) {
            cur_r *= 2;
            cur_r -= a[i];
            cur_r = min(cur_r, r[i]);
            ll cur_leaves = cur_l;
            cur_l = max<ll>(0, cur_leaves - a[i]);
            cur_l = max(cur_l, l[i]);
            if (cur_l > cur_r) {
                cout << -1;
                return;
            }
            ans += cur_r;
            ans+=a[i];
        }

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


    fast_io();
    cout.precision(9);
    cout << fixed;
    auto start = chrono::steady_clock::now();
//    int t;
//    cin >> t;
    for (int i = 1; i <= 1; ++i)solve(i);
    auto end = chrono::steady_clock::now();

    debug("time", chrono::duration_cast<chrono::milliseconds>(end - start).count() / 1000.0);

}


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

char max[72];
char matrix[72][72];
char num[72][72][72];

int large(char *num1, char *num2)
{
	if (strlen(num1) < strlen(num2)){
		return (-1);
	}
	if (strlen(num1) == strlen(num2)){
		return (strcmp(num1, num2));
	}

	return (1);
}

int main(void)
{
	int W, H, C;
	int i, j;
	int x, y;
	char c, c1, c2;
	
	
	while (1){
		scanf("%d%d", &W, &H);
		if (W == 0 && H == 0){
			break;
		}
		
		memset(matrix, 0, sizeof(matrix));
		for (y = 1; y <= H; y++){
			scanf("%s", &matrix[y][1]);
		}
		

		memset(num, 0, sizeof(num));
		max[0] = '\0';
		for (y = 1; y <= H; y++){
			for (x = 1; x <= W; x++){
				c = matrix[y][x];
				if ('0' <= c && c <= '9'){
					if (large(num[y - 1][x], num[y][x - 1]) > 0){
						strcpy(num[y][x], num[y - 1][x]);
					}
					else {
						strcpy(num[y][x], num[y][x - 1]);
					}
					if (num[y][x][0] != '\0' || c != '0'){
						num[y][x][strlen(num[y][x])] = c;
						num[y][x][strlen(num[y][x]) + 1] = '\0';
					}
//printf("[%s]", num[y][x]);
					
					
					if (large(max, num[y][x]) < 0){
						strcpy(max, num[y][x]);
					}
					
				}
//				else{
//printf("[*]");
//				}
			}
//printf("\n");

		}
		for (x = 0; max[x] == '0'; x++);
		printf("%s\n", &max[x]);
	}
	
	return (0);
}

Measured memory_bytes: 984
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int N;
  cin >> N;
  int a = 1;
  int b = 0;
  vector<int> point(N);
  for(int i = 0; i < N; i++){
    cin >> point.at(i); 
  }
  for(int j = 0; j < N; j++){
    b++;
  	a = point.at(a - 1);
    if (a == 2){
    break;
    }
  }
  if (b == N){
  cout << -1 << endl;
  }else{
  cout << b << endl;
  }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define lli	long long int
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define rep(i,a,b)	for(i=a;i<b;i++)
using namespace std;
lli is_pri(lli x)
{
	lli i;
	for(i=2;i*i<=x;i++)
	{
		if(x%i==0)	return 0;
	}
	return 1;
}
int main()
{
	lli x,i;
	cin >> x;
	if(x==2)	cout << "2" << endl;
	else{
	if(x%2==0)	x++;
	while(!is_pri(x))
	{
		x+=2;
	}
	cout << x << endl;
	}
	
	
	
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
using namespace std;

int main(){
    int n;
    cin >> n;
    int h[n];
    REP(i,n) cin >> h[i];

    int result = 0;
    int val = 0;
    for(int i=n-1; i>=0; i--){
        if(h[i] <= h[i-1]) val++;
        else val = 0;
        result = max(result, val);
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 768