akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

const long long int MOD = 1e9 + 7;

long long int dfs(int K, const vector<vector<int>>&graph, int now, int from){

    int can_use_color_num;
    if(from == -1){
        can_use_color_num = K - 1;
    }else{
        can_use_color_num = K - 2;
    }
    if(K < graph[now].size()){
        return 0;
    }else{
        long long int case_num = 1;
        for(auto e: graph[now]){
            if(e == from) continue;

            case_num *= can_use_color_num;
            can_use_color_num--;
            case_num %= MOD;
        }
        for( auto e: graph[now]){
            if(e == from) continue;
            case_num *= dfs(K, graph, e, now);
            case_num %= MOD;
        }
        return case_num;
    }
}

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

    vector<vector<int>> graph(N);
    for(int i = 0; i < N - 1; i++){
        int a, b; cin >> a >> b;a--, b--;

        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    long long int answer = K * dfs(K, graph, 0, -1);
    answer %= MOD;
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 11520
import java.util.*;
public class Main{
	
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String s = sc.next();
      if((s.length()>=3)&&(s.length()<=20)){
        String ans=s.substring(0,3);
		System.out.println(ans);
      }
    }
}

Measured memory_bytes: 26996
alpha = 'abcdefghijklmnopqrstuvwxyz'
alp_num = dict(zip(alpha,range(26)))
num_alp = dict(zip(range(26),alpha))
alp_num[' ']=' ' ; num_alp[' ']=' ' ; alp_num['.']='.' ; num_alp['.']='.'
while True:
	try:
		cipher = raw_input()
		numcipher = [alp_num[val] for val in cipher]
		while True:
			cipher = ''
			for val in numcipher: cipher += str(num_alp[val])
			if 'the'in cipher or 'this'in cipher or 'that'in cipher:
				print cipher; break
			else: 
				numcipher2 = []
				for val in numcipher:
					if val == ' ': numcipher2.append(' ')
					elif val == '.': numcipher2.append('.')
					elif val == 25: numcipher2.append(0)
					else: numcipher2.append(val+1)
				numcipher = numcipher2
				continue
	except: break

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

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	int d, t, s; cin >> d >> t >> s;
	cout << (s * t >= d ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
	int n,a,b;
	cin>>n>>a>>b;
	if((b-a)%2)cout<<"Borys"<<endl;
	else cout<<"Alice"<<endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,x;
	cin >> n >> x;
	vector<ll> v(n);
	for(int i=0;i<n;i++) cin >> v[i];
	sort(v.begin(),v.end());
	int tot = 0,i=0;
	for(i=0;i<n;i++)
	{
		if(x>=v[i])
		{
			 x-=v[i];
			 tot++;
		}
		else break;
	}
	if(x>0 and tot>0 and i==n) tot--;
	cout << tot << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 200005
using namespace std;
typedef pair <int,int> P;
typedef long long int ll;

vector <int> vec[SIZE];
queue <int> vb,vw;
int ans[SIZE];

void dfs(int v=0,int p=-1,int d=0)
{
	if(d%2==0) vb.push(v);
	else vw.push(v);
	for(int i=0;i<vec[v].size();i++)
	{
		int to=vec[v][i];
		if(to!=p) dfs(to,v,d+1);
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);a--,b--;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	dfs();
	if(vb.size()<vw.size()) swap(vb,vw);
	for(int i=1;i<=n;i++)
	{
		if(i%3==1)
		{
			int v=vb.front();vb.pop();
			ans[v]=i;
		}
	}
	if(vb.size()<vw.size()) swap(vb,vw);
	for(int i=1;i<=n;i++)
	{
		if(i%3==2)
		{
			int v=vb.front();vb.pop();
			ans[v]=i;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(i%3==0)
		{
			int v;
			if(!vb.empty()) {v=vb.front();vb.pop();}
			else {v=vw.front();vw.pop();}
			ans[v]=i;
		}
	}
	for(int i=0;i<n;i++) printf("%d ",ans[i]);puts("");
	return 0;
}

Measured memory_bytes: 19072
#include <iostream>
using namespace std;
typedef long long ll;

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

ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a / g * b;
}


// verified
//   https://onlinejudge.u-aizu.ac.jp/courses/library/6/NTL/1/NTL_1_C
void AOJ_NTL_1_C() {
    int n;
    cin >> n;
    int ans = 1;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        ans = lcm(ans, a);
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 3112
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;

int main()
{
	int a,b;
    cin>>a>>b;
    cout<<6-a-b;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int d, n;
    cin >> d >> n;
    for (int i = 1; true; i++) {
        int count = 0;
        int x = i;
        while (x % 100 == 0) {
            count++;
            x /= 100;
        }
        if (count == d) {
            n--;
            if (n == 0) {
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}

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

struct mint{
    // 自動的にmodを取ってくれるクラスです。
    ll x;
    mint(ll x = 0):x(x%mod){}

    mint& operator+=(const mint a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a){
        if((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if(!t) return 1;
        mint b = pow(t/2);
        b *= b;
        if(t%2 == 1) b *= *this;
        return b;
    }

    mint inv() const{
        return pow(mod-2);
    }
    mint& operator/=(const mint a){
        (*this) *= a.inv();
        return *this;
    }
    mint operator/(const mint a) const{
        mint res(*this);
        return res/=a;
    }

};

int main(){
    ll n;
    cin >> n;
    mint u(10);
    mint w(8);
    mint y(9);
    mint juu = u.pow(n);
    mint kyuu =y.pow(n);
    mint hati = w.pow(n);
    mint ans = juu-hati;
    ans -= (kyuu-hati);
    ans -= (kyuu-hati);
    cout << ans.x << endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>

using namespace std;

int n, W;
int v[10001], w[10001], m[10001];
int dp[2][10001];
int ct = 0;

int main() {
	cin >> n >> W;
	for (int i = 0; i < n; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		//press
		while (c > 0) {
			for (int i = 1; i <= c; (i <<= 1)) {
				v[ct] = i * a, w[ct] = i * b;
				c -= i, ct++;
			}
		}
	}
	for (int i = 0; i < ct; i++) {
		for (int j = 0; j <= W; j++) {
			if (j < w[i])dp[(i + 1) % 2][j] = dp[i % 2][j];
			else dp[(i + 1) % 2][j] = max(dp[i % 2][j], dp[i % 2][j - w[i]] + v[i]);
		}
	}
	cout << dp[ct % 2][W] << endl;
	return 0;
}

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

const int MAXN = 2005;
const ll Mod = 1e9+7;
ll dp[MAXN][MAXN];
int N, M;
int S[MAXN], T[MAXN];

void solve() {
  for (int i = N-1; i >= 0; --i) {
    for (int j = M-1; j >= 0; --j) {
      dp[i][j] += dp[i+1][j] + dp[i][j+1] - dp[i+1][j+1];
      dp[i][j] = (dp[i][j] + Mod) % Mod;
      if (S[i] == T[j]) dp[i][j] += dp[i+1][j+1] + 1;
      dp[i][j] %= Mod;
    }
  }
  ll ans = (dp[0][0]+1) % Mod;
  cout << ans << endl;
}

int main() {
  cin >> N >> M;
  rep(i, N) cin >> S[i];
  rep(i, M) cin >> T[i];
  solve();
  return 0;
}

Measured memory_bytes: 31616
import math

class Ufo:
  def __init__(self, x, y, r, v):
    self.dist = get_dist(x, y)
    self.angle = get_angle(y, x)
    self.rad = r
    self.v = v

def get_dist(x, y):
  return (x ** 2 + y ** 2) ** (1 / 2)

def get_angle(x, y):
  angle = math.atan2(y, x)
  if angle < 0:
    angle += math.pi * 2
  return angle

def reache(ufos, R):
  remove_lst = []
  for ufo in ufos:
    ufo.dist -= ufo.v
    if ufo.dist <= R:
      remove_lst.append(ufo)
  for ufo in remove_lst:
    ufos.remove(ufo)
  return len(remove_lst)

def is_dead(ufo, laser, R):
  diff = abs(ufo.angle - laser)
  if diff > math.pi:
    diff = math.pi * 2 - diff
  if (diff <= math.pi / 2 and ufo.dist * math.sin(diff) <= ufo.rad) or (ufo.dist <= ufo.rad):
    if ufo.dist * math.cos(diff) + (ufo.rad ** 2 - (ufo.dist * math.sin(diff)) ** 2) ** (1 / 2) > R:
      return True
  return False

def shoot(ufos, laser, R):
  remove_lst = []
  for ufo in ufos:
    if is_dead(ufo, laser, R):
      remove_lst.append(ufo)
  for ufo in remove_lst:
    ufos.remove(ufo)

while True:
  R, n = map(int, input().split())
  if R == 0:
    break

  ufos = []
  for _ in range(n):
    x, y, r, v = map(int, input().split())
    ufos.append(Ufo(x, y, r, v))
  
  ans = 0
  while ufos:
    ans += reache(ufos, R)
    if ufos:
      laser = min(ufos, key=lambda ufo:ufo.dist).angle
      shoot(ufos, laser, R)
  print(ans)


Measured memory_bytes: 5836
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string s; cin >> s;
    int n = s.length(), ans = 0;
    FOR(i, 0, n / 2) {
        if (s[i] != s[n - i - 1])++ans;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

def lcm(x, y):
    return (x * y) // gcd(x, y)

N = int(input())
A = []
s = input().split(" ")
for i in range(N):
    A.append(int(s[i]))

tmp=lcm(A[0],A[1]);
i = 2
while  i < N:
    tmp = lcm(tmp, A[i]);
    i += 1

# print(tmp)

tmp = tmp - 1;
ans=0;
for i in range(N):
    ans = ans + tmp % A[i];
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int x; cin >> x;
	cout << (x ? 0 : 1);

	return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
using namespace std;
int n,k,t;
long long arr[100005],pre[100005];
const int mod=1000000007;
int main(){
    scanf("%d%d",&n,&k);
    arr[0]=1;
    for (int x=0;x<=k;x++) pre[x]=1;
    for (int x=0;x<n;x++){
        scanf("%d",&t);
        t+=1;
        for (int x=0;x<=k;x++){
            arr[x]=pre[x];
            if (x>=t) arr[x]-=pre[x-t];
            arr[x]%=mod;
            if (arr[x]<0) arr[x]+=mod;
        }
        for (int x=1;x<=k;x++) pre[x]=(pre[x-1]+arr[x])%mod;
        //for (int x=0;x<=k;x++) printf("%d ",arr[x]);
        //printf("\n");
    }
    printf("%d\n",arr[k]);
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization_level 3
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
 
int main(){
  ll N;
  cin >> N;
  rep(i, 9){
    ll temp = N / (i+1);
    ll amari = N % (i+1);
    if(1<=temp && temp<=9 && amari==0){
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  
  return 0;
	
}

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

int main() {
  int A,B;
  cin>>A>>B;
  if(A%3==0 || B%3==0 || (A+B)%3==0){
    cout<<"Possible"<<endl;
  }
  else{
    cout<<"Impossible"<<endl;
  }
}


Measured memory_bytes: 256
N, M = map(int, input().split())
a = [input() for i in range(N)]
counter = 0
numlist = []
delMlist = []

for i in range(N):
    #print(a[i])
    if a[i].count('#') == 0:
        delMlist.append(i)
#print(delMlist)

for i in delMlist:
    a.pop(i-counter)
    #print(a)
    counter += 1
#print('---------')
#print(a)
N = N - len(delMlist)
#print(N)
newlist = []
for i in range(N):   
    for j in range(M):
        if a[i][j] == '.' :
            numlist.append([i,j])
    newlist.append([a[i]])
llist = []
for i in range(N):
    #llist = list(a[i])
    llist.append(list(a[i]))
#print(llist)
counter1 = 0
fst = ''
delNlist = []
#print(N)
for i in range(M):
    for j in range(N):
        #print(j)
        if llist[j][i] == '.':
            counter1 += 1
        if counter1 == N:
            delNlist.append(i)
    counter1 = 0
#print(delNlist)
#print('---------')
#anslist = []
counter2 = 0
if delNlist != []:
    for h in delNlist:
        for i in range(N):
            a[i] = (a[i][:h-counter2] + a[i][h+1-counter2:])
        counter2 += 1
for i in a:
    print(i)
#print(a)  
        

Measured memory_bytes: 4084
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string s;cin>>s;
  int l=s.length();
  int ans=0;
  for(int i=0;i<l;i++)
  {
     ans = ans + (s[i]-'0');
  }
  if(ans%9==0)
    cout<<"Yes";
    else
    cout<<"No";
}


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

int main() {
    while (true) {
        int L;
        cin >> L;
        if (L == 0) {
            break;
        }
        int saving = 0;
        int result = 0;
        for (int i = 0; i < 12; i++) {
            int M, N;
            cin >> M >> N;
            saving += M - N;
            if (L <= saving && result == 0) {
                result = i + 1;
            }
        }
        if (result > 0) {
            cout << result << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef vector<ll>vi;
typedef pair<ll,ll>pi;
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
ll max(ll a,ll b){return (a>b?a:b);}
ll min(ll a,ll b){return (a<b?a:b);}
ll gcd(ll a,ll b)
{return (b?gcd(b,a%b):a);
}
void algo()
{
    ll n;
    cin>>n;
    string s;
    cin>>s;
    if(s.size()>n)
        cout<<s.substr(0,n)<<"...";
    else
        cout<<s;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout<<setprecision(20);
    ll t=1;//cin>>t;
    while(t--)
    {
        algo();
	cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3644
n = int(input())
a = list(map(int, input().split()))

a.sort()
an = a[-1]
a.pop()

rx = an/2
mx = rx - a[0]
r = a[0]
for i in a:
    if mx > abs(rx - i):
        mx = abs(rx - i)
        r = i

print(an, r)

Measured memory_bytes: 14428
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
int n;
ll x,y;
int main(void){
    cin>>n>>x>>y;
    for(int i=0;i<n-1;i++){
        ll a,b;
        cin>>a>>b;
        ll r=max((x+a-1)/a,(y+b-1)/b);
        x=a*r;
        y=b*r;
    }
    cout<<x+y<<endl;
}


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

int main() {
	string s,t;
	cin >> s >> t;
	int ans = 0;
	rep(i,s.length()) if (s[i]!=t[i]) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3800
package main

import "fmt"

func resolve(n, h, w int) int {
	return (n - h + 1) * (n - w + 1)
}
func main() {
	var n, h, w int
	fmt.Scanf("%d\n%d\n%d\n", &n, &h, &w)

	ans := resolve(n, h, w)
	fmt.Println(ans)
}

Measured memory_bytes: 512
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

const int MX = 100000;

int n, m, k, q;
vector<vector<pi> > e;

int d[MX], p[MX], ans[MX];
set<int> s[MX];

int root(int x){
	if(x == p[x]) return x;
	return p[x] = root(p[x]);
}

int main()
{
	scanf("%d%d%d%d", &n, &m, &k, &q);
	e.resize(n);
	
	vector<pair<int, pi> > es;
	
	rep(i, m){
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		a--; b--;
		e[a].pb(mp(b, c));
		e[b].pb(mp(a, c));
		
		es.pb(mp(0, mp(a, b)));
	}
	
	{
		priority_queue<pi> q;
		rep(i, k){
			int t;
			scanf("%d", &t);
			q.push(mp(0, t - 1));
		}
		
		rep(i, n) d[i] = inf;
		while(!q.empty()){
			int c = q.top().second, cost =- q.top().first;
			q.pop();
			
			if(d[c] <= cost) continue;
			d[c] = cost;
			
			rep(i, e[c].size()){
				int to = e[c][i].first;
				int ncost = cost + e[c][i].second;
				if(d[to] > ncost) q.push(mp(-ncost, to));
			}
		}
	}
	
	rep(i, q){
		int a, b;
		scanf("%d%d", &a, &b);
		a--; b--;
		s[a].insert(i);
		s[b].insert(i);
	}
	
	rep(i, n) p[i] = i;
	rep(i, m){
		es[i].first = -min(d[es[i].second.first], d[es[i].second.second]);
	}
	sort(all(es));
	
	rep(i, m){
		int a = root(es[i].second.first);
		int b = root(es[i].second.second);
		
		if(a == b) continue;
		if(s[a].size() < s[b].size()) swap(a, b);
		
		each(j, s[b]){
			if(s[a].count(*j)){
				ans[*j] = -es[i].first;
				s[a].erase(*j);
			}
			else s[a].insert(*j);
		}
		p[b] = a;
	}
	
	rep(i, q) printf("%d\n", ans[i]);
	
	return 0;
}

Measured memory_bytes: 53092
#include <bits/stdc++.h>
using namespace std;
typedef tuple<string,int,int> tup;
bool mycompare(const tup &lhs,const tup &rhs) {
        if (get<0>(lhs)!=get<0>(rhs)) {
            return get<0>(lhs)<get<0>(rhs);
        }
        if (get<1>(lhs)!=get<1>(rhs)) {
            return get<1>(rhs)<get<1>(lhs);
        }
        return get<2>(lhs)<get<2>(rhs);
}
int main(void){
    vector<tup> vec;
    int n,score;
    cin>>n;
    string city;
    for (int i=1;i<=n;i++) {
        cin>>city>>score;
        vec.emplace_back(city,score,i);
    }
    
    sort(vec.begin(),vec.end(),mycompare);
    for (int j=0;j<n;j++) {
        int& hoge=get<2>(vec[j]);
        cout<<hoge<<endl;
    }
}


Measured memory_bytes: 256
R,G,B,N=map(int,input().split())

ans=0

for i in range(N+1):
  if i*R > N:
    break
  else:
    for j in range(N+1):
      if i*R+j*G > N:
        break
      else:
        if N-(i*R+j*G) == 0 or (N-(i*R+j*G)) % B == 0:
          ans+=1
          
print(ans)


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

using namespace std;

// dp_less[i][j] - no of ways to make a prefix of size i
// such that last number is equal to j

const int mod = 1e9+7;

int dp[3001][3001];
int prefix[3001][3001];

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

void add_self(int &a, int b) {
    a += b;
    if(a >= mod) a -= mod;
}

int mul(int a, int b) {
    long long m = (long long) a * (long long) b;
    a = m % mod;
    return a;
}

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

int main() {
    int n;
    string s;
    char c;
    cin >> n;
    cin >> s;
    memset(dp, 0, sizeof dp);
    memset(prefix, 0, sizeof prefix);
    dp[1][1] = 1;
    prefix[1][1] = 1;

    for(int i = 2; i <= n; i++) {   // i - size of new prefix
        c = s[i-2];
        if(c == '>') {
            for(int j = 1; j <= i; j++) {
                add_self(dp[i][j], sub(prefix[i-1][i-1], prefix[i-1][j-1]));
                prefix[i][j] = add(prefix[i][j-1], dp[i][j]);
            }
        } else {
            for(int j = 1; j <= i; j++) {
                add_self(dp[i][j], prefix[i-1][j-1]);
                prefix[i][j] = add(prefix[i][j-1], dp[i][j]);
            }
        }
    }
    cout << prefix[n][n] << "\n";
}

Measured memory_bytes: 70656
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

s = list(sr())
s.reverse()
dp = [0 for i in range(len(s)+1)]
tmod = 1
for i,c in enumerate(s):
    now = int(c)
    dp[i+1] = (dp[i]+now*tmod)%2019
    tmod = (tmod*10)%2019
ans = 0
for _,v in collections.Counter(dp).items():
    ans+=(v*(v-1)//2)
print(ans)




Measured memory_bytes: 101384
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn mod_pow(n: i64, p: i64, m: i64) -> i64 {
    if p == 0 {
        1
    } else if p % 2 == 0 {
        let pow = mod_pow(n, p / 2, m) % m;
        pow * pow % m
    } else {
        let pow = mod_pow(n, p - 1, m);
        n * pow % m
    }
}

fn calc_remove(n: i64, a: i64, mod_num: i64) -> i64 {
    let mut x = 1;
    for i in (n + 1 - a)..(n + 1) {
        x = x * i % mod_num
    }

    let mut y: usize = 1;
    for i in 1..(a + 1) as usize {
        y = y * i % mod_num as usize
    }

    let y_pow = mod_pow(y as i64, mod_num - 2, mod_num);

    x * y_pow % mod_num
}

fn main() {
    input! {
        n: i64,
        a: i64,
        b: i64,
    }

    let mod_num = 1_000_000_007;

    let ans = mod_pow(2, n as i64, mod_num) - 1;

    let a_del = calc_remove(n, a, mod_num);

    let b_del = calc_remove(n, b, mod_num);

    let ans = ans - a_del - b_del;
    let ans = {
        let mut ret = ans;
        while ret < 0 {
            ret = ret + mod_num
        }
        ret % mod_num
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
n, k = map(int,input().split())

person = [0 for i in range(n)]
for i in range(k):
    input()
    a = list(map(int,input().split()))
    for j in a:
        person[j-1] +=1

answer = len([person[i] for i in range(n) if person[i]==0])

print(answer)

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define reg register
inline int read()
{
    reg int s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}
using namespace std;
const int maxn = 505;
int f[maxn], g[maxn];
int a[maxn][maxn];

void get(int l, int r) {
    int n = r - l + 1;
    if(n <= 2) {
        a[l][r] = f[n];
        return;
    }
    int mid = l + g[n] - 1;
    get(l, mid);
    get(mid + 1, r);
    for(int i = l; i <= mid; i ++)
        for(int j = mid + 1; j <= r; j ++)
            a[i][j] = f[n];
}

int main() {
    int n = read();
    f[1] = f[2] = 1;
    for(int i = 3; i <= n; i ++) {
        f[i] = 1000000000;
        for(int j = 1; j < i; j ++) {
            int v = std::max(f[j], f[i - j]) + 1;
            if(v < f[i]) {
                f[i] = v;
                g[i] = j;
            }
        }
    }
    get(1, n);
    for(int i = 1; i < n; i ++) {
        for(int j = i + 1; j <= n; j ++)
            printf("%d ", a[i][j]);
        puts("");
    }
}

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,m,x,y,i,i1;
    cin>>n>>m;
    vector<ll>v[100010];
    for (i=0;i<m;i++){
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    queue<ll>q;
    ll par[100010];
    for (i=0;i<=n;i++)par[i]=-1;
    q.push(1);
    par[1]=0;
    while (!q.empty()){
        x = q.front();
        q.pop();
        for (i=0;i<v[x].size();i++){
            if (par[v[x][i]]==-1){
                par[v[x][i]] = x;
                q.push(v[x][i]);
            }
        }
    }
    for (i=2;i<=n;i++){
        if (par[i]==-1){
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
    for (i=2;i<=n;i++)cout<<par[i]<<'\n';
}

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

#define sswap(x, y) { x+=y; y=x-y; x-=y; }
#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	int n;
	cin >> n;
	int A[n+1];
	mset(A, 0);

	int ai;
	while (cin >> ai) A[ai]++;

	for (int i = 1; i <= n; i++)
		cout << A[i] << ende;
  return 0;
}


Measured memory_bytes: 4400
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>

using namespace std;
using ll = long long;

int main()
{
	long long a, b;
	long long res;
	cin >> a >> b;

	int x = b % 4;
	long gb = b-x;
	for (long long i = b-x+1; i <= b; i++)
		gb ^= i;

	a--;
	x = a % 4;
	long ga = a-x;
	for (long long i = a-x+1; i <= a; i++)
		ga ^= i;

	cout << (ga ^ gb) << endl;
}



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

int main(){
    string a, b;
    cin >> a >> b;

    string c = a + b;

    int flag = 0;
    for(int i=0; i < 10001; i++){
        if(i * i == stoi(c)) flag = 1;
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - RGB Cards
            var s = Console.ReadLine();

            //r,g,bの間のスペースを削除
            int n = int.Parse(s.Replace(" ", ""));

            if (n % 4 == 0)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

using ll = long long;
#define f(i,a,b) for (int i = a; i < b; i++)
#define fr(i,a,b) for (int i = b-1; i >= a; i--)

const int mod = 998244353;
const int mxn = 1e5;
int n,K;

void add(ll &a, ll b) { if (b>=mod) b%=mod; a+=b; if (a>=mod) a-=mod; }
ll modpow(ll a, ll b) {
	return b?modpow(a*a%mod,b/2)*(b&1?a:1)%mod:1;
}
struct Comb {
	ll fac[mxn], inv[mxn], twopow[mxn];	
	Comb() {
		f(i,0,mxn) {
			fac[i]=i?fac[i-1]*i%mod:1;
			twopow[i]=i?twopow[i-1]*2%mod:1;
		}
		inv[mxn-1]=modpow(fac[mxn-1],mod-2);
		fr(i,0,mxn-1) {
			inv[i]=inv[i+1]*(i+1)%mod;
		}
	}
	ll choose(int n, int r) {
		if (n<0||n<r||r<0) return 0;
		return fac[n]*inv[r]%mod*inv[n-r]%mod;
	}
	ll multichoose(int n, int k) {
		if (!n&&!k) return 1;
		return choose(n+k-1,k);
	}
	ll pow2(int n) {
		if (n<0) return 0;
		return twopow[n];
	}
} C;

ll solve(int x) {
	ll ans = 0;
	int a = 0, b = 0;
	f(i,1,K+1) {
		if (i+i==x) b++;
		if (i<=K && x-i<=K && x-i>0) a++;
	}
	a/=2;
	f(na,0,a+1) {
		f(nb,0,b+1) {
			add(ans,C.pow2(na)*C.choose(a,na)%mod*C.multichoose(na+K-2*a-b,n-na-nb));		
		}
	}
	return ans;
}

const int DEBUG = 1;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	if (DEBUG) freopen("input.txt", "r", stdin);
	if (DEBUG) freopen("output.txt", "w", stdout);
#endif

	cin >> K >> n;
	for (int x = 2; x <= 2*K; x++)
		cout << solve(x) << endl;
	cout << endl;

	return 0;
}



Measured memory_bytes: 2688
import numpy as np
N, C = map(int,input().split())
T1 = [[] for _ in range(C)]
for _ in range(N):
    s, t, c = map(int,input().split())
    T1[c-1].append([s,t])
for i in range(C):
    T1[i].sort()
T2 = [[] for _ in range(C)]
for i in range(C):
    for s, t in T1[i]:
        if len(T2[i]) != 0 and T2[i][-1][1] == s:
            T2[i][-1][1] = t
        else:
            T2[i].append([s,t])

L = np.zeros(10 ** 5 + 2, int)
for i in range(C):
    for time in T2[i]:
        L[time[0]] += 1
        L[time[1]+1] -= 1

ans = L.cumsum().max()

print(ans)

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

int n;
ll k;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    cin >> k;
    vector<ll> a(n);
    vector<ll> f(n);

    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());

    ll l, r;
    l = r = -1;
    for (int i = 0; i < n; i++)
        r = max(r, a[i]*f[i]);

    while (r > l + 1)  {
        ll x = (r + l)/2;
        ll sum = 0;
        for (int i = 0; i < n; i++)
            sum += max(0ll, a[i] - x/f[i]);
        if (sum <= k)
            r = x;
        else
            l = x;
    }
    cout << r << endl;
    return 0;
}


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

bool check(int in){
	for (int i = 3; i<=sqrt(in); i+=2){
		if (i != 5 && i % 5 == 0)	continue;
		if (in % i == 0)
			return false;
	}
	return true;
}

int PrimeNumber(int in, int start){
	int count = 0;
	if (in >= 2 && start==3)	count++;
	for (int i = start; i <=in; i+=2){
		if (check(i))	count++;
	}

	return count;
}

int main(){
	int in;
	int count250000 = PrimeNumber(250000, 3);
	int count500000 = count250000 + PrimeNumber(500000, 250001);
	int count750000 = count500000 + PrimeNumber(750000, 500001);

	while (cin >> in, !cin.eof()){
		if (in <= 250000)
			cout << PrimeNumber(in, 3) << endl;
		else if (in <= 500000)
			cout << count250000 + PrimeNumber(in, 250001) << endl;
		else if (in <= 750000)
			cout << count500000 + PrimeNumber(in, 500001) << endl;
		else
			cout << count750000 + PrimeNumber(in, 750001) << endl;
	}
}

Measured memory_bytes: 1160
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		boolean allplus = true;
		boolean allminus = true;
		long total = 0;
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			if(A[i] <= 0)
				allplus = false;
			if(A[i] >= 0)
				allminus = false;
			total += Math.abs(A[i]);
		}
		Arrays.sort(A);
		StringBuilder ans = new StringBuilder();
		if(allplus) {
			int a = A[0];
			System.out.println(total-A[0]*2);
			for(int i = 1; i < N-1; i++) {
				ans.append(a + " " + A[i] + "\n");
				a -= A[i];
			}
			ans.append(A[N-1] + " " + a + "\n");
			System.out.print(ans);
			return;
		}
		if(allminus) {
			int a = A[N-1];
			System.out.println(total+A[N-1]*2);
			for(int i = 0; i < N-1; i++) {
				ans.append(a + " " + A[i] + "\n");
				a -= A[i];
			}
			System.out.print(ans);
			return;
		}
		int a = A[0];
		int minusnum = 0;
		System.out.println(total);
		for(int i = N-2; i >= 0; i--) {
			if(A[i] > 0) {
				ans.append(a + " " + A[i] + "\n");
				a -= A[i];
			}
			else {
				minusnum = i;
				break;
			}
		}
		int b = A[N-1];
		ans.append(b + " " + a + "\n");
		b -= a;
		for(int i = 1; i <= minusnum; i++) {
			ans.append(b + " " + A[i] + "\n");
			b -= A[i];
		}		
		System.out.print(ans);

	}

}

Measured memory_bytes: 67228
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;

int main()
{
    auto cmp = [](const pair<int, int> &a, const pair<int, int> &b) {
        return a.second < b.second;
    };
    int n, p, d1, d2;
    for (; ;) {
        scanf("%d", &n);
        if (n == 0) break;
        priority_queue<pair<int, int>, vector<pair<int, int> >, decltype (cmp) > pq(cmp);
        for (int i = 0; i < n; i++) {
            scanf("%d %d %d", &p, &d1, &d2);
            pq.push({p, d1+d2});
        }
        printf("%d %d\n", pq.top().first, pq.top().second);
    }

}



Measured memory_bytes: 2720
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;

int main(){
    int h, w;

    while(true){
        cin >> h >> w;
        if(h == 0 && w == 0) {
            break;
        }

        for(int y=0;y<h;y++){
            for(int x=0;x<w;x++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


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

#define endl '\n'

int main() {
    ios::sync_with_stdio(0);

    string s;
    cin >> s;
    
    string t = "";
    for(int i = 0; i < (int)s.length(); i++) {
        if(s[i] != 'x') t += s[i];
    }

    string tt = t;
    reverse(tt.begin(), tt.end());
    if(t != tt) {
        cout << -1;
        return 0;
    }

    int l = 0;
    int r = (int)s.length() - 1;
    int res = 0;
    while(l < r) {
        if(s[l] == s[r]) {
            l++; r--;
            continue;
        }
        res++;
        if(s[l] == 'x')
            l++;
        else
            r--;
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i, N) for (int i=0; i<(int)N; i++)
#define rep1(i, N) for (int i=1; i<(int)N; i++)

using namespace std;

int n, m;

int main() {
  cin >> n >> m;
  if (n == m) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

constexpr ll mod = 924844033;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    
    auto calc = [&](int s){
        vvec<mint> dp(N+1,vec<mint>(2));
        if(s<K) dp[0][0] = 1;
        else dp[0][1] = 1;
        int c = 0;
        for(int i=s;i<N;i+=2*K){
            c++;
            vvec<mint> ndp(N+1,vec<mint>(2));
            for(int j=0;j<c;j++){
                ndp[j+1][1] += dp[j][1];
                if(i+K<N) ndp[j+1][0] += dp[j][0]+dp[j][1];
                ndp[j][1] += dp[j][0]+dp[j][1];
            }
            dp.swap(ndp);
        }
        dp.resize(c+1);
//        cerr << s << "\n";
//        for(int i=0;i<=c;i++) cerr << dp[i][0] << " " << dp[i][1] << "\n";
        return dp;
    };

    vec<mint> dp(N+1);
    dp[0] = 1;
    int now = 0;
    for(int i=0;i<2*K;i++){
        auto res = calc(i);
        vec<mint> ndp(N+1);
        int n = res.size();
        for(int j=0;j<=now;j++){
            for(int k=0;k<n;k++) if(j+k<=N) ndp[j+k] += dp[j]*(res[k][0]+res[k][1]);
        }
        now += n-1;
        dp.swap(ndp);
    }
    mint ans = 0;
    vec<mint> fact(N+1,1);
    for(int i=1;i<=N;i++) fact[i] = fact[i-1]*i;
    for(int i=0;i<=N;i++){
        mint now = dp[i]*fact[N-i];
        if(i%2) ans -= now;
        else ans += now;
    }
    cout << ans << "\n";
}

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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    string s, t; cin >> s >> t;
    s += t[t.size()-1];
    cout << ((s==t)?"Yes":"No") << '\n';
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
#define foreach(r,p) for(r::iterator it=p.begin();it!=p.end();++it)
using namespace std;

string check(vector<int> s)
{
    if( (s[0]==s[1]&&s[0]==s[2]&&s[0]==s[3])|| (s[1]==s[2]&&s[1]==s[3]&&s[1]==s[4]))
        return "four card";

    if((s[0]==s[1]&&s[0]==s[2]&&s[3]==s[4])||(s[0]==s[1]&&s[2]==s[3]&&s[2]==s[4]))
        return "full house";
    
    if((s[0]==(s[1]-1) &&s[0]==(s[2]-2) && s[0] ==(s[3]-3) && s[0]==(s[4]-4))
            ||(s[0]==1 && s[1]==10 &&s[2]==11&&s[3]==12&&s[4]==13))
        return "straight";
    if((s[0]==s[1]&&s[0]==s[2])||(s[1]==s[2]&&s[1]==s[3]) || (s[2]==s[3]&&s[2]==s[4]))
        return "three card";
    
    if((s[0]==s[1]&&s[2]==s[3])||(s[0]==s[1]&&s[3]==s[4])||(s[1]==s[2]&&s[3]==s[4]))
        return "two pair";
    
    if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]||s[3]==s[4])
        return "one pair";

    return "null";
}


int main()
{
    int n[5];
    char t;
    while( cin >>n[0]>>t>>n[1]>>t>>n[2]>>t>>n[3]>>t>>n[4])
    {
        vector<int> card;
        if(cin.eof()) break;
        for(int i=0;i<5;i++)
        {
            card.push_back(n[i]);
        }
        sort(card.begin(),card.end());
        cout << check(card) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
# https://atcoder.jp/contests/abc077/tasks/abc077_b

import itertools
import collections
import bisect

def main():
    N = int(input())

    ans =1
    i = 1
    while N >= i * i:
        ans = i * i
        i += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

/*template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
*/

int main(){
	int m,d;cin>>m>>d;
	int c=0;
	for(int i=2;i<=d;i++){
		if(i/10>=2&&i%10>=2){
			if((i/10)*(i%10)<=m){
				c++;
			}
		}		
	}
	
	cout<<c<<endl;
	return 0;
}


Measured memory_bytes: 256