akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    int n,k;cin>>n>>k;
    vector<vector<ll> > v(n);
    rep(i, n){
        ll t,d;cin>>t>>d;
        t--;
        v[t].push_back(d);
    }
    rep(i,n){
        sort(v[i].rbegin(),v[i].rend());
    }
    vector<ll> f,others;
    rep(i,n){
        rep(j,v[i].size()){
            if(j==0){
                f.push_back(v[i][j]);
            }else{
                others.push_back(v[i][j]);
            }
        }
    }
    sort(rall(f));
    sort(rall(others));
    ll ans = 0;
    rep(i,k+1){
        ll tmp = 0;
        ll m = min((ll)i, (ll)f.size());
        if(others.size() < k-m)continue;
        tmp += pow(m,2);
        rep(j,m){
            tmp += f[j];
        }
        rep(j,k-m){
            tmp += others[j];
        }
        ans = max(ans,tmp);
    }
    cout << ans << endl;
}



Measured memory_bytes: 6904
// atcoder/abc139/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n;
  while (cin >> n) {
    lli x = (n - 1) * n / 2;
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import heapq
N, M = [int(x) for x in input().split()]
AB_list = [[] for _ in range(M)]
for _ in range(N):
    A, B = list(map(int, input().split()))
    if (A > M): continue
    AB_list[A-1].append(B)
h = []
ans = 0
for i in range(M):
    for B in AB_list[i]:
        heapq.heappush(h, -B)
    # print(AB_list, h)
    if (len(h)):
        ans += -heapq.heappop(h)
print(ans)


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
string S;
int dp[305][305][305];
int K;

int main() {
    //cout.precision(10);
    cin >> S;
    cin >> K;
    int n = S.size();
    S = "#" + S;
    int ans = 0;
    for(int k = 0; k <= K; k++) {
        for(int i = 0; i <= n; i++) {
            for(int j = n + 1; j >= max(1, i); j--) {
                ans = max(ans, dp[i][j][k]);
                //cerr << i << " " << j << " " << k << " " << dp[i][j][k] << endl;
                dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k]);
                dp[i][j-1][k] = max(dp[i][j-1][k], dp[i][j][k]);
                if(S[i+1] == S[j-1]) {
                    if(i+1 == j-1) dp[i+1][j-1][k] = max(dp[i+1][j-1][k], dp[i][j][k]+1);
                    else dp[i+1][j-1][k] = max(dp[i+1][j-1][k], dp[i][j][k] + 2);
                }
                if(i+1 == j-1) dp[i+1][j-1][k+1] = max(dp[i+1][j-1][k+1], dp[i][j][k] + 1);
                else dp[i+1][j-1][k+1] = max(dp[i+1][j-1][k+1], dp[i][j][k] + 2);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 110848
//1.includes
#include<iostream>
#include<queue>
#include<tuple>
#include<algorithm>
using namespace std;
//2.defines
#define MAX_N 60
#define INF 1000000000
//3.variables
int dp[MAX_N][MAX_N][MAX_N][MAX_N];
int H, W, A1, A2, B1, B2;
int x[MAX_N][MAX_N];
queue<tuple<int, int, int, int>>Q;
//4.functions
int solve() {
	dp[A1][A2][B1][B2] = 0;
	Q.push(make_tuple(A1, A2, B1, B2));
	while (!Q.empty()) {
		tuple<int, int, int, int>tup = Q.front();
		Q.pop();
		int a1 = get<0>(tup);
		int a2 = get<1>(tup);
		int a3 = get<2>(tup);
		int a4 = get<3>(tup);
		int dx[4] = { 1,0,-1,0 };
		int dy[4] = { 0,-1,0,1 };
		for (int i = 0; i < 4; i++) {
			int cx = a1 + dx[i], cy = a2 + dy[i];
			int ex = a3 - dx[i], ey = a4 - dy[i];
			if (x[cx][cy] == 1) { cx = a1; cy = a2; }
			if (x[ex][ey] == 1) { ex = a3; ey = a4; }
			if (dp[cx][cy][ex][ey] > dp[a1][a2][a3][a4] + 1) {
				dp[cx][cy][ex][ey] = dp[a1][a2][a3][a4] + 1;
				Q.push(make_tuple(cx, cy, ex, ey));
			}
		}
	}
	int minx = INF;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			minx = min(minx, dp[i][j][i][j]);
		}
	}
	return minx;
}
void _memset() {
	for (int i = 0; i < MAX_N; i++) {
		for (int j = 0; j < MAX_N; j++) {
			for (int k = 0; k < MAX_N; k++) {
				for (int l = 0; l < MAX_N; l++) {
					dp[i][j][k][l] = INF;
				}
			}
		}
	}
	for (int i = 0; i < MAX_N; i++) {
		for (int j = 0; j < MAX_N; j++) {
			x[i][j] = 1;
		}
	}
}
int main() {
	while (true) {
		_memset();
		cin >> W >> H;
		if (H == 0 && W == 0) { break; }
		cin >> A2 >> A1 >> B2 >> B1;
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				cin >> x[i][j];
			}
		}
		int v = solve();
		if (v >= 100) { cout << "NA" << endl; }
		else { cout << v << endl; }
	}
	return 0;
}

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

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

  double X[N];
  string U[N];
  
for(int i=0; i<N ;i++){
  cin >> X[i] >> U[i];
}

  double sum=0;
for(int i=0; i<N ;i++){
  if(U[i]=="JPY"){
    sum += X[i];
  }
  else{
    sum += X[i]*380000;
  }
}
  
  cout << sum << endl;
}
  

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

int main(void){
    int a,b,c,d;cin>>a>>b>>c>>d;
    if(a+b>c+d)cout<<"Left"<<endl;
    else if(a+b==c+d)cout<<"Balanced"<<endl;
    else cout<<"Right"<<endl;
    
    return 0;
}


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

using namespace std;

int main(void){
	while(1){
		int x, y, s; cin >>x>>y>>s;
		if(!x && !y && !s) break;
		
		int ans = 0;
		for(int i=1; i<s; i++){
			for(int j=1; j<s; j++){
				if(i*(100+x)/100 + j*(100+x)/100 == s){
					int tmp = i*(100+y)/100 + j*(100+y)/100;
					ans = max(tmp, ans);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	cin >> n;
	
	map<ll, ll> mp;
	for(ll x = 1; x < 101; ++x) {
		for(ll y = 1; y < 101; ++y) {
			for(ll z = 1; z < 101; ++z) {
				ll v = x * x + y * y + z * z + x * y + y * z + z * x;
				mp[v]++;
			}
		}
	}
	
	for(int i = 1; i <= n; ++i) {
		cout << mp[i] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 5928
#include<stdio.h>

int N,U,K,V,G[105][105]={0},i,j;
int main()
{
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d%d",&U,&K);
		for(j=0;j<K;j++)
		{
			scanf("%d",&V);
			G[U][V]=1;
		}
	}
	for(i=1;i<=N;i++)
		for(j=1;j<=N;j++)
			printf("%d%c",G[i][j],j==N?'\n':' ');
	return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
long long n,a[111];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	long long ans=1e18;
	for(long long i=-100;i<=100;i++)
	{
		long long cnt=0;
		for(long long j=0;j<n;j++)
		{
			cnt+=(a[j]-i)*(a[j]-i);
		}
		ans=min(cnt,ans);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        double ans = 0.0;
        for(int i=0; i<n; i++) {
            ans += 1.0 / (double)sc.nextDouble();
        }
        System.out.println(1 / ans);
    }
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

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

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 200005;

int main(){
  int N; cin >> N;
  string s;
  int num[20],res[20];
  int l,r,mid;
  int lres,rres;
  num[0] = 0; num[1] = N/2;
  rep(i,20){
    cout << num[i] << endl;
    cin >> s;
    if(s=="Vacant") return 0;
    else if(s=="Male") res[i] = 1;
    else res[i] = 0;
    if(i==1){
      if((res[i]==res[i-1] && (N/2)%2==1)||((res[i]!=res[i-1] && (N/2)%2==0))){
        l = 0;
        mid = N/4;
        r = N/2;
        lres = res[0];
        rres = res[1];
      }else{
        l = N/2;
        r = N;
        mid = N*3/4;
        lres = res[1];
        rres = res[0];
      }
      num[i+1] = mid;
    }
    if(i>=2){
      if((res[i]==lres && (mid-l)%2==1)||((res[i]!=lres)&&((mid-l)%2==0))){
        r = mid; rres = res[i];
      }else if(((res[i]==rres)&&((r-mid)%2==1))||((res[i]!=rres)&&((r-mid)%2==0))){
        l = mid; lres = res[i];
      }else{
        // l = mid, lres = res[i];
      }
      mid = (l+r)/2;
      num[i+1] = mid;
    }
  }
  return 0;
}

Measured memory_bytes: 852
N = int(input())
x = []
y = []
h = []

for _ in range(N):
    xx, yy, hh = map(int, input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)

V_MAX = 100

for cx in range(V_MAX + 1):
    for cy in range(V_MAX + 1):
        # 頂上がどのくらいの高さであって欲しいか
        # -1: 未定, 0以上は確定しているとき
        # -2: 不可能だと分かったとき
        needH = - 1

        for i in range(N):
            if h[i] > 0:
                dist = abs(x[i] - cx) + abs(y[i] - cy)
                # この頂点から見て, 頂上がcx, cyのときに, どの位の高さがあって欲しいか
                tmp = h[i] + dist
                if needH == -1:
                    needH = tmp
                else:
                    if needH != tmp:
                        needH = -2
                        break

        if needH == -2:
            continue # ダメだったら別の場所を探す

        for i in range(N):
            if h[i] == 0:
                dist = abs(x[i] - cx) + abs(y[i] - cy)
                if needH > dist:
                    needH = - 2
                    break

        if needH == -2:
            continue # ダメだったら別の場所を探す

        print(cx, cy, needH)

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
	int n;
	scanf("%d",&n);
	int h[100000];
	for(int i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	if(n==1){
		printf("Yes\n");
		return 0;
	}
	if(h[n-2]-h[n-1]>1){
		printf("No\n");
		return 0;
	}
	for(int i=n-2;i>=0;i--){
		if(h[i]-h[i+1]==1)h[i]--;
		else if(h[i]-h[i+1]>1){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, ok = true;
	cin >> num;
	vector<int> d(num);
	rep(i, num)
		cin >> d[i];
	sort(d.begin(), d.end());
	rep(i, num - 1) {
		if (d[i] == d[i + 1]) {
			ok = false;
			break;
		}
	}
	if (ok)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

Measured memory_bytes: 1024
n = gets
arr = gets.chomp.split.map(&:to_i)
least_odd = nil
arr.each{|x| least_odd = x if x.odd? && (least_odd.nil? || least_odd > x)}
sum = arr.inject(:+)
puts (sum.even? ? sum / 2 : (sum - least_odd) / 2)


Measured memory_bytes: 6868
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}

int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    unsigned long long ans = 0;
    vector<unsigned long long> a(10000001,2);
    a[1]=1;
    for(int i=2;i*i<=10000000;i++){
        for(int j=i;j*i<=10000000;j++){
            if(i*j<i*i){
                continue;
            }
            else if(j==i){
                ++a[i*j];
            }
            else{
                ++++a[j*i];
            }
        }
    }
    for(unsigned long long i=1;i<=n;i++){
        ans += i*a[i];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 81304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n);(i)>0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  COMinit();
   lint x,y;
   cin>>x>>y;
   lint cnt1=x;
  lint cnt2=0;
   rep(i,x){
     if(y==(cnt1*2+cnt2))break;
     else {
       cnt1-=2;
      cnt2++;
     }
     if(i==(x-1)){
       cout<<0;
       return 0;
     }
   }
lint ans=1;
lint g=cnt1;
lint h=cnt2;
cout<<COM(cnt1+cnt2,cnt1);

}

Measured memory_bytes: 234752
from collections import deque

S = input()
Q = int(input())

d = deque(list(S))
reverse = False

for i in range(Q):
    query = input().split()

    if query[0] == '1':
        reverse = not reverse

    elif query[0] == '2':
        if query[1] == '1' and not reverse:
            d.appendleft(query[2])
        elif query[1] == '2' and not reverse:
            d.append(query[2])
        elif query[1] == '1' and reverse:
            d.append(query[2])
        elif query[1] == '2' and reverse:
            d.appendleft(query[2])

if reverse:
    d.reverse()

print(''.join(d))

Measured memory_bytes: 74600
N,M = gets.split.map &:to_i
gs = {}
M.times {
  u,v = gets.split.map &:to_i
  (0...3).each{ |i|
    uu = u*10+i; vv = v*10+(i+1)%3
    gs[uu] ||= {}
    gs[uu][vv] = 1
  }
}
S,T = gets.split.map{ |s| s.to_i * 10 }
#p gs

ans = 1
visited = {}
queue = (gs[S] || {}).keys
while queue.size > 0 do
  vs = {}
  queue.each{ |u| visited[u] = 1 }
  queue.each{ |u|
    if u == T
      p ans / 3; exit
    end
    (gs[u] || {}).keys.each{ |v|
      next if visited[v]
      vs[v] = 1
    }
  }
  queue = vs.keys
  ans += 1
end
p -1

Measured memory_bytes: 146300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef deque<int> di;
typedef pair<int,int> pi;
#define pb push_back
#define mp make_pair
#define mh make_heap
#define pf push_front
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF 1000000000
#define FOR(i,a,b) for(ll i=a;i<b;i++)


int main()
{
    //freopen("contest.txt","r",stdin);
    //freopen("contest.txt","w",stdout);
    IOS
    string s;
    ll n;
    cin>>n;
    cin>>s;
    int count_=0;
    ll i=0,j=s.size()-1;
    while(i<j)
    {
        if(s[i]=='R')
            i++;
        if(s[j]=='W')
            j--;
        if(s[i]=='W' && s[j]=='R')
        {
            count_++;
            swap(s[i],s[j]);
            i++;
            j--;
        }
    }
    cout<<count_<<endl;

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>

using namespace std;

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

	int k, a, b;
	cin >> k >> a >> b;
	if(a % k == 0 || a + k - (a % k) <= b) {
		cout << "OK\n";
	} else {
		cout << "NG\n";
	}
	return 0;

}

Measured memory_bytes: 3640
def main
  sum = 0
  sumnum = 0
  count = 0
  while arg = gets
    arg = arg.split(",").map(&:to_i)
    sum += arg[0] * arg[1]
    sumnum += arg[1]
    count += 1
  end
  puts sum, (sumnum.to_f / count).round
end
main

Measured memory_bytes: 6108
a[6]={2,3,5,10,12,15},b[6]={380,550,850,1520,1870,2244},m[51],T;
int s(p,n){
	int d=5;
	if(!n)return 0;
	if(m[n]>99999)for(;~d;d--){
		if(a[d]>n)continue;
		T=s(p,n-a[d])+b[d];
		if(m[n]>T)m[n]=T;
	}
	return m[n];
}

main(n){
	memset(m,99,sizeof(m));
	for(;scanf("%d",&n),n;)printf("%d\n",s(m,n/100));
	exit(0);
}

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

int main(){
  int n;
  cin>>n;
  ll ans=1;
  for(int i=1;i<=n;i++){
    ans=(ans*i)%1000000007;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<deque>
#define ll long long
using namespace std;
#define BUF_SIZE 1048576
char _buf[BUF_SIZE],*_is=_buf,*_it=_buf;
inline char rdc(){
	if (_is==_it) _it=(_is=_buf)+fread(_buf,1,BUF_SIZE,stdin);
	return *_is++;
}
inline void rdi(int &x){
	int f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	if(f) x=-x;
}
inline void rdi(ll &x){
	ll f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	if(f) x=-x;
}
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(int x){
	write(x);
	putchar(' ');
}
inline void print(int x){
	write(x);
	putchar('\n');
}
inline void write(ll x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(ll x){
	write(x);
	putchar(' ');
}
inline void print(ll x){
	write(x);
	putchar('\n');
}
struct dsu{
	int par[200200];
	inline void init(int _n){for(int i=0;i<_n;++i) par[i]=i;}
	inline int find(int now){
		if(par[now]==now) return now;
		return par[now]=find(par[now]);
	}
	inline bool unite(int a, int b){
		int Pa(find(a)),Pb(find(b));
		if(Pa==Pb) return false;
		par[Pa]=Pb;
		return true;
	}
};
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,a,b,ans;
	cin>>n>>a>>b;
	ans=n+1;
	if(b>a+2){
		if(n<(a-1)){
			cout<<n+1<<endl;
			return 0;
		}else{
			n-=(a-1);
			ans=max(ans,(int)(n/2)*(b-a)+(int)(n%2)+a);
			cout<<ans<<endl;
			return 0;
		}
	}
	cout<<n+1<<endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int l[n];
    int tmp=0;
    for(int i=0;i<n;i++){
        cin >> l[i];
    }
    sort(l,l+n,greater<int>());
    for(int i=1;i<n;i++){
        tmp+=l[i];
    }
    if(tmp>l[0]) cout << "Yes" << endl;
    else cout << "No" << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll A,B,C,N,M,K,X,Y;
string S;
vector<pair<ll,ll>> vec;

void solve() {
	map<char, int> m;
	cin >> S;
	int si=0;

	rep(i, 4) {
		m[S[i]]++;
		if (m[S[i]] == 2) si++;
	}
	if (si == 2) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

int main() {
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	vector<char> v;
	for(int i=0;i<s.size();i++)
	{
		v.push_back(s[i]);
	}
	while(v.size()!=0)
	{
		if(v[0]=='h'&&v[1]=='i')
		{
			v.erase(v.begin());
			v.erase(v.begin());
		}
		else
		{
			cout<<"No";return 0;
		}
	}
	cout<<"Yes";
}

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

int main() {
	int H, W, T;
	char A;
	int i;
	int flag[26];
	int count1 = 0, count2 = 0;
	for (i = 0; i < 26; i++)flag[i] = 0;
	cin >> H >> W;
	T = H*W;
	for (i = 0; i < T; i++) {
		int x;
		cin >> A;
		x = (int)(A - 'a');
		flag[x]++;
	}
	for (i = 0; i < 26; i++) {
		count1 += flag[i] % 4;
		count2 += flag[i] % 2;
	}
	int p1 = 0, p2 = 0;
	if (H % 2 != 0) { p1 += W; p2 += W / 2 + W % 2; }
	if (W % 2 != 0) { p1 += H; p2 += H / 2 + W % 2; }
	p2 = 0;
	if (!(H % 2 == 0 || W % 2 == 0)) { p1 -= 1; p2 = 1; }
	if (count1 <= p1&&count2 <= p2)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main()
{
	int N, cnt(0);
	string s;
	cin >> N >> s;
	for(int i(0);i<N;++i){
		if(s[i] == 'R') cnt++;
	}
	if(cnt > N - cnt) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n,m,k;
  cin>>n>>m>>k;
  bool flag = false;
  REP(i,n+1){
    REP(j,m+1){
      if(i*(m-j)+j*(n-i)==k){
        flag = true;
        break;
      }
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
using namespace std;

int n, m, x, y,xp[110],yp[110];

int main()
{


	cin >> n >> m >> x >> y;

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

	for (int i = 0; i < m; i++) cin >> yp[i];

	for (int i=x+1;i<=y;i++) 
	{
		int flag = 0;

		for (int j=0;j<n;j++) 
		{
			if (xp[j]>=i) 
			{
				flag = 1;

				break;
			}
		}

		for (int k=0;k<m;k++) 
		{
			if (yp[k] < i)
			{
				flag = 1;

				break;
			}
		}

		if (flag==0) 
		{
			cout << "No War" << endl;

			return 0;
		}
	}

	cout << "War" << endl;

	return 0;
}

Measured memory_bytes: 256
/*
 * 16-10-15_ABC046_B.cpp
 *
 *  Created on: 2016/10/15
 *      Author: ryoma
 */

#include<iostream>

using namespace std;

int main(){
	int N,K;
	cin >> N >> K;
	int ans = K;
	for(int i=1;i<N;i++)
		ans *= K-1;
	cout <<ans<< endl;
	return 0;
}




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

using namespace std;

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

#define X real()
#define Y imag()

typedef long double D;
typedef complex<D> P;
struct L{P a, b;};
typedef vector<P> Pol;

const D EPS = 1e-8;

int sig(D a, D b = 0) {return a < b - EPS ? -1 : a > b + EPS ? 1 : 0;}

D arg(P base, P a, P b) {return arg((b - base) / (a - base));}

int main() {
  while (true) {
    int n, q;
    D r;
    cin >> n >> r >> q;
    if (n == 0) break;
    Pol pol;
    rep (i, n) {
      D x, y;
      cin >> x >> y;
      pol.push_back(P(x, y));
    }
    int pre = -1;
    rep (_, q) {
      int k = -1;
      rep (i, n) if (i != pre && sig(abs(pol[i]), r) == 0) {
	k = i;
	break;
      }
      rep (i, n) if (i != k) {
	D theta = asin(abs(pol[k] - pol[i]) / 2 / r);
	P p = polar(r, arg(pol[k]) - theta * 2);
	theta = arg(pol[k], pol[i], p);
	Pol pol2;
	rep (j, n) pol2.push_back(pol[k] + (pol[j] - pol[k]) * polar((D)1, theta));
	rep (j, n) if (sig(abs(pol2[j]), r) > 0) goto next;
	printf("%.12Lf %.12Lf\n", p.X, p.Y);
	pol = pol2;
	pre = k;
	break;
      next:;
      }
    }
  }
}

Measured memory_bytes: 1292
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n = 0, m = 0; string s; cin >> s;
	for (int h = 0; h < s.size(); h++) {
		if (h % 2 == 0) {
			if (s[h] == '1') { n++; }
		}
		else {
			if (s[h] == '0') { n++; }
		}
	}
	for (int h = 0; h < s.size(); h++) {
		if (h % 2 == 0) {
			if (s[h] == '0') { m++; }
		}
		else {
			if (s[h] == '1') {  m++; }
		}
	}
	cout << min(n, m) << endl;
	cin >> n;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int n,m,bx[105],by[105];
char mp[105][105];
int main()
{
	scanf("%d%d",&n,&m);
	for(RI i=1;i<=n;++i) scanf("%s",mp[i]+1);
	for(RI i=1;i<=n;++i) {
		int flag=1;
		for(RI j=1;j<=m;++j) if(mp[i][j]=='#') {flag=0;break;}
		if(flag) bx[i]=1;
	}
	for(RI j=1;j<=m;++j) {
		int flag=1;
		for(RI i=1;i<=n;++i) if(mp[i][j]=='#') {flag=0;break;}
		if(flag) by[j]=1;
	}
	for(RI i=1;i<=n;++i) {
		if(bx[i]) continue;
		for(RI j=1;j<=m;++j)
			if(!by[j]) putchar(mp[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;
ll bin_pow(ll a,ll n){
    ll ans=1;
    while(n>0){
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans%mod;
}

ll inv_mod(ll a){
  return bin_pow(a,mod-2);
}

int main()
{
  ll n;
  cin>>n;
  vector<ll> a(n);
  ll sum=0;
  for(auto&& e: a) 
  {
    cin>>e;
    sum+=e;
  }
  ll ans=0;
  for(auto&& e: a) 
  {
    ans+=(((sum-e)%mod)*e)%mod;
    ans%=mod;
    sum-=e;
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 4828
#include <bits/stdc++.h>
#define mod 998244353
using namespace std;
int read();
int n;
int m1, m2, m3;
void Add(int& x, int y) { (x += y) >= mod ? x -= mod : x; }

vector<int> e[3][100005];
void add(int f, int t, int d) { e[d][f].push_back(t), e[d][t].push_back(f); }
int sg[3][100005];
vector<int> nx[100005];
void solve(int d) {
    for (int i = 1; i <= n; ++i) nx[i].clear();
    for (int u = n; u >= 1; --u) {
        sort(nx[u].begin(), nx[u].end());
        for (int v : nx[u]) {
            if (sg[d][u] == v) sg[d][u]++;
            if (sg[d][u] < v) break;
        }
        for (int v : e[d][u]) nx[v].push_back(sg[d][u]);
    }
}

int fsp(int base, int p) {
    int rt = 1;
    while (p) {
        if (p & 1) rt = 1ll * rt * base % mod;
        base = 1ll * base * base % mod, p >>= 1;
    }
    return rt;
}
int M(int x) { return x + (x >> 31 & mod); }
struct Poly {
    int x[300005];
    int& operator[](int p) { return x[p]; }
    void fwt(int len) {
        for (int l = 2; l <= len; l <<= 1)
            for (int i = 0, m = l >> 1; i < len; i += l)
                for (int j = i, t; j < i + m; ++j)
                    t = x[j + m], x[j + m] = M(x[j] - t), Add(x[j], t);
    }
} F[3];

int main() {
    n = read(), m1 = read();
    for (int i = 1; i <= m1; ++i) add(read(), read(), 0);
    m2 = read();
    for (int i = 1; i <= m2; ++i) add(read(), read(), 1);
    m3 = read();
    for (int i = 1; i <= m3; ++i) add(read(), read(), 2);
    for (int i = 0; i < 3; ++i) {
        solve(i);
        for (int j = 1, t = 1, p = fsp(10, 18); j <= n; ++j)
            t = 1ll * t * p % mod, Add(F[i][sg[i][j]], t);
    }
    int len = 1;
    while (len <= n) len <<= 1;
    F[0].fwt(len), F[1].fwt(len), F[2].fwt(len);
    for (int i = 0; i < len; ++i)
        F[0][i] = 1ll * F[0][i] * F[1][i] % mod * F[2][i] % mod;

    F[0].fwt(len);
    printf("%d\n", 1ll * F[0][0] * fsp(len, mod - 2) % mod);
    return 0;
}

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') f = (c == '-') ? -1 : f, c = getchar();
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}


Measured memory_bytes: 25216
package main

import (
	"fmt"
)

var dp = [30001][4][1001]bool{}

func main() {
	var N int
	var S string
	fmt.Scan(&N, &S)

	dp[0][0][0] = true
	for i := 0; i < N; i++ {
		for j := 0; j <= 3; j++ {
			for k := 0; k < 1000; k++ {
				if dp[i][j][k] == false {
					continue
				}
				dp[i+1][j][k] = true
				if j <= 2 {
					dp[i+1][j+1][k*10+int(S[i]-'0')] = true
				}
			}
		}
	}

	ans := 0
	for i := 0; i < 1000; i++ {
		if dp[N][3][i] {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 118144
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>

using ll = long long;

using namespace std;

ll mod=1e9+7;


int main() {
	int h,w;
	cin>>h>>w;
	vector<vector<bool>>map(h,vector<bool>(w));
	queue<pair<pair<int,int>,int>>todo;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			char c;
			cin>>c;
			if(c=='.'){
				map[i][j]=true;
			}else{
				todo.push(pair<pair<int,int>,int>(pair<int,int>(i,j),0));
			}
		}
	}
	int ans=0;
	int dx[]={1,0,-1,0};
	int dy[]={0,1,0,-1};
	while(todo.empty()!=1){
		ans++;
		auto tmp=todo.front();
		todo.pop();
		int x=tmp.first.first,y=tmp.first.second;
		int depth=tmp.second;
		ans=depth;
		for(int k=0;k<4;k++){
			int nx=x+dx[k];
			int ny=y+dy[k];
			if(nx<0||nx>=h||ny<0||ny>=w)continue;
			if(map[nx][ny]){
				map[nx][ny]=false;
				todo.push(pair<pair<int,int>,int>(pair<int,int>(nx,ny),depth+1));
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

import sys
import os


N = int(input())
dices = []
for i in range(N):
    dice = list(map(int, input().split()))
    dices.append(dice)

def dice_roll(dice, c):
    copy = dice[:]
    if c == 'E':
        dice[2] = copy[0]
        dice[5] = copy[2]
        dice[3] = copy[5]
        dice[0] = copy[3]
    elif c == 'N':
        dice[0] = copy[1]
        dice[4] = copy[0]
        dice[5] = copy[4]
        dice[1] = copy[5]
        pass
    elif c == 'S':
        dice[1] = copy[0]
        dice[0] = copy[4]
        dice[4] = copy[5]
        dice[5] = copy[1]
    elif c == 'W':
        dice[0] = copy[2]
        dice[2] = copy[5]
        dice[5] = copy[3]
        dice[3] = copy[0]
    # Y???????????¢
    elif c == 'R':
        dice[2] = copy[1]
        dice[4] = copy[2]
        dice[3] = copy[4]
        dice[1] = copy[3]
    return dice


def check(dice0_input, dice1_input):
    # ??????????????¶?????????????????????????????????copy?????±???
    dice0 = dice0_input[:]
    dice1 = dice1_input[:]

    # up???????????????
    num = 0
    while dice0[0] != dice1[0]:
        if num % 2 == 0:
            dice0 = dice_roll(dice0, 'E')
        else:
            dice0 = dice_roll(dice0, 'N')
        num += 1
        if num > 10:
            return False

    # front???????????????
    num = 0
    while dice0[1] != dice1[1]:
        dice0 = dice_roll(dice0, 'R')
        num += 1
        if num > 10:
            return False

    if dice0[2] == dice1[2] and dice0[3] == dice1[3] and dice0[4] == dice1[4] and dice0[5] == dice1[5]:
        return True
    else:
        return False


def check2(dice0, dice1):
    # ?????¨????????¢???????????????6????????§????????????
    for i in range(6):
        result = check(dice0, dice1)
        if result:
            return True
        else:
            if i % 2 == 0:
                dice0 = dice_roll(dice0, 'N')
            else:
                dice0 = dice_roll(dice0, 'E')
    return False

for i in range(N):
    for j in range(i+1, N):
        is_same = check2(dices[i], dices[j])
        if is_same:
            print('No')
            quit()
print('Yes')

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 7;
const LL LINF = INF * INF;

const int mod = 1e9 + 7;

inline int add(int x, int y)
{
	if (x + y >= mod)
		return x + y - mod;
	return x + y;
}

inline int mult(int x, int y)
{
	return x * (LL) y % mod;
}

const int MAX = 1 << 18;
int n;
VI g[MAX];
int dp[MAX][2];

void dfs(int v, int p)
{
	for(auto i: g[v])
		if (i != p)
			dfs(i, v);
	
	dp[v][0] = dp[v][1] = 1;
	for(auto i: g[v])
		if (i != p)
		{
			dp[v][0] = mult(dp[v][0], add(dp[i][0], dp[i][1]));
			dp[v][1] = mult(dp[v][1], dp[i][0]);
		}
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);

	cin >> n;
	int u, v;
	FOR(i, 0, n - 1)
	{
		cin >> u >> v;
		g[u].PB(v);
		g[v].PB(u);
	}
	
	dfs(1, 0);
	int ans = add(dp[1][0], dp[1][1]);
	cout << ans << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 17280
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		for (int i = 0; i <= 50; i++) {
			for (int j = 0; j <= 25; j++) {
				if ((i + j == x) && (2 * i + 4 * j == y)) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}

}


Measured memory_bytes: 35776
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int n,m;
  cin>>n>>m;
  vector<long> vec(n);
  rep(i,n) cin>>vec[i], vec[i]--;

  long crnt = 0;
  long diff = 0;
  vector<vector<pair<long,long>>> v(100005, vector<pair<long,long>>());
  rep(i,n-1){
    if( (vec[i]+1)%m == vec[i+1]){
      crnt++;
      continue;
    }
    long s = (vec[i+1]-vec[i]+m)%m;
    if( (vec[i]+1)%m < vec[i+1]){
      crnt += s;
    } else {
      crnt += vec[i+1]+1;
      diff--;
    }
    v[(vec[i]+1)%m].pb(mp(0, -1));
    v[vec[i+1]].pb(mp(s-1, +1));
  }

  long best = crnt;
  rep(i,m){
    for(auto p : v[i]){
      crnt += p.first;
      diff += p.second;
    }
    crnt += diff;
    best = min(best, crnt);
  }

  cout << best << endl;

  return 0;
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
    int m,d;
    cin >> m >> d;
    int ans = 0;
    for (int i = 1; i <= m; i++) {
        for (int j = 22; j <= d; j++) {
            if (j % 10 < 2) continue;
            int aa = j / 10;
            int bb = j % 10;
            ans += (aa * bb == i);
        }
    }
    cout << ans << endl;
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

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

int main() {
    double a, b, c;
    cin >> a >> b >> c;
    cout << a*b/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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

#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
//#define vvector(name,typ,m,n)vector<vector<typ> > name(m,vector<typ> (n))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
ll ceil(ll a,ll b){
    return ((a+b-1)/b);
}
const int INF = 2000000000;
const ll INF64 = 9223372036854775807ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//mapは、if関数などで覗いただけで構成されるので注意しよう！
//std::vector<vector<int>> g;
int main(){
    int h,hh,m,mm;
    int k;
    std::cin >> h>>m>>hh>>mm>>k;
    int d=(hh-h)*60+mm-m;
    std::cout << d-k << std::endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}


int main() {
  int64_t A,B,C,D;
  cin>>A>>B>>C>>D;
  int64_t ca=(A-1)/C,cb=B/C,da=(A-1)/D,db=B/D;
  int64_t s=C*D/__gcd(C,D);
  int64_t sa=(A-1)/s,sb=B/s;
  int64_t sumB=B-(db+cb)+sb;
  int64_t sumA=A-1-(da+ca)+sa;
  cout<<sumB-sumA<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 62;

int main() {
  //
  ll n, k;
  cin >> n >> k;
  ll cnt = 0;
  rep(i, n) {
    ll h;
    cin >> h;
    if (h >= k) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int((a).size())
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c , s , e ) for(int pos=s; pos<e ; pos++) cout << c[pos] << " ";
#define inf 1e18;
#define PI acos(-1)
const int M = 1000000007;
const int N=2e5+5;
//#define Rohit
#ifdef Rohit
template<typename... T >
void bug(T... __VA_ARGS__) {
    ((cerr << __VA_ARGS__ << " ") , ...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__) , cerr << endl;
#endif


int f[2020];
void solve() {
    string s;
    cin >> s;
    int cur = 1;
    int mod = 0;
    int ans = 0;
    f[0] = 1;
    for(int i=s.size()-1 ; i>=0 ; i--){
        mod = (mod + cur*(s[i] - '0'))%2019;
        cur  = (cur*10)%2019;
        ans+=f[mod];
        f[mod]++;
    }
    cout << ans << endl;

}

signed main()
{
//    FAST;
    //TODO:  check test cases are there or not?
    int tc=1;
//    cin >> tc;
    for(int t = 1 ; t <= tc ; t++)
    {
        solve();
    }
}

Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;


void solve(){
  int n, m; cin >> n >> m;
  int *l = new int[m], *r = new int[m];
  for(int i = 0; i < m; i++) cin >> l[i] >> r[i];
  int minid = l[0];
  int maxid = r[0];
  for(int i = 1; i < m; i++){
    minid = max(l[i], minid);
    maxid = min(r[i], maxid);
  }
  if(maxid - minid + 1 < 0) cout << 0 << endl;
  else cout << maxid - minid + 1 << endl;
  return;
}

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


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

const int N = 2e5 + 10, mod = 1e9 + 7;

int n, k, c, dppref[N], dpsuf[N];
int pref[N];
char s[N];

int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    scanf("%d%d%d", &n, &k, &c);
    scanf("%s", s + 1);
    for(int i = 1; i <= n; i++) {
        dppref[i] = max(dppref[i], dppref[i - 1]);
        int j = max(i - c - 1, 0);
        if(s[i] == 'o') dppref[i] = max(dppref[i], dppref[j] + 1);
    }
    for(int i = n; i >= 1; i--) {
        dpsuf[i] = max(dpsuf[i], dpsuf[i + 1]);
        int j = min(i + c + 1, n + 1);
        if(s[i] == 'o') dpsuf[i] = max(dpsuf[i], dpsuf[j] + 1);
    }
    for(int i = 1 - c; i <= n; i++) {
        int l = max(0, i);
        int r = min(n + 1, i + c + 1);
        // cout << l << ' ' << r << ' ' << dppref[l] << ' ' << dpsuf[r] << '\n';
        if(dppref[l] + dpsuf[r] >= k) pref[max(1, i + 1)]++, pref[r]--;
    }
    if(!c && dppref[n] > k) return 0;
    for(int i = 1; i <= n; i++) {
        pref[i] += pref[i - 1];
        if(!pref[i] && s[i] == 'o') printf("%d\n", i);
    }
    return 0;
}

Measured memory_bytes: 4096
n = int(input())
p = list(map(int, input().split()))

pr = sorted(p)
count = 0
for i in range(len(pr)):
    if pr[i] != p[i]:
        count += 1
    else:
        continue
        
if count == 2 or count == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

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

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

// C - Distinct or Not
int main() {
    int N;
    map<long long, bool> mapA;
    cin >> N;
    long long a;
    for (int i = 0; i < N; i++) {
        cin >> a;
        mapA[a] = true;
    }

    if (N == mapA.size()) cout << "YES";
    else cout << "NO";
}


Measured memory_bytes: 16088