akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<random>
#include<stdio.h>
using namespace std;

typedef long long ll;

long long Mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

#define INF 1e+16
#define MAX_V 1000000

ll mod=1000000007;

struct edge {
    ll to;
    ll cost;
};

// <最短距離, 頂点の番号>
using P = pair<ll, ll>;

ll V;
vector<edge> G[MAX_V];
ll d[MAX_V];
ll cnt[MAX_V];


void dijkstra(ll s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    fill(cnt,cnt+V,0);
    cnt[s]=1;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;

        for (ll i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
                cnt[e.to]=cnt[v];
            }
            else if (d[e.to] == d[v] + e.cost){
                cnt[e.to]+=cnt[v];
                cnt[e.to]=Mod(cnt[e.to],mod);
            }
        }
    }
}




int main(){
    cin>>V;
    ll M;
    cin>>M;
    ll S,T;
    cin>>S>>T;
    for (ll i=0;i<M;i++){
        ll u,v,d;
        cin>>u>>v>>d;
        edge e={v-1,d};
        edge f={u-1,d};
        G[u-1].push_back(e);
        G[v-1].push_back(f);
    }

    vector<ll> spath(V);
    vector<ll> tpath(V);

    vector<ll> Sways(V);
    vector<ll> Tways(V);


    dijkstra(S-1);
    for (ll i=0;i<V;i++){
        spath[i]=d[i];
        Sways[i]=cnt[i];
    }

    dijkstra(T-1);
    for (ll i=0;i<V;i++){
        tpath[i]=d[i];
        Tways[i]=cnt[i];
    }

    ll ans=Sways[T-1]*Tways[S-1];
    ans=Mod(ans,mod);
    ll minus=0;
    for (ll u=0;u<V;u++){
        for (ll j=0;j<G[u].size();j++){
            edge e=G[u][j];
          	ll v=e.to;
            ll d=e.cost;
            if (spath[u]+d+tpath[v]==spath[T-1]  and ((tpath[v]+d>spath[u] and spath[u]>=tpath[v]) or (tpath[v]+d>=spath[u]+d and spath[u]+d>tpath[v]))){
                ll m=Tways[v]*Sways[u];
                m=Mod(m,mod);
                m=Mod(m*m,mod);
                minus+=m;
                minus=Mod(minus,mod);
            }
        }
    }

    for (ll i=0;i<V;i++){
        if (spath[i]+tpath[i]==spath[T-1] and spath[i]==tpath[i]){
            ll M=Tways[i]*Sways[i];
            M=Mod(M,mod);
            M=Mod(M*M,mod);
            minus+=M;
            minus=Mod(minus,mod);
        }
    }

    ans-=minus;
    ans=Mod(ans,mod);

    cout<<ans<<endl;
  

}

Measured memory_bytes: 46036
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 2005;
int s1[N][N],n,m,s2[N][N],s3[N][N],s[N][N],q;
char ts[N][N];
void pre(){
	for (int i = 1;i <= n;i++)
	for (int j = 1;j <= m;j++)	s1[i][j] = s1[i-1][j]+s1[i][j-1]+s[i][j]-s1[i-1][j-1];
	for (int i = 1;i <= n;i++){
	for (int j = 1;j < m;j++){
	s2[i][j] = s2[i-1][j]+s2[i][j-1]+(s[i][j]&&s[i][j+1]?1:0)-s2[i-1][j-1];
	}
	}
	for (int i = 1;i < n;i++){
	for (int j = 1;j <= m;j++){
	s3[i][j] = s3[i-1][j]+s3[i][j-1]+(s[i][j]&&s[i+1][j]?1:0)-s3[i-1][j-1];
	}
	}
}
int query(int c,int x1,int y1,int x2,int y2){
	if (c == 1){
	return s1[x2][y2]-s1[x1-1][y2]-s1[x2][y1-1]+s1[x1-1][y1-1];
	}
	else if (c == 2){
	return s2[x2][y2]-s2[x1-1][y2]-s2[x2][y1-1]+s2[x1-1][y1-1];	
	}
	else {
	return s3[x2][y2]-s3[x1-1][y2]-s3[x2][y1-1]+s3[x1-1][y1-1];
	}
}
int main(){
//	freopen("read.in","r",stdin);
	cin >> n >> m >> q;
	for (int i = 1;i <= n;i++)	scanf("%s",ts[i]+1);
	for (int i = 1;i <= n;i++){
	for (int j = 1;j <= m;j++){
	s[i][j] = ts[i][j]-'0';
	}
	}
	pre();
	while (q--){
	int x1,y1,x2,y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << query(1,x1,y1,x2,y2)-query(2,x1,y1,x2,y2-1)-query(3,x1,y1,x2-1,y2) << endl;
	}
	return 0;
}

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

int main(){
  ll n,m;
  cin>>n>>m;
  vector<int> v(n);
  rep(i,n){
    cin>>v.at(i);
  }
  ll sum =0;
  rep(i,n){
    sum+=v.at(i);
  }
  ll num = 0;
  rep(i,n){
    if (v.at(i)*4*m >= sum){
      num++;
    }
  }
  if (num >= m){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define MAX_N 100'000
vector<i64> G[MAX_N];

int main() {
    i64 N; cin >> N;
    REP(i, N - 1) {
        i64 a, b; cin >> a >> b;
        a--, b--;
        G[a].pb(b);
        G[b].pb(a);
    }

    auto bfs = [&](i64 s) {
        vector<i64> d(N, -1);
        queue<i64> que;
        d[s] = 0;
        que.push(s);
        while (!que.empty()) {
            i64 u = que.front(); que.pop();
            for (i64 v : G[u]) {
                if (d[v] != -1) continue;
                d[v] = d[u] + 1;
                que.push(v);
            }
        }
        return d;
    };

    vector<i64> d0 = bfs(0);
    vector<i64> dN = bfs(N - 1);

    i64 cnt0 = 0;
    REP(i, N) {
        if (d0[i] <= dN[i]) cnt0++;
    }

    if (cnt0 > (N - cnt0)) {
        cout << "Fennec" << endl;
    } else {
        cout << "Snuke" << endl;
    }

    return 0;
}

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


    int main() {
      cin >> num1;
      if ( num1 % 1000 % 111 == 0) {
        cout << "Yes" << endl;
      }
      else if ( num1 / 10 % 111 == 0) {
        cout << "Yes" << endl;
      }
      
      else {
        cout << "No" << endl;
      }
      
    }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<a[k-1]<<endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {
	static PrintStream out = System.out;
	static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {
		String str = in.nextLine();
		int q = in.nextInt();
		for (int i = 0; i < q; i++) {
			String s = in.next();
			int a = in.nextInt();
			int b = in.nextInt();
			if (s.startsWith("print")) {
				print(str, a, b);
			} else if (s.startsWith("reverse")) {
				str = reverse(str, a, b);
			} else if (s.startsWith("replace")) {
				String p = in.next();
				str = replace(str, a, b, p);
			}
		}
	}
	static void print(String str, int a, int b) {
		char[] cs = new char[b-a+1];
		for (int i = a; i <= b; i++) {
			cs[i-a] = str.charAt(i);
		}
		out.println(new String(cs));
	}
	static String reverse(String str, int a, int b) {
		char[] cs = str.toCharArray();
		for (int i = a; i < a + (b - a + 1) / 2; i++) {
			char temp = cs[i];
			cs[i] = cs[b-(i-a)];
			cs[b-(i-a)] = temp;
		}
		return new String(cs);
	}
	static String replace(String str, int a, int b, String p) {
		char[] cs = str.toCharArray();
		char[] pp = p.toCharArray();
		for (int i = a; i <= b; i++) {
			cs[i] = pp[i-a];
		}
		return new String(cs);
	}
}

Measured memory_bytes: 22292
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    auto S = sread();
    long N = S.length;
    writeln(max(S[0] - '0' - 1 + 9 * (N - 1), S.map!"a-'0'"().sum()));

}


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

#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(int i=a; i<b; i++)
#define ll long long

const ll mod = 1e9 + 7;

int n;
bool arr[25][25];
ll dp[22][1<<22];

int main()
{
    FASTIO
    memset(dp,0,sizeof(dp));
    cin >> n;
    rep(i,0,n)
    {
        rep(j,0,n) cin >> arr[i][j];
    }
    dp[0][0] = 1;
    rep(i,1,n+1)
    {
        rep(j,0,1<<n)
        {
            if(__builtin_popcount(j) == i-1)
            {
                rep(k,0,n)
                {
                    if(arr[i-1][k] && !(j&(1<<k)))
                        dp[i][j|(1<<k)] = (dp[i][j|(1<<k)]%mod+dp[i-1][j]%mod)%mod;
                }
            }
        }
    }
    cout << dp[n][(1<<n)-1]%mod << "\n";
    return 0;
}

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

#define ll long long
#define endl "\n"
#define vi vector<int>
#define pb push_back
#define F first
#define S second

unsigned long long power(unsigned long long x,
                         int y, int p)
{
	unsigned long long res = 1; // Initialize result

	x = x % p; // Update x if it is more than or
	// equal to p

	while (y > 0) {
		// If y is odd, multiply x with result
		if (y & 1)
			res = (res * x) % p;

		// y must be even now
		y = y >> 1; // y = y/2
		x = (x * x) % p;
	}
	return res;
}

// Returns n^(-1) mod p
unsigned long long modInverse(unsigned long long n, int p)
{
	return power(n, p - 2, p);
}

// Returns nCr % p using Fermat's little
// theorem.
unsigned long long nCrModPFermat(unsigned long long n,
                                 int r, int p)
{
	// Base case
	if (r == 0)
		return 1;

	// Fill factorial array so that we
	// can find all factorial of r, n
	// and n-r
	unsigned long long fac[n + 1];
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = (fac[i - 1] * i) % p;

	return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p;
}

void solve() {

}

int main() {
#ifndef ONLINE_JUDGE
	freopen("manish.txt", "r", stdin);
	//freopen("ps.txt", "w", stdout);
#endif
	int t;
	//cin >> t;
	t = 1;
	while (t--) {
		int n;
		cin >> n;
		ll mod = 1e9 + 7;

		ll ans = (power(10, n, mod) - 2 * power(9, n, mod) % mod + power(8, n, mod) + mod) % mod;

		cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,a[N],b[N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
        b[i]=i;
    int ans=0;
    for(int i=2;i<n;i++)
    {
        int x=a[i-1],y=a[i],z=a[i+1];
        if(y<x) swap(x,y);if(z<x) swap(x,z);
        if(z<y) swap(y,z);
        if(a[i]==y) ans++;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    int m,d,r;

    while (1)
    {
        cin>>m>>d;
        if (m==0 || d==0)
            break;
        else
        {
            if (m==1)
                r=d;
            else if (m==2)
                r=31+d;
            else if (m==3)
                r=31+29+d;
            else if (m==4)
                r=31+29+31+d;
            else if (m==5)
                r=31+29+31+30+d;
            else if (m==6)
                r=31+29+31+30+31+d;
            else if (m==7)
                r=31+29+31+30+31+30+d;
            else if (m==8)
                r=31+29+31+30+31+30+31+d;
            else if (m==9)
                r=31+29+31+30+31+30+31+31+d;
            else if (m==10)
                r=31+29+31+30+31+30+31+31+30+d;
            else if (m==11)
                r=31+29+31+30+31+30+31+31+30+31+d;
            else if (m==12)
                r=31+29+31+30+31+30+31+31+30+31+30+d;
        }
        if (r%7==1)
            cout<<"Thursday"<<endl;
        else if (r%7==2)
            cout<<"Friday"<<endl;
        else if (r%7==3)
            cout<<"Saturday"<<endl;
        else if (r%7==4)
            cout<<"Sunday"<<endl;
        else if (r%7==5)
            cout<<"Monday"<<endl;
        else if (r%7==6)
            cout<<"Tuesday"<<endl;
        else if (r%7==0)
            cout<<"Wednesday"<<endl;
    }
}


Measured memory_bytes: 3084
/*

Code for problem D by cookiedoth
Generated 22 Mar 2020 at 06.57 PM


   ,##.                   ,==.
 ,#    #.                 \ o ',
#        #     _     _     \    \
#        #    (_)   (_)    /    ; 
 `#    #'                 /   .'  
   `##'                   "=="

=_=
>_<
o_O

*/

#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <complex>
#include <cassert>
#include <random>
#include <cstring>
#include <numeric>
#define ll long long
#define ld long double
#define null NULL
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define debug(a) cerr << #a << " = " << a << endl
#define forn(i, n) for (int i = 0; i < n; ++i)
#define sz(a) (int)a.size()

using namespace std;

template<class T> int chkmax(T &a, T b) {
	if (b > a) {
		a = b;
		return 1;
	}
	return 0;
}

template<class T> int chkmin(T &a, T b) {
	if (b < a) {
		a = b;
		return 1;
	}
	return 0;
}

template<class iterator> void output(iterator begin, iterator end, ostream& out = cerr) {
	while (begin != end) {
		out << (*begin) << " ";
		begin++;
	}
	out << endl;
}

template<class T> void output(T x, ostream& out = cerr) {
	output(x.begin(), x.end(), out);
}

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

int MOD;

int mul(int a, int b) {
	return (1LL * a * b) % MOD;
}

void add(int &a, int b) {
	a = (a + b) % MOD;
}

int power(int a, int deg) {
	int res = 1;
	while (deg) {
		if (deg & 1) {
			res = mul(res, a);
		}
		a = mul(a, a);
		deg >>= 1;
	}
	return res;
}

int inverse(int a) {
	return power(a, MOD - 2);
}

const int mx = 6010;
int n, dp[mx][2 * mx], inv[2 * mx], dim2_zero;

signed main() {
	fast_io();
	vector<int> delta = {0, 1, -1, 0};
	cin >> n >> MOD;
	dim2_zero = 3 * n;
	inv[1] = 1;
	for (int i = 2; i <= 3 * n; ++i) {
		inv[i] = mul(MOD - MOD / i, inv[MOD % i]);
	}
	dp[0][dim2_zero] = 1;
	for (int s = 0; s < 3 * n; ++s) {
		for (int d = 0; d <= 2 * dim2_zero; ++d) {
			for (int bl = 1; bl <= 3; ++bl) {
				int s1 = s + bl;
				int d1 = d + delta[bl];
				if (s1 <= 3 * n && d1 >= 0 && d1 <= 2 * dim2_zero) {
					add(dp[s1][d1], mul(dp[s][d], inv[s1]));
				}
			}
		}
	}
	int ans = 0;
	for (int bal = dim2_zero; bal <= 2 * dim2_zero; ++bal) {
		add(ans, dp[3 * n][bal]);
	}
	for (int i = 1; i <= 3 * n; ++i) {
		ans = mul(ans, i);
	}
	cout << ans << endl;
}


Measured memory_bytes: 281984
#include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        int a , b, c;
        cin >> a >> b >> c;
        if(a == b ){
            cout <<  c  <<  endl;
        }else if( b == c){
            cout <<  a  <<  endl;
        }else{
            cout <<  b  <<  endl;
        }

        return 0;
    }

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  auto a=(scanElem+11)%13;
  auto b=(scanElem+11)%13;
  if(a<b)end("Bob");
  if(a>b)end("Alice");
  end("Draw");
}


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

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <thread>///////////////////

#define rep(i,m,n) for(int i=(m);i<(n);++i)
#define rem(i,m,n) for(int i=(m);i>(n);--i)
#define MOD 1000000007

using namespace std;

using ll = long long int;
using std::swap;

vector<int> v;
vector<long long int> vll;
vector<long long int> w;
vector<vector<int>> vec(50, vector<int>(4, 0));

int N, Y;
int mode = 0;

//tuple<int, int, int> calc(int A, int B, int C) {}



int main() {
	int x, y, z;
  cin >> x >> y>>z;
	cout << z << " " << x << " " << y << '\n';
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

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

int main()
{
  ll N, mg = 1;
  vector<ll> A(1e5), G(1e5), L(1e5);
  cin >> N;
  REP(i, N)
  {
    cin >> A[i];
  }

  REP(i, N + 1)
  {
    G[i] = i == 0 ? 0 : gcd(G[i - 1], A[i - 1]);
    L[i] = i == 0 ? 0 : gcd(L[i - 1], A[N - i]);
  }

  REP(i, N)
  {
    mg = max(mg, gcd(G[i], L[N - i - 1]));
  }

  cout << mg << '\n';

  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    cout << ((n - 1) + (k - 1) - 1) / (k - 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a, b, x;
	char op;
	while(1){
		scanf("%d %c %d", &a, &op, &b);
		if(op=='?'){
			break;
		}
		if(op=='+'){
			x=a+b;
		}
		if(op=='-'){
			x=a-b;
		}
		if(op=='*'){
			x=a*b;
		}
		if(op=='/'){
			x=a/b;
		}
		printf("%d\n",x);
	}
			
	return 0;
}

Measured memory_bytes: 600
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/arc071/tasks/arc071_b

//参考：
//https://bakamono1357.hatenablog.com/entry/2019/08/26/021151

//ポイント：
//変数の分離
//愚直にΣ使った式を立てるのも大事

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

//https://github.com/atcoder-live/library/blob/master/mint.cpp
struct mint {
  LL x; 
  mint(LL x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
struct combination {
  vector<mint> fact, ifact;//factに階乗を計算、ifactはその各々に対する逆元
  combination(LL n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (LL i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (LL i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(LL n,LL k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

LL N,M;
LL X[100000],Y[100000];

mint ans = 0;

mint diff_sum(LL *array,int size){
	mint ret = 0;
	mint pos = 0;
	mint neg = size-1;
	for(int i=0;i<size;i++){
		ret += (pos-neg)*mint(array[i]);
		pos += mint(1);
		neg -= mint(1);
	}
	return ret;
}

void solve(){
	ans = diff_sum(X,N)*diff_sum(Y,M);
}

int main(){
    cin >> N >> M;
    for(int i=0;i<N;i++) cin >> X[i];
    for(int i=0;i<M;i++) cin >> Y[i];

    solve();

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

Measured memory_bytes: 4716
#include<bits/stdc++.h>
using namespace std;
int main(){
	int o=0;
	string s;
	cin>>s;
	int len=s.size();
	for (int i=0;i<len;i++){
		if (s[i]=='C'&&o==0){
			o=1;
			continue;
		}
		if (s[i]=='F'&&o==1){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding=utf_8 -*-
import re

N = int(input())

l = list(i+1 for i in range(N))

for i in l:
    if(i % 3 == 0 and i % 5 != 0):
        l[i-1] = "Fizz"
    elif(i % 3 != 0 and i % 5 == 0):
        l[i-1] = "Buzz"
    elif(i % 3 == 0 and i % 5 == 0): 
        l[i-1] = "FizzBuzz"
    else:
        l[i-1] = l[i-1]

a = []
for k in l:
    if isinstance(k, int):
        a.append(int(k))
    else:
        pass
print(sum(a))

Measured memory_bytes: 53192
#include<bits/stdc++.h>
using namespace std;
int main(){
  char x,y;
  cin>>x>>y;
  if(x<y){
    cout<<"<"<<'\n';
  }
  else if(x > y){
    cout<<">"<<'\n';
  }
  else{
    cout<<"="<<'\n';
  }

  return 0;
}


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

int main()
{
    string s;
    cin>>s;
    int i=0;
    int m=0;
    while(i<s.length())
    {
        int c=0;
        if(s[i]=='R')
        {
            while(s[i]=='R' && i<s.length())
            {
                c++;
                i++;
            }
            m=max(m,c);
        }
        else
        {
            i++;
        }
    }
    cout<<m<<endl;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll qw(ll x,ll y){ll res = 1;while(y){if(y & 1) res *= x;x = x * x;y >>= 1;}return res;}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n,m,q,cnt,ans;
int a[50],b[50],c[50],d[50],s[15];
void dfs(int k,int cur){
	if(k == n){
		int tmp = 0;
		for(int i = 0;i < q;i++){
			if(s[b[i]] - s[a[i]] == c[i]) tmp += d[i];
		}
//		for(int i = 0;i < n;i++) cout << s[i] << " "; cout << endl;
		ans = max(ans,tmp);
		return;
	}
	for(int i = cur;i <= m;i++){
		s[cnt++] = i;
		dfs(k+1,i);
		s[cnt--] = 0;
	}
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m >> q;
	for(int i = 0;i < q;i++){
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		b[i]--; a[i]--;
	} 
	dfs(0,1);
	cout << ans << endl;
	return 0;
}
//do smt instead of nothing! never give up!


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

using namespace std;

const int MaxN = 1e5 + 15;
const int MOD = 1e9 + 7;
const long long INF = 1e18;

int n;
pair<int, int> a[MaxN];

vector <int> ans[MaxN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);

    cin >> n;

    if(n == 1)
    {
        cout << "Yes\n";
        cout << "2\n";
        cout << "1 1\n1 1\n";
        return 0;
    }

    for(int k = 2; k * (k - 1) <= 2 * n; ++k)
        if(k * (k - 1) == 2 * n)
        {
            int p = 0;
            for(int l = 1; l < k; ++l)
                for(int r = l + 1; r <= k; ++r)
                {
                    ++p;
                    ans[l].push_back(p);
                    ans[r].push_back(p);
                }

            cout << "Yes\n";
            cout << k << '\n';
            for(int i = 1; i <= k; ++i)
            {
                cout << ans[i].size() << ' ';
                for(int x : ans[i])
                    cout << x << ' ';
                cout << '\n';
            }
            return 0;
        }

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


Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define lint long long
#define MAX 100000

int main() {
	int N, M; cin >> N >> M;
	vector<pair<int, int>> I(M);
	//vector<int> B(N);
	for (int i = 0; i < M; i++)
	{
		int x, y; cin >> x >> y;
		I[i] = make_pair(y, x);
	//	B[i] = -1;
	}
	sort(I.begin(), I.end());

	int br = 0;
	int ans = 0;
	for (int i = 0; i < M; i++)
	{
		if (ans == 0) {
			ans++;
			br = I[i].first - 1;
		}
		if (ans != 0) {
			if (I[i].second <= br && I[i].first > br) {
				continue;
			}
			else {
				ans++;
				br = I[i].first - 1;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import heapq
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, M = map(int, input().split())
X = list(map(int, input().split()))

X.sort()
dif_X = []
move = [[X[M - 1]] * 2 for _ in range(N)]

for i in range(M - 1):
	heapq.heappush(dif_X, (X[i] - X[i + 1], i))
	
move[0][0] = X[0]

for i in range(N - 1):
	if len(dif_X) > 0:
		tmp = heapq.heappop(dif_X)
		move[i][1] = X[tmp[1]]
		move[i + 1][0] = X[tmp[1] + 1]

move[N - 1][1] = X[M - 1]
ans = 0

for i in range(N):
	ans += move[i][1] - move[i][0]
	
print(ans)

Measured memory_bytes: 74464
n=int(input())
l0=[0]*n
l=[l0[:] for _ in range(26)]
for i in range(n):
  a=input()
  for x in a:
    if x=='a':
      l[0][i]+=1
    elif x=='b':
      l[1][i]+=1
    elif x=='c':
      l[2][i]+=1
    elif x=='d':
      l[3][i]+=1
    elif x=='e':
      l[4][i]+=1
    elif x=='f':
      l[5][i]+=1
    elif x=='g':
      l[6][i]+=1
    elif x=='h':
      l[7][i]+=1
    elif x=='i':
      l[8][i]+=1
    elif x=='j':
      l[9][i]+=1
    elif x=='k':
      l[10][i]+=1
    elif x=='l':
      l[11][i]+=1
    elif x=='m':
      l[12][i]+=1
    elif x=='n':
      l[13][i]+=1
    elif x=='o':
      l[14][i]+=1
    elif x=='p':
      l[15][i]+=1
    elif x=='q':
      l[16][i]+=1
    elif x=='r':
      l[17][i]+=1
    elif x=='s':
      l[18][i]+=1
    elif x=='t':
      l[19][i]+=1
    elif x=='u':
      l[20][i]+=1
    elif x=='v':
      l[21][i]+=1
    elif x=='w':
      l[22][i]+=1
    elif x=='x':
      l[23][i]+=1
    elif x=='y':
      l[24][i]+=1
    elif x=='z':
      l[25][i]+=1
b=0
s=''
for x in l:
  c=min(x)
  if b==0:
    s+='a'*c
  elif b==1:
    s+='b'*c
  elif b==2:
    s+='c'*c
  elif b==3:
    s+='d'*c
  elif b==4:
    s+='e'*c
  elif b==5:
    s+='f'*c
  elif b==6:
    s+='g'*c
  elif b==7:
    s+='h'*c
  elif b==8:
    s+='i'*c
  elif b==9:
    s+='j'*c
  elif b==10:
    s+='k'*c
  elif b==11:
    s+='l'*c
  elif b==12:
    s+='m'*c
  elif b==13:
    s+='n'*c
  elif b==14:
    s+='o'*c
  elif b==15:
    s+='p'*c
  elif b==16:
    s+='q'*c
  elif b==17:
    s+='r'*c
  elif b==18:
    s+='s'*c
  elif b==19:
    s+='t'*c
  elif b==20:
    s+='u'*c
  elif b==21:
    s+='v'*c
  elif b==22:
    s+='w'*c
  elif b==23:
    s+='x'*c
  elif b==24:
    s+='y'*c
  elif b==25:
    s+='z'*c
  b+=1
print(s)

Measured memory_bytes: 3280
from fractions import gcd
def lcm(p,q):
    return p*q//gcd(p,q)
n,m = map(int, input().split())
a = list(map(int, input().split()))
x = 1
for i in range(n):
    a[i] = a[i]//2
    x = lcm(x,a[i])
for i in range(n):
    if (x//a[i])%2==0:
        print(0)
        exit()
p = m//x
print(p//2 if p%2==0 else p//2+1)

Measured memory_bytes: 89580
#include <bits/stdc++.h>
#define ll long long int
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define pb(v, a) v.push_back(a)
#define Sort(v) sort(v.begin(), v.end())
#define For(m) for (auto it = m.begin(); it != m.end(); it++)
#define mp(p1,p2) make_pair(p1,p2)
#define mod 1000000007
#define PI 3.14159265358979323846
#define pii pair<ll ,ll>
using namespace std;
#define fast                                                                   \
 ios_base::sync_with_stdio(false);                                            \
 cin.tie(NULL);                                                               \
 cout.tie(NULL);
 vector<ll>graph[100005];
 ll arr[100005];
 ll n;
 ll in=0;
 ll ans[100005];
 void dfs(ll u,ll par)
 {
   ans[u]=arr[n-1-in];
   in++;
   For(graph[u])
   {
      if(*it!=par)dfs(*it,u);
   }
 }
 
int main()
{
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
   
   cin >> n;
   fr(i,0,n-1)
   {
      ll u,v;
      cin >> u >> v;
      pb(graph[u],v);
      pb(graph[v],u);
   }
   ll sum=0;
   fr(i,0,n)
   cin >> arr[i],sum+=arr[i];
   sort(arr,arr+n);
   sum-=arr[n-1];
   dfs(1,0);
   cout << sum << "\n";
   fr(i,1,n+1)
   cout << ans[i] << " ";
   return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> v(N);
  for(int i=0; i<N; i++){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  for(int i=1; i<N; i++){
    if (v[i]==v[i-1]){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout <<"YES"<<endl;
}

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

int main(){
int n;
cin >> n;
vector<int> x(n);
rep(i,n) cin >> x[i];

int count = 0;
rep(i,n) count +=x[i];
int avg = count / n;
int avg1 = avg+1;
int total1=0,total2=0,ans;
rep(i,n){
  total1+=(x[i]-avg)*(x[i]-avg);
  total2+=(x[i]-avg1)*(x[i]-avg1);
} 
cout << min (total1,total2) << endl;
}

Measured memory_bytes: 256
import math
n=int(input())
X=list(map(int,input().split()))
Y=list(map(int,input().split()))
D=[abs(x-y) for x,y in zip(X,Y)]
p1=sum(D)
p2=math.sqrt(sum(i**2 for i in D))
p3=sum(i**3 for i in D)**(1/3)
pinf=max(D)
print(p1)
print(p2)
print(p3)
print(pinf)


Measured memory_bytes: 5696
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        double x = (double) n / (1.08);
        boolean bl = true;
        if ((int) (x + 0.5) != (int) (x))
            bl = false;
        if ((int) x * 1.08 == n) {
            System.out.println((int) (x + 0.5));
            System.exit(0);
        }

        if ((int) ((int) (x + 1) * 1.08) == n) {
            System.out.println((int) (x + 1));
            System.exit(0);
        }

        if ((int) ((int) (x - 1) * 1.08) == n) {
            System.out.println((int) (x - 1));
            System.exit(0);
        }

        System.out.println(":(");
        s.close();
    }
}

Measured memory_bytes: 22612
#include <algorithm>
#include <cstddef>
#include <functional>
#include <initializer_list>
#include <vector>
template <typename T> class SegmentTree {
  using F = std::function<T(T, T)>;

private:
  F updater, operation; // 葉ノード更新時処理、区間に対する処理
  T e;                  // 単位元
  std::vector<T> node;
  size_t n; // 管理している要素数

  T query(size_t a, size_t b, size_t k, size_t l, size_t r) {
    // a,b := クエリ範囲[a,b)
    // k := 今見ているノードの番号
    // l,r := 今見ているノードに対応する範囲
    if (r <= a || b <= l) {
      // 交差しない
      return e;
    }
    if (a <= l && r <= b) {
      // クエリ範囲に完全に含まれる
      return node[k];
    }
    size_t m = (l + r) / 2;
    return operation(query(a, b, 2 * k + 1, l, m),
                     query(a, b, 2 * k + 2, m, r));
  }

public:
  SegmentTree(size_t N, T e, F operation, F updater)
      : e(e), operation(std::move(operation)), updater(std::move(updater)) {
    n = 1;
    while (n < N)
      n <<= 1;
    node.assign(2 * n - 1, e);
  }

  template <typename Iterator>
  SegmentTree(size_t N, T e, F operation, F updater, Iterator start,
              Iterator end)
      : e(e), operation(std::move(operation)), updater(std::move(updater)) {
    n = 1;
    while (n < N)
      n <<= 1;
    node.assign(2 * n - 1, e);
    init(start, end);
  }
  template <typename Iterator> void init(Iterator start, Iterator end) {
    for (auto i = start; i < end; i++) {
      int idx = i - start;
      update(idx, *i);
    }
  }

  void update(int idx, T x) {
    // idxの値をxに更新
    idx += n - 1;
    node[idx] = updater(node[idx], x);
    while (idx > 0) {
      idx = (idx - 1) / 2;
      node[idx] = operation(node[idx * 2 + 1], node[idx * 2 + 2]);
    }
  }

  T query(size_t a, size_t b) {
    // [a,b)の処理
    return query(a, b, 0, 0, n);
  }

  const T &operator[](size_t idx) { return node[idx + n - 1]; }
};

#include <iostream>
using namespace std;

int main() {
  int n, q;
  string s;
  cin >> n;
  cin >> s;
  cin >> q;
  vector<int> dat(n, 0);
  for (int i = 0; i < n; i++) {
    dat[i] = 1 << (s[i] - 'a');
  }
  auto st = SegmentTree<int>(
      n, int(0), [](int a, int b) { return a | b; },
      [](int a, int b) { return b; }, dat.begin(), dat.end());
  for (int i = 0; i < q; i++) {
    int a;
    cin >> a;
    if (a == 1) {
      int idx;
      char c;
      cin >> idx >> c;
      idx--;
      st.update(idx, 1 << (c - 'a'));
    } else {
      int l, r;
      cin >> l >> r;
      l--;
      int res = st.query(l, r);
      cout << __builtin_popcount(res) << endl;
    }
  }
}


Measured memory_bytes: 6916
import static java.lang.System.out;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int W = scan.nextInt();
        int H = scan.nextInt();
        int x = scan.nextInt();
        int y = scan.nextInt();
        int r = scan.nextInt();

        boolean flagX = true;
        boolean flagY = true;

        if ((x - r) < 0 || W < (x + r)) {
            flagX = false;
        }
        if ((y - r) < 0 || H < (y + r)) {
            flagY = false;
        }

        if (flagX && flagY) {
            out.println("Yes");
        } else {
            out.println("No");
        }
    }   
}   

Measured memory_bytes: 26256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=2005,Mod=1e9+7;
int dp[N][N],fac[N*N],inv[N*N];
inline int C(int n,int m){
	return 1ll*fac[n]*inv[m]%Mod*inv[n-m]%Mod;
}
inline int qpow(int a,int b){
	int ans=1;
	while (b){
		if (b&1) ans=1ll*ans*a%Mod;
		a=1ll*a*a%Mod,b>>=1;
	}
	return ans;
}
int main (){
	int n,k;scanf ("%d%d",&n,&k);
	if (k==1) {puts("1");return 0;}
	dp[0][0]=1;fac[0]=1;
	for (int i=1;i<=n*k;i++) fac[i]=1ll*fac[i-1]*i%Mod;
	inv[n*k]=qpow(fac[n*k],Mod-2);for (int i=n*k-1;i>=0;i--) inv[i]=1ll*inv[i+1]*(i+1)%Mod;
	for (int i=1;i<=n;i++)
        for (int j=0;j<=i;j++){
            if (j!=i) dp[i][j]=1ll*dp[i-1][j]*(n-i+1)%Mod;
            if (j!=0) (dp[i][j]+=1ll*dp[i][j-1]*C(n*k-(i+(j-1)*(k-1))-1,k-2)%Mod)%=Mod;
        }
    printf ("%d",dp[n][n]);
	return 0;
}

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

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

char s[10][10];

int calc(int y, int x, char c) {
    char c2 = "ox"[c == 'o'];
    int res = 0;
    for (int i = 0; i < 8; ++i) {
        int ty = y + dy[i];
        int tx = x + dx[i];
        if (s[ty][tx] != c2) continue;

        int pt = 0;
        while (s[ty][tx] == c2) {
            pt++;
            ty += dy[i];
            tx += dx[i];
        }
        if (s[ty][tx] != c) continue;
        res += pt;
    }
    return res;
}

void place(int y, int x, char c) {
    s[y][x] = c;

    char c2 = "ox"[c == 'o'];
    for (int i = 0; i < 8; ++i) {
        int ty = y + dy[i];
        int tx = x + dx[i];
        if (s[ty][tx] != c2) continue;

        while (s[ty][tx] == c2) {
            ty += dy[i];
            tx += dx[i];
        }
        if (s[ty][tx] != c) continue;

        do {
            s[ty][tx] = c;
            ty -= dy[i];
            tx -= dx[i];
        } while (s[ty][tx] == c2);
    }
}

int main() {
    for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) {
            s[i][j] = '#';
            if (0 < i && i < 9 && 0 < j && j < 9) { cin >> s[i][j]; }
        }
    }

    while (1) {
        bool end = true;
        for (char ck : "ox") {
            int maxpt = 0, y, x;
            for (int i = 1; i < 9; ++i) {
                for (int j = 1; j < 9; ++j) {
                    if (s[i][j] != '.') continue;
                    int pt = calc(i, j, ck);
                    if ((ck == 'o' && maxpt < pt) || (ck == 'x' && maxpt <= pt)) {
                        maxpt = pt;
                        y = i;
                        x = j;
                    }
                }
            }
            if (0 < maxpt) {
                place(y, x, ck);
                end = false;
            }
        }
        if (end) break;
    }

    for (int i = 1; i < 9; ++i) {
        for (int j = 1; j < 9; ++j) { cout << s[i][j]; }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>
#include<math.h>

int n;

typedef struct {
  double x;
  double y;
}XY;
 
void kock(int n, XY p1, XY p2){
  if(n == 0)return;
  XY s,t,u;

  s.x = (2*p1.x + 1*p2.x)/3;
  s.y = (2*p1.y + 1*p2.y)/3;
  t.x = (1*p1.x + 2*p2.x)/3;
  t.y = (1*p1.y + 2*p2.y)/3;
  u.x = (t.x - s.x)*cos(60*M_PI/180.0) - (t.y - s.y)*sin(60*M_PI/180.0) + s.x;
  u.y = (t.x - s.x)*sin(60*M_PI/180.0) + (t.y - s.y)*cos(60*M_PI/180.0) + s.y;

  kock(n-1, p1, s);
  printf("%.8f %.8f\n",s.x,s.y); 
  kock(n-1, s, u);
  printf("%.8f %.8f\n",u.x,u.y); 
  kock(n-1, u, t);
  printf("%.8f %.8f\n",t.x,t.y); 
  kock(n-1, t, p2);
}

int main(){

  XY start,end;
  start.x = 0,start.y = 0;
  end.x = 100,end.y = 0;

  scanf("%d",&n);
  printf("%.8f %.8f\n",start.x,start.y);
  kock(n,start,end);
  printf("%.8f %.8f\n",end.x,end.y);

 return 0;
}



Measured memory_bytes: 2108
#[macro_use]
extern crate text_io;

fn main() {
    let target_list = vec![vec![2, 4, 5, 7, 9], vec![0, 1, 6, 8], vec![3]];
    let ans_list =["hon", "pon", "bon"];

    let mut input: String = read!();
    let target = input.pop().unwrap() as i32 - 48;

    for (i, t) in target_list.iter().enumerate() {
        if let Some(_) = t.iter().find(|&&x| x == target) {
            println!("{}", ans_list[i]);
        }
    }
}


Measured memory_bytes: 2188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define INF 100000007
typedef long long ll;
using namespace std;
ll n, k, r, b[200010];
int main() {
  cin >> n >> k;
  rep(i, n) {
    int a;
    cin >> a;
    b[a]++;
  }
  sort(b, b + n + 1);
  for (int i = 1; i < n - k + 1; ++i) {
    r += b[i];
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 1792
while True :
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    0 <= a,b <= 2 * 10**4 
    if op == "?" : break

    if op == "+" : print(a + b)
    elif op == "-" : print(a - b) 
    elif op == "*" : print(a * b)
    elif op == "/" : print(a // b)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

const int maxn=2002;
const long long mod=1e9+7;
long long dp[2002]; // dp is a bit
int s;

void update(int x, long long val){
	while (x<maxn){
		dp[x]+=val;
		dp[x]%=mod;
		x+=x&-x;
	}
}

long long query(int x){
	long long ret=0;
	while (x>0){
		ret+=dp[x];
		ret%=mod;
		x-=x&-x;
	}
	return ret;
}

int main(){
	cin >> s;
	s++;
	memset(dp,0,sizeof dp);
	update(1,1);
	update(2,mod-1);
//	cout << query(2) << "\n";
	for (int j=0;j<s;j++){
		update(j+3,query(j));
	}
//	for (int i=1;i<=s;i++) cout << query(i) << " ";
//	cout << "\n";
	cout << query(s) << "\n";
}

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

const int maxN = 5005, mod = 1e9 + 7;

int n, m;
int f[maxN + 1][maxN + 1], sum[maxN + 1][maxN + 1];
int pw[maxN + 1], ipw[maxN + 1];

inline int ADD(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }

int main()
{
	scanf("%d %d", &n, &m);

	int I = (mod + 1) / 2;
	pw[0] = ipw[0] = 1;
	for(int i = 1; i <= m; i++)
	{
		pw[i] = 2ll * pw[i - 1] % mod;
		ipw[i] = 1ll * I * ipw[i - 1] % mod;
	}

	for(int j = 1; j <= m; j++) f[1][j] = pw[j];
	for(int j = 1; j < m; j++) sum[1][j] = ADD(sum[1][j - 1], 1ll * f[1][j] * j % mod * ipw[j + 1] % mod);
	for(int i = 2; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			f[i][j] = 1ll * (j + 1) * f[i - 1][j] % mod;
			f[i][j] = ADD(f[i][j], 1ll * sum[i - 1][j - 1] * pw[j] % mod);
		}
		for(int j = 1; j < m; j++) 
			sum[i][j] = ADD(sum[i][j - 1], 1ll * f[i][j] * j % mod * ipw[j + 1] % mod);
	}

	printf("%d\n", f[n][m]);
	return 0;
}


Measured memory_bytes: 199324
#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 = 1e2 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	LL l = 0, r = INF * INF;
	vector<LL> v(5);
	LL n;
	cin >> n;
	for (auto& x : v) cin >> x;
	for (int i = 1; i < 5; i++)
	{
		v[i] = min(v[i], v[i - 1]);
	}
	LL res = 0;
	while (l <= r)
	{
		LL mid = (l + r) / 2;
		int flag = 1;
		LL pre = n;
		for (int i = 0; i < 5; i++)
		{
			if ((n + v[i] - 1) / v[i] > mid - i)
			{
				flag = 0;
				break;
			}
		}
		if (flag) res = mid, r = mid - 1;
		else l = mid + 1;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 384