akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) = yorukatsu10f()

fun yorukatsu10f() {
    val (h, w, a, b) = readLine()!!.split(' ').map { it.toInt() }

    nCkInit()
    var answer = 0L

    for (i in 0 until w - b) {
        val nCk = nCk(b + i + (h - a) - 1, h - a - 1) * nCk(w - b + a - 2 - i, a - 1)
        answer += nCk
        answer %= MOD
    }

    println(answer)
}

private const val MOD = (1e9 + 7).toLong()

private const val MAX = 1000000
private val fac = LongArray(MAX)
private val fInv = LongArray(MAX)
private val inv = LongArray(MAX)

private fun nCk(n: Int, k: Int): Long {
    if (n < k) return 0
    if (n < 0 || k < 0) return 0
    return fac[n] * (fInv[k] * fInv[n - k] % MOD) % MOD
}

private fun nCkInit() {
    fac[0] = 1
    fac[1] = 1
    fInv[0] = 1
    fInv[1] = 1
    inv[1] = 1
    for (i in 2 until MAX) {
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[(MOD % i).toInt()] * (MOD / i) % MOD
        fInv[i] = fInv[i - 1] * inv[i] % MOD
    }
}


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

int main() {
  int a,b,c,r,A,B,C,k,x;
  x=0;
  cin >>k;
  for(a=1; a<k+1; a++){
    for(b=1; b<k+1; b++){
      for(c=1;c<k+1;c++){
        A = max(a,b);
        B = min(a,b);
        r = A%B;
        while(r!=0){
          A = B;
          B = r;
          r = A%B;
        }
        A = max(B,c);
        C = min(B,c);
        r = A%C;
        while(r!=0){
          A = C;
          C = r;
          r = A%C;
        }
        x = x+C;
      }
    }
  }
  cout <<x <<endl;
}

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


int main(){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(((x-r)>=0)&&((y-r)>=0)&&((x+r)<=W)&&((y+r)<=H)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
     
}


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

int main(){
  int n;
  cin >> n;
  string a,b,c;
  cin >> a >> b >> c;
  int count=2*n;
  for(int i=0;i<n;i++){
    if(a.at(i)==b.at(i)&&a.at(i)==c.at(i)){
      count=count-2;
    }
    else if(a.at(i)==b.at(i)||a.at(i)==c.at(i)||b.at(i)==c.at(i)){
      count--;
    }
  }
  cout << count << endl;
}
      
  

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

int main(){
  int n;
  vector <int> a;
  cin >> n;
  for(int i=0;i<n;i++){
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  
  int counter = 0;
  bool flag =true;
  while(true){
    for(int i=0;i<n;i++){
      if(a[i]%2==0){
        a[i] = a[i] / 2;
      }else{
        flag = false;
      }
    }
    if(!flag)break;
    counter++;
  }
  
  cout << counter << endl;
}

Measured memory_bytes: 256
package main

import "fmt"
var N, M int
var u, w, v int
var dp []int
var DP, A [][]int
var vis, dist []int
var dpf []float64
var P float64
const (
	MaxInt = 1<<31 - 1
	MinInt = -MaxInt - 1
)
func max(a, b int) int {
	if a > b { return a }
	return b
}

func min(a, b int) int {
	if a < b { return a }
	return b
}

func abs(a int) int {
	if a < 0 { return -a }
	return a
}

func main() {
	_,e := fmt.Scanf("%d", &N)
	if e != nil { return }
	dpf = make([]float64, N+1)
	dpf[0] = 1
	for i :=0; i<N; i++ {
		_,e = fmt.Scanf("%f", &P)
		if e != nil { return }
		for j:=i+1; j>=0; j-- {
			if j == 0 {
				dpf[j]= (1.0-P)*dpf[j]
			} else {
				dpf[j] = dpf[j-1]*P + (1.0-P)*dpf[j]
			}
		}
	}

	ans := 0.0
	for i:=0; i<=N; i++ {
		if i > N-i {
			ans += dpf[i]
		}

	}
	fmt.Println(ans)
}


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

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

  rep(i,n+1) {
    rep(j,m+1) {
      if (i*j+(n-i)*(m-j) == k) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    if(a<b)
    {
        cout<<"0"<<endl;
    }
    else
    {
        cout<<"10"<<endl;
    }
    
    return 0;
}

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

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		int answer = (n - (h-1)) * (n - (w-1));
		System.out.println(answer);
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
    return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int n,a[100010];
signed main(){
    cin>>n;
    int ans=1;
    rep(i,n){
        cin>>a[i];
        if(i){
            if(a[i-1]>=a[i])ans++;
        }
    }
    cout<<ans<<endl;
    cout<<n<<endl;
    return 0;
}



Measured memory_bytes: 3904
def q2():
    from collections import deque
    sa = deque(list(input()))
    sb = deque(list(input()))
    sc = deque(list(input()))

    s = sa.popleft()
    while True:
        if s == 'a':
            if len(sa) == 0:
                return 'A'
            else:
                s = sa.popleft()
        elif s == 'b':
            if len(sb) == 0:
                return 'B'
            else:
                s = sb.popleft()
        elif s == 'c':
            if len(sc) == 0:
                return 'C'
            else:
                s = sc.popleft()


if __name__ == '__main__':
    print(q2())


Measured memory_bytes: 3316
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		cout << "x";
	}
	return 0;
}


Measured memory_bytes: 256
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args) {

            string s = Console.ReadLine();
            int x = 0;

            foreach(char c in s) {
                if(c == '+') {
                    x++;
                }
                else {
                    x--;
                }
            }

            Console.WriteLine(x);
        }
    }
}


Measured memory_bytes: 11092
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int A = scan.nextInt();
        int B = scan.nextInt();
        int[] groups = new int[3];
        for (int i = 0; i < N; i++) {
            int p = scan.nextInt();
            if (p <= A) {
                groups[0] += 1;
            } else if (B < p) {
                groups[2] += 1;
            } else {
                groups[1] += 1;
            }
        }
        System.out.println(Arrays.stream(groups).min().getAsInt());
    }
}


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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  int countr = 0;
  char R = 'R';
  char W = 'W';
  
  for(int i=0; i<N ;i++){
    if(S.at(i) == R){
      countr = countr+1;
    }
  }
  
  int countw = 0;
  for(int i=0; i<countr ; i++){
    if(S.at(i) == W){
      countw = countw + 1;
    }
  }
  
  cout << countw << endl;
  
}

Measured memory_bytes: 3736
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

class UnionFind:
    def __init__(self, n):
        self.d = [-1]*n
    
    def find(self, x):
        if self.d[x] < 0:
            return x
        else:
            self.d[x] = self.find(self.d[x])
            return self.find(self.d[x])
    
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return False
        if self.d[x] > self.d[y]:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True
    
    def same(self, x, y):
        if self.find(x)==self.find(y):
            return True
        return False
    
    def size(self, x):
        return (-1) * self.d[self.find(x)]

N = ii()

l_x = []
l_y = []
for i in range(N):
    x, y = mi()
    l_x.append([i, x])
    l_y.append([i, y])
l_x.sort(key=lambda x:x[1])
l_y.sort(key=lambda x:x[1])

path = []
for i in range(N-1):
    path.append([l_x[i][0], l_x[i+1][0], l_x[i+1][1]-l_x[i][1]])
    path.append([l_y[i][0], l_y[i+1][0], l_y[i+1][1]-l_y[i][1]])
path.sort(key=lambda x:x[2])

T = UnionFind(N)
cnt = 0
for i in range(2*N-2):
    s, t, d = path[i][0], path[i][1], path[i][2]
    if not T.same(s, t):
        T.unite(s, t)
        cnt += d

print(cnt)

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

using namespace std;
using namespace __gnu_pbds; 
#define     mod             1e9+7
#define     MOD             998244353
#define     ll              long long
#define     mp              make_pair
#define     F               first
#define     S               second
#define     t()             int test;cin>>test;while(test--)
#define     ii              pair<int,int>
#define     que_max         priority_queue <int>
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            "\n"
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif






 
int main()
 
{  
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    IOS;
    
   int n;
   cin>>n;
   std::vector<int> v(n);

   for(int i=0; i<n; i++)cin>> v[i];

   sort(v.begin(), v.end(), greater<int>()); 

   ll ans =0;

   ans += v[0];

   n -= 2;
   int i=1;
   while(n>=2)
   {
      ans +=2*v[i];
      n-=2;
      i++;
   }

   if(n)
   {
      ans += v[i];
   }
   cout<<ans<<endl;
   
}

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

int main() {
    int n;
    cin >> n;
    vector<string> S(n);
    for (int i = 0; i < n; i++)
        cin >> S[i];

    vector<int> cnt(26);
    string s = S[0];
    for (int i = 0; i < s.size(); i++)
        cnt[s[i] - 'a']++;

    for (int i = 1; i < n; i++) {
        string t = S[i];
        vector<int> c(26);
        for (int j = 0; j < t.size(); j++)
            c[t[j] - 'a']++;
        for (int j = 0; j < 26; j++)
            cnt[j] = min(cnt[j], c[j]);
    }

    string res = "";
    for (int i = 0; i < 26; i++) {
        if (cnt[i]) {
            for (int j = 0; j < cnt[i]; j++) {
                res += i + 'a';
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, X = MAP()

# 最初のN以外は、平行四辺形を小さくしていくと考える
def rec(a, b):
    if b == 0:
        # 最後に割り切れた時は半分でいいので減らす
        return -a
    a, b = min(a, b), max(a, b)
    # 同じだけ小さくする所はまとめてやる
    return a*2*(b//a) + rec(a, b%a)

print(N+rec(X, N-X))


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

int main() {
  string S;
  cin >> S;
  int result;
  if (S == "MON") result = 6;
  else if (S == "TUE") result = 5;
  else if (S == "WED") result = 4;
  else if (S == "THU") result = 3;
  else if (S == "FRI") result = 2;
  else if (S == "SAT") result = 1;
  else if (S == "SUN") result = 7;
  cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define FOR(i, n) for (int i = 0; i < (int)(n); i++)
const int MAX_N = 210000;
using namespace std;
using ll = long long;

int main() {
  ll N, K;

  cin >> N >> K;

  vector<ll> A(N + 1, 0);
  FOR(i, N) cin >> A[i];

  // 何番目か
  vector<int> ord(N + 1, -1);
  //　頂点の保存
  vector<int> s;

  // cは周期 lはループ前の長さ
  int c = 1, l = 0, v = 1;
  while (ord[v] == -1) {
    ord[v] = s.size();
    s.emplace_back(v);
    v = A[v - 1];
  }
  c = s.size() - ord[v];
  l = ord[v];

  if (K < l)
    cout << s[K] << endl;
  else {
    K -= l;
    K %= c;
    cout << s[l + K] << endl;
  }
  return 0;
}


Measured memory_bytes: 6668
#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>;

int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
  return 0;
}


Measured memory_bytes: 3620
n = int(input())
D={}
for i in range(n):
	a = input()
	if a in D:
		D[a]+=1
	else:
		D[a]=1

m = max(D.values())
ans=[]
for key in D:
	if D[key]==m:
		ans.append(key)

ans.sort()
for i in ans:
	print(i)

Measured memory_bytes: 32096
#include <bits/stdc++.h>
#include <string>
using namespace std;
//#define scl(n) scanf("%d", &n);
//#define pcl(n) printf("%d\n", n)
//#define pcl1(n) printf("%lld ", n)
//;
int main()
{
	int x, n,p;
	cin>>x;
	cin>>n;
	int arr[102]= {0};
	for (int i = 0; i < n; i++)
	{
		//int p;
		cin>>p;
		arr[p] = p;
	}
	int z = 120, res = 0;
	if (n > 0)
	{
		for (int j = 0; j <= 101; j++)
		{
			if (arr[j]==0)
			{
				int px = abs(x - j);
				if (px < z)
				{
					z = px;
					res = j;
					//cout<<res<<endl;
				}
			}
		}
		cout<<res<<endl;
	}
	else
		cout << x << endl;
	return 0;
}

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

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

ll H,W,K;
ll ans = 0;

cin >> H >> W >> K;

vector<string> c(H);

vector<ll> arrW(H,0);
vector<ll> arrH(W,0);

for(ll i = 0;i < H;++i) cin >> c[i];

for(ll h = 0;h < (1<<H);++h) {
  for(ll w = 0;w < (1<<W);++w) {
    ll count = 0;
    for(ll i = 0;i < H;++i){
      for(ll j = 0;j < W;++j){

        if(h>>i & 1) continue;
        if(w>>j & 1) continue;
        if(c[i][j] == '#') ++count;

      }
    }
    if(count == K) ++ans;
  }
}

cout << ans << endl;

return 0;

}   


Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())

x = [0]*n
y = [0]*n
for i in range(n):
    xx,yy= map(int, input().split())
    x[i] = xx-1
    y[i] = yy-1

if n==1:
    print(1)
    exit()

from collections import defaultdict
d = defaultdict(lambda:0)

for i in range(n):
    for j in range(n):
        if i==j:continue

        p = x[j]-x[i]
        q = y[j]-y[i]

        d[p*10**9+q] +=1

dv = d.values()
mad =max(dv)

print(n-mad)


Measured memory_bytes: 39152
#include <stdio.h>
int main(void)
{
    char s1[101], s2[101], s3[101], a[4];

    scanf("%s%s%s", s1, s2, s3);

    a[0]=s1[0];
    a[1]=s2[0];
    a[2]=s3[0];
    a[3]='\0';

    printf("%s\n", a);
   
  
    return 0;
}


Measured memory_bytes: 128
x1, y1, x2, y2 = map(int, input().split())

xv_12, yv_12 = x2-x1, y2-y1
xv_23, yv_23 = yv_12*-1, xv_12
xv_34, yv_34 = yv_23*-1, xv_23

x3, y3 = x2+xv_23, y2+yv_23
x4, y4 = x3+xv_34, y3+yv_34

print(x3, y3, x4, y4)



Measured memory_bytes: 9164
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int TEN(int n) {return (n==0)?1:10*TEN(n-1);}

template<class T>
T pow(T x, ll n) {
    T r = 1;
    while (n) {
        if (n & 1) r *= x;
        x *= x;
        n >>= 1;
    }
    return r;
}

template<uint MD>
struct ModInt {
    uint v;
    ModInt() : v{0} {}
    ModInt(ll v) : v{normS(v%MD+MD)} {}
    static uint normS(const uint &x) {return (x<MD)?x:x-MD;};
    static ModInt make(const uint &x) {ModInt m; m.v = x; return m;}
    const ModInt operator+(const ModInt &r) const {return make(normS(v+r.v));}
    const ModInt operator-(const ModInt &r) const {return make(normS(v+normS(MD-r.v)));}
    const ModInt operator*(const ModInt &r) const {return make((ull)v*r.v%MD);}
    ModInt& operator+=(const ModInt &r) {return *this=*this+r;}
    ModInt& operator-=(const ModInt &r) {return *this=*this-r;}
    ModInt& operator*=(const ModInt &r) {return *this=*this*r;}
    static ModInt inv(const ModInt &x) {
        return pow(ModInt(x), MD-2);
    }
};
using Mint = ModInt<TEN(9)+7>;

const int MN = 4000400;
Mint fact[MN], iFac[MN];

void first() {
    fact[0] = 1;
    for (int i = 1; i < MN; i++) {
        fact[i] = fact[i-1]*i;
    }
    iFac[MN-1] = Mint::inv(fact[MN-1]);
    for (int i = MN-2; i >= 0; i--) {
        iFac[i] = iFac[i+1]*(i+1);
    }
}

Mint C(int n, int k) {
    return fact[n]*iFac[n-k]*iFac[k];
}

Mint csm(int i, int j);

int n, K;
Mint dp[2020][2020];
bool used[2020][2020];
Mint calc(int i, int j) {
    if (j < i) return 0;
    if (i == n) return 1;
    if (used[i][j]) return dp[i][j];
    used[i][j] = true;
    int a = (n-i)*K;
    int b = n-j;
    Mint off = C(a+b+K-1, K-1);
    Mint ans = 0;
/*    for (int k = j; k <= n; k++) {
        ans += calc(i+1, k);
    }*/
    ans += csm(i+1, j);
    return dp[i][j] = ans*off;
}

Mint dp2[2020][2020];
bool used2[2020][2020];
Mint csm(int i, int j) {
    if (j == n+1) return 0;
    if (used2[i][j]) return dp2[i][j];
    used2[i][j] = true;
    return dp2[i][j] = (calc(i, j) + csm(i, j+1));
}

Mint solve() {
    if (K == 1) {
        return 1;
    }
    K--;
    Mint ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += calc(1, i);
    }
    return ans*fact[n];
}

int main() {
    first();
    cin >> n >> K;
    cout << solve().v << endl;
    return 0;
}

Measured memory_bytes: 71552
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;
const double PI = 3.14159265359;

int main()
{
    int N, M; cin >> N >> M;
    vector<int> ballNums(N, 1);
    vector<bool> redExists(N, false);
    redExists[0] = true;
    for (int i = 0; i < M; ++i)
    {
        int x, y; cin >> x >> y; --x; --y;
        --ballNums[x];
        ++ballNums[y];
        if (redExists[x])
        {
            redExists[y] = true;
            if (ballNums[x] == 0) redExists[x] = false;
        }
    }
    cout << count(redExists.begin(), redExists.end(), true) << endl;
}


Measured memory_bytes: 3732
n = int(input())
l = [input().split() for i in range(1,n+1)]

for i in range(1,n+1):
    l[i-1].append(i)
#print(l)

for i in range(n):
    l[i][1] = (int(l[i][1]))*(-1)
#print(sorted(l))
sl = sorted(l)

#ans = sorted(l.sort(),reverse = True, key = lambda x:x[1])
#print(ans)

for i in range(n):
    print(sl[i][2])

Measured memory_bytes: 8920
/**
 * @author: shashankchdhry
 * @made:   2020-04-02 20:19:42 
**/
#include <bits/stdc++.h>

using namespace std;

inline void add_direction(string &, string, int);

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

    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    string ans;
    add_direction(ans, "U", y2-y1);
    add_direction(ans, "R", x2-x1);
    add_direction(ans, "D", y2-y1);
    add_direction(ans, "L", x2-x1);

    add_direction(ans, "L", 1);
    add_direction(ans, "U", y2-y1+1);
    add_direction(ans, "R", x2-x1+1);
    add_direction(ans, "D", 1);
    add_direction(ans, "R", 1);
    add_direction(ans, "D", y2-y1+1);
    add_direction(ans, "L", x2-x1+1);
    add_direction(ans, "U", 1);

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

void add_direction(string &str, string temp, int no_of_times)
{
    for (int i = 0; i < no_of_times; i++)
        str += temp;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if(a<b){
      for (int i = 0; i < b; i++)
      {
          cout << a;
      }
      
  }else{
      for (int i = 0; i < a; i++)
      {
          cout << b;
      }
  } 
  cout << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

long long calc(long long A) {
  long long sum = (A+1)/2;
  long long ans = sum%2;
  if (A%2 == 0){
    return ans^A;
  } else {
   return ans;
  }
}

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

  long long A; cin >> A;
  long long B; cin >> B;

  cout << (calc(B)^calc(A-1)) << endl;
}

Measured memory_bytes: 256
#include<string.h>
#include<math.h>
int main()
{
    int n,a,b,c;
    scanf("%d",&n);
            a=n/100;
            b=(n%100)/10;
            c=n%10;
            if(a==c)
                printf("Yes\n");
            else
                printf("No\n");

}

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

typedef long long ll;
typedef long double lld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
typedef pair<ll, ll> pll;
typedef pair<ll, pair<ll, ll>> plll;

void solve()
{
  ll n;
  cin >> n;
  if (n % 2 == 0 || n % 5 == 0)
  {
    cout << -1 << endl;
    return;
  }
  ll num = 7;
  ll ans = 1;
  while (1)
  {
    if (num % n == 0)
    {
      cout << ans << endl;
      return;
    }
    ans++;
    num = (num * 10 + 7) % n;
  }
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

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

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#include <string>
#include <vector>

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

int main() {
    int ans, n, k;
    cin >> n >> k;
    vector<int> h(n);

    rep(i, n) cin >> h.at(i);

    ans = 0;
    rep(i, n) {
        if (h[i] >= k) {
            /* code */
            ans++;
        }
    }
    cout << ans;
}

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

int main(){

  int n;
  cin>>n;

  int card[4][13] = {};
  for(int i=0;i<n;i++){
    string suit;
    int num;
    cin>>suit>>num;

    if(suit == "S") card[0][num-1] = 1;
    if(suit == "H") card[1][num-1] = 1;
    if(suit == "C") card[2][num-1] = 1;
    if(suit == "D") card[3][num-1] = 1;
  }

  string str[4] = {"S", "H" , "C", "D"};
  for(int i=0;i<4;i++){
    for(int j=0;j<13;j++){
      if(card[i][j] == 1) continue;
      cout<<str[i]<<" "<<j+1<<endl;
    }
  }

  
  return 0;
}



Measured memory_bytes: 3144
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
using namespace std;
int main()
{
    int n; cin >> n;
    vector< int > v(n);
    for(int i=0;i<n;i++) cin >> v[i];

    int result = v[0];
    for(int i=1;i<v.size();i++)
        result^=v[i];

    for(int i=0;i<v.size();i++)
    {
        cout << (result^v[i]);

        if(i==v.size()-1)
            cout << endl;
        else
            cout << " ";
    }




    #ifdef TarekHasan
        //main();
    #endif // TarekHasan

    return 0;
}



Measured memory_bytes: 3552
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s;
    cin >> s;
    if ((s[0]==s[1] && s[1]==s[2]) || (s[1]==s[2] && s[2]==s[3])) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 *
 * @author 97797
 */
public class Main {
     public static void main(String[] args) {
        System.out.println(new Main().run(args, System.in));
    }
    public String run(String[] args, InputStream in) {
        String result = null;
        try {
            
            BufferedReader reader = new BufferedReader(new InputStreamReader(in));
            int N = Integer.parseInt(reader.readLine());
            
            List<Integer> list = reader.lines()
                    .flatMap(s -> Stream.of(
                            s.replaceAll("\\s+", " ").split(" ")))
                    .limit(N).map(Integer::parseInt)
                    //.sorted(Comparator.reverseOrder())
                    .sorted()
                    .collect(Collectors.toList());
            int min = list.get(0);
            int max = list.get(N-1);
            result = String.valueOf(max-min);
        } catch (IOException ex) {

        }
        return result;
    }   
}


Measured memory_bytes: 26836
n, m, k = map(int, input().split())
set_num = set([])
for n_i in range(n + 1):
    for m_i in range(m + 1):
        set_num.add((n_i * m) + (m_i * n) - ((n_i * m_i) * 2))
if k in set_num:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 20892
N, M = map(int, input().split())
SC = []
for i in range(M):
    SC.append(list(map(int, input().split())))
flag = 0
a = ""
A = [[] for row in range(N)]
for i, S in enumerate(SC):
    if not (str(S[1]) in A[S[0]-1]):
        A[S[0]-1].append(str(S[1]))
for i in range(0,N):
    if len(A[i]) == 0:
        if i == 0 and N>1:
            a += "1"
        else:
            a += "0"
    elif i==0 and A[i][0] == "0"  and N>1:
        flag = 1
        break
    elif len(A[i]) == 1:
        a += A[i][0]
    else:
        flag = 1
        break

if flag == 1:
    print(-1)
else:
    print(int(a))

Measured memory_bytes: 3064
import java.util.Scanner;

abstract class Product {
	
	public abstract Integer calc(Integer x);
}

abstract class Factory {
	
	public Product create() {
		
		return createProduct();
	}
	
	protected abstract Product createProduct();
}

class Xcubic extends Product {

	@Override
	public Integer calc(Integer x) {
		
		return x * x * x;
	}
	
}

class XCubicFactory extends Factory {

	@Override
	protected Product createProduct() {
		
		return new Xcubic();
	}
	
}
public class Main {

	public static void main(String[] args) {
		
		System.out.println(new XCubicFactory().create().calc(Integer.parseInt(new Scanner(System.in).next())));

	}

}



Measured memory_bytes: 26132
import sys
input = sys.stdin.readline
from operator import itemgetter

lis = []
n = 0
m = 0
ans = 0

def dfs(i, d, fr, used):
    global lis, ans
    if i in used:
        return
    if d == n - 1:
        ans += 1
        return
    for j in lis[i]:
        if j != fr:
            used.append(i)
            # print(i+1 , j+1)
            dfs(j, d+1, i, used)
            used.pop()


def main():
    global lis, n, m, ans
    n, m = map(int, input().strip().split())
    lis = [[] for _ in range(8)]
    for _ in range(m):
        a, b = list(map(lambda x: x-1, map(int, input().strip().split())))
        lis[a].append(b)
        lis[b].append(a)
    # print("##")
    dfs(0, 0, -1, [])
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 44600
#include<stdio.h>
int main()
{
    int A,P;
    scanf("%d%d",&A,&P);
    while(0<=A,P<=100){
    if(A*3+P>2){
        printf("%d",(A*3+P)/2);
        break;
    }
    else {
        printf("0");
         break;
    }
}
}

Measured memory_bytes: 2128
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

struct edge{__int128 from, to, cost;};

int main(void) {
	ll N, M;
	cin>>N>>M;
	vector<__int128> d(N, -INF);
	vector<edge> es(M);
	REP(i, M) {
		ll a, b, c;
		cin>>a>>b>>c;
		--a;
		--b;
		edge e = {a, b, c};
		es[i] = e;
	}
	d[0] = 0;
	__int128 cnt = 0;
	ll cnthoge = 0;
	bool f = false;
	while(true) {
		if(f || d[N - 1] > 10000000000000 || d[N - 1] < -10000000000000 && d[N - 1] != -INF || cnt > 10000) {
			f = true;
			break;
		}
		bool update = false;
		REP(i, es.size()) {
			edge e = es[i];
			if(d[e.from] != -INF && d[e.to] < d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				if(e.to == N - 1) ++cnthoge;
				if(d[e.to] > 10000000000000 || d[e.to] < -10000000000000) {
					f = true;
					break;
				}
				update = true;
			}
		}
		if(!update) break;
		++cnt;
	}
	if(f && cnthoge > 1000)cout<<"inf"<<endl;
	else {
		if(d[N - 1] == -INF) {
			cout<<0<<endl;
		} else {
			ll ans = d[N - 1];
			cout<<ans<<endl;
		}
	}
}


Measured memory_bytes: 384
def d_grid_Coloring(H, W, N, A):
    # 方針:数字を「うなぎ」のようにくねくね並べれば、
    # 条件を満たすものが1つ見つかる

    # 1から順にそれで塗る回数だけ書き込む
    tmp = []
    for i, a in enumerate(A):
        tmp.extend([str(i + 1)] * a)
    # tmpをW文字ごとに分割
    tmp = [tmp[i:i + W] for i in range(0, len(tmp), W)]
    # 奇数行目は「折り返す」
    tmp = [row if i % 2 == 0 else row[::-1] for i, row in enumerate(tmp)]

    # 出力形式に合わせて整形
    ans = ''
    for s in tmp:
        ans += ' '.join(s)
        ans += '\n'
    ans = ans[:-1]
    return ans

H,W = [int(i) for i in input().split()]
N = int(input())
A = [int(i) for i in input().split()]
print(d_grid_Coloring(H, W, N, A))

Measured memory_bytes: 3828
/* -> Written by <-
   -----------
  |K_A_Z_A_M_A|
  |___________|
  |    ___    |
  |   (^_^)   |
  |  /( | )\  |
  |____|_|____|
    H O A N G
*/

// i hope i get better

// Task name:
#define Task ""
using namespace std;

// Include
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <string>
#include <sstream>
#include <cstdio>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>

// Define
#define reset(x, value) memset((x), (value) ,sizeof((x)))
#define fr(i,a,b) for(int i = (a); i <= (b); i++)
#define FR(i,a,b) for(int i = (a); i < (b); i++)
#define frr(i,a,b) for(int i = (a); i >= (b); i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define nl "\n"
#define bit(x,i) (x >> i) & 1
#define all(x) (x).begin(), (x).end()
#define optimize(x) (x).resize(unique(all(x)) - (x).begin())
#define Inpf freopen(Task".inp","r",stdin)
#define Outf freopen(Task".out","w",stdout)
#define fasterIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

// typedef
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vii;
typedef vector<ll> vll;

const int base = 131;
const int MOD = 1e9 + 7;
const ll MM = 1ll * MOD * MOD;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

void AddMOD(int &x, int y)
{
    x += y;
    if (x >= MOD)
        x -= MOD;
}
int Gcd(int x, int y)
{
    if (y == 0)
        return x;
    return Gcd(y, x % y);
}
template <class T> inline void Gmax(T &x,T y)
{
    x = max((x), (y));
}
template <class T> inline void Gmin(T &x,T y)
{
    x = min((x), (y));
}

void exit_with_runtime()
{
    db x = 1.0 * clock() / CLOCKS_PER_SEC;
    cerr << "\n\n---------------------\nTime elapsed: " << x << " s.\n\n";
    if (x > 1)
        cerr << "TIME LIMIT EXCEEDED!\n\n";
    exit(0);
}

// --------------------------------------------------------------------
const int maxn = 2e5 + 5;
// --------------------------------------------------------------------

void Solve()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i ++)
    {
        if (i % 2 == 0 && s[i] == 'L')
        {
            cout << "No";
            return;
        }
        if (i % 2 == 1 && s[i] == 'R')
        {
            cout << "No";
            return;
        }
    }
    cout << "Yes";

}

int main()
{
#ifndef ONLINE_JUDGE
//    Inpf;
//    Outf;
#endif // ONLINE_JUDGE
    fasterIO;
    int test = 1;
//    cin >> test;
    while (test --)
        Solve();

    // Did you check with the special test case n = 0, n = 1??
    exit_with_runtime();
}

// Goodbye, see u again


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve(args);
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve(string[] args)
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();


			int n = int.Parse(Console.ReadLine());
			int ac = 0, wa = 0, tle = 0, re = 0;
			for (int i = 0; i < n; i++) {
				string s = Console.ReadLine();
				switch (s) {
					case "AC":
						ac++;
						break;
					case "WA":
						wa++;
						break;
					case "TLE":
						tle++;
						break;
					case "RE":
						re++;
						break;
				}
			}
			Console.WriteLine($"AC x {ac}");
			Console.WriteLine($"WA x {wa}");
			Console.WriteLine($"TLE x {tle}");
			Console.WriteLine($"RE x {re}");
		}
	}
}


Measured memory_bytes: 30644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s, t;
    cin >> s >> t;
    vector<vector<int>> v(26);
    int n = s.size();
    int m = t.size();
    rep(i, 0, n) v[s[i] - 'a'].push_back(i);
    rep(i, 0, n) v[s[i] - 'a'].push_back(i + n);
    ll ans = 0;
    int p = 0;
    rep(i, 0, m) {
        int c = t[i] - 'a';
        if ((int)v[c].size() == 0) {
            cout << -1 << endl;
            return 0;
        }
        p = *lower_bound(all(v[c]), p) + 1;
        if (p > n) {
            p -= n;
            ans += n;
        }
    }
    ans += p;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1724
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int n; cin >> n;
    string s;
    cin >> s;
    typedef pair<string, int> psi;
    vector<psi> arr;
    for (int i = 0; i < n; i++) {
        arr.push_back(psi(s.substr(i), i));
    }
    sort(arr.begin(), arr.end());
    int ans = 0;
    vector<int> height(n);
    for (int i = 0; i + 1 < n; i++) {
        const string &now = arr[i].first;
        const string &next = arr[i + 1].first;
        int tmp = 0;
        for (int j = 0; j < now.length() && j < next.length();) {
            if (now[j] == next[j]) {
                tmp++;
                j++;
            } else {
                break;
            }
        }
        height[i] = tmp;
    }
    for (int tmp = 1; tmp < n; tmp++) {
        bool check = false;
        int min_i = 1E9, max_i = -1E9;
        for (int i = 0; i < n; i++) {
            if (height[i] >= tmp) {
                min_i = min(min_i, arr[i].second);
                min_i = min(min_i, arr[i + 1].second);
                max_i = max(max_i, arr[i].second);
                max_i = max(max_i, arr[i + 1].second);
            } else {
                if (tmp <= max_i - min_i) {
                    check = true;
                    break;
                }
                min_i = 1E9;
                max_i = -1E9;
            }
        }
        if (check) {
            ans = tmp;
        } else {
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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


int main()
{
    ll n, m;
    cin >> n >> m;
    priority_queue<ll, vector<ll>, less<ll>> a;
    for(ll i = 0; i < n; i++){
        ll temp;
        cin >> temp;
        a.push(temp);
    }
    for(ll i = 0; i < m; i++){
        ll temp = a.top();
        a.pop();
        temp /= 2;
        a.push(temp);
    }

    ll ans = 0;
    while(!a.empty()){
        ans += a.top();
        a.pop();
    }
    cout << ans << endl;


}

Measured memory_bytes: 1400
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>

int main(void)
{
	int H, W;

	int i, j;


	while (1) {

		scanf("%d %d", &H, &W);

		if (H == 0 && W == 0)
			break;
		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				printf("#");
			}printf("\n");
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2604
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <string>

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

using namespace std;
int N, M;

int main()
{
    scanf("%d %d", &N, &M);
    vector<int> V;
    FOR(i, 1, int(sqrt(M))+2) {
        if(M%i==0) {
            V.push_back(i);
            V.push_back(M/i);
        }
    }
    sort(V.begin(), V.end());
    int ans;
    for(auto v: V) {
        if(M/v<N)
            break;
        else
            ans = v;
    }
    printf("%d\n", ans);
    return 0;
}


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

template<typename T>
vector<T> Divisors(T n)
{
    vector<T> result;

    T boundary = sqrt(n);

    for (T i = 1; i <= boundary; i++) {
        if (n % i == 0) {
            result.push_back(i);
            if(i != (n / i) && i * i != n)
                result.push_back(n/i);
        }
    }
    sort(result.begin(),result.end());
    reverse(result.begin(),result.end());
    return result;
}

int main(){
    long long n,m,ans;
    cin >> n >> m;
    long long hoge = m;
    //vector<long long> yakusuu;
    auto v = Divisors<long long>(m);
    for(int i = 0;i<v.size();i++){
        cerr << v[i] << endl;
        if(m/v[i] >= n){
            ans = v[i];
            break;
        }
    }

    cout << ans<<endl;
}

Measured memory_bytes: 256
import math
def main():
  K = int(input())
  ans = 0
  for i in range(1,K+1):
    for j in range(1,K+1):
      for k in range(1,K+1):
        ans += math.gcd(math.gcd(i,j),k)
  print(ans)
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 9204
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)

using namespace std;


int main(){
	for(;;){
		int n;
		cin >> n;
		if(n==0) break;
		vector<string> es;
		
		rep(i, n){
			string s;
			cin >> s;
			es.push_back(s);
		}
		stack<int> s;
		int lv = 0;
		rrep(i, n){
			int l = 0;
			for(;es[i][l] == '.'; ++l);
			for(;lv<l; lv++) s.push(-1);

			if(es[i][l] == '+'){
				int v = 0;
				for(; !s.empty(); ){
					if(s.top() == -1){
						s.pop();
						break;
					}
					v += s.top(); s.pop();
				}
				s.push(v);
			}else if(es[i][l] == '*'){
				int v = 1;
				for(; !s.empty(); ){
					if(s.top() == -1){
						s.pop();
						break;
					}
					v *= s.top(); s.pop();
				}
				s.push(v);
			} else {
				s.push(es[i][l] - '0');
			}
			lv = l;
		}
		//cerr << "# " << s.size() << endl;
		cout << s.top() << endl;
	}


	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  bool tri = false;
  for (int i=0; i<n; i++) {
    int a, b;
    cin >> a >> b;
    if (a == b)
      cnt++;
    else
      cnt = 0;
    if (cnt >= 3) {
      tri = true;
      break;
    }
  }
  if (tri) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=1;i<=n;i++)

int main(){
    int n; cin >> n;
    cout << n*n;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<pair<int,int> > vp;
#define pb push_back
#define mp make_pair
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int l, n;
	cin>>l;
	for(int i=20;i>=0;i--){
		if((1<<i) <= l){
			n = i+1;
			break;
		}
	}	
	l -= (1<<(n-1));
	vector<pair<int,pair<int,int> > > edges;
	int cur = 0;
	for(int i=0;i<n-1;i++){
		edges.pb(mp(cur, mp(i, i+1)));
		edges.pb(mp(1<<i,mp(i,i+1)));
	}
	int val = (1<<(n-1));
	int pw = 21;
	while(pw--){
		if(1<<(pw) <= l){
			edges.pb(mp(val, mp(pw,n-1)));
			l -= (1<<pw);
			val = val + (1<<pw);
		}
	}
	cout<<n<<" "<<edges.size()<<'\n';
	for(int i=0;i<edges.size();i++){
		cout<<edges[i].second.first+1<<" "<<edges[i].second.second+1<<" "<<edges[i].first<<'\n';
	}
}

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

main(){
	int n ;
	while( cin >> n , n ){
		int p=1000 , cnt=0 ;
		int c[4] = {} ;
		for( int i=0 ; i<4 ; i++ ){
			c[i] = n/p ;
			n -= c[i] * p ;
			p /= 10 ;
		}
		n = 0 ;
		for( int i=0 ; i<4 ; i++ ){
			if( c[0] == c[i] ) cnt++ ;
			n += c[3-i] * pow(10,i) ;
		}
		
		if( cnt == 4 ) cout << "NA" << endl ;
		else {
			cnt = 0 ;
			while(n-6174){
				sort(c,c+4) ;
				int mx=0 , mn=0 ;
				for( int i=0 ; i<4 ; i++ ) mx += c[i] * pow(10,i) ;
				for( int i=0 ; i<4 ; i++ ) mn += c[3-i] * pow(10,i) ;
				n = mx - mn ;
				p = 1000 ;
				for( int i=0 ; i<4 ; i++ ){
					c[i] = n/p ;
					n -= n/p * p ;
					p /= 10 ;
				}
				n = mx - mn ;
				cnt++ ;
			}
			cout << cnt << endl ;
		}
	}
}

Measured memory_bytes: 1228
/*map,set,priority_queue,stack,queue*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define el "\n"
#define pb push_back
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
typedef vector<int> vi;
const int inf = (1e18)+7;
const int neginf = -1*((int)1e18 ) + 7 ;
const int mod = (int)1e9 + 7;
//const int N = 500007;
/*int arr[N];
vector<int> adj[N];

void dfs(int x,int par)
{
    arr[x]+=par;
    arr[par] = 0;
    for(auto child:adj[x])
    {
        if(child==par)
            continue;
        dfs(child,x);
    }
}
*/

int32_t main() 
{
fastio
    int t=1;
    //cin>>t;
    while(t--)
    {
       int a,b;
        cin>>a>>b;
        int ans = a*b;
        if(a<=9&&b<=9)
            cout<<a*b;
        else
            cout<<"-1";
        
    }
    
    
    return 0;
}


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

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


  int count=0;
  for(int i=1;i<=m;i++){
    for(int j=1;j<=d;j++){
      int d1 =j%10;
      int d10=j/10;
      if(d1>=2&&d10>=2&&d1*d10==i) {
        //cout<<d1<<" "<<d10<<" "<<i<<endl;
        count++;
      }
    }
  }

cout<<count<<endl;
}


Measured memory_bytes: 256
//
//  main.cpp
//  ABC
//
//  Created by Amarsanaa Davaasuren on 2019/08/31.
//  Copyright © 2019 Amarsanaa Davaasuren. All rights reserved.
//
# include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define rn return
typedef std::pair<int,int> P;

using namespace std;
using ll = long long;

int main(){
    int N,M; cin >> N >> M;
    P a[M];
    rep(i,M) cin >> a[i].first >> a[i].second;
    sort(a,a+M);
    int ans = 1;
    int right_limit = a[0].second;
    FOR(i,1,M){
        if (a[i].first >= right_limit){
            ans++;
            right_limit = a[i].second;
        }
        else right_limit = min(a[i].second,right_limit);
    }
    cout << (ans == 0 ? 1 : ans);
    
    rn 0;
}



Measured memory_bytes: 1024