akhauriyash/Code-Regression huggingface dataset:
N,C=map(int,input().split())
stc=sorted([list(map(int,input().split())) for _ in [0]*N],key=lambda x:x[0])
rokuga=[]
for i in range(N):
    for j,r in enumerate(rokuga):
        if r[0]==stc[i][2]:
            if r[1]<=stc[i][0]:
                rokuga[j][1]=stc[i][1]
                break
    else:
        for j,r in enumerate(rokuga):
            if r[1]<stc[i][0]:
                rokuga[j]=[stc[i][2],stc[i][1]]
                break
        else:
            rokuga.append([stc[i][2],stc[i][1]])
print(len(rokuga))

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

fn main() {
    input! {
        n: usize,
         k: usize,
        a: [Usize1;n]
    }

    let mut v: Vec<usize> = Vec::new();
    let mut ord: Vec<Option<usize>> = vec![None; n];

    let mut loop_len = 1;
    let mut cur = 0;

    for i in 0..n {
        if let Some(n) = ord[cur] {
            loop_len = v.len() - n;
            break;
        }
        ord[cur] = Some(i);
        v.push(cur);
        cur = a[cur];
    }

    let bef_loop = v.len() - loop_len;

    if k < v.len() {
        println!("{}", v[k] + 1);
    } else {
        let k = k - bef_loop;
        let ans = v[bef_loop + k % loop_len] + 1;
        println!("{}", ans);
    }
}


Measured memory_bytes: 9336
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		long min = 5000000000l,max = 0,buf;
		for(int i = 0;i < N;i++) {
			buf = Math.abs(scn.nextLong());
			if(buf < min) {
				min = buf;
			}
			if(buf > max) {
				max = buf;
			}
		}
		scn.close();
		System.out.println(max - min);
	}
}


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

#define rep(n, i) for (int i = 0; i < (n); ++i)

using ll = long long;
using namespace std;

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

    auto answer = "No";
    if ( s[0] == '7' || s[1] == '7' || s[2] == '7' )
      answer = "Yes";

    cout << answer << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define print(x) std::cout<<x<<"\n"
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = lcm(a, v[i]);} return a;}
VI Bit2Vector(const ll bit, ll n) {	VI s;	rep(i,n) if (bit & (1 << i)) s.push_back(i); return s;}

struct DFS{
	ll m_n;
	ll ret=0;

	DFS(ll n){
		m_n=n;
	}
	void search(ll x, bool three, bool five, bool seven){
		if(x > m_n) return;
		if(three && five && seven) ret++;
		search(10 * x + 3, true, five, seven);
		search(10 * x + 5, three, true, seven);
		search(10 * x + 7, three, five, true);
	}
};

void Main()
{
	ll n,m,l; ll res=0;
	string s,t,u; string sres="No or NO";

	cin>>n;
	DFS dfs(n);
	dfs.search(0, 0, 0, 0);
	res=dfs.ret;
	cout << res << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>
 
#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
 
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e10
 
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 long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
 
using namespace std;

bool fact(ll n){
    for(ll i=1; i*i<=n; i++){
        if((i>1)&&(n % i == 0)){
            return false;
        }
    }
    return true;
}

int main()
{
    ll x;
    cin >> x;
    ll mm = 10000000;
    ll itr = x;

    while(true){
        if(fact(itr)) break;
        else itr++;
    }

    cout << itr;
}

Measured memory_bytes: 256
class PriorityQueue
  class Node
    attr_reader :value, :priority
    def initialize(value, priority)
      @value = value
      @priority = priority
    end
  end

  def initialize
    @heap = [nil]
  end

  def size
    @heap.size - 1
  end

  def empty?
    size == 0
  end

  def enqueue(value, priority)
    @heap.push(Node.new(value, priority))
    up_heap
    self
  end

  def dequeue
    return nil if empty?
    return @heap.pop.value if size == 1
    ret = @heap[1].value
    @heap[1] = @heap.pop
    down_heap
    ret
  end

  def peek
    @heap[1].value.dup
  end

  private

  def up_heap
    pos = size
    while pos > 1
      parent = pos / 2
      break if @heap[pos].priority <= @heap[parent].priority
      tmp = @heap[pos]
      @heap[pos] = @heap[parent]
      @heap[parent] = tmp
      pos = parent
    end
  end

  def down_heap
    pos = 1
    loop{
      left = pos * 2 
      right = pos * 2 + 1
      break if left >= @heap.size
      if right >= @heap.size || @heap[left].priority >= @heap[right].priority
        break if @heap[pos].priority >= @heap[left].priority
        tmp = @heap[pos]
        @heap[pos] = @heap[left]
        @heap[left] = tmp
        pos = left
      else
        break if @heap[pos].priority >= @heap[right].priority
        tmp = @heap[pos]
        @heap[pos] = @heap[right]
        @heap[right] = tmp
        pos = right
      end
    }
  end
end

N,M,R=gets.split.map(&:to_i)
r=gets.split.map(&:to_i)
E=Array.new(N+1){[]}
M.times{
	a,b,c=gets.split.map(&:to_i)
	E[a]<<[b,c]
	E[b]<<[a,c]
}
warn E.inspect
D=[]
r.each{|s|
	d=Array.new(N+1){10**9}
	d[s]=0
	q=PriorityQueue.new
	q.enqueue(s,-d[s])
	until q.empty?
		v=q.dequeue
		E[v].each{|u,l|
			if d[u]>d[v]+l
				d[u]=d[v]+l
				q.enqueue(u,-d[u])
			end
		}
	end
	D[s]=d
}
warn D.inspect
q=PriorityQueue.new
r.each{|s|
	q.enqueue([[s],0],0)
}
min = 10**9
until q.empty?
	v,d=q.dequeue
	if v.size == r.size
		min=d
		warn v.inspect
		break
	end
	r.each{|o|
		next if v.include?(o)
		n=v+[o]
		nd=d+D[v[-1]][o]
		q.enqueue([n,nd],-nd)
	}
end
puts min


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

// #define DEBUG 1

#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define iter2(c) for(auto it2=c.begin(); it2!=c.end(); it2++)
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define sqr(x) ((x)*(x))
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define pmod(x,m) (((x)%(m)+m)%m)
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define priter(v) iter(v) {pr(*it)} nl
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define priter(v)
#define debug
#endif
#define MAXN 200000

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

ll x[MAXN+5];

ll get_cost(int n, ll X, ll g)
{
    ll tot = g*X;
    ll c = n/g + 1;
    // prl(c) 
    int i;
    for (i=1; i<=n%g; i++) {
        ll cost = c == 1 ? 5 : 2*c+1;
        tot += cost * x[i];
        // pr(i) pr(c) nl 
    }
    for (c--; c>=1; c--) {
        ll cost = c == 1 ? 5 : 2*c+1;
        // pr(c) pr(cost) nl 
        for0(j,g) {
            assert(i<=n);
            tot += x[i] * cost;
            // pr(i) pr(c) nl 
            i++;
        }
    }  
    assert(i == n+1);
    return tot;
}

ll solve(int n, ll X, int low, int high)
{
    if (low == high) {
        return get_cost(n,X,high);
    }
    else if (low == high-1) {
        ll a = get_cost(n,X,low);
        ll b = get_cost(n,X,high);
        return min(a,b);
    }
    else {
        int m1 = low + (high-low)/3;
        int m2 = low + 2*(high-low)/3;
        ll a = get_cost(n,X,m1);
        ll b = get_cost(n,X,m2);
        if (a == b)
            return solve(n,X,m1,m2);
        else if (b > a) 
            return solve(n,X,low,m2-1);
        else 
            return solve(n,X,m1+1,high);
    }
}

int32_t main()
{
    #ifdef DEBUG
    //freopen("B.txt","r",stdin);
    //freopen("","w",stdout);
    #endif
    
    int n,X;
    cin >> n >> X;
    for0(i,n) 
        read(x[i+1]);
        
    // ll best = INFL;
    // for (int g=1; g<=(n+1)/2; g++) {
        // prl(g)
        // ll tot = get_cost(n,X,g);
        // best = min(best,tot);
        // nl
        // cout<<g<<" "<<best<<endl;
    // }
    
    ll best = solve(n,X,1,(n+1)/2);    
    ll ans = best + n*X;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	for(int i=0;i<a.size();i++)
	{
		for(int j=i;j<a.size();j++)
		{
			if(a[i]=='C'&&a[j]=='F')
			{
			cout<<"Yes";
			return 0;
			}

	}
	}
    cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define BUF 1e5
#define INF 1 << 30
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
constexpr ll mod = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> A >> B;
    cout << max(max(A + B, A - B), A * B);
}

Measured memory_bytes: 764
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
const int lmod = 998244353;
vector<int> v;
int n;
vector<vector<ll>> dp;
ll modpow(ll a, ll b) {
  if (b == 0)
    return 1;
  ll f = modpow(a, b / 2);
  f = (f * f) % lmod;
  if (b & 1)
    f = (f * a) % lmod;
  return f;
}
ll solve(int i, int s) {
  if (s < 0) {
    return 0;
  }
  if (s == 0) {
    return modpow(2, n - i);
  }
  if (i == n) {
    return 0;
  }
  if (dp[i][s] != -1)
    return dp[i][s];
  dp[i][s] = (2 * solve(i + 1, s)) % lmod;
  dp[i][s] = (dp[i][s] + solve(i + 1, s - v[i])) % lmod;
  return dp[i][s];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int s;
  cin >> n >> s;
  v = vector<int>(n);
  dp = vector<vector<ll>>(n + 1, vector<ll>(s + 1, -1));
  for (auto &x : v)
    cin >> x;
  cout << solve(0, s) << "\n";
}

Measured memory_bytes: 73948
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	line1 := scanner.Text()

	s := strings.Split(line1, " ")
	a, _ := strconv.Atoi(s[0])
	b, _ := strconv.Atoi(s[1])
	_t, _ := strconv.Atoi(s[2])
	t := float32(_t)+0.5

	biscuits := 0
	for i := a; float32(i) <= t; i+=a {
		biscuits += b
	}

	fmt.Printf("%d\n", biscuits)
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	long long n,temp,semen,i = 0;
	char input[1005];
	scanf("%lld",&n);
	while(n)
	{
		temp = n / 26;
		semen = n % 26;
		if(semen == 0)
		{
			semen += 26;
			temp--;
		}
		input[i] = semen + 'a' - 1;
		n = temp;
		i++;
	}
	for(int j = i-1;j>=0;j--)
	{
		printf("%c",input[j]);
	}
	return 0;
}

Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    int n,q;
    cin >> n >> q;
    Graph tree(n);
    for (int i=0; i<n-1;i++){
        int a,b;
        cin >> a >> b;
        tree.at(a-1).push_back(b-1);
        tree.at(b-1).push_back(a-1);
    }

    vector<int> sousa(n);
    for (int i=0; i<q;i++){
        int p,x;
        cin >> p >> x;
        sousa.at(p-1) += x;
    }

    vector<long> point(n);
    queue<int> nodes;
    nodes.push(0);
    vector<int> seen(n);
    seen.at(0) = 1;
    //for(int count = 0 ; count < 10; count++){
    while(!nodes.empty()){
        int node = nodes.front();
        point.at(node) += sousa.at(node);
        for(auto itr = tree.at(node).begin(); itr != tree.at(node).end(); ++itr) {
            int child = *itr;
            if(seen.at(child) == 0){
                point.at(child) += point.at(node);
                nodes.push(child);
                seen.at(child) = 1;
            }
        }
        nodes.pop();
    }

    for (int i=0; i<n;i++){
        cout << point.at(i) << " ";
    }

}

Measured memory_bytes: 17908
def main():
    num = [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]
    K = int(input())
    print(num[K-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 3e5+1, mod = 998244353;
int n, a, b, k, ans;
int Pow [N];
int cal (int a, int b)
{
	if (b == 1) return a;
	int res = cal (a, b/2);
	res = (res*res) % mod;
	if(b % 2) res = (res * a) % mod;
	return res;
}
int Ckn (int k, int n)
{
	if (k > n) return 0LL;
	int res = Pow[n];
	res = (res * cal( (Pow[k]*Pow[n-k])%mod, mod-2)) % mod;
	return res;
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> a >> b >> k;
	Pow[0] = 1;
	for(int i = 1 ; i <= n ; ++ i)
		Pow[i] = (Pow[i-1] * i) % mod;
	for(int i = 0 ; i <= n ; ++ i)
	{
		int x = i;
		int y = k - a * i;
		if (y < 0 | y % b) continue;
		y /= b;
		ans = (ans + (Ckn(x,n)*Ckn(y,n)) % mod) % mod;
	}
	cout << ans;
}

Measured memory_bytes: 2688
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
ll f[ohara], fr[ohara];

ll mod_pow(ll xx, ll nn, ll mod) {
  ll ret = 1;
  while (nn > 0) {
    if (nn & 1) ret = ret * xx % mod;
    xx = xx * xx % mod;
    nn >>= 1;
  }
  return ret;
}

ll ncr(ll nn, ll r) {
  if (nn < r) return 0;
  return f[nn] * fr[r] % MOD * fr[nn - r] % MOD;
}

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

  cin >> n >> k;

  f[0] = 1;
  rrep(i, 1, n + 3) { f[i] = f[i - 1] * i % MOD; }
  fr[n + 2] = mod_pow(f[n + 2], MOD - 2, MOD);
  rrrep(i, n + 1, 0) { fr[i] = fr[i + 1] * (i + 1) % MOD; }

  rrep(i, 1, k + 1) {
    ans = 0;
    if (i == 1) {
      ans = ncr(n - k + 1, n - k);
    } else {
      rrep(j, i - 1, n - k + 1) {
        (ans += ((ncr(j - 1, i - 2) * ncr(n - k - j + 1, n - k - j)) % MOD) *
                ncr(k - 1, i - 1) % MOD) %= MOD;
      }
    }
    Cout(ans);
  }
  return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, W;
    scanf("%d %d",&N, &W);
    int w[N], v[N];
    for(int i = 0; i < N; i++){
        scanf("%d %d",&w[i], &v[i]);
    }
    vector<vector<long long> > dp(N+1, vector<long long>(W+1, -1));
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= W; j++){
            if(i == 0 || j==0) {
                dp[i][j] = 0;
                continue;
            }
            if( j >= w[i-1]){
                dp[i][j] = max(dp[i-1][j-w[i-1]] + v[i-1], dp[i-1][j]);
            }
            else{
                dp[i][j] = dp[i-1][j];
            }

        }
    }
    printf("%lld\n", dp[N][W]);
    return 0;
}

Measured memory_bytes: 80256
### subroutines

def max_mul(cs, n, k)
  nmk = n - k
  ck = max_ck = cs[0...k].inject(1){|m, c| m * c}
  for i in (1..nmk)
    ck = ck * cs[i + k - 1] / cs[i - 1]
    max_ck = ck if max_ck < ck
  end
  max_ck
end

### main

loop do
  n, k = gets.split.map(&:to_i)
  break if (n | k) == 0

  cs = n.times.map{gets.to_i}
  #p cs

  max_ck = max_mul(cs, n, k)

  max_ckd = 1

  for i in (0...n)
    for j in ((i + 1)...n)
      tmp = cs[i]; cs[i] = cs[j]; cs[j] = tmp
      ckd = max_mul(cs, n, k)
      tmp = cs[i]; cs[i] = cs[j]; cs[j] = tmp
      max_ckd = ckd if max_ckd < ckd
    end
  end

  puts (max_ckd >= max_ck ? max_ckd - max_ck : 'NO GAME')
end

Measured memory_bytes: 7076
#include<bits/stdc++.h> 
using namespace std; 
int main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL); 
  int n;
  cin>>n;
  vector<long long int> v(n+1,1);
  for(int i=2;i<=n;i++){
    for(int j=i;j<=n;j+=i){
      v[j]++;
    }
  }
  long long sum=0;
  for(int i=1;i<=n;i++){
    sum+=v[i]*i;
  }
  cout<<sum<<endl;

  

} 

Measured memory_bytes: 81320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;
ll s[maxn];
ll f[maxn];
int main()
{
	ll n;cin>>n;
	for(ll i=0;i<n;i++)
	{
		scanf("%lld",&s[i]);
	}
	//ll c=1;
	ll mx=0;
	for(ll c=1;c<n-1;c++)
	{
		ll sz=(n-2)/c;
		unordered_map<ll,ll> mp;
		ll ans=0;
		for(ll k=1;k<=sz;k++)
		{
			if(n-1-k*c-c<=0) break;
			//n-1>=k*c+a,a-b=c>0,a>c
			//n-1-k*c-c should be >0; 
			if(mp.count(n-1-k*c)) break;
			mp[n-1-k*c]++;
			if(mp.count(k*c)) break;
			mp[k*c]++;
			ans+=s[k*c]+s[n-1-k*c];
			mx=max(ans,mx);
		 } 
	}
	cout<<mx<<endl;
}

Measured memory_bytes: 5168
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		Scanner sc = new Scanner(System.in);
		main.solve(sc);
		sc.close();
	}

	void solve(Scanner sc) {
		String S = sc.next().replaceAll("/", "");
		if(Integer.parseInt(S) <= 20190430) {
			System.out.println("Heisei");
		}else {
			System.out.println("TBD");
		}
	}
}


Measured memory_bytes: 25172
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

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

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

struct Point {
	double x, y;
};

LL x;

LL solve() {
	return 1;
}

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

	cin >> x;
	LL base = x / 11, mod = x % 11, ans = 0;

	ans = base * 2;
	if (6 < mod) {
		ans += 2;
	} else {
		if (mod != 0) ans++;
	}

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main()
{
 int n,s=0;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    int x;
    cin>>x;
    if(x%2!=0 && (i+1)%2!=0)
      s++;
  }
  cout<<s;
  
  

}

Measured memory_bytes: 3616
#include<stdio.h>

int main() {
	int a,b,c,d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	int i,j, sum = 0;
	for(i = a; i < b; ++i) {
		for(j = c; j < d; ++j) {
			if(i == j) sum++;
		}
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	string S; cin>>S;
	string T; cin>>T;
	ote(T+S);
}


Measured memory_bytes: 256
import sys

def solve():
    file_input = sys.stdin
    N, W = map(int, file_input.readline().split())
    C = [0] * (W + 1)
    for line in file_input:
        item_v, item_w = map(int, line.split())
        for i, vals in enumerate(zip(C[item_w:], C)):
            v1, v2 = vals
            v1 += item_v
            if v1 > v2:
                C[i] = v1
    print(C[0])

solve()


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

int main()
{
	int a;
	int b;

	cin >> a;

	b = a % 10;

	if (b == 3)cout << "bon";

	else if (b == 0 || b == 1 || b == 6 || b == 8)cout << "pon";

	else cout << "hon";

	return 0;
}

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

typedef long long ll;
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

int main(){
    int A,B;
    cin>>A>>B;
    cout<<A*B-A-B+1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void) {
    int n, m, i, j, a[1003], b, c, l[1003] = {}, dp[1003][4100] = {};
    const int INF = 1e9;

    cin >> n >> m;
    for (i = 0; i < m; i++) {
        cin >> a[i] >> b;
        for (j = 0; j < b; j++) {
            cin >> c;
            l[i] += (1 << (c - 1));
        }
    }

    for (i = 0; i <= m; i++) for (j = 1; j < (1 << n); j++) {
        dp[i][j] = INF;
    }

    dp[0][0] = 0;
    for (i = 0; i < m; i++) {
        for (j = 0; j < (1 << n); j++) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            dp[i + 1][j | l[i]] = min(dp[i + 1][j | l[i]], dp[i][j] + a[i]);
        }
    }

    if (dp[m][(1 << n) - 1] == INF) {
        cout << -1 << endl;
    }
    else {
        cout << dp[m][(1 << n) - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 16256
#include <bits/stdc++.h>
#define N 1000000007
using namespace std;

long long n;
string s;
long long dp[3005][3005] = {0};

long long solve();

int main() {
  cin >> n >> s;
  --n;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  dp[0][1] = dp[0][0] = 1;
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j <= i + 1; ++j) {
      long long now = 0;
      if(s[i] == '<') {
        if(j != 0) now = dp[i][j - 1];
        now %= N;
      }
      else {
        now = dp[i][i];
        if(j > 0) now -= dp[i][j - 1];
        while(now < 0) now += N;
        now %= N;
      }
      dp[i + 1][j] = now % N;
      if(j != 0) dp[i + 1][j] += dp[i + 1][j - 1];
      dp[i + 1][j] %= N;
    }
  }
  return dp[n][n];
}

Measured memory_bytes: 68992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

const int MAX_N=1010;
ll inv[MAX_N+1], fact[MAX_N+1], ifact[MAX_N+1];

ll comb(int n, int k){
  if(n<k) return 0;
  return fact[n]*ifact[k]%MOD*ifact[n-k]%MOD;
}

void prepare(){
  inv[1]=fact[0]=fact[1]=ifact[0]=ifact[1]=1LL;
  for(int i=2;i<=MAX_N;i++){
    inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
    fact[i]=fact[i-1]*i%MOD;
    ifact[i]=ifact[i-1]*inv[i]%MOD;
  }
}


// dp[k][n]:n人に対して，k人以下のグループを作った場合のグループ分けの個数
ll dp[1010][1010];

int main(){
  prepare();
  int N,A,B,C,D; cin>>N>>A>>B>>C>>D;
  rep(i,1010) dp[i][0]=1;
  for(int i=A;i<=B;i++) for(int j=1;j<=N;j++){
    dp[i][j]+=dp[i-1][j];
    ll tmp=1;
    for(int k=1;k*i<=j&&k<=D;k++){
      (tmp*=comb(j-(k-1)*i,i))%=MOD;
      if(k>=C)(dp[i][j]+=tmp*dp[i-1][j-i*k]%MOD*ifact[k]%MOD)%=MOD;
    }
  }
  cout<<dp[B][N]<<endl;
  return 0;
}


Measured memory_bytes: 8192
package main

import (
	"fmt"
	"math"
)

func main() {
	var h int
	fmt.Scan(&h)
	ans := 1
	i := 1
	fmt.Println(test(ans, h, i))

}

func test(r int, h int, i int) int {
	if h == 1 {
		return r
	} else {
		j := float64(i)
		r += int(math.Pow(2, j))
		h /= 2
		i++
		return test(r, h, i)
	}
}


Measured memory_bytes: 512
n = gets.to_i
1.upto(n) do
  a = gets.chomp
  b = gets.chomp
  if a.length > 80 || b.length > 80 || (a.to_i + b.to_i).to_s.length > 80
    puts "overflow"
  else
    puts a.to_i + b.to_i
  end
end

Measured memory_bytes: 8628
#include <iostream>
#include <stdio.h>
#include <utility>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long LL;
typedef pair<LL,LL> pii;
const int MAX_N = 1e5 + 6;

pii p[MAX_N];
LL d[MAX_N];
bool visit[MAX_N];

vector<pii> vx,vy;

map<pii,int> mp;

LL get_dis(pii a,pii b) {
	return min(abs(a.first-b.first),abs(a.second-b.second));
}

pii rev(pii p) {
	return make_pair(p.second,p.first);
}

LL Kirino(int n) {
	LL ret=0;
	visit[mp[p[1]]] = 0;
	priority_queue<pii,vector<pii>,greater<pii> > pq;
	pq.push(make_pair(0,mp[p[1]]));
	while (!pq.empty()) {
		pii p=pq.top();
		pq.pop();
		pii pp=vx[p.second];
		if (visit[p.second]) continue;
		ret += p.first;
//		cout<<"pp = "<<pp.first<<" , "<<pp.second<<" , val = "<<p.first<<endl;
		visit[p.second]=1;
		if (p.second + 1<vx.size()) {
			pq.push(make_pair(get_dis(vx[p.second],vx[p.second+1]),p.second+1));
		}
		if (p.second-1 >= 0) {
			pq.push(make_pair(get_dis(vx[p.second],vx[p.second-1]),p.second-1));
		}
		int hor=lower_bound(vy.begin(),vy.end(),rev(pp) ) - vy.begin();
		pp = vy[hor];
		if (hor + 1 < vy.size()) {
			pq.push(make_pair(get_dis(vy[hor],vy[hor+1]),mp[rev(vy[hor+1] )] ));
		}
		if (hor-1>=0) {
			pq.push(make_pair(get_dis(vy[hor],vy[hor-1]),mp[rev(vy[hor-1] )]));
		}
	}
	return ret;
}

int main () {
	int n;
	scanf("%d",&n);
	for (int i=1;n>=i;i++) {
		int x,y;
		scanf("%d %d",&x,&y);
		p[i] = make_pair(x,y);
		vx.push_back(make_pair(x,y));
		vy.push_back(make_pair(y,x));
	}
	sort(p+1,p+n+1);
	sort(vx.begin(),vx.end());vx.resize(unique(vx.begin(),vx.end()) - vx.begin());
	int id=0;
	for (auto i:vx) mp[i] = id++;
	sort(vy.begin(),vy.end());vy.resize(unique(vy.begin(),vy.end()) - vy.begin());
	printf("%lld\n",Kirino(n));
}


Measured memory_bytes: 17380
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <random>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
#define bicnt(x)	__buildin__popcount(x)
#define debug(x)	cout<<"debug: "<<x<<endl
#define DEBUG 0

const ll inf = (ll)1e18;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

vint s;
int k, n;

void backstr() {
	int a = s.size()-1;
	if (s[a] == 1) {
		s.pop_back();
	}
	else{
		s[a]--;
		while (s.size() < n)	s.push_back(k);
	}
}

int main() {
	cin >> k >> n;
	if (k % 2 == 0) {
		cout << k / 2;
		srep(i, 1, n)	cout << " " << k;
		cout << endl;
	}
	else {
		s = vint(n, (k + 1) / 2);
		rep(i, n/2)	backstr();
		rep(i, s.size())	cout << (i ? " " : "") << s[i];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3456
# coding: utf-8
# Your code here!

import numpy as np

N, W = map(int, input().rstrip().split(' '))

dp = np.ones(N * int(1e4)) * int(1e10)
dp[0] = 0
for i in range(N):
    w, v = map(int, input().rstrip().split(' '))
    dp[v:] = np.min(np.vstack([dp[v:], dp[:-v] + w]), axis=0)
    
    
print(1 + np.where(dp[1:] <= W)[0][-1])

Measured memory_bytes: 43696
#include <stdio.h>
#include <string.h>
#define MAX1 10000
#define MAX2 500
int S[MAX1];
int linearSearch(int,int);
 
int main()
{
  int n,q,i,T[MAX2],x,cnt=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&S[i]);
    }
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&T[i]);
    }
 
  for(i=0;i<q;i++)
    {
      x=linearSearch(T[i],n);
      if(x==1) cnt=cnt+1;   
    }
  
 printf("%d\n",cnt);  
  return 0;
}
 
 
int linearSearch(int key,int n)
{
  int i; 
  i=0;
  S[n]=key;
  while(S[i]!=key)
    {
      i++;
      if(i==n)
    {
      return 0;
    }
    }
  if(i!=n) return 1;
}

Measured memory_bytes: 636
// The moment you think of giving up you have already lost the battle
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define M   1000000007
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}

int main()
{
  ll N;
  cin>>N;
  ll p=fast(N,10,M);
  ll q=fast(N,9,M);
  ll r=fast(N,8,M);
  q=(q*2)%M;
  p-=q;
  if(p<0)
  {
      p+=M;
      p%=M;
  }
  p=(p%M+r%M)%M;
  cout<<p;
}



Measured memory_bytes: 3632
#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;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll a[222222];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	ll x=0;
	for(int i=0;i<n;i++) {
		cin>>a[i]; x^=a[i];
	}
	for(int i=0;i<n;i++)
	{
		cout<<(x^a[i]);
		if(i+1<n) cout<<' ';
	}
	cout<<'\n';
	
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define MOD 1000000007
typedef long long ll;

int main(){
	ll n;cin >> n;
	string str;cin >> str;

	ll ans = 1;
	ll cou = 0;
	REP(i, str.size()){
		int now = ((cou % 2 == 0) + (str[i] == 'B')) % 2;

		if(now){
			ans = (ans * cou) % MOD;
			cou--;
		}
		else {
			cou++;
		}

		if(cou < 0){
			cout << 0 << endl;
			return 0;
		}
	}

	for(int i = 1;i <= n;i++){
		ans = (ans * i) % MOD;
	}

	cout << (cou == 0 ? ans : 0) << endl;

	return 0;
}


Measured memory_bytes: 640
N=int(input())

if N==1:
    print(1)
elif 2<=N<=3:
    print(2)
elif 4<=N<=7:
    print(4)
elif 8<=N<=15:
    print(8)
elif 16<=N<=31:
    print(16)
elif 32<=N<=63:
    print(32)
elif 64<=N<=100:
    print(64)

Measured memory_bytes: 3064
($N,$W)=glob<>;
@0=@1=@2=@3=(0);
/ /,$w1//=$`,push@{$`-$w1},$' for<>;
@$_=sort{$b-$a}@$_ for 0..3;
for$n3(0..$#{3}){
	for$n2(0..$#{2}){
		for$n1(0..$#{1}){
			for$n0(0..$#{0}){
				if($n3*($w1+3)+$n2*($w1+2)+$n1*($w1+1)+$n0*$w1<=$W){
					$a=0;
					$a+=$_ for@3[0..$n3-1],@2[0..$n2-1],@1[0..$n1-1],@0[0..$n0-1];
					if($a>$%){
						$%=$a
					}
				}
			}
		}
	}
}
print$%


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






int main(){
  int n,m;
  cin>>n>>m;
  int a[n];
  int s=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    s+=a[i];

  }
  double t=(double)s/(double)(4*m);

  int y=0;
  for(int i=0;i<n;i++){
    if(a[i]>=t)y++;
  }
  if(y>=m)cout<<"Yes";
  else cout<<"No";

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        // ##### 初期読み込み #######################################################################
        // 1行 文字 複数 ----------------------------------------------------------------------------
        String[] stringArray = scanner.nextLine().split("");
        String s1 = stringArray[0];
        String s2 = stringArray[1];
        String s3 = stringArray[2];

        // ##### メイン処理 #######################################################################
        if (s1.equals(s2) && s2.equals(s3)) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define NFOR(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); --i)
#define rep(i, a) for (ll i = 0; i < a; i++)
#define endl "\n"
#define fi first
#define se second
#define MOD 1000000007
#define inf 1e18
#define pb push_back
#define Case cout<<"Case #"<<++cas<<": ";
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}

const int maxn = 22;
ll dp[1 << maxn];

void solve() {
	ll n;
	cin >> n;
	ll a[n][n];
	rep(i, n) rep(j, n) cin >> a[i][j];

	memset(dp, 0, sizeof(dp));
	dp[0] = 1;
	FOR(mask, 1, (1 << n) - 1) {
		ll i = __builtin_popcount(mask);
		dp[mask] = 0;
		rep(j, n) {
			if (mask & (1 << j)) 
				if (a[i-1][j]) 
					dp[mask] = (dp[mask] + dp[mask ^ (1 << j)]) % MOD;
		}
	}

	cout << dp[(1 << n) - 1] << endl;
}

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


Measured memory_bytes: 33024
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,m,cnt=0,o,p,aa[220000],cntl=0,ab[220000];
pair<int,int> pp[220000];
string s,ss[220000];
char c,cc[5000][5000]={};
queue<int> que;
signed main(){
    cin>>s;
    if(s=="ABC"){
        cout<<"ARC"<<endl;
    }else{
        cout<<"ABC"<<endl;
    }
}


Measured memory_bytes: 10484
#include <iostream>

using namespace std;

int main()
{
	long long ans = 0, i, j, k, K, S, X, Y, Z;

	cin >> K >> S;

	for (i = (S>=2*K?S-2*K:0); (i <= K)&&(i <= S); i++) {
		for (j = i; (j <= K)&&(i+j <= S); j++) {
			for (k = j; (k <= K)&&(i + j + k <= S); k++) {
				if (i + j + k == S) {
					if ((i == j) && (j == k) && (k == i))
						ans++;
					else if ((i == j) || (j == k) || (k == i))
						ans += 3;
					else
						ans += 6;
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
typedef long long ll;
#define out(i) cout<<(i)<<endl

int main() {
  ll N,M,sum=0;
  cin>>N>>M;
  vector<ll> data(M);
  rep0(i,M){cin>>data[i];}
  rep0(i,M){sum+=data[i];}
  if(N-sum<0){cout<<-1<<endl;}
  else{cout<<N-sum<<endl;}
}

Measured memory_bytes: 3684
#include <iostream>
#include <math.h>
#define eps 1e-8

using namespace std;

struct vec2d{
  double x, y;
  vec2d(){}
  vec2d(double x, double y){
    this->x = x, this->y = y;
  }
  double add(double a, double b){
    if(fabs(a+b) < eps * (fabs(a) + fabs(b))) return 0.0;
    return a+b;
  }
  vec2d operator+(vec2d ope){
    return vec2d(add(x, ope.x), add(y, ope.y));
  }
  vec2d operator-(vec2d ope){
    return vec2d(add(x, -ope.x), add(y, -ope.y));
  }
  vec2d operator*(double t){
    return vec2d(x*t, y*t);
  }
  vec2d operator/(double t){
    return vec2d(x/t, y/t);
  }
  double dot(vec2d ope){
    return add(x*ope.x, y*ope.y);
  }
  double cross(vec2d ope){
    return add(x*ope.y, -y*ope.x);
  }
  double norm(){
    double d2 = dot(*this);
    if(d2 > 0) return sqrt(d2);
    return 0.0;
  }
};

double distPP(vec2d p, vec2d q){
  return (p-q).norm();
}
double distSP(vec2d p, vec2d q, vec2d x)
{
  if((x-p).dot(q-p) <= 0) return distPP(p, x);
  if((x-q).dot(p-q) <= 0) return distPP(q, x);
  return fabs( (x-p).cross(q-p) / distPP(p, q) );
}

int n;
double r[16];
vec2d s[16], t[16];
int dp[1<<16];

int main(void)
{
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> r[i] >> s[i].x >> s[i].y >> t[i].x >> t[i].y;
  }
  int N = 1<<n;
  for(int i = 0; i < N; i++) dp[i] = -10000000;
  dp[0] = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < n; j++){
      if(i & (1<<j)) continue;
      bool flag = true;
      for(int k = 0; k < n; k++){
        if(j == k) continue;
        if((i & (1<<k)) && distSP(s[j], t[j], t[k]) <= r[j]+r[k]) flag = false;
        if((i & (1<<k)) == 0 && distSP(s[j], t[j], s[k]) <= r[j]+r[k]) flag = false;
      }
      if(flag) dp[i|(1<<j)] = max(dp[i|(1<<j)], dp[i] + 1);
    }
  }
  int ans = 0;
  for(int i = 0; i < N; i++) ans = max(ans, dp[i]);
  cout << ans << endl;

  return 0;
}



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

int main() {
	
	int n;
	int A[100];
	int max1 = 0,now1 = 0;
	cin >> n;
	for(int i=0; i!=n; i++){
		cin >> A[i];
		if(A[i] == 1){
			now1 += 1;
			if(max1 < now1){
				max1 = now1;
			}
		}else{
			now1 = 0;
		}
	}
	cout << max1+1 << '\n';
	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const int INF = 100000000;

int main()
{
    ll x;
    cin >> x;

    ll joy = 1000 * (x / 500);
    x = x % 500;
    joy += 5 * (x / 5);
    cout << joy << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	n := getInt()
	as := getIntSlice(n)

	boxes := make([]int, n)
	m := 0
	for i := n - 1; i >= 0; i-- {
		sum := 0
		for x := i*2 + 1; x < n; x += i + 1 { // i=3の時、 x = 7, 11, 15...
			sum += boxes[x]
		}

		boxes[i] = as[i] ^ (sum % 2)
		if boxes[i] == 1 {
			m++
		}
	}

	fmt.Println(m)
	for i := range boxes {
		if boxes[i] == 1 {
			fmt.Println(i + 1)
		}
	}
}

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

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


Measured memory_bytes: 5504
def med(l):
	t = len(l)
	if t%2:
		return l[t//2]
	else: return (l[t//2]+l[t//2-1])/2

n = int(input())
a = []
b = []
for i in range(n):
	x,y = map(int,input().split())
	a+=[x]
	b+=[y]
a.sort()
b.sort()

if n%2==0:
	print(int((med(b)-med(a))*2)+1)
else:
	print(med(b)-med(a)+1)


Measured memory_bytes: 25456
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    cins(all(a));
    vector<vector<ll>> cnt(60,vector<ll>(2,0));
    rep(i,n){
        rep(j,60){
            if (a[i]&(1ll<<j)){
                cnt[j][1]++;
            }
            else{
                cnt[j][0]++;
            }
        }
    }
    ll ans = 0;
    rep(i,60){
        (ans += cnt[i][0]*cnt[i][1]%MOD*((1ll<<i)%MOD))%=MOD;
    }
    PRINT(ans);
}


Measured memory_bytes: 2688
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lld;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<"NO"<<endl;return 0
const int mod=1000000007;
const int big=1e9+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	llint i,n,wa=0;cin>>n;
	vector<llint>a(n+1);
	for(i=0;i<n;i++){cin>>a[i];wa+=a[i];}
	a[n]=a[0];
	if(wa%(n*(n+1)/2)!=0){cout<<"NO"<<endl;return 0;}
	llint fe=wa/(n*(n+1)/2);
	for(i=0;i<n;i++){
		llint s=fe+a[i]-a[i+1];
		if(s<0||s%n!=0){cout<<"NO"<<endl;return 0;}
	}
	cout<<"YES"<<endl;
    return 0;
}

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

int n,i,total,freq[100002],ar[100002];


int main(){
    scanf("%d",&n); total=0;
    for(i=1;i<=n;i++){
        scanf("%d",&ar[i]);
        if(ar[i]>100000){total++;}
        else{freq[ar[i]]++;}
    }
    for(i=1;i<=100000;i++){
        if(freq[i]>i){total+=(freq[i]-i);}
        else if(freq[i]<i){total+=freq[i];}
    }
    printf("%d\n",total);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
const int MOD=1e9+7;
const ll INF=1e18;
const ll inf=1e9;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  int n,m;
  cin >> n >> m;
  vector<int>a(n),b(n),c(m),d(m);
  rep(i,n) cin >> a[i] >> b[i];
  rep(i,m) cin >> c[i] >> d[i];
  vector<int> ans(n);
  rep(i,n){
    int dist = inf;
    int pos = m;
    rep(j,m){
      int di = abs(a[i]-c[m-1-j])+abs(b[i]-d[m-1-j]);
      if(di<=dist){
        dist = di;
        pos = m-1-j+1;
      }
    }
    ans[i]=pos;
  }
  rep(i,n) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 3640
n, l = map(int, input().split())

min_taste = l
max_taste = l + n - 1

ans = (min_taste + max_taste) * n // 2
if max_taste * min_taste > 0:
  if min_taste > 0:
    ans -= min_taste
  else:
    ans -= max_taste

print(ans)

Measured memory_bytes: 3060