akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
queue <pair<string,int> > worm;
map <string,int> M;
int s1,n;
string str,strrr,sample[3]={"gggggggggg","bbbbbbbbbb","rrrrrrrrrr"},worms[3];
bool flag=false;

int main(){
    while(1){
        cin >> str;
        if(str=="0")break;
            s1=str.size();
            for(int i=0;i<3;i++)worms[i]=sample[i].substr(0,s1);
            worm.push(make_pair(str,0));


        while(!worm.empty()){
            str=worm.front().first;
            n=worm.front().second;
            worm.pop();
            if(M[str]>0);
            else{
            //cout << n << endl;
            if(s1*2<n)break;
            M[str]++;
            if(str==worms[0]||str==worms[1]||str==worms[2]){
                    flag=true;
                cout  << n << endl;
                while(!worm.empty())worm.pop();
                break;
            }else{
                for(int i=1;i<s1;i++){
                    if(str[i]!=str[i-1]){
                        if(str[i]!='r'&&str[i-1]!='r'){
                            strrr=str;
                            str[i]='r',str[i-1]='r';
                            worm.push(make_pair(str,n+1));
                            str=strrr;
                        }
                        if(str[i]!='b'&&str[i-1]!='b'){
                            strrr=str;
                            str[i]='b',str[i-1]='b';
                            worm.push(make_pair(str,n+1));
                            str=strrr;
                        }
                        if(str[i]!='g'&&str[i-1]!='g'){
                            strrr=str;
                            str[i]='g',str[i-1]='g';
                            worm.push(make_pair(str,n+1));
                            str=strrr;
                        }
                    }
                }

            }
        }

    //end:
    }

        if(flag==false)cout << "NA" << endl;
        flag=false;
        while(!worm.empty())worm.pop();
        n=0;
        M.clear();

    }

return 0;
}

Measured memory_bytes: 3352
import bisect
import sys
x,n = map(int,input().split())
if n==0:
    print(x)
    sys.exit()
l = list(map(int,input().split()))
l.sort()
index = bisect.bisect_left(l,x)
lis=[]
if l[index]==x:
    for i in l:
        lis.append(abs(i-x))
    lis.sort()
    key=0
    for i in range(1,100):
        a=lis.count(i)
        if a!=2:
            key=i
            break
    ans=x-key
    if ans not in l:
        print(ans)
        sys.exit()
    else:
        print(x+key)
        sys.exit()
else:
    print(x)

Measured memory_bytes: 9252
#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)

using namespace std;

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> a(3 * N);
    REP(i, 3 * N) cin >> a[i];

    multiset<int> s;

    ll left_sum = accumulate(a.begin(), a.begin() + N, 0ll);
    REP(i, N) {
        s.insert(a[i]);
    }
    vector<ll> left_sums(N + 1);
    left_sums[0] = left_sum;
    FOR(i, 1, N + 1) {
        int j = N + i - 1;
        left_sum += a[j];
        s.insert(a[j]);
        left_sum -= *s.begin();
        s.erase(s.begin());
        left_sums[i] = left_sum;
    }

    s.clear();

    ll right_sum = accumulate(a.begin() + 2 * N, a.end(), 0ll);
    FOR(i, 2 * N, 3 * N) {
        s.insert(a[i]);
    }
    vector<ll> right_sums(N + 1);
    right_sums[0] = right_sum;
    FOR(i, 1, N + 1) {
        int j = 2 * N - i;
        right_sum += a[j];
        s.insert(a[j]);
        right_sum -= *(prev(s.end(), 1));
        s.erase(prev(s.end(), 1));
        right_sums[i] = right_sum;
    }

    ll result = LLONG_MIN;
    REP(i, N + 1) {
        result = max(result, left_sums[i] - right_sums[N - i]);
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 7680
<?php
$n = intval(fgets(STDIN));
$a = array_map("intval", explode(" ", trim(fgets(STDIN))));
$free = 0;
foreach($a as $b){
    if($b < 3200){
        $color[intdiv($b,400)] = true;
    }else{
        $free++;
    }
}
$min = count($color);
$max = count($color) + $free;
if($min == 0)$min = 1;
echo $min, " ", $max,"\n";

Measured memory_bytes: 4604
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000000000000ll
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
//#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  ll cnt = 0;
  while (true) {
    sort(ALL(a));
    ll b = a.back() / 2;
    for (ll i = n - 1; i >= 0; i--) {
      if (a[i] < b) break;
      a[i] /= 2;
      cnt++;
      if (cnt == m) {
        ll ans = 0;
        sort(ALL(a));
        DEBUGS(a);
        REP(i, n) ans += a[i];
        cout << ans << '\n';
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3976
N, W = map(int, input().split())

values = [0]
weights = [0]
for _ in range(N):
    v, w = map(int, input().split())
    values.append(v)
    weights.append(w)

dps = [[0 for _ in range(W + 1)] for _ in range(N + 1)]


for i in range(1, N + 1):
    for j in range(1, W + 1):
        if i == 1:
            if j >= weights[i]:
                dps[i][j] = values[i] * (j // weights[i])
        else:
            if j >= weights[i]:
                dps[i][j] = max(dps[i][j - (weights[i])] +
                                values[i], dps[i - 1][j])
                # for k in range(j // weights[i] + 1):
                # dps[i][j] = max(dps[i][j - (weights[i] * k)] + (values[i] * k),
                #                 dps[i][j])
                dps[i][j] = max(dps[i][j], dps[i][j - 1])
            else:
                dps[i][j] = max(dps[i][j - 1], dps[i - 1][j])
print(dps[N][W])



Measured memory_bytes: 42308
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, d) = (v[0], v[1]);
    println!("{}", (n + 2 * d)  / (2 * d + 1));
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<iostream>
#include <iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int n,c[100010]={},k,f=0,s=0;
vector<int> E[101000];
bool flag=false;

void dfs(int x){
    for(int y:E[x]){
        if(c[y]==0){
            c[y]=c[x]+1;
            dfs(y);
        }
    }
    return;
}

void dfs2(int x){
    if(!flag){
    for(int y:E[x]){
        if(c[y]==c[x]-1){
            if(c[y]==k){
                E[x].erase(remove(all(E[x]),y),E[x].end());
                E[y].erase(remove(all(E[y]),x),E[y].end());
                for(auto it=E[x].begin();it!=E[x].end();it++){
                    if(*it==y){
                        E[x].erase(it);
                    }
                }
                for(auto it=E[y].begin();it!=E[y].end();it++){
                    if(*it==x){
                        E[y].erase(it);
                    }
                }
                flag=true;
            }
            dfs2(y);
        }
    }
    }
    return;
}

void dfs3(int x){
    c[x]=0;
    f++;
    for(int y:E[x]){
        if(c[y]!=0){
            dfs3(y);
        }
    }
    return;
}

void dfs4(int x){
    s++;
    c[x]=0;
    for(int y:E[x]){
        if(c[y]!=0){
            dfs4(y);
        }
    }
    return;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    c[1]=1;
    rep(i,n-1){
        int a,b;
        cin >>a>>b;
        E[a].pb(b);
        E[b].pb(a);
    }
    dfs(1);
    if(c[n]%2==0){
        k=c[n]/2;
    }
    else{
        k=(c[n]+1)/2;
    }
    dfs2(n);/*
    for(int y:E[4]){
        cout<<y<<endl;
    }*/
    c[1]=0;
    c[n]=0;
    dfs3(1);
    dfs4(n);
    //cout<<f<<" "<<s<<endl;
    if(f>s){
        cout<<"Fennec"<<endl;
    }
    else cout<<"Snuke"<<endl;
    return 0;
}

Measured memory_bytes: 9216
#include<stdio.h>

int main(){
	int k,i,c,sum;
	while(0<=scanf("%d",&k)){
		if(k==0) break;
		sum=0;
		for(i=0;i<k*(k-1)/2;i++){
			scanf("%d",&c);
			sum+=c;
		}
		printf("%d\n",sum/(k-1));
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


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

    vector<int> f(N+1, 1);
    FOR(i, 2, N+1){
        for(long long j = 1; i*j <= N; ++j) ++f[i*j];
    }

    long long ans = 0;
    FOR(K, 1, N+1) ans += (long long) K*f[K];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 42324
#include <stdint.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

void solve(long long N, std::vector<long long> a) {
  ll x = 0;
  REP(i, N) {
    x ^= a[i];
  }
  REP(i, N) {
    cout << (x ^ a[i]) << " ";
  }
  cout << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, std::move(a));
  return 0;
}


Measured memory_bytes: 4828
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

typedef long long ll;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

ll N,K;
v_ll P2;
ll m;


ll solve(ll n){
  ll ok=m,ng=-1,mid=0;
  while (ok-ng>1){
    mid = (ok+ng)/2;
    if (n*P2[mid]<K) ng=mid;
    else ok=mid;
  }
  return ok;
}

int main(){
  cin >>N >> K;
  ll i=1;
  m=0;
  while (i<=2*K){
    P2.push_back(i);i*=2;m++;
  }
  P2.push_back(i);
  ll ans=0;
  for (ll i=1;i<=N;i++){
    ans+=P2[m-solve(i)];
  }
  double ans2=(double)ans/N/P2[m];
  printf("%10.15lf",ans2);
  cout << endl;
}


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

void solve(long N, vector<ll> A) {
  ll ans = 1;
  auto is0 = find(A.cbegin(), A.cend(), 0);
  if (is0 != A.cend()) {
    cout << 0 << endl;
    return;
  }
  REP(i, N) {
    if (1E18 / A[i] < ans) {
      cout << -1 << endl;
      return;
    }
    ans *= A[i];
  }
  if (ans > 1000000000000000000)
    cout << -1 << endl;
  else
    cout << ans << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  long N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N)
    cin >> A[i];

  solve(N, move(A));

  return 0;
}


Measured memory_bytes: 3988
import Data.List
import qualified Data.ByteString.Char8 as BS
main=do
 n<-readLn;a<-reverse.sort.map (read.BS.unpack).BS.words<$>BS.getLine
 print(f n a)
  where f 0 a = 0
        f n (x:y:a) = y+(f (n-1) a)

Measured memory_bytes: 49532
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;
vector<pair<int, int>> vp[N];
int ans[N];
void dfs(int x, int c = 0, int fa = 0)
{
	ans[x] = c;
	for (auto& p : vp[x])
	{
		int y, w;
		tie(y, w) = p;
		if (y == fa) continue;
		dfs(y, c ^ w, x);
	}
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	for (int i = 1; i < n; i++)
	{
		int x, y, w;
		cin >> x >> y >> w;
		w &= 1;
		vp[x].emplace_back(y, w);
		vp[y].emplace_back(x, w);
	}
	dfs(1);
	for (int i = 1; i <= n; i++) printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 8320
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define rep(i,a) for(ll i = 0;i<a;++i)
#define mod 1000000007
#define inf 11451419198
using namespace std;

ll dp[101][4][2];

int main(){
	rep(i, 101) rep(j, 4) rep(k, 2) dp[i][j][k] = 0;
	string s; cin >> s;
	ll n = s.size(), K; cin >> K;
	dp[0][0][0] = 1;
	rep(i, n) rep(j,4) rep(k,2){
		ll x = s[i] - '0';
		rep(a, 10){
			ll ni = i + 1, nj = j, nk = k;
			if (a) nj++;
			if (nj > K) continue;
			if (k == 0){
				if (a > x) continue;
				if (a < x) nk = 1;
			}
			dp[ni][nj][nk] += dp[i][j][k];
		}
	}cout << dp[n][K][0] + dp[n][K][1] << endl;
	return 0;
}

Measured memory_bytes: 256
/*input
8
1 2 1 4 2 1 4 1
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-6;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll sub(ll a,ll b){
    ll x=a-b;
    while(x<0) x+=MOD;
    while(x>MOD) x-=MOD;
    return x;
}
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
#define int ll
int arr[maxn]; 
int arr2[maxn];
int32_t main(){
	int n,k;
	cin>>n;
	REP(i,n){
		int x;
		cin>>x;
		--x;
		arr2[i]=x;
		arr[x]++;
	}
	ll ans=0;
	REP(x,n){
		ans+=(arr[x]*(arr[x]-1))/2;
	}
	REP(i,n){
		int x=arr2[i];
		cout<<(ans-arr[x]*(arr[x]-1)/2)+((arr[x]-1)*(arr[x]-2))/2<<'\n';
	}
}


Measured memory_bytes: 4736
n = int(input())
list = [0,0,0,0]

for i in range(n):
  judge = input()
  if judge == 'AC':
    list[0] += 1
  elif judge == 'WA':
    list[1] += 1
  elif judge == 'TLE':
    list[2] += 1
  elif judge == 'RE':
    list[3] += 1
    
print( 'AC x {}'.format(list[0]) )
print( 'WA x {}'.format(list[1]) )
print( 'TLE x {}'.format(list[2]) )
print( 'RE x {}'.format(list[3]) )

Measured memory_bytes: 9152
n,m,k = map(int,input().split())
mod = 998244353
ans = 0
fact = [1,1]
finv = [1,1]
for i in range(2, n+1):
    fact += [fact[i-1] * i % mod]
    finv += [pow(fact[i], mod-2, mod)]


def comb(n,k, mod):
    return (fact[n] * finv[k] * finv[n-k]) % mod



for i in range(0, k+1):
    ans += m * pow(m-1, n-i-1, mod) * comb(n-1, i, mod)
    ans %= mod
print(ans)

Measured memory_bytes: 25008
while 1:
    # A = input()
    # A = int(input())
    n, x = map(int, input().split())
    plus1 = lambda x: x + 1
    # A = list(map(int, input().split()))
    # A = [int(input()) for i in range(N)]
    #
    # c = collections.Counter()

    if (n, x) == (0, 0):
        break
    else:
        c = 0
        for i in range(n):
            for j in range(i):
                for k in range(j):
                    if (i+1) + (j+1) + (k+1) == x:
                        c += 1

    print(c)


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

int LCGs(int N, int X, int A, int B, int C, const int *Y) {
  int counter = 0;

  for(int i = 0; i < N; i ++) {
    for(; counter <= 10000; counter++) {
      if(X == Y[i]) {
        if(i < (N-1) && Y[i] == Y[i+1]) {
          counter++;
          X = ((A * X + B) % C);
        }
        break;
      }
      X = ((A * X + B) % C);
    }
  }

  if(counter <= 10000)
    return counter;
  else
    return -1;
}

int main() {
  int N; //リールの数                                                                                     
  int X; //乱数の初期値                                                                                   
  int A, B, C; //定数                                                                                     
  vector<int> Y; //特殊な絵柄で停止する条件                                                               

  while(1) {
    cin >> N >> A >> B >> C >> X;
    if(N == 0)
      break;

    int y;
    for(int i = 0; i < N; i++) {
      cin >> y;
      Y.push_back(y);
    }

    cout << LCGs(N, X, A, B, C, &Y.front()) << endl;
    Y.clear();
  }
}



Measured memory_bytes: 3076
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b float64
	fmt.Scan(&a, &b)
	for i := 13; i <= 1000; i++ {
		if math.Floor(0.08*float64(i)) == a && math.Floor(0.1*float64(i)) == b {
			fmt.Println(i)
			return
		}
	}
	fmt.Println(-1)
}


Measured memory_bytes: 512
h,w = map(int, input().split())
ans = 10**9
for p,o in zip([h,w],[w,h]):
  for i in range(1, p//2 + 1):
    sa = i * o
    hi = (p-i)//2
    sb = o * hi
    sc = o * (p - i - hi)
    t = max(sa,sb,sc) - min(sa,sb,sc)
    ans = min(ans, t)
    
    wi = o//2
    sb = (p - i) * wi
    sc = (p - i) * (o - wi)
    t = max(sa,sb,sc) - min(sa,sb,sc)
    ans = min(ans, t)
print(ans)

Measured memory_bytes: 9084
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

#define MOD 1000000007

ll fact(ll x){
    if(x == 1)return 1;
    return x%MOD*fact(x-1)%MOD;
}

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

    ll nf = fact(n);
    ll mf = fact(m);

    if(abs(n-m) == 0)cout << (nf*mf)%MOD*2%MOD;
    else if(abs(n-m) <= 1)cout << (nf*mf)%MOD;
    else cout << 0;

    return 0;

}

Measured memory_bytes: 1792
A, B, M = [int(n) for n in input().split()]
a = [int(n) for n in input().split()]
b = [int(n) for n in input().split()]

x = [None] * M
y = [None] * M
c = [None] * M

w = {}
m = min(a) + min(b)

for i in range(M):
    x[i], y[i], c[i] = [int(n) for n in input().split()]
    p = a[x[i]-1] + b[y[i]-1] - c[i]
    if p < m:
        m = p

print(m)

Measured memory_bytes: 23380
n=int(input())
i=1
a=0
m=n
while n-26**i>0:
    n=n-26**i
    i+=1
    a+=n**i #桁数
ans=""
b=0
l=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for j in range(i):
    b=m%26
    m=m//26
    if b==0:
      m=m-1
    ans=l[b-1]+ans
print(ans)

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);
  
  ll n, k; cin >> n >> k;
  ll ans = 0;

  rep2(i, k+1, n) {
    ll v = n / i;
    ans += (i - k) * v;
    // cout << i << " :" << (n % i) - k + 1 << endl;
    ans += max(0LL, (n % i) - k + 1);
  }

  if (k == 0) ans -= n;

  cout << ans << endl;
}

Measured memory_bytes: 3532
// Move and Win
#include <cmath>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    bool win = false;
    if ((B - A) % 2 == 0) win = true;
    if (win) cout << "Alice" << endl;
    else cout << "Borys" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

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

  ll W,H,x,y;
  int e=0;
  double s;
  cin>>W>>H>>x>>y;
  s = W*H/2.0;
  if(x==W/2.0){
    if(y==H/2.0){
      e=1;
    }
  }
  printf("%.11f %d\n", s,e);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;
#include <deque>

int main(void){
    Cin(int, n);
    vc<vc<bool>> e(n, vc<bool>(n));
    For(i, n) For(j, n){
        Cin(char, c);
        e[i][j] = (c == '1');
    }
    
    int ans = -1;
    For(s, n){
        vc<int> v(n, 0);
        v[s] = 1;
        deque<int> q;
        q.push_back(s);
        while(!q.empty()){
            int i = q.front();
            q.pop_front();
            For(j, n){
                if(e[i][j]){
                    if(v[j] == 0){
                        v[j] = v[i]+1;
                        q.push_back(j);
                    }
                    if(abs(v[i] - v[j]) != 1){
                        goto next;
                    }
                }
            }
        }
        For(i, n) Maxi(ans, v[i]);
        next:;
    }
    Cout(ans);
}




Measured memory_bytes: 256
n = int(input())
x = 1
y = 1
z = 1
a = [0]*(10**5)
for j in range(x,100):
    for k in range(y,100):
      for l in range(z,100):
        a[j**2+k**2+l**2+j*k+k*l+l*j]+=1
for i in range(1,n+1):
  print(a[i])

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

#define ran 101101

int n;
int a[ran], b[ran];

int main() {
	scanf("%d", &n);
	for(int i=0;i<=n;i++) scanf("%d", &a[i]);
	for(int i=0;i<n;i++) scanf("%d", &b[i]);
	
	long long ans = 0;
	for(int i=0;i<n;i++) {
		int x = min(b[i], a[i]);
		ans += x;
		a[i] -= x; b[i] -= x;
		
		x = min(b[i], a[i+1]);
		ans += x;
		a[i+1] -= x; b[i] -= x;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define rgi register int
#define rgl register long long
#define il inline

using namespace std;

const int oo = 0x3f3f3f3f;

string s, t;
int cnt;

il int read()
{
	rgi x = 0, f = 0, ch;
	while(!isdigit(ch = getchar())) f |= ch == '-';
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return f ? -x : x; 
}

int main()
{
	cin >> s >> t;
	for(rgi i = 0; i < 3; ++i)
		if(s[i] == t[i])
			cnt++;
	cout << cnt;
	return 0;
}

Measured memory_bytes: 384
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>

using namespace std;

int
main()
{
    int n;
    assert(scanf("%d", &n) == 1);
    vector<int> cards;
    for (int i = 0; i < n; i++) {
        int c;
        assert(scanf("%d", &c) == 1);
        cards.push_back(c);
    }
    if (n % 2 == 1)
        cards.push_back(0);

    sort(cards.begin(), cards.end());
    int diff = 0;
    for (int i = 0; i < n; i += 2)
        diff += cards[i + 1] - cards[i];

    printf("%d\n", diff);
    exit(0);
}


Measured memory_bytes: 256
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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 T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll n;cin>>n;

    ll m=-1;
    rep(i,1000){
        if(i*(i-1)/2==n)m=i;
    }

    if(m==-1){
        cout<<"No"<<endl;
        return;
    }

    vvl a(m);
    ll idx=1;
    rep(i,m)rep(j,i+1,m){
        a[i].push_back(idx);
        a[j].push_back(idx);
        ++idx;
    }

    cout<<"Yes"<<endl;
    cout<<m<<endl;
    rep(i,m){
        cout<<m-1;
        rep(j,m-1)cout<<' '<<a[i][j];
        cout<<endl;
    }
}

Measured memory_bytes: 3200
#define _USE_MATH_DEFINES


#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <numeric>

#include <cmath>

using namespace std;

typedef long long LL;

int main() {
	vector<pair<int, int>> vec;
	int H, W;

	while (true)
	{
		cin >> H >> W;
		if (H == 0 && W == 0) break;

		auto p = make_pair(H, W);
		vec.emplace_back(p);
	}

	for (auto&& v : vec) {
		for (int j = 0; j < v.first; ++j) {
			for (int i = 0; i < v.second; ++i) {
				cout << "#";
			}
			cout << "\n";
		}
		cout << "\n";
	}

	return 0;
}



Measured memory_bytes: 3076
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>

using namespace std;

void trace(int A[], int N) {
	int i;
	for (i = 0; i < N; ++i) {
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}

void insert(int A[], int N) {
	int j, i, v;
	for (i = 1; i < N; ++i) {
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trace(A, N);
	}
}

int main() {
	int N, i, j;
	int A[100];

	cin >> N;
	for (i = 0; i < N; ++i) cin >> A[i];

	trace(A, N);
	insert(A, N);

	return 0;
}


Measured memory_bytes: 3120
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,tmp=0;
  ll a[LIMIT1]={0};
  
  cin >> n;
  rep(i,n){
    cin >> a[i];
    tmp ^= a[i];
  }
  rep(i,n){
    cout << (tmp^a[i]) << (i==n-1 ? "\n" : " ");
  }
  return 0;
}

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

template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};
using namespace std;
void solve(){
    char A[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>A[i][j];
            
        }
    }
    cout<<A[0][0]<<A[1][1]<<A[2][2];
}
int main(){
//   #ifndef ONLINE_JUDGE
//      freopen("in.txt", "r", stdin);
//      freopen("out.txt", "w", stdout);
//   #endif  
    std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    // int x;
    // cin>>x;
    // while(x--)
    solve();
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int isprime(int n){
    for(int i=2; i*i<=n; i++){
        if(n%i==0)
        return 0;
    }
    return 1;
}
int main(){
    int num;
    while(1){
        scanf("%d", &num);
        if(num==0)break;
        for(int i=num; i>2; i--){
            if(isprime(i)==1)
                if(isprime(i-2)==1){
                    printf("%d %d\n", i-2, i);
                    break;
                }
        }
    }
    return 0;
}

Measured memory_bytes: 1784
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while( sc.hasNext() ) {
			String line = sc.nextLine();
			for(char ch : line.toCharArray()) {
				System.out.print( Character.toUpperCase(ch) );
			}
			System.out.println();
		}
		
	}

}

Measured memory_bytes: 12000
#include<iostream>
#include<algorithm>
#include<vector>
#include<unordered_map>
using namespace std;
int main()
{
    /*long long int n,m,x,ans;
    string s,t,temp;
    cin>>n>>m>>x;
    
    for(int i = 1;i <= n;i ++)
    {
        cin>>

    }*/
    long long int n,k,temp,len=0,ans=1,road,fin,count;
    vector<long long int> all;
    long long int map[200005]={0};//这个用来记录每一个具体的点的
    cin>>n>>k;
    all.push_back(-1); //先放一个进去垫底
    for(int i = 1;i<=n;i++)
    {
        cin>>temp;
        all.push_back(temp);
    }
    //unordered_map<long long int,long long int> hash;
    count = 1;
    if(k<=n)
    {
        for(long long int i=1;i<=k;i++)
        {
            ans=all.at(ans);
        }
        cout<<ans<<endl;
        return 0;
    }
    for(long long int i = 1;i<=k;i++)
    {
        //hash[ans]++;
        len++;
        if(map[ans]==0)
            map[ans]=count;
        else
        {
                road=count-map[ans];//这一圈的长度，得知，求余数！
                fin=(k-(map[ans]-1))%road;
               // cout<<road<<" "<<fin<<endl;
                break;
        }
        count++;
        ans=all.at(ans);
    }
    //ans=1;ans不用变！直接就地开始
    for(long long int i=1;i<=fin;i++)
    {
        ans=all.at(ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6908
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, m;
    cin >> n >> m;    
    
    vvl G(n);  // 辺の重みがすべて1のグラフ
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
    }
 
    ll sv, gv;
    cin >> sv >> gv;
    sv--;  gv--;
    
    // BFS。計算量はO(V+E)
    vvl dist(n, vl(3, -1));  // dist[v][x] : 頂点svから頂点vへの、移動回数を3で割った余りがｘとなる最短距離(-1のとき未訪問)
    queue<P> Q;
    dist[sv][0] = 0;
    Q.push(make_pair(sv, 0));
    while(!Q.empty()) {
        ll v = Q.front().first;
        ll x = Q.front().second;
        Q.pop();
        for(auto u : G[v]) {
            ll nx = (x+1)%3;
            if(dist[u][nx] == -1) {
                dist[u][nx] = dist[v][x] + 1;
                Q.push(make_pair(u, nx));
            }
        }
    }
 
    if(dist[gv][0] == -1) {
        out(-1);
    }
    else {
        out(dist[gv][0]/3);
    }
 
    re0;
}

Measured memory_bytes: 11136
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i++)
#define reprev(i, n) reprrev(i, 0, n)

#define PI M_PI
#define INF 100000000
#define NINF -100000000

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<bool>> vvb;


int N, K;

int main()
{
	cin >> N >> K;
	vll x(N), y(N);
	vll x1(N), y1(N);
	rep(i, N) {
		cin >> x[i] >> y[i];
		x1[i] = x[i];
		y1[i] = y[i];
	}

	sort(x1.begin(), x1.end());
	sort(y1.begin(), y1.end());

	ll ans = (x1[N - 1] - x1[0]) * (y1[N - 1] - y1[0]);

	rep(i, N) {
		repr(j, i, N) {
			rep(k, N) {
				repr(l, k, N) {

					int num = 0;
					ll lx = x1[i], rx = x1[j];
					ll by = y1[k], uy = y1[l];

					rep(c, N) {
						if (lx <= x[c] && x[c] <= rx && by <= y[c] && y[c] <= uy) {
							num++;
						}
					}

					if (num >= K) ans = min(ans, (rx - lx) * (uy - by));
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}



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

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

const int N = 2e3 + 5, M = N * N, mod = 1e9 + 7;

int n, k;
ll dp[N][N], fact[M], rev[M];

ll pw(ll a, ll b) {
	if(!b)
		return 1;
	ll ans = pw(a, b / 2);
	ans = (ans * ans) % mod;
	if(b & 1)
		ans *= a;
	return ans % mod;
}

void prep() {
	fact[0] = 1;
	for (int i = 1; i < M; i++)
		fact[i] = (fact[i - 1] * i) % mod;
	rev[M - 1] = pw(fact[M - 1], mod - 2);
	for (int i = M - 2; ~i; i--)
		rev[i] = (rev[i + 1] * (i + 1)) % mod;
}

int sum(int a, int b) {
	a += b;
	if(a >= mod)
		a -= mod;
	if(a < 0)
		a += mod;
	return a;
}

ll c(int x, int y) {
	if(y > x)
		return 0;
	ll ans = (fact[x] * rev[y]) % mod;
	ans = (ans * rev[x - y]) % mod;
	return ans;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);	
	cin >> n >> k;
	prep();
	if(k == 1)
		return cout << 1 << "\n", 0;
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= i; j++) {
			dp[i][j] = sum(dp[i][j], dp[i - 1][j]);
			if(j) {
				ll cost = c((n * k) - ((j - 1) * (k - 1)) - i - 1, k - 2);
				dp[i][j] = sum(dp[i][j], dp[i][j - 1] * cost % mod);
			}
		}
	}
	cout << (fact[n] * dp[n][n]) % mod << "\n";
 }


Measured memory_bytes: 94464
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		//リュカ数の配列を作成
		long L0 = 2;
		long L1 = 1;
		long L2;

		long[] numList = new long[86];

		numList[0] = L1;

		for (int i=1; i < 86; i++){
			L2 = L0 + L1;

			numList[i] = L2;

			L0 = L1;
			L1 = L2;
		}

		// 整数の入力
		int n = sc.nextInt();

		System.out.println(numList[n-1]);

		sc.close();
	}

}


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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n; cin>>n;
    int ans=0;
    for(int i=1; i<=n; i+=2){
        int cnt=0;
        for(int j=1; j<=i; j++){
            if(i%j==0) cnt++;
        }
        if(cnt==8) ans++;
    }
    cout << ans << endl;
}

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

budget = A* X+ B* Y
i = 1

while True:
  if(max(A* (X- i), 0)+ max(B* (Y- i), 0)+ C* 2* i< budget):
    budget = max(A* (X- i), 0)+ max(B* (Y- i), 0)+ C* 2* i
  else:
    break
  i+= 1

print(budget)

Measured memory_bytes: 3064
from math import floor
from fractions import gcd

A, B, C, D = map(int,input().split())
lcm = (C*D) // gcd(C,D)

bc = B // C
bd = B // D
bcd = B // lcm

ac = (A-1) // C
ad = (A-1) // D
acd = (A-1) // lcm

ans = B-bc-bd+bcd-(A-1-ac-ad+acd)
print(ans)

Measured memory_bytes: 5076
a,b,x = gets.split.map(&:to_f)
t = x/a**2
at = a*t

if at < a*b/2
  d = 2 * at / b
  ans = Math.atan(b/d) * 180 / Math::PI
else
  d = 2*(b-x/(a**2))
  ans = Math.atan(d/a) * 180 / Math::PI
end

puts ans

Measured memory_bytes: 1788
#include <stdio.h>

int	main(void)
{
	char	s[100001];
	int	red = 0;
	int	blue = 0;
	int	i = 0;

	scanf("%s", s);
	while (s[i])
	{
		if (s[i] == '0')
			red++;
		else
			blue++;
		i++;
	}
	printf("%d", red > blue ? blue * 2 : red * 2);
	return 0;
}

Measured memory_bytes: 2252
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N;
int x[100000];
typedef long long ll;
ll mod=1e9+7;
int main(){
	cin>>N;
	rep(i,N) cin>>x[i];
	ll ans=1;
	int j=0;
	rep(i,N){
		while(j<N&&x[j]>2*(j-i)) j++;
		ans*=(min(N,j+1)-i);
		ans%=mod;
//		show(j+1-i);
	}
	cout<<ans<<endl;
}


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

int main() {
	int n, a, b, t;

	cin >> n >> a >> b;

	t = n * a;

	if (t < b) {
		cout << t << endl;
	}

	else if(t == b){
		cout << t << endl;
	}

	else if(t > b){
		cout << b << endl;
	}


}


Measured memory_bytes: 3196
import sys
sys.setrecursionlimit(10**7)

def main():
    N, M = map(int, input().split())
    C = [[] for _ in range(N)]
    for _ in range(M):
        l, r, d = map(int, input().split())
        C[l - 1].append((r - 1, d))
        C[r - 1].append((l - 1, -d))
    INF = 10 ** 10
    P = [INF] * N
    def dfs(n, p, f):
        if P[n] != INF:
            if P[n] != p:
                return False
            return True
        P[n] = p
        for i, d in C[n]:
            if i == f:
                continue
            if not dfs(i, p + d, n):
                return False
        return True
            
    for i in range(N):
        if P[i] != INF:
            continue
        if not dfs(i, 0, -1):
            return False
    return True

print('Yes' if main() else 'No')


Measured memory_bytes: 148372
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vb=vector<bool>;

struct Node{
    int key;
    Node *prev,*next;
};

Node *nil;

Node* listSearch(int key){
    Node* cur = nil->next;
    while(cur != nil && cur->key != key) cur = cur->next;
    return cur;
}
void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}
void printList(){
    Node* cur = nil->next;
    int isf = 0;
    while(true){
        if(cur==nil) break;
        if(isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}
void deleteNode(Node* t){
    if(t==nil) return;
    (t->prev)->next = t->next;
    (t->next)->prev = t->prev;
    free(t);
}
void deleteFirst(){deleteNode(nil->next);}
void deleteLast(){deleteNode(nil->prev);}
void deleteKey(int key){deleteNode(listSearch(key));}
void insert(int key){
    Node* x = (Node*) malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    (nil->next)->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    int n;cin >> n;
    init();
    rep(i,n){
        string s;
        int k;
        cin >> s;
        if(s=="insert") {cin >> k;insert(k);}
        if(s=="delete") {cin >> k;deleteKey(k);}
        if(s=="deleteFirst") deleteFirst();
        if(s=="deleteLast") deleteLast();
    }
    printList();
    return 0;
}


Measured memory_bytes: 34532
N = int(input())
s = ["a" for i in range(N)]
t = [0 for i in range(N)]

for i in range(N):
    s[i],t[i] = input().split(" ")

X = input()

p = s.index(X)

T=0
for i in range(p+1,N):
    T += int(t[i])

print(T)

Measured memory_bytes: 3060
require 'thread'

$dy = [0,1,0,-1]
$dx = [1,0,-1,0]

$visited = nil
$field = nil

def dfs(y, x)
  $visited[y][x] = true
  4.times{|i|
    yy = y + $dy[i]
    xx = x + $dx[i]
    next if yy < 0 || yy >= 12 || xx < 0 || xx >= 12
    next if $visited[yy][xx]
    dfs(yy,xx) if $field[yy][xx] == "1"
  }
end

def solve()
  $field = []
  12.times{
    tmp = gets
    return true if tmp == nil
    $field.push(tmp.strip)
  }
  gets

  # p $field

  $visited = Array.new(12){Array.new(12,false)}

  ans = 0
  12.times{|y|
    12.times{|x|
      if $visited[y][x] == false && $field[y][x] == "1"
        dfs(y,x)
        ans += 1
      end
    }
  }
  p ans
  return false
end

while true
  owari = solve()
  break if owari
end

Measured memory_bytes: 6320
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <list>
#include <string>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;

int main()
{
    int A, B;
    cin >> A >> B;
    int ret = 0;
    if (A >= 13)
        ret = B;
    else if (A >= 6)
        ret = B / 2;
    else
        ret = 0;

    cout << ret << endl;
}

void cheatsheet()
{
    // loop
    // vector<int> vec(10);
    vector<int> vecloop;
    REP(i, 10)
    {
        vecloop.push_back(i);
    }

    // swap
    int a = 1;
    int b = 5;
    swap(a, b); // -> a = 5, b = 1

    // sort
    int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    sort(arr, arr + 9, greater<int>()); // 9 8 7 6 5 4 3 2 1

    // lower
    vector<int> vec(arr, end(arr));
    sort(vec.begin(), vec.end());
    cout << lower_bound(vec.begin(), vec.end(), 2)[0]; // 2

    // map
    map<Pll, ll> m;
    m[Pll(10, 100)] = 100;
}

Measured memory_bytes: 256