akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int main(){
    ll n,k;
    cin >> n >> k;
    ll x = n/k;
    if(k%2==0){
        ll y;
        if(n%k>=k/2){
            y = x+1;
        }else{
            y = x;
        }
        cout << x*x*x+y*y*y << endl;
    }else{
        cout << x*x*x << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>

using namespace std;
int main() {
    string s;
    cin >> s;
    if(s == "AAA" || s == "BBB") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"

namespace modulo {
    using ll = long long;
    const ll MOD = 1000000007;
 
    ll add(ll a) { return a; }
    ll mul(ll a) { return a; }
    ll mod(ll a) { return (a % MOD) + (a < 0) * MOD; }
    ll inv(ll a, const ll m = MOD) { return (a > 1 ? m - inv(m % a, a) * m / a : 1); }
 
    template<typename... Args>
    ll add(ll a, Args... args) { return (a += add(args...)) >= MOD ? (a -= MOD) : a; }
    template<typename... Args>
    ll mul(ll a, Args... args) { return a * mul(args...) % MOD; }
 
    ll sub(ll a, ll b) { return (a -= b) < 0 ? (a += MOD) : a; }
    ll div(ll a, ll b) { return mul(a, inv(b)); }
    ll pow(ll a, ll n, ll r = 1) {
        if (n < 0) n = -n, a = inv(a);
        while (n) {
            if (n & 1) r = mul(r, a);
            n >>= 1LL, a = mul(a, a);
        }
        return r;
    }
}

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cout.tie(nullptr);
    std::cin.tie(nullptr);

    int n;
    std::cin >> n;

    std::cout << (n < 2 ? 0 : modulo::add(modulo::sub(modulo::pow(10, n), modulo::mul(2, modulo::pow(9, n))), modulo::pow(8, n)));
}

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

class Program
{
    void Calc()
    {
        var sc = new Scanner();
        int a = sc.NextInt();
        int b = sc.NextInt();
        int c = sc.NextInt();
        if (c >= a && b >= c)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }

    }

    static void Main()
    {
        new Program().Calc();
    }

    class Scanner
    {
        string[] s = new string[0];
        int i = 0;
        char[] cs = new char[] { ' ' };

        public string Next()
        {
            if (i < s.Length) return s[i++];
            s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return s[i++];
        }
        public int NextInt() { return int.Parse(Next()); }
        public long NextLong() { return long.Parse(Next()); }
        public double NextDouble() { return double.Parse(Next()); }
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;
public class Main {
    public static void main (String args[]){
    	Scanner str =new Scanner(System.in);
        StringBuffer buf = new StringBuffer();
    	while(true){
    	    int a = str.nextInt();
    	    int b = str.nextInt();
    	    if(a==0&&b==0){
    	    	break;
    	    }
    	    if(a<b){
    	        buf.append(Integer.toString(a)).append(" ").append(Integer.toString(b)).append("\n");
    	    }
    	    if(a>b){
    	    	buf.append(Integer.toString(b)).append(" ").append(Integer.toString(a)).append("\n");
    	    }
    	    if(a==b){
    	    	buf.append(Integer.toString(b)).append(" ").append(Integer.toString(a)).append("\n");
    	    }

    	}
    	System.out.print(buf);
    }
}

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    //INT_MAX = 2147483647, UINT_MAX = 4294967295

    int n;
    cin >> n;

    map<string, int> items;

    for(int i = 0; i < n; i++){
        string value;
        cin >> value;
        if(items.count(value)) items[value]++;
        else items[value] = 1;
    }

    int count = 0;
    for(auto x: items) count++;
    cout << count << '\n';

    return 0;
}

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

using namespace std;

typedef long long ll;

bool reversecompare(int a, int b)
{
    return a > b;
}

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

    ll N, Y, d10, d5, d1, selisih;

    int counter;
    bool can;

    counter = 0;
    d5 = 0;
    d10 = 0;

    cin >> N >> Y;

    Y /= 1000;
    d1 = Y;

    if (d1 < N)
        cout << "-1 -1 -1" << endl;
    else if (d1 == N)
        cout << d10 << " " << d5 << " " << d1 << endl;
    else
    {
        selisih = d1-N;
        can = true;
        while(can)
        {
            
                if (counter > N)
                {
                    can = false;
                    cout << "-1 -1 -1" << endl;
                }
                
                else if ((selisih - (counter*9))%4 == 0)
                {
                    d10 = counter;
                    // cout << "selisih" << selisih << endl;
                    d5 = (selisih - (counter*9))/4;
                    d1 = N - d10 - d5;
                    if ((d5 < 0) || (d1 < 0))
                    {
                        counter++;
                        continue;
                    }
                    can = false;
                    cout << d10 << " " << d5 << " " << d1 << endl;

                }
                counter++;
        }
    }


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int a[100000000];
int main()
{
	long long int n,k,m,t=0;
	scanf("%lld%lld",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	for(int i=0;i<n-k;i++){
		t+=a[i];
	}
	printf("%lld\n",t);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef int64_t ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  int n, m;
  cin >> n >> m;
  vector<vector<ll>> sums(8, vector<ll>(n, 0));
  rep(i, n) {
    ll x, y, z;
    cin >> x >> y >> z;
    sums[0][i] += (x + y + z);
    sums[1][i] += (x + y - z);
    sums[2][i] += (x - y + z);
    sums[3][i] += (x - y - z);
    sums[4][i] += (-x + y + z);
    sums[5][i] += (-x + y - z);
    sums[6][i] += (-x - y + z);
    sums[7][i] += (-x - y - z);
  }

  rep(i, 8) {
    sort(ALL(sums[i]), greater<ll>());
  }

  ll ans = 0;
  rep(i, 8) {
    ll tmp = 0;  
    rep(j, m) {
      tmp += sums[i][j];
    }
    chmax(ans, tmp);
  }

  cout << ans << endl;  

  return 0;
}


Measured memory_bytes: 384
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t A, B, N;
  cin >> A >> B >> N;
  int64_t max_val = (A * min(B - 1, N)) / B;
  cout << max_val << endl;

  return 0;
}


Measured memory_bytes: 3628
program D_Lucky_PIN
    implicit none
    integer::n,i,j,k,ans
    character(:),allocatable::str,tmpstr,ttmpstr
    character::array(10) = (/"0","1","2","3","4","5","6","7","8","9"/)
    read*,n
    allocate(character(n)::str)
    read*,str
    ans = 0

    do i = 1,10
        if (index(str,array(i)) > 0) then
            tmpstr = str(index(str,array(i))+1:n)
            do j = 1,10
                if (index(tmpstr,array(j)) > 0) then
                    ttmpstr = str(index(str,array(i))+index(tmpstr,array(j))+1:n)
                    do k = 1,10
                        if (index(ttmpstr,array(k)) > 0) then
                            ans = ans + 1
                        end if
                    end do
                end if
            end do
        end if
    end do

    print*,ans
end program D_Lucky_PIN

Measured memory_bytes: 384
//Bokann ga bokka--nn!!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int main(){
	while(1)
	{
		int n;
		scanf("%d",&n);
		if(!n) return 0;
		int a=0,b=0;
		for(int i=0;i<n;i++)
		{
			int x,y;
			scanf("%d %d",&x,&y);
			if(x>y) a+=x+y;
			else if(x<y) b+=x+y;
			else { a+=x; b+=y;}
		}
		printf("%d %d\n",a,b);
	}
}

Measured memory_bytes: 1188
import java.io.BufferedReader
import java.util.*
import kotlin.math.max

fun main() = abc175e()

@OptIn(ExperimentalStdlibApi::class)
fun abc175e() = SimpleFastIOWithToken_abc175e().exec {
    val (rows, cols, k) = List(3) { readInt() }
    val items = List(k) { List(3) { readInt() } }

    val grid = Array(rows) { LongArray(cols) }
    items.forEach { (r, c, v) -> grid[r - 1][c - 1] = v.toLong() }
    val rowMaxes = LongArray(cols)

    for (y in 0 until rows) {
        val rowDp = Array(4) { LongArray(cols) }
        rowDp[0] = rowMaxes

        for (x in 0 until cols) {
            for (take in 2 downTo 0) {
                rowDp[take + 1][x] = max(rowDp[take + 1][x], rowDp[take][x] + grid[y][x])
            }

            if (x + 1 < cols) for (take in 0..3) {
                rowDp[take][x + 1] = max(rowDp[take][x + 1], rowDp[take][x])
            }
        }

        for (x in 0 until cols) rowMaxes.changeMax(x, rowDp.map { it[x] }.max()!!)
    }

    val answer = rowMaxes.last()

    println(answer)
}

private fun LongArray.changeMax(i: Int, v: Long) = run { this[i] = max(this[i], v) }

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleFastIOWithToken_abc175e(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private var st: StringTokenizer = StringTokenizer("")
    private val sb: StringBuilder = StringBuilder()
    private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }

    fun readString(): String = run { prepareNext() }.run { st.nextToken() }
    fun readInt(): Int = Integer.valueOf(readString())
    fun readLong(): Long = java.lang.Long.valueOf(readString())

    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }

    fun exec(action: SimpleFastIOWithToken_abc175e.() -> Unit) {
        var t: Throwable? = null
        Thread(null, { action() }, "solve", 128 * 1024 * 1024)
            .apply { setUncaughtExceptionHandler { _, t1 -> t = t1 } }
            .apply { start() }.join()
        t?.let { throw it }
        kotlin.io.print(sb)
    }

    fun readLine(): Nothing = error("readLine is disabled.")
}
// endregion kokomade template dayo (^o^)


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T;
	cin >> T;
	ll arr[T];
	for(int i = 0; i<T;i++)
	{
		cin >>arr[i];
	}
	ll ans = 0;
	for(int i = 1; i<T;i++)
	{
		if(arr[i] < arr[i-1])
		{
			ans += arr[i-1] - arr[i];
			arr[i] = arr[i-1];
		}
	}
	cout <<ans<<endl;
}


Measured memory_bytes: 5228
#!usr/bin/env python3
import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
from bisect import bisect, bisect_left, bisect_right

MOD = 10 ** 9 + 7
INF = 10 ** 18
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

N = int(input())
a = list(map(int, input().split()))

dp = [[INF] * (N + 10) for _ in range(N + 10)]
dp2 = [[0] * (N + 10) for _ in range(N + 10)]

for l in range(N):
    dp[l][l] = a[l]

for i in range(N - 2, -1, -1):
    for j in range(i + 1, N):
        dp2[i][j] = min(dp[i][k] + dp2[k + 1][j] + dp2[i][k] + dp[k + 1][j] for k in range(i, j))
        for val in ([dp[i][k] + dp2[k + 1][j] + dp2[i][k] + dp[k + 1][j], k] for k in range(i, j)):
            if val[0] == dp2[i][j]:
                k = val[1]
        dp[i][j] = dp[i][k] + dp[k + 1][j]
print(dp2[0][N - 1])

Measured memory_bytes: 73176
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9+1;
int main(){
	int N,M;cin>>N>>M;
	cout<<(N==M ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define INF 100000000
typedef long long ll;

using namespace std;

int main()
{
    char str[50];
    cin >> str;
    str[3] = '8';
    cout << str << endl;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;


#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main(){
  ll A,B,C;
  cin >> A >> B >> C;
  ll ans;
  
  if ((A%2)*(B%2)*(C%2)==0){
     cout << 0 << endl;
  }
  else{
    ans = min(A*B,B*C);
    ans = min(ans, C*A);
    cout << ans << endl;
  }
    
 return;
 }
  
int main(){
 cin.tie(nullptr);
 ios_base::sync_with_stdio(false);
 cout << fixed << setprecision(15);
 Main();
 return 0;
 }


Measured memory_bytes: 256
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		String[] S=sc.next().split("");
		String[] T=sc.next().split("");

		int lenS=S.length;
		int lenT=T.length;

		//後ろから探っていく。
		if(lenT>lenS) {
			System.out.println("UNRESTORABLE");
			return;
		}

		int start=lenS-lenT;
		int locatefound=-1;
		for (int i = 0; i < start+1; i++) {
			boolean flg=true;
			for (int j = 0; j < lenT; j++) {
				if(!S[start-i+j].equals(T[j])) {
					if(!S[start-i+j].equals("?") ) {
						flg=false;
					}
				}
			}

			if(flg==true) {
				locatefound=start-i;
				break;
			}
		}

		if(locatefound==-1) {
			System.out.println("UNRESTORABLE");
			return;
		}

		for (int i = locatefound; i < locatefound+lenT; i++) {

			S[i]=T[i-locatefound];

		}

		for (int i = 0; i < lenS; i++) {
			if(S[i].equals("?")) {
				S[i]="a";
			}
		}

		for (int i = 0; i < lenS; i++) {
			System.out.print(S[i]);
		}

		nl();
	}

	//以下テンプレート

	public static int[] extgcd(int a, int b) {

		int x0 = 1;
		int x1 = 0;

		int y0 = 0;
		int y1 = 1;

		while (b != 0) {
			int q = a / b;
			int r = a % b;

			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;

			a = b;
			b = r;

			x0 = x1;
			x1 = x2;

			y0 = y1;
			y1 = y2;
		}

		return new int[] { a, x0, y0 };

	}

	static int gcd(int a, int b) {

		if (b == 0)
			return a;

		if (a < b) {
			int t = a;
			a = b;
			b = t;
		}

		return gcd(b, a % b);

	}

	static int lcm(int a, int b) {
		return a * b / gcd(a, b);
	}

	static void swap(int[] a) {
		int t;

		t = a[0];
		a[0] = a[1];
		a[1] = t;

		return;
	}

	static <T> void output(List<T> list) {

		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(i));

			if (i != list.size() - 1) {
				System.out.print(" ");
			} else {
				nl();
			}
		}

	}

	static void output(String[][] str) {

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				print(str[i][j]);
			}

			nl();
		}

	}

	static void output(boolean flg, String Yes, String No) {

		if (flg) {
			pln(Yes);
		} else {
			pln(No);
		}

	}

	static void output(String[][] str, int digit) {

		String dig = "%" + String.valueOf(digit) + "s";

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				System.out.printf(dig, str[i][j]);
			}
			nl();
		}

	}

	static void pln(String str) {
		System.out.println(str);
	}

	static void pln(int x) {
		System.out.println(x);
	}

	static void print(String str) {
		System.out.print(str);
	}

	static void print(int x) {
		System.out.print(x);
	}

	static void print(String str, int times) {
		for (int i = 0; i < times; i++) {
			print(str);
		}
	}

	static void print(int x, int times) {
		for (int i = 0; i < times; i++) {
			print(x);
		}
	}

	static void nl() {
		System.out.println();
	}

}


Measured memory_bytes: 21972
#include<iostream>
using namespace std;
int main(){
  long long q,h,s,d,n;
  cin>>q>>h>>s>>d>>n;
  q*=4;
  h*=2;
  if(q<s)s=q;
  if(h<s)s=h;
  if(s*2<d)cout<<s*n;
  else {
    if(n%2==0)cout<<n/2*d;
    else cout<<n/2*d+s;
  }
  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
MOD = 10**9 + 7

D = [[0]*(K+1) for i in range(N+1)]
for i in range(1, N+1):
    D[i][1] = 1
for i in range(1, min(N, K)+1):
    D[i][i] = 1
for n in range(1, N+1):
    for k in range(2, min(n-1, K)+1):
        D[n][k] = (D[n-k][k] + D[n-1][k-1]) % MOD
print(D[N][K] % MOD)



Measured memory_bytes: 28828
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
#include <cctype>
#include <deque>
using namespace std;
typedef long long ll;
//__builtin_popcount(n);
#define IOS ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define RI register int
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int SZ = 2e5 + 10;
ll n;

vector<int> prime_factor(ll n)
{
	vector<int> res;
	for(ll i = 2;i * i <= n;i ++)
	{
		int temp = 0;
		while(n % i == 0)
		{
			temp ++;
			n /= i;
		}
		if(temp != 0) res.push_back(temp); 
	}
	if(n != 1) res.push_back(1);
	return res;
} 

int main()
{
	/*
	int T;
	scanf("%d",&T);
	while(T --)
	{
		
	}
	*/
	//system("pause");
	scanf("%lld",&n);
	vector<int> prime =  prime_factor(n);
	ll ans = 0;
	for(auto x: prime)
	{
		int now = 1;
		while(x - now >= 0) 
		{
			x -= now;
			now ++;
			ans ++;
		}	
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 3256
#include "stdio.h"

int day;
int num;
int temp[201];
int wear[200];
int dp[201][200] = {};
int min[201] = {};
int max[201] = {};
int ans=0;

int abs(int a) {
	if (a > 0)return a;
	return -a;
}

int Max(int a, int b) {
	if (a > b)return a;
	return b;
}

int main() {
	scanf("%d %d", &day, &num);
	for (int i = 0; i < day; i++) {
		scanf("%d", &temp[i + 1]);
	}
	for (int i = 0; i < num; i++) {
		scanf("%d %d %d", &min[i], &max[i], &wear[i]);
	}
	for (int i = 2; i <= day; i++) {
		for (int j = 0; j < num; j++) {
			if (temp[i] >= min[j] && temp[i] <= max[j]) {
				for (int k = 0; k < num; k++) {
					if (temp[i-1] >= min[k] && temp[i-1] <= max[k]) {
						dp[i][j] = Max(dp[i][j], dp[i - 1][k] + abs(wear[k] - wear[j]));
					}
				}
			}
		}
	}
	for (int i = 0; i < num; i++)ans = Max(ans, dp[day][i]);
	printf("%d\n", ans);
	return 0;

}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  if (N < 112) cout << 111;
  if (111 < N && N < 223) cout << 222;
  if (222 < N && N < 334) cout << 333;
  if (333 < N && N < 445) cout << 444;
  if (444 < N && N < 556) cout << 555;
  if (555 < N && N < 667) cout << 666;
  if (666 < N && N < 778) cout << 777;
  if (777 < N && N < 889) cout << 888;
  if (888 < N && N < 1000) cout << 999;
}



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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値


vector<ll> cnt(100010,0);

int main(){
    ll N;
    ll ans=0;
    cin>>N;
    vector<ll> A(N);
    REP(i,N){
        cin>>A[i];
        cnt[A[i]]++;
        ans+=A[i];
    }
    ll Q;
    cin>>Q;
    vector<ll> B(Q),C(Q);
    REP(i,Q) cin>>B[i]>>C[i];
    
    REP(i,Q){
        ll tmp=cnt[B[i]];
        cnt[B[i]]=0;
        cnt[C[i]]+=tmp;
        ans+=tmp*(C[i]-B[i]);
        cout<<ans<<endl;
    }

}

Measured memory_bytes: 6408
import bisect


def LIS(seq):
    r = [seq[0]]
    for n in seq[1:]:
        if n > r[-1]:
            r.append(n)
        else:
            idx = bisect.bisect_left(r, n)
            r[idx] = n
    return r
N = int(input())
for _ in range(N):
    seq = list(map(int, input().split()))
    left = set(LIS(seq))
    remain = [n for n in seq if n not in left]
    right = LIS(remain)
    print("YES" if len(left) + len(right) == len(seq) else "NO")


Measured memory_bytes: 5640
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	int A,B;
	cin >> A >> B;
	if(A<10 && B<10){
		cout << A*B << endl;
	}else{
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n[101];
  int i;
  int num;
  cin >> num;
  for(i=0;i<num;i++) cin >> n[i];
  cout << n[num-1];
 for(i=1;i<num;i++) cout <<" "<< n[num-i-1];
  cout << endl;
  return 0;
}



Measured memory_bytes: 3096
#include<cstdio>
int count[10005];

int main(){
    int n;
    scanf("%d",&n);
    int upper = 10000;
    for(int i = 1; i <= 100; i++){
        for(int j = 1; j <= 100; j++){
            for(int k = 1; k <= 100; k++){
                int res= i*i+j*j+k*k+i*j+i*k+j*k;
                if(res<=upper) count[res]++;
            }
        }
    }
    for(int i = 1; i <= n; i++) printf("%d\n",count[i]);
    return 0;
}


Measured memory_bytes: 1716
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n;
	cin >> n;
	vi d(n);
	int jump = 0;
	bool can = true;
	rep(i, 0, n) {
		cin >> d[i];
		jump = max(jump, 10 * i + d[i]);
		if (jump < 10 * (i + 1)) can = false;
	}
	if (!can) {
		cout << "no\n";
		return 0;
	}
	jump = 0;
	reverse(all(d));
	rep(i, 0, n) {
		jump = max(jump, 10 * i + d[i]);
		if (jump < 10 * (i + 1)) {
			cout << "no\n";
			return 0;
		}
	}
	cout << "yes\n";
	return 0;
}


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

using namespace std;

int main()
{
     int L,R,d,ans(0);
     cin>>L>>R>>d;
     while(L<=R){
        ans += L%d == 0 ? 1 : 0;
        L++;
     }
     cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3572
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

 class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] str = new String[2];
		str = in.readLine().split(" ");
		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);

		if (a < 1 || b < 1 || Math.pow(10, 9) < a || Math.pow(10, 9) < b) {
			throw new RuntimeException("error: Range over");
		}
		int d = a / b;
		int r = a % b;
		double f = a / (double) b;
		System.out.printf("%d %d %.5f", d, r, f);
	}
}

Measured memory_bytes: 17004
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int N = int.Parse(s[0]);
        int K = int.Parse(s[1]);
        double ans = 0;
        int iter = 1;
        while(N + 1 > iter)
        {
            int pow = 0;
            int num = iter;
            while (K > num)
            {
                pow++;
                num *= 2;
            }
            ans += 1/Math.Pow(2, pow);
            iter++;
        }

        Console.WriteLine(ans / N);
    
    }
}


Measured memory_bytes: 13140
from collections import deque
H,W=map(int,input().split())
arr=[list(map(str,input())) for i in range(H)]

vist=[[0]*W  for i in range(H)]
dxdy=[[-1,0],[1,0],[0,-1],[0,1]]

d=deque([[0,0,1]])


ans=0

while len(d)>0:
    a=d.popleft()
    x,y,z=a[0],a[1],a[2]

    if x==H-1 and y==W-1:
        ans=z
        break
    
    elif arr[x][y]=="." and vist[x][y]==0:
        vist[x][y]=1
        for dx,dy in dxdy:
            if (0<=x+dx<H) and (0<=y+dy<W):
                if arr[x+dx][y+dy]==".":
                    d.append([x+dx,y+dy,z+1])

count=0
for i in range(H):
    for j in range(W):
        if arr[i][j]=="#":
            count+=1
if ans==0:
    print(-1)
else:
    print(H*W-count-ans)

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  int count=0;
  int sum=0;
  while(true){
    for(int i=0;i<n;i++){
      if(a.at(i)%2==1){
        sum++;
        break;
      }
    }
    if(sum==0){
      count++;
      for(int i=0;i<n;i++){
        a.at(i)=a.at(i)/2;
      }
    }
    else{
      break;
    }
  }
  cout << count << endl;
}


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

int main()
{
  int n;
  int count = 0;
  int res=1;
  cin >> n;

  for (int i = 1; i <= n; i++)
  {
    int c=0;
    int ii=i;
    while (ii % 2 == 0)
    {
      ii = ii / 2;
      c++;
      // cout << i << ':' <<c << endl;
    }
    if(count<=c){
      count=c;
      res=i;
    }
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define hii cout << "hii" << endl
#define int long long
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int N = 5e5 + 5;
const int MAX = 250000 + 5;
const int M = 5e6 + 5;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int INF = 1e15;
const int LG = 21;

int arr[N];
int brr[N];

void solve()
{
	string input;
	cin >> input;
	int sum = 0;
	for(auto x : input)
	{
		sum += (x - '0');
	}
	if(sum % 9 == 0) cout << "Yes" << endl;
	else cout << "No"<< endl;
}
 
int32_t main() 
{	
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

Measured memory_bytes: 3788
ABCD = input()
A, B, C, D = (int(ABCD[i]) for i in range(4))
op = ['+', '-']
for i in range(2):
    if i == 0:
        W = A + B
    else:
        W = A - B
    for j in range(2):
        if j == 0:
            X = W + C
        else:
            X = W - C
        for k in range(2):
            if k == 0:
                Y = X + D
            else:
                Y = X - D
            if Y == 7:
                print(A, op[i], B, op[j], C, op[k], D, '=7', sep='')
                exit()


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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    rep (i, s.length()) {
        if (s[i] == 'R') {
            for (int j = i;j < s.length() && s[j] == 'R';j++) {
                ans = max(ans, j - i + 1);
            }
        }
    }

    cout << ans << endl;
}


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

int a[101];

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    rep(i, m) {
        int b;
        cin >> b;
        a[b]++;
    }
    int l = 0;
    int r = 0;
    rep(i, x) {
        l += a[i];
    }
    repl(i, x, n) {
        r += a[i];
    }
    cout << min(l, r) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue
#include <map>
#include <set> //multiset set<int,greater<int>>大到小
#include <vector>// vector<int>().swap(v);清空释放内存
#include <stack>
#include <cmath> // auto &Name : STLName  Name.
#include <utility>
#include <sstream>
#include <string>//__builtin_popcount(ans);//获取某个数二进制位1的个数
#define mod 1000000007
#define mod9 998244353
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
typedef long double ld;
const db eps=1e-10;
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
#define rep(i,be,en) for (int i=be;i<=en;i++)
#define per(i,be,en) for (int i=en;i>=be;i--)
//ll ksm(ll a,ll b,ll c){ll ans=1;a=a%c;while(b>0){if(b%2) ans=(ans*a)%c;b=b/2;a=(a*a)%c;}return ans;}
using namespace std;

const int N=2e5+7;
int t,n,m,fl=0;

int main(){
    scanf("%d%d%d",&n,&m,&t);
    if(t==1e9){
        rep(i,1,n){
            if(i<=m) printf("%d ",t);
            else printf("%d ",1);
        }
    }else{
        rep(i,1,n){
            if(i<=m) printf("%d ",t);
            else printf("%d ",t+1);
        }
    }

    return 0;
}

Measured memory_bytes: 1280
import numpy as np

N = int(input())
A = [int(x) for x in input().split()]

A_rot = np.array(list(enumerate(A, 1))).T.astype(np.float128)
theta = np.pi / 4
R = np.array([[np.cos(theta), np.sin(theta)], [-np.sin(theta), np.cos(theta)]], dtype=np.float128)
A_rot = np.dot(R, A_rot).T
loss = np.abs(A_rot[:, 1] - np.median(A_rot[:, 1])).sum()
print(int(np.round(np.sqrt(2) * loss)))

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

using namespace std;

#define int long long

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k)
  {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k)
  {
    return (-data[find(k)]);
  }
};

signed main()
{
  int N, M, U[200000], V[200000];

  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    cin >> U[i] >> V[i];
  }

  UnionFind tree2(N + N), tree3(N);
  for(int i = 0; i < M; i++) {
    tree2.unite(U[i] + N, V[i]);
    tree2.unite(V[i] + N, U[i]);
    tree3.unite(U[i], V[i]);
  }

  bool isright[100000] = {};
  for(int i = 0; i < N; i++) {
    isright[tree3.find(i)] |= tree2.find(i) != tree2.find(i + N);
  }

  int connect = 0, other = 0, one = 0, two = 0;
  for(int i = 0; i < N; i++) {
    if(tree3.find(i) != i) continue;
    if(tree3.size(i) == 1) {
      ++other;
      continue;
    }
    bool f = isright[i];
    if(f) ++two;
    else ++one;
  }

  int latte = other * N * 2 - other * other;
  cout << latte + two * two * 2 + one * one + two * one * 2 << endl;
}

Measured memory_bytes: 5760
fun main(args: Array<String>) {
    val (k, n) = readLine()!!.split(' ').map { it.toInt() }
    val a = readLine()!!.split(' ').map { it.toInt() }
    var mx = 0
    for (i in 1 until n) {
        mx = Math.max(a[i] - a[i - 1], mx)
    }
    mx = Math.max(a.first() + k - a.last(), mx)
    println(k - mx)
}


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

static const int N = 40;
static const int INF = 4001;
static const int max_s = N * 10;
int a[N], b[N], c[N], dp[N + 1][max_s + 1][max_s + 1];

int main(){
    int n, ma, mb;
    cin >> n >> ma >> mb;
    rep(i, n)
        cin >> a[i] >> b[i] >> c[i];
    rep(i, n + 1)
        rep(j, max_s + 1)
            rep(k, max_s + 1) dp[i][j][k] = INF;

    dp[0][0][0] = 0;

    rep(i, n)
        rep(sa, max_s + 1)
            rep(sb, max_s + 1){
                if(dp[i][sa][sb] == INF) continue;
                dp[i + 1][sa][sb] = 
                    min(dp[i + 1][sa][sb], dp[i][sa][sb]);
                dp[i + 1][sa + a[i]][sb + b[i]] = 
                    min(dp[i + 1][sa + a[i]][sb + b[i]], dp[i][sa][sb] + c[i]);
            }

    int ans = INF;
    for(int sa = 1; sa <= max_s; sa++)
        for(int sb = 1; sb <= max_s; sb++)
            if(sa * mb == sb * ma) ans = min(ans, dp[n][sa][sb]);
    
    cout << (ans != INF ? ans : -1) << endl;
    return 0;
}

Measured memory_bytes: 25984
#include<iostream>
#include <string.h>
#include<stdio.h>
#include <vector>

using namespace std;



int main(){
	int x[5];
	for (int i = 0; i < 5; i++) {
		cin >> x[i];
		if (x[i] == 0) {
			cout << i + 1 << endl;
		}
	}
	
return 0;

}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
#define INF 1e5
int main(){
	string s,t;
	cin>>s>>t;
	int ans=0;
	rep(i,3){
		if(s[i]==t[i]) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
s = gets.chomp.split("")
arr = 1.upto(s.count)
i_odd = []
i_even = []
o = []
e = []

arr.each { |i|
  if i.odd?
      i_odd << i
  end
 }

i_odd.each { |i|
    o << s[i-1]
}

arr.each { |i|
  if i.even?
      i_even  << i
  end
 }

i_even.each { |i|
    e << s[i-1]
}

o = o.uniq
e = e.uniq

if o.include?("L") ||  e.include?("R")
  puts "No"
else
  puts "Yes"
end


Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main(void){
    string S;
    cin>>S;
    long long i,N,sum=0,count=0;
    N=S.length();
    for(i=0;i<N;i++){
        if(S[i]=='W'){
            sum+=i;
            count++;
        }
    }
    sum=sum-count*(count-1)/2;
    cout<<sum<<endl;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
typedef long long LL;
const int N=3002;
const LL MOD=1e9+7;
int n,q,a[N],x[N],y[N];
LL dp[N][N];
int main(){
    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=q;i++) scanf("%d%d",&x[i],&y[i]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            if(a[i]<a[j])dp[i][j]=1;

    for(int i=1;i<=q;i++){
        for(int A=1;A<=n;A++){
            if(A!=x[i] && A!=y[i]) 
            {
                LL tmpX = dp[x[i]][A];
                LL tmpY = dp[y[i]][A];
                dp[y[i]][A] = (dp[y[i]][A] + tmpX) * ((MOD+1)/2) % MOD;
                dp[x[i]][A] = (dp[x[i]][A] + tmpY) * ((MOD+1)/2) % MOD;
            }
        }

        for(int A=1;A<=n;A++){
            if(A!=x[i] && A!=y[i]) 
            {
                LL tmpX = dp[A][x[i]];
                LL tmpY = dp[A][y[i]];
                dp[A][y[i]] = (dp[A][y[i]] + tmpX) * ((MOD+1)/2) % MOD;
                dp[A][x[i]] = (dp[A][x[i]] + tmpY) * ((MOD+1)/2) % MOD;
            }
        }
        
        {
            LL tmpX = dp[x[i]][y[i]];
            LL tmpY = dp[y[i]][x[i]];
            dp[x[i]][y[i]] = (dp[x[i]][y[i]] + tmpY) * ((MOD+1)/2) % MOD;
            dp[y[i]][x[i]] = (dp[y[i]][x[i]] + tmpX) * ((MOD+1)/2) % MOD;
        }
        /*
        printf("Round %d\n", i);
        for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)
            printf("dp[%d][%d]=%d\n", i,j,dp[i][j]);
        */
    }
    LL ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<i;j++){
            ans=(ans+dp[i][j])%MOD;
        }
    }
    for(int i=1;i<=q;i++)ans=ans*2LL%MOD;
    cout<<ans<<endl;
}






Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<string> S(N);
  map<string, int> mp;
  REP(i, N){
    cin >> S[i];
    mp[S[i]]++;
  }
  bool flag = true;
  REP(i, N-1){
    int tmp = S[i].size() - 1;
    if(S[i][tmp] != S[i+1][0]) flag = false;
  }
  for(auto i : mp){
    if(i.second > 1) flag = false;
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

using namespace std;

const int N = 2e3 + 10;
const int Mod = 1e9 + 7;

int add(int a, int b) {
  return (a += b) >= Mod ? a - Mod : a;
}

int sub(int a, int b) {
  return (a -= b) < 0 ? a + Mod : a;
}

int mul(int a, int b) {
  return 1ll * a * b % Mod;
}

int fast_pow(int a, int b) {
  int res = 1;
  for (; b; b >>= 1, a = mul(a, a)) {
    if (b & 1) {
      res = mul(res, a);
    }
  }
  return res;
}

int n, k, f[N][N], inv[N * N], fac[N * N];

void init(int limit) {
  inv[0] = fac[0] = 1;
  for (int i = 1; i <= limit; i++) {
    fac[i] = mul(fac[i - 1], i);
  }
  inv[limit] = fast_pow(fac[limit], Mod - 2);
  for (int i = limit - 1; i >= 1; i--) {
    inv[i] = mul(inv[i + 1], i + 1);
  }
}

int C(int a, int b) {
  return (a >= b) ? mul(fac[a], mul(inv[b], inv[a - b])) : 0;
}

int main() {
  scanf("%d %d", &n, &k);
  if (k == 1) {
    puts("1");
    return 0;
  }
  init(n * k);
  f[0][0] = 1;
  for (int i = 0; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      if (i) {
        f[i][j] = f[i - 1][j];
      }
      if (j > i) {
        f[i][j] = add(f[i][j], mul(f[i][j - 1], C(i + j * (k - 1) - 1, k - 2)));
      }
    }
  }
  printf("%d\n", mul(f[n][n], fac[n]));
  return 0;
}

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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

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

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

  int N,M,C;
  cin >> N >> M >> C;
  int A[N][M],B[M];
  REP(i,M) {
    cin >> B[i];
  }
  REP(i,N) {
    REP(j,M) {
      cin >> A[i][j];
    }
  }

  int ans = 0;
  REP(i,N) {
    int sum = 0;
    REP(j,M) {
      sum += A[i][j] * B[j];
    }
    if (sum + C > 0) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int n = a[0], k = a[1];
		var h = new int[n].Select(_ => int.Parse(Console.ReadLine())).OrderBy(x => x).ToArray();
		Console.WriteLine(Enumerable.Range(0, n - k + 1).Min(i => h[i + k - 1] - h[i]));
	}
}


Measured memory_bytes: 19036
#!/usr/bin/env ruby
n = gets.chomp.to_i
con = 0

n.times do
  input = gets.chomp.split(' ')
  if input[0] == input[1]
    con += 1
  else
    con = 0
  end
  return puts 'Yes' if con >= 3
end

puts 'No'


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

int A[100000];

int partition(int A[], int p, int r)
{
    int x = A[r];
    int i = p;
    for(int j=p; j<r; j++) {
        if(A[j]<=x) swap(A[i++], A[j]);
    }
    swap(A[i], A[r]);
    return i;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=0; i<n; i++) cin>>A[i];
    int q = partition(A, 0, n-1);
    for(int i=0; i<n; i++) {
        if(i) cout<<' ';
        if(i==q) cout<<'['<<A[i]<<']';
        else cout<<A[i];
    }
    cout<<'\n';
    return 0;
    
}

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

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

  vector<vector<bool>> check(n, vector<bool>(m, false));
  for (int i = 0; i < m; i++) {
    int a, b; cin >> a >> b; a--; b--;
    check[a][b] = check[b][a] = true;
  }

  vector<int> ord(n);
  for (int i = 0; i < n; i++) {
    ord[i] = i;
  }

  int ans = 0;
  do {
    if (ord[0] != 0) break;

    bool ok = true;
    for (int i = 0; i < n - 1; i++) {
      int from = ord[i];
      int to = ord[i+1];
      if(!check[from][to]) ok = false;
    }
    if(ok) ans++;
  } while (next_permutation(ord.begin(), ord.end()));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stdlib.h>
#include <ctype.h>
#include <stack>
#include <bitset>
#include <iterator>
using namespace std;
#define ull unsigned long long
#define ll long long
#define ls k<<1
#define rs k<<1|1
#define lson l,mid,k<<1
#define rson mid+1,r,k<<1|1
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<double,int> pdi;
int lowbit(int x){return x&(-x);}
const int maxn=15;
int x[maxn][25],n,d;
bool ispinfang(int a,int b){
    int tot=0;
    for(int i=0;i<d;++i) tot+=(x[a][i]-x[b][i])*(x[a][i]-x[b][i]);
    int y=sqrt(tot*1.0);
    return y*y==tot;
}
int main(void){
    scanf("%d%d",&n,&d);
    for(int i=0;i<n;++i)
        for(int j=0;j<d;++j) scanf("%d",&x[i][j]);
    int ans=0;
    for(int i=0;i<n;++i)
        for(int j=i+1;j<n;++j)if(ispinfang(i,j)) ++ans;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;int main(){string s[3];cin>>s[0]>>s[1]>>s[2];int turn=0;int p[]={0,0,0};while(!(p[turn]==s[turn].size())){p[turn]++;turn=s[turn].at(p[turn]-1)-'a';}cout<<(char)('A'+turn);}

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

int n,a[100005],dp[100005];

int main() {
	scanf("%d",&n);
	for (int i=0; i<n; i++) {
		scanf("%d",&a[i]);
	}
	dp[0] = 0;
	for (int i=1; i<n; i++) {
		dp[i] = (1<<30);
		dp[i] = min(dp[i],dp[i-1]+abs(a[i]-a[i-1]));
		if (i >= 2) dp[i] = min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
	}
	printf("%d\n",dp[n-1]);
	return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline

n = int(input())
s = ["a"]
ord_a = ord("a")
ans = []

def dfs(s):
    if len(s) == n:
        ans.append("".join(s))
        return   
    max_ord = 0
    for i in s:
        max_ord = max(max_ord, ord(i) - ord_a)
    for j in range(max_ord + 2):
        new_s = s[:]
        new_s.append(chr(j + ord_a))
        dfs(new_s)
if n == 1:
    print("a")
    sys.exit()
dfs(s)
ans.sort()
for i in ans:
    print(i)
    







Measured memory_bytes: 57564
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;
using int32 = __uint32_t;

void solve() {
    int a;
    cin >> a;

    string s;
    cin >> s;

    if(a < 3200)cout << "red";
    else cout << s;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};
int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	
 
const ll mod=1e9+7;
const int INF=INT_MAX/2;

int main(){
    int N, R;
    cin>>N>>R;
    if(N>=10){
        cout<<R<<endl;
    }else{
        cout<<R+100*(10-N)<<endl;
    }
}
 

Measured memory_bytes: 256
N = int(input())
a = [0]
a.extend(list(map(int, input().split())))
b = [0 for _ in range(N+1)]

for i in reversed(range(1, N+1)):
    total = 0
    for j in range(i+i, N+1, i):
        total ^= b[j]
    b[i] = total ^ a[i]

ans_n = 0
ans_l = []
for i in range(N+1):
    if b[i]:
        ans_n += 1
        ans_l.append(str(i))

print(ans_n)
print(' '.join(ans_l))


Measured memory_bytes: 17200
#include <iostream>

using namespace std;

int main() {
    string dance;
    cin >> dance;
    for (int i = 0; i < dance.size(); ++i) {
        if (i % 2 == 0) {
            if (dance[i] == 'L') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (dance[i] == 'R') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256