akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long int;

const int MAX_N = (int)(50 + 5);

int n, a, b;
ll v[MAX_N];

double ans_key;
ll ans_num = 0;

/////////////////////////////////////////////////////////////
class Combination {
private:
  ll comb_pascal[MAX_N][MAX_N];
public:
  Combination(int n) {
    init(n);
  }

  void init(int n) {
    for (int i = 0; i <= n; ++i) {
      comb_pascal[i][0] = 1;
      comb_pascal[i][i] = 1;
    }

    for (int i = 1; i <= 50; ++i) for (int j = 1; j <= i - 1; ++j) {
      comb_pascal[i][j] = comb_pascal[i - 1][j - 1] + comb_pascal[i - 1][j];
    }
  }

  ll comb(int n, int r) {
    if (r > n) return 0;
    else return comb_pascal[n][r];
  }
};
/////////////////////////////////////////////////////////////

int main(void) {
  // Here your code !
  scanf("%d %d %d", &n, &a, &b);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &(v[i]));
  }

  Combination comb(n + 5);

  sort(v, v + n, std::greater<ll>());

  ll tmp_sum;
  for (int i = 0; i < a; ++i) {tmp_sum += v[i];}

  ans_key = (double)(tmp_sum) / (double)(a);

  int need_a = 0;
  int whole_a = 0;

  for (int i = 0; i < n; ++i) {
    if (v[i] == v[a]) {
      whole_a += 1;
      if (i < a) need_a += 1;
    }
  }

  if (v[0] != v[a - 1]) {
    ans_num = comb.comb(whole_a, need_a);
  }
  else {
    for (int take = a; take <= b; ++take) {
      ans_num += comb.comb(whole_a, take);
    }
  }

  printf("%lf\n", ans_key);
  printf("%lld\n", ans_num);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define fastio ios::sync_with_stdio(false); cin.tie(nullptr);
using namespace std;
typedef long long ll;
const int mxN = 2e5;
ll n, d, x[mxN], y[mxN];
int main() {
	fastio;
	cin >> n >> d;
	for (int i = 0; i < n; i++)
		cin >> x[i] >> y[i];

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (x[i] * x[i] + y[i] * y[i] <= d * d)
			ans++;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 6732
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(int argc, char *argv[])
{
        for(;;) {
                int n;
                cin >> n;
                if(n==0) break;
                vector<int> vs;
                for(int i = 0; i < n; i++) {
                        int k;
                        cin >> k;
                        vs.push_back(k);
                }
                sort(vs.begin(), vs.end());
                int a = abs(vs[0]-vs[1]);
                for(int i = 0; i < n-1; i++) a = min(a, abs(vs[i]-vs[i+1]));
                cout << a << endl;
        }
        return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {
    int n, x[100], y[100], d[100];
    double sum;
    cin >> n;
    cout << fixed << setprecision(6);

    for (int i=0; i<n; i++)
        cin >> x[i];
    for (int i=0; i<n; i++)
        cin >> y[i];
    for (int i=0; i<n; i++)
        d[i] = abs(x[i] - y[i]);

    sum = 0;
    for (int i=0; i<n; i++)
        sum = sum + d[i];
    cout << sum << endl;

    sum = 0;
    for (int i=0; i<n; i++)
        sum = sum + d[i]*d[i];
    cout << sqrt(sum) << endl;
        
    sum = 0;
    for (int i=0; i<n; i++)
        sum = sum + d[i]*d[i]*d[i];
    cout << pow(sum, 1.0/3) << endl;

    sum = 0;
    for (int i=0; i<n; i++)
        if (d[i] > sum)
            sum = d[i];
    cout << sum << endl;
}


Measured memory_bytes: 3400
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	ll a, b;
	cin >> a >> b;
	if (a == b) {
		cout << "1\n";
		return 0;
	}
	for (int i = 59; i >= 0; i--) {
		if (((a >> i) & 1) != ((b >> i) & 1)) break;
		else if (((a >> i) & 1)) a ^= 1ll << i, b ^= 1ll << i;
	}
	ll n = 1, m = 1;
	while (n <= b) n <<= 1;
	n >>= 1;
	ll ans = n - a;
	ll x = b - n;
	while (m <= x) m <<= 1;
	cout << ans + min(n, m + n - a) << '\n';
}

Measured memory_bytes: 3620
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#pragma GCC optimize ("Ofast,unroll-loops,-ffloat-store")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")

#include <bits/stdc++.h>
using namespace std;

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ll = int_fast64_t; using ld = long double;

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

void solve() {
    int n; cin >> n;
    cout << (n + 1) / 2 << '\n';
}

int main() {
    fast_io; cin_exception;
    int t = 1; // cin >> t;
    for (int i = 0; i < t; ++i) {
        solve();
    }
}

Measured memory_bytes: 256
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect

n,m=map(int,input().split())
x=int(pow(m,0.5))
res=[]
for i in range(1,x+1):
    if m%i==0:
        res.append(i)
        if i!=m//i:
            res.append(m//i)
res.sort()
ans=bisect.bisect_left(res,n)
print(m//res[ans])

Measured memory_bytes: 67200
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ALDS1_11_B_Depth_First_Search
{
	class Program
	{
		static void Main ( string[] args )
		{
			int vertexCount = int.Parse (Console.ReadLine ());
			Graph graph = new Graph (vertexCount);

			for (int lp = 0; lp < vertexCount; lp++)
			{
				int[] inputNum = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);

				for (int lp2 = 0; lp2 < inputNum[1]; lp2++)
				{
					graph.GetPath (inputNum[0], inputNum[2 + lp2]);
				}
			}

			Console.Write (graph);
		}
	}

	class Graph
	{
		public Graph ( int size )
		{
			this.Map = new int[size, size];
			this.Timestamp = new int[size, 2];
			this.UsedIndex = new int[size];
			this.StateArray = new int[size];
		}

		private int[,] Map { set; get; }
		private	int[,] Timestamp { set; get; }
		private int[] UsedIndex { set; get; }
		private int[] StateArray { set; get; }
		private int Time = 1;

		public const int Exist = 1;
		private const int OutOfRange = -1;

		const int NotVisited = 0;
		const int Stay = 1;
		const int Visited = 2;

		public void GetPath ( int beginPoint, int adjacencyPoint )
		{
			Map[beginPoint - 1, adjacencyPoint - 1] = Exist;
		}

		public int[,] DepthFirstSearch ()
		{
			for (int lp = 0; lp < Map.GetLength(0); lp++)
			{
				if (StateArray[lp] == NotVisited)
				{
					Search (lp);
				}
			}

			return Timestamp;
		}

		private void Search ( int lp )
		{
			const int First = 0;
			const int Last = 1;

			UsedIndex.Initialize ();

			Stack<int> stack = new Stack<int> (Timestamp.Length / 2);
			stack.Push (lp);
			StateArray[lp] = Stay;
			Timestamp[lp, First] = Time;
			Time++;

			while (stack.Count != 0)
			{
				int point = stack.Peek ();
				int index = NextIndex (point);

				if (index != OutOfRange)
				{
					if (StateArray[index] == NotVisited)
					{
						StateArray[index] = Stay;
						Timestamp[index, First] = Time;
						Time++;
						stack.Push (index);
					}
				}
				else
				{
					stack.Pop ();
					StateArray[point] = Visited;
					Timestamp[point, Last] = Time;
					Time++;
				}
			}
		}

		private int NextIndex ( int index )
		{
			for (int lp = UsedIndex[index]; lp < UsedIndex.Length; lp++)
			{
				if (Map[index, lp] == Exist)
				{
					UsedIndex[index] = lp + 1;
					return lp;
				}
			}

			UsedIndex[index] = UsedIndex.Length + 1;

			return OutOfRange;
		}

		public override string ToString ()
		{
			int[,] result = DepthFirstSearch ();
			StringBuilder output = new StringBuilder (result.Length * 2);

			for (int row = 0; row < result.GetLength (0); row++)
			{
				output.Append (row + 1);
				output.Append (" ");
				output.Append (result[row, 0]);
				output.Append (" ");
				output.Append (result[row, 1]);
				output.AppendLine ();
			}

			return output.ToString ();
		}
	}
}

Measured memory_bytes: 10204
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>
#include<map>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) a[i]--;
    vector<int> s(n+1);
    rep(i, n){
        s[i+1] = (s[i] + a[i])%k;
    }
    map<int, int> mp;
    ll ans = 0;
    queue<int> q;
    rep(j, n+1){
        ans += mp[s[j]];
        mp[s[j]]++;
        q.push(s[j]);
        if(q.size() == k){
            mp[q.front()]--;
            q.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 15044
import math
A, B, H, M = map(int, input().split())
Hno = 30 * H + 0.5 * M
Mno = 6 * M
 
angle = Hno - Mno
if angle < 0:
    angle *= -1
 
cos = math.cos(math.radians(angle))
x = A ** 2 + B ** 2 - (2 * A * B * cos)
print(math.sqrt(x))

Measured memory_bytes: 9504
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

int main(){
    string s;
    string cut;
    cin >> s;
    int counter = 9999;

    for(int i = 0; i < s.length()-2; i++){
        cut = s.substr(i,3);
        int num = atoi(cut.c_str());
        if(counter > abs(753-num))counter = abs(753-num);
    }
    cout << counter << endl;
}

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

int main()
{
    int num,a,b,c,d;
    cin >> num >> a >> b >> c >> d;
    string str;
    cin >> str;
    if(c==d){
        cout << "No" << endl;
        return 0;
    }
    if(c>d){
        string str1="...";
        int judge = true;
        for(int i=b-2;i<=d-2;i++){
            if(str.compare(i,3,str1)==0){
                judge = false;
            }
        }
        if(judge){
            cout << "No" << endl;
            return 0;
        }
    }
    string str2 = "##";
    if(d<c){
        swap(c,d);
    }
    for(int i=a-1;i<=d-2;i++){
        if(str.compare(i,2,str2)==0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 764
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

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

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
	#ifndef ONLINE_JUDGE
	if (fopen("INPUT.txt", "r"))
	{
		freopen ("INPUT.txt" , "r" , stdin);
		//freopen ("OUTPUT.txt" , "w" , stdout);
	}
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	clock_t clk;
	clk = clock();
//-----------------------------------------------------------------------------------------------------------//

	ld A,B,C;
	cin>>A>>B>>C;
	ld D=sqrt(A*B);
	if(2*D<C-A-B)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	

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


	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcdEx(ll a, ll b, ll *x, ll *y){if(!a){*x=0;*y=1;return b;}
ll x1,y1,gcd=gcdEx(b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
ll modI(ll b, ll m)      {ll x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}

typedef pair<ll, ll>      pii;
typedef vector<ll>         vi;
typedef vector<pii>         vii;
typedef set<ll>            si;
typedef map<string, ll>    msi;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define loop(i,b,n)           for(ll i=b;i<n;i++)
#define loopv(b,n,a)         for(ll i=b;i<n;i+=a)
#define loopr(b,n)           for(ll i=n;i>=0;i--)

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define mp                  make_pair
#define ff                  first
#define ss                  second
#define pb                  push_back
#define MOD                 1000000007
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(int)(MOD+((a%MOD)-(b%MOD))%MOD):(int)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (ll)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)

#define trace1(x)                  cerr<<#x<<": "<<x<<endl
#define trace2(x, y)               cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)            cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)         cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)      cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<end
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;}
y=y>>1; x=(x*x)%MOD;} return r;}
ll min(ll a,ll b ) {     if(a<b)     return a;     else    return b;  }
ll max(ll a,ll b ) {     if(a>b)     return a;     else    return b;  }
ll brute(string s)
{
    ll ans=0,n,b;
string ss,a="";
n=s.size();
loop(l,0,n)
{

loop(r,l,n)
{
    a=s;
    loop(k,l,r+1)
    {
    if(a[k]=='1')
a[k]='0';
else
    a[k]='1';
    }
    loop(i,0,n-1)
    if(a[i]==a[i+1])
    ans++;
}
}
    return ans;
}
int main()
{
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
ll t;
//  cin>>t;
 //freopen("input.txt","r",stdin);freopen("output.txt","w",stdout); 
t=1;
 while(t--)
{
ll ans=0,a,n,b;
string s,ss; 
cin>>s>>ss; 
cout<<ss<<s;
}
   return 0;

}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readLong()
    val ans = (1..n step 2).count { devisor(it).size == 8 }
    out.println(ans)
}

fun devisor(n: Long): List<Long> {
    val devisor = mutableListOf<Long>()
    var i = 1L
    while (i * i <= n) {
        if (n % i == 0L) {
            devisor.add(i)
            if (i * i != n) { devisor.add(n / i) }
        }
        i++
    }
    devisor.sort()
    return devisor
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

int main(){
  int n, m;
  cin >> n >> m;
  vector<bool> check(n, false);
  vi cnt(n, 0);
  
  rep(i, 0, m){
    int p;
    string s;
    cin >> p >> s;
    p--;
    if(s == "WA"){
      if(check[p] == false)
        cnt[p]++;
    }
    else if(s == "AC")
      check[p] = true;
  }
  
  int ac = 0;
  int wa = 0;
  
  rep(i, 0, n){
    if(check[i]){
      ac++;
      wa += cnt[i];
    }
  }
  
  cout << ac << " " << wa << endl;
  
  return 0;
  
}

Measured memory_bytes: 3768
#ABC164B_Battle.rb
a,b,c,d = gets.split.map(&:to_i)
count = 0
while a > 0 && c > 0
  if count % 2 == 0
    c -= b
    #puts "T atack T:#{a} A:#{c}"
  else
    a -= d
    #puts "A atack T:#{a} A:#{c}"
  end
  count += 1
end

if a > 0
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 14128
H,W = map(int, input().split())
g = []
for _ in range(H):
    g.append(list(input()))

dp = [[10**9 for _ in range(W)] for __ in range(H)]

dp[0][0] = 1 if g[0][0] == '#' else 0
d = ([0,1], [1,0])
for ix in range(H):
    for jx in range(W):
        for dx,dy in d:
            ni = ix + dx
            nj = jx + dy
            if ni >= H or nj >= W:
                continue
            add = 0
            if g[ix][jx] == '.' and g[ni][nj] == '#':
                add += 1
            dp[ni][nj] = min(dp[ni][nj], dp[ix][jx] + add)


print(dp[H-1][W-1])

Measured memory_bytes: 9348
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mk make_pair
#define pi pair<int, int>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;

constexpr int N = 3010;
ll g[N][N];
int n,m,k;
ll dp[N][N][4];

int main()
{
   IOS;
   cin >> n >> m >> k;
   while(k--)
   {
       int x,y;
       ll w;
       cin >> x >> y >> w;
       g[x][y] = w;
   }
   rep(i,1,n)
   {
       rep(j,1,m)
       {
           //不选：
           rep(k,0,3)dp[i][j][k] = max(dp[i][j][k],dp[i][j-1][k]);
           rep(k,0,3)dp[i][j][0] = max(dp[i][j][0],dp[i-1][j][k]);
           //选且能选：
           if(g[i][j])
           {
               rep(k,1,3)dp[i][j][k] = max(dp[i][j][k],dp[i][j-1][k-1]+g[i][j]);
               rep(k,0,3)dp[i][j][1] = max(dp[i][j][1],dp[i-1][j][k]+g[i][j]);
           }
       }
   }
   ll ans = 0;
   rep(k,0,3)ans = max(ans,dp[n][m][k]);
   cout << ans;
}


Measured memory_bytes: 356300
n = int(input())
a = list(map(int,input().split()))
del a[0]
b = list(map(int,input().split()))
del b[0]
c = list(map(int,input().split()))
del c[0]
count = 0
for i in range(n):
    i += 1
    if i in c and ((not i in a) or i in b):
        count += 1
print(count)


Measured memory_bytes: 5596
#include<iostream>
using namespace std;
int main() {
	int l[2][7];
	for (int i = 0; i < 7; i++){
		for (int j = 0; j < 2; j++){
			cin >> l[j][i];
		}
	}
	for (int i = 0; i < 7; i++){
		cout << l[0][i] - l[1][i] << endl;
	}
	char c;
	cin >> c;
}

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

using namespace std;
#define pi acos(-1)
#define _terminated return 0
#define endl "\n"
#define yes cout << "yes" << endl 
#define no cout << "no" << endl 
#define booster ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<long> > v2l;

const int mod = 1e+5;
const int mx = 2e+5;
const ll inf = 1e18;

void upper_bubble_sort(){
     int i,j,temp,number_of_input;
     int array[100];
     cin >> number_of_input;
     for(i=0; i<number_of_input; i++)
         cin >> array[i];
         for(i=0; i<number_of_input; i++){
             for(j=0; j<(number_of_input-i-1); j++){
               if(array[j] > array[j+1]){
                 temp = array[j];
                 array[j] = array[j+1];
                 array[j+1] = temp;
                }
              }
         }
    for(i=0; i<number_of_input; i++)
      cout << array[i] << endl;
}
void bst(void){
          int low,high,mid,keynum,num,array[100];
          cin >> keynum;
          low = 1;
	         high = num;
         	do{
		        mid = (low + high) / 2;
		         if(keynum < array[mid])
			         high = mid - 1;
		         else if (keynum > array[mid])
			         low = mid + 1;
	         } 
          while (keynum != array[mid] && low <= high);
	        if(keynum == array[mid]){
            cout << "number located at " << mid +1 << endl;}
         else
           no;
        }
void solve(){ 
	   int a,b,i;
    cin >> a >> b;
    if(a>b){
       for(i=1; i<=a; i++)
         cout << b;
    }
    else{
       for(i=1; i<=b; i++)
         cout << a;
    }
         cout << endl;
}
    
    
int main(){
    booster;
    solve();
    _terminated;
}

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

int w1, w2, h1, h2, sum;
int hash_a[800][800][10], hash_b[800][10];
int cumo_a[800][800][10], cumo_b[800][10];
char s[800][700],t[800][800];


void make_table(){
  rep(i,h1) rep(j,w1-w2+1) {
    rep(k,w2){
      rep(l,6) hash_a[i][j][(k*6)/60] = hash_a[i][j][(k*6)/60]*2 + ( ((s[i][j+k]>>l)&1)?1:0);
      rep(l,6) cumo_a[i][j][(k*6)/60] = cumo_a[i][j][(k*6)/60]*2 + (s[i][j+k]==63?1:0);
    }
  }
  rep(i,h2) {
    rep(j,w2){
      rep(k,6) hash_b[i][(j*6)/60] = hash_b[i][(j*6)/60]*2 + (((t[i][j]>>k)&1)?1:0);
      rep(k,6) cumo_b[i][(j*6)/60] = cumo_b[i][(j*6)/60]*2 + (t[i][j]==63?1:0);
    }
  }
}

void count_s(){
  rep(i,h1-h2+1) {
    rep(j,w1-w2+1) {
      rep(k,h2) {
        int p1[10]={} ,p2[10]={} ;int flag = 0;
        rep(l,10){
          p1[l] = hash_a[i+k][j][l] ^ hash_b[k][l];
          p2[l] = cumo_a[i+k][j][l] | cumo_b[k][l];
          if( (p1[l] | p2[l]) != p2[l] ) { flag ++; break; }
        }
        if( flag ) break ;
        if( k == h2-1 ) sum++;
      }
    }
  }
}

void Za_a_tsu(){
  rep(i,h1)rep(j,w1){
    if('0'<=s[i][j]&&s[i][j]<='9')s[i][j]=(s[i][j]-'0');
    if('a'<=s[i][j]&&s[i][j]<='z')s[i][j]=(s[i][j]-'a'+11);
    if('A'<=s[i][j]&&s[i][j]<='Z')s[i][j]=(s[i][j]-'A'+37);
  }
  rep(i,h2)rep(j,w2){
    if('0'<=t[i][j]&&t[i][j]<='9')t[i][j]=(t[i][j]-'0');
    if('a'<=t[i][j]&&t[i][j]<='z')t[i][j]=(t[i][j]-'a'+11);
    if('A'<=t[i][j]&&t[i][j]<='Z')t[i][j]=(t[i][j]-'A'+37);
  }
}

signed main(){
  cin >> w1 >> h1 >> w2 >> h2;
  rep(i,h1) scanf("%s", s[i]);
  rep(i,h2) scanf("%s", t[i]);
  Za_a_tsu();
  make_table();
  count_s();
  cout << sum << endl;
}

Measured memory_bytes: 103684
#include<stdio.h>
int main(void)
{
  int n,k;
  
  scanf("%d %d",&n,&k);
  int a=n/k;
  int b=n%k;
  if(b>=1){
    printf("%d\n",1);
  }
  else{
    printf("%d\n",0);
  }
  return 0;
}

Measured memory_bytes: 128
'use strict'

const main = (input) => {
    input = input.split(' ').map(v => parseInt(v))
    const a = input[0]
    const b = input[1]
    const c = input[2]
    const d = input[3]
    if(b <= c || d <= a){
        console.log(0)
        return
    }
    const arr = [a, b, c, d].sort((a, b) => a - b)
    console.log(arr[2] - arr[1])
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

const long long INF = 1LL << 60;

#define rep(i, e) for (int i = 0; i < e; i++)
#define repp(i, s, e) for (int i = s; i < e; i++)
#define N_Max 100
#define Card_Max 36
#define p(a) printf("%d\n", a);
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define NIL -1

void print(const std::vector<ll> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    ll N, P[8] = {}, Q[8] = {}, p_index = 0, q_index = 0;
    vector<ll> v;
    cin >> N;
    for (int i = 0; i < N; i++) {
        v.push_back(i + 1);
        cin >> P[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> Q[i];
    }

    // for (int i = 0; i < N; i++)
    // {
    //     cout << v[i] << endl;
    //     cout << "P[" << i << "]: " << P[i] << endl;
    //     cout << "Q[" << i << "]: " << Q[i] << endl;
    // }

    int index = 1;
    do {
        bool pflag = true;
        bool qflag = true;
        // print(v);
        for (int i = 0; i < N; i++) {
            if (P[i] != v[i]) {
                pflag = false;
            }

            if (Q[i] != v[i]) {
                qflag = false;
            }
        }
        if (pflag) {
            p_index = index;
        }
        if (qflag) {
            q_index = index;
        }
        index++;
    } while (std::next_permutation(v.begin(), v.end()));

    // cout << p_index << endl;
    // cout << q_index << endl;
    cout << abs(p_index - q_index) << endl;
}


Measured memory_bytes: 3608
/**
 * @author torith
 * @date 2018-10-29
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K; cin >> N >> K;

    map<ll,ll> abpair;
    for (int i = 0; i < N; ++i) {
        ll a,b;
        cin >> a >> b;
        abpair[a] += b;
    }

    ll ans = 0;
    ll last = 0;
    for (auto & p: abpair) {
        ans += p.second;
        if (ans >= K) {
            cout << p.first << "\n";
            return 0;
        }
        last = p.first;
    }

    cout << last << "\n";

    return 0;
}



Measured memory_bytes: 4224
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>

int main(void) {
	int n, a_cnt = 0, b_cnt = 0;
	char s[15] = { 0 };
	long long ans = 0;
	int flag = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", s);
		for (int i = 0; i < strlen(s); i++) {
			if (s[i] == 'A' && s[i + 1] == 'B')ans++;
		}
		if (s[0] == 'B' && s[strlen(s) - 1] == 'A') {
			ans++;
			flag = 1;
		}
		else if (s[0] == 'B')
			b_cnt++;
		else if (s[strlen(s) - 1] == 'A')
			a_cnt++;
	}
	//printf("a_cnt=%d b_cnt=%d\n", a_cnt, b_cnt);
	if (a_cnt == 0 && b_cnt == 0)printf("%lld", ans - flag);
	else if (a_cnt > b_cnt)printf("%lld", ans + b_cnt);
	else printf("%lld", ans + a_cnt);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
// the little guy below helps me to create unordered set of vectors
// just declare it like this ---> unordered_set<vector<int>, VectorHash>>
// credits:: https://stackoverflow.com/users/2069064/barry
struct VectorHash
{
    size_t operator()(const std::vector<int> &v) const
    {
        std::hash<int> hasher;
        size_t seed = 0;
        for (int i : v)
        {
            seed ^= hasher(i) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
        }
        return seed;
    }
};
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

vector<ll> adj[200002];
ll cols[200002];
ll cnts[200002];
ll k;
ll ans;
void dfs(ll node)
{
    cols[node] = k;
    cnts[k]++;
    ans = max(ans, cnts[k]);
    for (int i:adj[node])
    {
        if (!cols[i])
        {
            dfs(i);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m,u,v;
    cin>>n>>m;
    for (int i = 0; i < m; i++)
    {
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    k = 1;
    ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (!cols[i])
        {
            dfs(i);
            k++;
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 22368
import kotlin.math.absoluteValue
import kotlin.math.min

fun main() {
    val ln = nextLongList()
    val ans = solve(ln)
    println(ans)
}


fun solve(ln: List<Long>): Long {
    val currentPoint = ln[0]
    val moveCount = ln[1]
    val moveAmount = ln[2]


    //移動する必要がある
    if (currentPoint.absoluteValue > moveAmount) {
        //一時的にに移動する回数
        //moveAmountを超える回数まで移動したあとは偶数か奇数かで移動回数が決まる。0回か1回
        //moveAmountを超える回数までの移動回数は？　→　初期値が一番0に近づくポイントへ近づく移動回数。
        // ただし与えられている移動回数を超えることはできない。
        val tempMoveCount =
            if (currentPoint.absoluteValue / moveAmount > moveCount)
                moveCount
            else
                currentPoint.absoluteValue / moveAmount

        //一度絶対値付近まで移動させる
        val tempPoint = calculateMinPoint(
            point = currentPoint,
            moveCount = tempMoveCount,
            moveAmount = moveAmount
            )

        return calculateMinPoint(
            point = tempPoint,
            moveCount = (moveCount - tempMoveCount) % 2,
            moveAmount = moveAmount
        )

    } else {
        //移動回数が偶数である場合
        if (moveCount % 2 == 0L) {
            return currentPoint.absoluteValue
            //移動回数が奇数である場合
        } else {
            val oddMoveCount = 1L
            return calculateMinPoint(
                point = currentPoint,
                moveCount = oddMoveCount,
                moveAmount = moveAmount
            )
        }
    }
}

//所与の条件から最小ポイントへ移動する
private fun calculateMinPoint(point: Long, moveCount: Long, moveAmount: Long): Long {
    return (point.absoluteValue - moveAmount * moveCount).absoluteValue
}

fun nextInt(): Int {
    return readLine()!!.toInt()
}

fun nextIntList(): List<Int> {
    return readLine()!!.split(" ").map { it.toInt() }
}

fun nextLongList(): List<Long> {
    return readLine()!!.split(" ").map { it.toLong() }
}

fun nextString(): String {
    return readLine()!!
}

Measured memory_bytes: 36496
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=input.trim().split("\n");
var n=Arr.shift()-0;
var ans=[];
for(var i=0;i<n;i++)ans[i]=0;
var m=Arr.shift()-0;
var t=Arr.shift().split(" ").map(Number);
for(var I=0;I<m;I++){
   var arr=Arr[I].split(" ").map(Number);
   var target=t[I];
   var bad=0;
   arr.forEach(function(v,i){
      (v==target)?ans[i]++:bad++;
   });
   ans[target-1]+=bad;
}
console.log(ans.join("\n"));

Measured memory_bytes: 9880
// C - Walk on Multiplication Table
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	ll N; cin>>N;
	ll ans = LLONG_MAX;
	ll n = sqrt(N);
	for(ll a=n; a>=1; --a){
		if(N%a) continue;
		ans = a + N/a - 2;
		break;
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


#A
def A():
    n,h,w = IR(3)
    print((n-h+1)*(n-w+1))
    return

#B
def B():
    n = I()
    a,b = LI()
    p = LI()
    k = [0 for i in range(a+1)]
    k += [1 for i in range(b-a)]
    k += [2 for i in range(max(p)+1-b)]
    d = defaultdict(int)
    for i in p:
        d[k[i]] += 1
    ans = min(d[0],d[1],d[2])
    print(ans)
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

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


Measured memory_bytes: 39152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.StringTokenizer;

/**
 * Graph I - Breadth First Search
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = Integer.parseInt(line);
			Graph1 g = new Graph1(n);
			for (int i = 0; i < n; i++) {
				g.add(br.readLine());
			}
			g.bfs(1);
			for (int i = 1; i <= n; i++) {
				System.out.print(g.get(i).printDistance());
			}
		}
	}
}

class Graph1 {

	private ArrayList<Vertex> vertexs;
	private int[] indexes;
	private LinkedList<Vertex> queue;

	public Graph1(int n) {
		vertexs = new ArrayList<Vertex>();
		indexes = new int[n + 1];
		queue = new LinkedList<Vertex>();
	}

	public void add(String info) {
		int id;
		int[] edge;
		String[] _edge;

		StringTokenizer st = new StringTokenizer(info);
		id = Integer.parseInt(st.nextToken());
		_edge = new String[Integer.parseInt(st.nextToken())];
		edge = new int[_edge.length];
		for (int i = 0; i < _edge.length; i++) {
			_edge[i] = st.nextToken();
		}
		// Arrays.sort(_edge);
		for (int i = 0; i < edge.length; i++) {
			edge[i] = Integer.parseInt(_edge[i]);
		}
		vertexs.add(new Vertex(id, edge));
		indexes[id] = vertexs.size() - 1;
	}

	public Vertex get(int id) {
		return vertexs.get(indexes[id]);
	}

	public void dfs(int t) {
		for (Vertex v : vertexs) {
			t = v.dfs(t);
		}
	}

	public void bfs(int s) {
		Vertex v1, v2;

		get(s).d = 0;
		queue.add(get(s));
		while (!queue.isEmpty()) {
			v1 = queue.removeFirst();
			for (int i = 0; i < v1.edge.length; i++) {
				v2 = get(v1.edge[i]);
				if (v2.d == -1) {
					v2.d = v1.d + 1;
					queue.add(v2);
				}
			}
		}
	}

	class Vertex {
		private int id, d, f;
		private int[] edge;

		private Vertex(int id, int[] edge) {
			this.id = id;
			d = -1;
			f = 0;
			this.edge = edge;
		}

		private int dfs(int t) {
			if (d == -1) {
				d = ++t;
				for (int i = 0; i < edge.length; i++) {
					t = get(edge[i]).dfs(t);
				}
				f = ++t;
			}
			return t;
		}

		public String printTime() {
			return String.format("%d %d %d\n", id, d, f);
		}

		public String printDistance() {
			return String.format("%d %d\n", id, d);
		}
	}
}

Measured memory_bytes: 18024
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        for (int i = 1; i <= 9; i++) {
            if(n<=111*i){
                out.println(111*i);
                break;
            }
        }
    }
}

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

double getInner( double x1, double y1, double x2, double y2 )
{
	return x1 * x2 + y1 * y2;
}

int main( void )
{
	double xA, yA, xB, yB, xC, yC, xD, yD;
	while ( cin >> xA >> yA >> xB >> yB >> xC >> yC >> xD >> yD )
	{
		// ÎIÈÀWÉ¼·
		double x, y;

		x = xA; y = yA;
		xA = xA - x;
		yA = yA - y;
		xB = xB - x;
		yB = yB - y;

		x = xC; y = yC;
		xC = xC - x;
		yC = yC - y;
		xD = xD - x;
		yD = yD - y;

		double d = getInner( xB, yB, xD, yD );
		if ( d == 0.0 )
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}

	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main()
{
	string S;

	cin >> S;

	int N = S.size();
	int *C = new int[ N ];
	fill( C, C+N, 0 );

	int rlpos = 0;
	int lrpos = 0;
	while ( 1 ) {
		rlpos = S.find( "RL", rlpos );
		int nr = rlpos - lrpos + 1;
		lrpos = S.find( "LR", lrpos );

		if ( rlpos == -1 ) break;
		if ( lrpos == -1 ) lrpos = N-1;
		int nl = lrpos - rlpos;


//		cout << rlpos << " " << lrpos << endl;
//		cout << " " << nr << " " << nl << endl;
		C[rlpos] = nr/2 + nr%2 + nl/2;
		C[rlpos+1]  = nr/2 + nl%2 + nl/2;


		rlpos ++;
		lrpos ++;
	}

	for ( int i = 0; i < N; i ++ ) {
		cout << C[i] << " ";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#define rep(i,j,k) for(register int i = j; i <= k; i++) 
#define dow(i,j,k) for(register int i = j; i >= k; i--)
#define fi first
#define se second
#define P pair<int,int>
#define PP pair<int,pair<int,int> >
#define mp(a,b) make_pair(a,b)
#define ll long long
#define ull unsigned long long
using namespace std;

inline int read() { 
	int s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;
}

const int N = 2005, M = N * N, NM = 4e6, p = 1e9+7;
inline void _(ll &x) { if( x >= p ) x -= p; }
ll f[N][N], fac[NM] = {1}, ni[NM] = {1,1};
inline ll C(int n,int m) { return fac[n] * ni[m] % p * ni[n-m] % p; }

int main() {
	int n = read(), K = read();
	if( K == 1 || n == 1 ) { puts("1"); return 0; }
	f[0][0] = 1;
	rep(i,1,n*K) fac[i] = fac[i-1] * i % p;
	rep(i,2,n*K) ni[i] = (p - p / i) * ni[p % i] % p;
	rep(i,2,n*K) ni[i] = ni[i] * ni[i-1] % p;
	rep(i,0,n) { 
		dow(j,i,0) {
			if( f[i][j] ) { 
				if( i < n ) _(f[i+1][j+1] += f[i][j]);
				if( j ) {
					int k = i - j; 
					(f[i][j-1] += f[i][j] * C(n*K-k*K-j-1,K-2) % p * C(n-k,1)) %= p; 
				}
			}
		}
	}
	cout<<f[n][0]<<endl;
	return 0;
}

Measured memory_bytes: 93440
#coding:utf-8

n = int(input().rstrip())

sl = [i for i in range(1,14)]
hl = [i for i in range(1,14)]
cl = [i for i in range(1,14)]
dl = [i for i in range(1,14)]

for i in range(n):
    mark, rank = input().rstrip().split(" ")
    rank = int(rank)

    if mark == "S":
        sl.remove(rank)
    elif mark =="H":
        hl.remove(rank)
    elif mark =="C":
        cl.remove(rank)
    else:
        dl.remove(rank)

#??????
"""
sl.reverse()
hl.reverse()
cl.reverse()
dl.reverse()
"""
for j in sl:
    print("S "+ str(j))
for j in hl:
    print("H "+ str(j))
for j in cl:
    print("C "+ str(j))
for j in dl:
    print("D "+ str(j))

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

using namespace std;

bool check_palindrome(string s) {
	string t(s.rbegin(), s.rend());
	return s == t;
}

int main() {

	string s;
	cin >> s;

	int n = s.size();

	bool is = check_palindrome(s);
	is &= check_palindrome(s.substr(0, (n - 1) / 2));
	is &= check_palindrome(s.substr((n + 1) / 2));
	
	cout << (is ? "Yes\n" : "No\n");

	return 0;
}


Measured memory_bytes: 256
/*
2つの数の和を求める。80桁を超える場合は"overflow"と表示
int型やlong型では80桁は扱えないことに注意
*/
#include <iostream>
using namespace std;

int main(void) {
    char n1[100], n2[100];                       // 入力する数字を格納する整数文字列
    int size1, size2, size_sum;                  // 入力した数字とその和の桁数を格納する変数
    int N1, N2, Sum;                             // N1,N2はそれぞれの桁をint型で格納。Sumは繰り上がりの判定
    int sum[100 + 1];                           // 和を格納する整数文字列
    int n;
    
    cin >> n;
    
    for(int k = 0; k < n; ++k) {
        cin >> n1 >>n2;
        size1    = 0;
        size2    = 0;
        size_sum = 0;
        Sum      = 0;
        while(n1[size1] != '\0') {
            size1++;
        }
        while(n2[size2] != '\0') {
            size2++;
        }
        if(size1 > size2) {
            while(size1 != 0) {
                if(size2 != 0) {
                    N1 = n1[--size1] - '0';
                    N2 = n2[--size2] - '0';
                } else {
                    N1 = n1[--size1] - '0';
                    N2 = 0;
                }
                Sum += N1 + N2;
                if(Sum >= 10) {
                    sum[size_sum++] = Sum - 10;
                    Sum = 1;
                } else { 
                    sum[size_sum++] = Sum;
                    Sum = 0;
                }
            }
        } else {
            while(size2 != 0) {
                if(size1 != 0) {
                    N1 = n1[--size1] - '0';
                    N2 = n2[--size2] - '0';
                } else {
                    N1 = 0;
                    N2 = n2[--size2] - '0';
                }
                Sum += N1 + N2;
                if(Sum >= 10) {
                    sum[size_sum++] = Sum - 10;
                    Sum = 1;
                } else { 
                    sum[size_sum++] = Sum;
                    Sum = 0;
                }
            }
        }
        if(Sum == 1) {
            sum[size_sum++] = 1;
        }
        if(size_sum > 80) {
            cout << "overflow" << endl;
        } else {
            for(int i = 1; i <= size_sum; ++i) {
                cout << sum[size_sum - i];
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

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

	vector<int> a(n);
	cin >> a;
	sort(all(a));

	vector<pair<int, int>> p(m);
	rep(i,m){
		int a, b;
		cin >> a >> b;
		p[i] = make_pair(b,a);
	}
	sort(all(p), greater<pair<int, int>>());

	vector<int> b;
	rep(i,m){
		rep(j,p[i].second){
			if(b.size() == n) break;
			b.emplace_back(p[i].first);
		}
	}
	while(b.size() < n) b.emplace_back(0);
	//cout << a << endl;
	//cout << b << endl;

	int sum = 0;
	rep(i,n){
		sum += max(a[i], b[i]);
	}
	cout << sum << endl;
}


Measured memory_bytes: 3704