akhauriyash/Code-Regression huggingface dataset:
W,H,C;
char m[22*22];
R(i){
	if(m[i]=='.'){
		m[i]=0;
		C++;
		R(i-1);
		R(i+1);
		R(i-W);
		R(i+W);
	}
}
main(){
	int i;
	char*p;
	for(;scanf("%d%d",&W,&H)*W;){
		memset(m,0,sizeof(m));
		W++;
		for(i=H*W;i--;)
			m[W+i]=getchar();
		C=0;
		p=strchr(m+W,'@');
		m[p-m]='.';
		R(p-m);
		printf("%d\n",C);
	}
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            while (true) {
                int n = sc.nextInt();
                if (n == 0) {
                    break;
                }
                int[] scores = new int[n];
                for (int i = 0; i < scores.length; i++) {
                    scores[i] = sc.nextInt();
                }
                double average = 0, variance = 0;
                for (int i = 0; i < scores.length; i++) {
                    average += scores[i];
                }
                average = average/scores.length;
                for (int i = 0; i < scores.length; i++) {
                variance += (scores[i]-average)*(scores[i]-average);
                }
                variance = variance/scores.length;
                System.out.println(Math.sqrt(variance));

            }
        }
    }
}


Measured memory_bytes: 31168
#include <stdio.h>
#include <string.h>
int n,p;
int a[52];
long long DT[52][3];
long long f(int x,int y){
	if(x==n+1) return y==p;
	if(DT[x][y]!=-1) return DT[x][y];
	return DT[x][y] = f(x+1,y)+f(x+1,(y+a[x])%2);
}
int main(){
	scanf("%d %d",&n,&p);
	for(int i=0;i<=50;i++){
		for(int j=0;j<3;j++){
			DT[i][j] = -1;
		}
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		a[i]=a[i]%2;
	}
	printf("%lld",f(1,0));
}

Measured memory_bytes: 128
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp =[1e10+5]*n
dp[0] = 0

for i in range(n):
    for j in range(1, k+1):
        if i-j < 0:
            break
        dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]))
print(dp[n-1])

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

bool isPrime(int x){
    for(int i=2; i*i<=x; ++i){
        if(x % i == 0) return false;
    }
    return true;
}

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

    vector<int> ans;
    for(int i=6; i<=55555 && ans.size() != n; i+=5){
        if(isPrime(i)) ans.push_back(i);
    }

    cout << ans[0];
    for(int i=1; i < n; ++i) cout << " " << ans[i];
    cout << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

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

int main(void){
    int n, s;
    int b[100];

    scanf("%d", &n);
    for(int i = 0; i < n - 1; i++) scanf("%d", &b[i]);

    s =  b[0] + b[n - 2];
    for(int i = 0; i < n - 2; i++) s += min(b[i], b[i+1]);

    printf("%d\n", s);

    return 0;
}

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

#define sf scanf
#define pf printf
#define rep(i, n) for (i = 0; i < n; ++i)
#define rep0(i, n) for (i = 0; i <= n; ++i)
#define rep1(i, n) for (i = 1; i <= n; ++i)
#define repp(i, a, n) for (i = a; i <= n; ++i)
#define pb push_back

using namespace std;

typedef long long ll;

int main() {
    int n, t, s = 0;
    sf("%d", &n);

    vector<int> v;
    while (n--) {
        sf("%d", &t);
        v.pb(t);
    }

    for (int i = 0; i < v.size(); ++i) {
        for (int j = i+1; j < v.size(); ++j) s += v[i]*v[j];
    }

    pf("%d\n", s);

    return 0;
}


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

public class Main{
    public static void main(String[] args){
	Scanner scanner = new Scanner(System.in);
	int n = scanner.nextInt();
	String S = scanner.next();
	int count = 0;
	for(int i=0;i < n;i++){
	    if(S.charAt(i)=='A'&&i<n-2){
		if(S.substring(i,i+3).equals("ABC")) count++;
	    }
	}
	System.out.println(count);
    }
}


Measured memory_bytes: 23892
a, b, c, x, y = map(int, input().split())

ans1 = a * x + b * y
ans2 = c * 2 * max(x, y)
if x == y:
  ans3 = ans2
elif x > y:
  ans3 = c * 2 * y + a * (x - y)
else:
  ans3 = c * 2 * x + b * (y - x)
print(min(ans1, ans2, ans3))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ll n;
	cin >> n;

	ll sum = 0;

	for (int i = 1; i <= n; i++)
	{
		if (i % 3 != 0 && i % 5 != 0)
		{
			sum += i;
		}
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1



int main() 
{
  int N;
  cin >> N;
  int A;
  rep(i, N){
    cin >>A;
    if(A%2==0){
    if(A%3!=0&&A%5!=0)
    {
      cout <<"DENIED" << endl;
      return 0;
    }
    }
  }
  cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>

int main() {
  size_t n, m;
  scanf("%zu %zu", &n, &m);
  m = n*n - m;

  std::vector<intmax_t> a(n);
  for (auto& ai: a) scanf("%jd", &ai);

  std::sort(a.begin(), a.end());

  auto f = [&](intmax_t x) -> bool {
    size_t m0 = 0;
    for (auto ai: a) {
      m0 += std::upper_bound(a.begin(), a.end(), x-ai) - a.begin();
    }
    return m0 <= m;
  };

  intmax_t lb = 0;
  intmax_t ub = 1e18+1;
  while (ub-lb > 1) {
    intmax_t mid = (lb+ub) >> 1;
    (f(mid)? lb: ub) = mid;
  }

  std::vector<intmax_t> sa(n+1);
  for (size_t i = 0; i < n; ++i)
    sa[i+1] = sa[i] + a[n-i-1];

  intmax_t res = 0;
  {
    size_t count = 0;
    for (auto ai: a) {
      auto it = std::upper_bound(a.begin(), a.end(), ub-ai);
      size_t c = it - a.begin();
      c = n - c;
      res += sa[c] + c * ai;
      count += c;
    }
    res += ((n*n-m)-count) * ub;
  }
  printf("%jd\n", res);
}


Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
 
using namespace std;
 
int main(void){
     
    int a, b;
 
    cin >> a >> b;
 
    if (a > b)
        cout << "a > b" << endl;
    else if (a < b)
        cout << "a < b" << endl;
    else
        cout << "a == b" << endl;
 
    return 0;
}

Measured memory_bytes: 3088
#include<stdio.h>
int main(){
  int n,k,i,j,a,b,c,e,h,mi,min;
  while(scanf("%d %d",&n,&k),n||k){
  int m[100][100]={0};
    while(k--){
      if(scanf("%d",&a),a){
	scanf("%d %d %d",&b,&c,&e);
	b--;
	c--;
	if(m[b][c]>e||m[b][c]==0)m[b][c]=m[c][b]=e;
      }
      else{
	scanf("%d %d",&b,&c);
	b--;
	c--;
	int d[100]={0};
	char f[100]={0};
	mi=b;
	for(i=0;i<n;i++){
	  f[mi]=2;
	  for(j=0;j<n;j++){
	    if(m[mi][j]==0||f[j]==2)continue;
	    if(d[j]==0||d[j]>d[mi]+m[mi][j]){
	      d[j]=d[mi]+m[mi][j];
	      f[j]=1;
	    }
	  }
	  min=2100000000;
	  for(j=h=0;j<n;j++){
	    if(f[j]!=1)continue;
	    h=1;
	    if(min>d[j]){
	      min=d[j];
	      mi=j;
	    }
	  }
	  if(!h)break;
	}
	if(d[c])printf("%d\n",d[c]);
	else    printf("-1\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 656
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll A[100010];
    rep(i,0,N) cin >> A[i];
    ll ans = (N-1+K-2) / (K-1);
    print(ans);
    

}

Measured memory_bytes: 1024
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))
a1 = 0
a2 = 0
a3 = 0

for i in p:
  if i <= a:
    a1 += 1
  elif a+1 <= i and i <= b:
    a2 += 1
  else:
    a3 += 1

print(min(a1,a2,a3))

Measured memory_bytes: 8940
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main() {
  int32_t H1 = 0, M1 = 0, H2 = 0, M2 = 0, K = 0;
  std::cin >> H1 >> M1 >> H2 >> M2 >> K;

  H2 -= K / 60;
  if (K % 60 != 0 && M2 < K % 60) {
    H2--;
    M2 += 60;
  }
  M2 -= K % 60;

  int32_t diff_H = H2 - H1, diff_M = M2 - M1;

  std::cout << diff_H * 60 + diff_M << std::endl;

  return 0;
}

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

int main(){
  int a,b,c;
  int lozenges = 0,rectangle = 0;
  while(~scanf("%d,%d,%d",&a,&b,&c)){
  if(a == b)lozenges++; 
  if(c*c == (a*a + b*b) )rectangle++;
  }
  cout << rectangle << endl;
  cout << lozenges << endl;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int a, count, ans = 100000;
  for (int i = 0; i < N; i++) {
    cin >> a;
    count = 0;
    while (a % 2 == 0) {
      a /= 2;
      count++;
    }
    if (count < ans) ans = count;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>
#include <ctgmath>
#include <queue>
#include <set>

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

const ll inf = 10e17;
const ll mod = inf;//1000000007;
const ld eps = 10e-9;



ll solve(void);
ll gcd(ll x, ll y);


ll mulmod(ll x, ll y)
{
	return (x * y) % mod;
}

ll submod(ll x, ll y)
{
	return (x - y + 100 * mod) % mod;
}

ll power(ll n, ll r)
{
	if ( r == 0 ) { return 1; }
	if ( r == 1 ) { return n; }
	if ( n == 0 ) { return 0; }
	if ( n == 1 ) { return 1; }

	if (r % 2 == 0)
	{
		ll y = power(n, r/2);
		return mulmod(y, y);
	}
	else
	{
		ll y = power(n, (r-1)/2);
		return n * mulmod(y, y) % mod;
	}
}

ll gcd(ll x, ll y)
{
	if (y == 1) { return 1;}
	if (x % y == 0) { return y; }
	return gcd(y, x % y);
}

vector<ll> perm;
vector<ll> inv;
void init_inv(ll m)
{
	perm.resize(m);
	inv.resize(m);
	
	perm[0] = 1;
	inv[0] = 1;

	for (ll i = 1; i < m; i++)
	{
		perm[i] = mulmod(perm[i-1], i);
	}
	
	for (ll i = 1; i < m; i++)
	{
		inv[i] = power(perm[i], mod - 2);
	}
}

ll ncr(ll n, ll r)
{
	// n (n-1) ... (n-r)
	if ( r == n || r == 0 ) { return 1; }

	ll ans = 1;
	for (ll i = 0; i < r; i++)
		ans = mulmod(ans, n - i);

	 return mulmod(ans, inv[r]);
	// return mulmod(perm[n], mulmod(inv[n-r], inv[r]));
}

bool binary_check(ll mid, ll key)
{
	return mid >= key;
}

ll binary_search()
{
//	ll ng = 0;
//	ll ok = x;
//
//	while (abs(ok - ng) > 1)
//	{
	//	ll mid = (ok+ng) / 2;
	//	if (binary_check(mid, k)) ok = mid;
	//	else ng = mid;
	//}

	return 0;
	//return ok;
}

void pushorcreate(map<ll, vector<ll>> &m, ll key, ll i)
{
	if (m.find(key) == m.end())
	{
		m[key] = vector<ll>(1, i);
	}
	else {
		m[key].push_back(i);
	}
}

bool iskaibun(string s)
{
	ll n = s.length();

	bool b = true;
	for (ll i = 0; i < n; i++)
		b &= (s[i] == s[n - 1 - i]);

	return b;
}

ll solve(void)
{
	string s;
	cin >> s;

	ll n = s.length();
	
	string substr = s.substr(0, (n-1)/2);
	
	string substr2 = s.substr((n+3)/2-1);

	bool b = iskaibun(s) && iskaibun(substr) && iskaibun(substr2);

	cout << (b ? "Yes" : "No") << endl;

	return 0;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
int n, d, arr[15][15], ans=0;

bool cek(int n){
		long double sr=sqrt(n);
		return (sr-floor(sr))==0;
	}
	
int main(){
	IOS
	cin >> n >> d;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=d;j++){
			cin >> arr[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			ll temp=0;
			for(int k=1;k<=d;k++){
				temp+=(arr[i][k]-arr[j][k])*(arr[i][k]-arr[j][k]);
			}
			//debug(temp);
			if(cek(temp)) ans++;
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3564
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/

ll ans(ll k){
   if(k==1) return 2;
   return ans(k-1)*2%MOD;
}
ll Ans(ll k){
    ll b=1;
    repf(i,1,k+1){
        b*=2;
        b%=MOD;
    }
    return b;
}

int main(){
    ll n;
    cin>>n;
    vec(a,n);
    a=getv<ll>(n);
    sort(all(a));
    ll cnt=0;
    if(n%2){
        rep(i,n){
        if(a[i]==((i+1)/2)*2){
            cnt++;
        }else {
            op(0);
            return 0;
        }
        }
        
    }else{
        rep(i,n){
            if(a[i]==(i/2+1)*2-1){
                cnt++;
            }else{
                op(0);
                return 0;
            }
        }
    }
    op(Ans(n/2));
    return 0;
}

Measured memory_bytes: 2168
import java.util.Scanner;
import java.lang.StringBuilder;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		StringBuilder bu = new StringBuilder();
		int h,w;
		while((h=sc.nextInt())!=0&&(w=sc.nextInt())!=0){
			for(int i=0;i<h;i++){
				for(int o=0;o<w;o++){
					if((i+o)%2==0){
						bu.append("#");
					}else{
						bu.append(".");
					}
				}
				bu.append("\n");
			}
			bu.append("\n");
		}
		System.out.print(bu);
	}
}

Measured memory_bytes: 27716
#include <stdio.h>

#define MAX(x, y) ((x) >= (y) ? (x) : (y))
int get_int() {
    int n = 0;
    int sign = 1;
    int c = getchar_unlocked();
    if(c == 45) sign = -1, c = getchar_unlocked();
    else if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) {
        n = 10 * n + (c & 0xf);
        c = getchar_unlocked();
    }
    return n * sign;
}

typedef struct Node {
    int parent, left, right, depth, height, sibling;
} Node;
typedef struct BinaryTree {
    Node nodes[25];
    int root;
} BinaryTree;
void bt_init(BinaryTree *BT) {
    for(int i = 0; i < 25; ++i) BT->nodes[i].parent = -1;
}
void bt__depth(BinaryTree *BT, int id, int depth) {
    if(id == -1) return;
    Node *node = &BT->nodes[id];
    node->depth = depth;
    bt__depth(BT, node->left, depth + 1);
    bt__depth(BT, node->right, depth + 1);
}
int bt__height(BinaryTree *BT, int id) {
    int h1 = 0, h2 = 0;
    Node *node = &BT->nodes[id];
    if(~node->left) h1 = bt__height(BT, node->left) + 1;
    if(~node->right) h2 = bt__height(BT, node->right) + 1;
    return node->height = MAX(h1, h2);
}
int bt__sibling(BinaryTree *BT) {
    for(int i = 0; i < 25; ++i) {
        Node *node = &BT->nodes[i];
        if(node->parent == -1) {
            node->sibling = -1;
            continue;
        }
        int left = BT->nodes[node->parent].left;
        int right = BT->nodes[node->parent].right;
        if(left != i && ~left) node->sibling = left;
        else if(right != i && ~right) node->sibling = right;
        else node->sibling = -1;
    }
}
void bt_make(BinaryTree *BT) {
    for(int i = 0; i < 25; ++i) {
        if(BT->nodes[i].parent == -1) {
            BT->root = i;
            break;
        }
    }
    bt__depth(BT, BT->root, 0);
    bt__height(BT, BT->root);
    bt__sibling(BT);
}
void bt_add_node(BinaryTree *BT, int id, int left, int right) {
    BT->nodes[id].left = left;
    BT->nodes[id].right = right;
    if(~left) BT->nodes[left].parent = id;
    if(~right) BT->nodes[right].parent = id;
}
int main(int argc, char **argv) {
    int n = get_int();
    BinaryTree BT;
    bt_init(&BT);
    for(int i = 0; i < n; ++i) {
        int id = get_int();
        int left = get_int();
        int right = get_int();
        bt_add_node(&BT, id, left, right);
    }
    bt_make(&BT);

    for(int i = 0; i < n; ++i) {
        int degree = 0;
        ~BT.nodes[i].left && degree++;
        ~BT.nodes[i].right && degree++;
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d",
               i, BT.nodes[i].parent, BT.nodes[i].sibling, degree, BT.nodes[i].depth, BT.nodes[i].height);
        if(BT.nodes[i].parent == -1) puts(", root");
        else if(BT.nodes[i].left == -1 && BT.nodes[i].right == -1) puts(", leaf");
        else puts(", internal node");
    }
    return 0;
}



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

#define ubuntu ios_base::sync_with_stdio, cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define mp make_pair
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()

const long long MXN = 3e6 + 1;
const long long MNN = 1e3 + 1;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef long double ldub;
typedef unsigned long long ullong;

using namespace std;

llong x , a , b; 

int main(){
    ubuntu;
    ///freopen("in.in", "r", stdin);
    ///freopen("out.out", "w", stdout);
    cin >> x >> a >> b;
    x -= a;
    while(x >= b){
        x -= b;
    }cout << x << nl;
    return 0;
}


Measured memory_bytes: 256
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

map<int, int> pf;

void prime_factor(int n) { // 素因数分解 (o(√N))
    for(int i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ++pf[i];
            n /= i;
        }
    }
    if (n != 1) pf[n] += 1;
}

int solve(){
  int N;cin>>N;
  rep(i, 2, N+1){
    prime_factor(i);
  }
  dump(pf);

  map<int, int> c;
  for (auto el:pf){
    if (el.second>=74) c[74]++;
    if (el.second>=24) c[24]++;
    if (el.second>=14) c[14]++;
    if (el.second>=4) c[4]++;
    if (el.second>=2) c[2]++;
  }
  int res=0;
  res += c[74];
  res += c[24]*(c[2]-1);
  res += c[14]*(c[4]-1);
  if (c[4]>=2 and c[2]>=3) res+=c[4]*(c[4]-1)/2*(c[2]-2);
  cout << res << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	int x,n = 0,a,b,c,d,e;
	public void pr() {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		if(n >= 3 && n <= 10000) {
			for(x = 3; x <= n;x++) {
				a = x % 3;
				b = x % 10;
				c = x / 10;
				d = x / 100;
				e = x / 1000;
				if(a == 0 || b == 3 || c == 3 || c % 10 == 3 || d == 3 || d % 10 == 3 || e == 3 || e % 10 == 3) {
					System.out.print(" " + x);
				}
			}
		}
		System.out.println();
	}
	public static void main(String[] args) {
		new Main().pr();
	}
}

Measured memory_bytes: 24124
import queue
N,M=map(int,input().split())
adj=[[] for i in range(N+1)]
parent=[-1] * (N+1)
for m in range(M):
    a,b=map(int,input().split())
    adj[a].append(b)
    adj[b].append(a)
q=queue.Queue()
q.put((1,0))
while(not q.empty()):
    x,p=q.get()
    if parent[x]!=-1:
        continue
    parent[x]=p
    for next in adj[x]:
        if parent[next]==-1:
            q.put((next,x))
print('Yes')
for p in parent[2:]:
    print(p)

Measured memory_bytes: 40188
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
typedef pair<int,int> pii;
int dp[1001][1001];
main(){
	int N,r,w,rL,mw,i,j;
	for(;~scanf("%d",&N),N;){
		vector<pii>v;
		for(i=0;i<N;i++)scanf("%d%d",&r,&w),v.push_back(make_pair(r,w));
		sort(v.begin(),v.end());
		pii m=v[v.size()-1];
		rL=m.first;
		for(r=w=i=0;i<N-1;i++)r+=v[i].first,w+=v[i].second;
		if(r>=rL){
			printf("%d\n",r+w+rL+m.second);
		}else{
			memset(dp,0,sizeof(dp));
			// http://acm-icpc.aitea.net/index.php?2013%2FPractice%2F%CC%CF%B5%BC%B9%F1%C6%E2%CD%BD%C1%AA%2F%B9%D6%C9%BE
			dp[0][0] = 1;
			for(i=0;i<N-1;i++){
				// rL-rが本Lを読むまでに生じる待ち時間
				for(j=0;j<=rL-r;j++)if(dp[i][j]){
					dp[i+1][j] = 1;
					if(j+v[i].second<=rL-r)dp[i+1][j+v[i].second]=1;
				}
			}
			for(mw=i=0;i<=rL-r;i++)if(dp[N-1][i])mw=i; // 待ち時間に書ける感想文の最大量
			printf("%d\n",2*rL+w+m.second-mw);
		}
	}
}

Measured memory_bytes: 4972
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n';
#define no cout<<"No"<<'\n';
using namespace std;

int main()
{
    godspeed
    ll  t,i,x,j,k,a,b,c;
    cin>>x>>a>>b;
    if(abs(x-a)<abs(x-b))
        cout<<"A"<<endl;
    else
        cout<<"B"<<endl;

    return 0;
}





Measured memory_bytes: 3556
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
int main(){
	int n;
	while(cin>>n,n){
		vector< vector<int> > v(n+1,vector<int>(n+1));
		for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin>>v[i][j];
		for(int i = 0; i < n; i++){
			int a = 0;
			for(int j = 0; j < n; j++) a += v[i][j];
			v[i][n] = a;
		}
		{
			int a = 0;
			for(int j = 0; j < n; j++) a += v[j][n];
			v[n][n] = a;
		}
		for(int i = 0; i < n; i++){
			int a = 0;
			for(int j = 0; j < n; j++) a += v[j][i];
			v[n][i] = a;
		}
		for (int i = 0; i <= n; i++){
			for (int j = 0; j <= n; j++){
				printf("%5d",v[i][j]);
			}
			puts("");
		}
	}
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int a,b;
    string s;
    cin >> a >> b >> s;
    if(s.size() == (a + b + 1) && s[a] == '-' && s[s.size() - b - 1] == '-' && count(s.begin(),s.end(),'-') == 1)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
C = [c for c in input()]

ans = 0
l,r = 0, n-1
while(l < r):
    while(C[l] == 'R'): 
        l += 1
        if (n == l): break
    
    while(C[r] == 'W' or -1 == r):
        r -= 1
        if (-1 == r): break

    if (l < r):
        ans += 1
    l += 1
    r -= 1

print(ans)

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


int main() {
  int n;
  vector<bool> prime(300100, false);
  for (int i = 1; i < prime.size(); i++) if (i % 7 == 1 || i % 7 == 6) prime[i] = true;
  vector<int> nlist;
  prime[1] = false;
  for (int i = 1; i < prime.size(); i++) {
    if (prime[i]) {
      nlist.push_back(i);
      for (int j = 2 *i; j < prime.size(); j += i) {
	prime[j] = false;
      }
    }
  }
  while (cin >> n, n != 1) {
    cout << n << ':';
    for (int i = 0; i < nlist.size(); i++) {
      if (n % nlist[i] == 0) cout << ' ' << nlist[i];
    }
    cout << endl;
  }
  

  return 0;
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N; cin >> N;
  map<int,int> xs;
  REP(i,N){
	int x; cin >> x;
	xs[x]++;
  }

  bool ok = true;
  PII b = *begin(xs);
  int n = b.FF - (b.SS>=2?1:0);
  if(b.SS > 2){
	ok = false;
  }
  int mn = b.FF;
  for(auto&& p: xs){
	if(p.FF == b.FF) continue;
	if(mn+1 != p.FF) ok = false;
	if(n <= 0) ok = false;

	mn = p.FF;
	--n;
  }

  cout << (ok?"Possible":"Impossible") << endl;
  
  return 0;
}


Measured memory_bytes: 384
/*
░░░░░░░░░░░░░░░░▄▄█▀▀██▄▄░░░░░░░
░░░░░░░░░░░░░▄█▀▀░░░░░░░▀█░░░░░░
░░░░░░░░░░░▄▀░░░░░░░░░░░░░█░░░░░
░░░░░░░░░▄█░░░░░░░░░░░░░░░█░░░░░
░░░░░░░██▀░░░░░░░▄▄▄░░▄░█▄█▄░░░░
░░░░░▄▀░░░░░░░░░░████░█▄██░▀▄░░░
░░░░█▀░░░░░░░░▄▄██▀░░█████░██░░░
░░░█▀░░░░░░░░░▀█░▀█▀█▀▀▄██▄█▀░░░
░░░██░░░░░░░░░░█░░█░█░░▀▀▄█▀░░░░
░░░░█░░░░░█░░░▀█░░░░▄░░░░░▄█░░░░
░░░░▀█░░░░███▄░█░░░░░░▄▄▄▄█▀█▄░░
░░░░░▀██░░█▄▀▀██░░░░░░░░▄▄█░░▀▄░
░░░░░░▀▀█▄░▀▄▄░▄░░░░░░░███▀░░▄██
░░░░░░░░░▀▀▀███▀█▄░░░░░█▀░▀░░░▀█
░░░░░░░░░░░░▄▀░░░▀█▄░░░░░▄▄░░▄█▀
░░░▄▄▄▀▀▀▀▀█▀░░░░░█▄▀▄▄▄▄▄▄█▀▀░░
░▄█░░░▄██▀░░░░░░░░░█▄░░░░░░░░░░░
█▀▀░▄█░░░░░░░░░░░░░░▀▀█▄░░░░░░░░
█░░░█░░░░░░░░░░░░░░░░░░█▄░░░░░░░
*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
#define mp make_pair
const ll mod = 1000000007;
const ll nmax=500003;
int n, a[202], b[202], c[202], ans;


int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    for(int i=1; i<=n; i++) cin>>a[i];
    for(int i=1; i<=n; i++) cin>>b[i];
    for(int i=1; i<n; i++) cin>>c[i];
    for(int i=1; i<=n; i++) ans+=b[a[i]];
    for(int i=1; i<n; i++) if(a[i]+1==a[i+1]) ans+=c[a[i]];
    cout<<ans;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

void solve(int test_case) {
	int n,t;
	cin>>n>>t;
	ll end=0,tot=0;
	while(n--) {
		int val;
		cin>>val;
		if(end>val) {
			tot-=end-val;
		}
		end=val+t;
		tot+=t;
	}
	cout<<tot;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3644
#include <cstdio>
#include <cmath>
#include <algorithm>

long double pi = acosl(-1.0L);

int main() {
  long double a, b, x;
  scanf("%Lf %Lf %Lf", &a, &b, &x);

  long double h = x / a / a;
  long double theta;
  if (x == a*a*b) {
    theta = 0.0;
  } else if (x*2 >= a*a*b) {
    // long double y = std::max(0.0L, 2*(b-h));
    long double y = 2*(b-h);
    // theta = std::acos(a / std::hypot(a, y));
    // theta = std::atan2(y, a);
    theta = std::atan(y / a);
  } else {
    long double y = 2*a*h / b;
    // theta = std::acos(y / std::hypot(b, y));
    // theta = std::atan2(b, y);
    theta = std::atan(b / y);
  }

  theta *= 180.0L / pi;
  printf("%.20Lf\n", theta);
}


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

int h, w;
char C[22][22];
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};
bool seen[22][22];

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


    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> C[i][j];
        }
    }

    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(C[i][j] == '#'){
                continue;
            }
            int D[h][w];
            for(int k = 0; k < h; k++){
                for(int k2 = 0; k2 < w; k2++){
                    D[k][k2] = 1e9;
                }
            }
            D[i][j] = 0;

            queue<pair<int, int>> q;
            q.push(make_pair(i, j));
            int mama = 0;
            while(!q.empty()){
                pair<int, int> t = q.front();
                q.pop();
                for(int i = 0; i < 4; i++){
                    int nx, ny;
                    nx = t.first + dx[i];
                    ny = t.second + dy[i];
                    if(nx < 0 or ny < 0 or nx >= h or ny >= w){
                        continue;
                    }
                    if(C[nx][ny] == '#'){
                        continue;
                    }
                    if(D[t.first][t.second] + 1 < D[nx][ny]){
                        D[nx][ny] = D[t.first][t.second] + 1;
                        mama = max(mama, D[nx][ny]);
                        q.push({nx, ny});
                    }
                }
            }
            ans = max(ans, mama);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
 int n;
 cin>>n;
 string s,s1,s2;
  cin>>s;
  int f =1;
  if(n%2!= 0 ){ cout<<"No"; return 0; }
  for(int i = 0;i<n/2;i++){
   if(s[i] != s[i+n/2])
   {f = 0; break;}
  }
  if(f) cout<<"Yes"; 
  else cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin>>S;
    if((S.at(0)=='B'&&S.at(1)=='B'&&S.at(2)=='B')||S.at(0)=='A'&&S.at(1)=='A'&&S.at(2)=='A') cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#define MAX 500000
//#define INFINITY 200000000
using namespace std;

void merge(int[],int,int,int,int);
void mergeSort(int[],int,int,int);
//int n,S[MAX];
int L[MAX/2+2],R[MAX/2+2];
int cnt;

int main(){
  int i,n;
  cnt = 0;
  int A[MAX];
  cin >> n;
  //scanf("%d",&n);
  for(i = 0; i < n; i++){
    cin >> A[i];
    //scanf("%d",&A[i]);
    //mergeSort(S[i],0,i);
  }
  mergeSort(A,n,0,n);
  for(i = 0; i < n; i++){
    if(0 < i){
      cout << " ";
      //printf(" ");
    }
    cout << A[i];
    //printf("%d",A[i]);
  }
  cout << endl << cnt << endl; /**/
  //printf("\n%d\n",cnt);
  return 0;
}
void merge(int A[],int n,int left,int mid,int right){
  int n1,n2,i,j,k;
  n1 = mid - left;
  n2 = right - mid;
  /*L[0...n1],R[0...n2]?????????*/
  for(i = 0; i < n1; i++){
    L[i] = A[left + i];
  }
  for(i = 0; i < n2; i++){
    R[i] = A[mid + i];
  }
  L[n1] = INFINITY;
  R[n2] = INFINITY;
  //L[n1] = SMAX;
  //R[n2] = SMAX;
  i = 0;
  j = 0;
  for(k = left; k < right; k++){
    cnt++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
}
void mergeSort(int A[], int n, int left, int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right)/2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

Measured memory_bytes: 6888
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
"""
#decomment when needed
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
"""
n,k = ips()
left = max(-100000 , k-n+1)
right = min(100000 , k+n)
a = [i for i in range(left,right)]
for i in range(len(a)-1):
    print(a[i],end = " ")
print(a[len(a)-1])

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

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int a,b;
    array<int,101> v;
    v.fill(0);
    while(cin>>a>>b){
        if(a==0&&b==0){
            int odd=0;
            loop(i,3,101)
                if(v[i]%2==1) odd++;
            cout<<(odd==0 && v[1]%2==1 && v[2]%2==1 ? "OK" : "NG")
                <<endl;
            v.fill(0);
        } else {
            v[a]++;v[b]++;
        }
    }
}

Measured memory_bytes: 1152
package main

import (
	. "fmt"
	"os"
	"sort"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	buf := make([]byte, 4096)
	_i := len(buf)
	rc := func() byte {
		if _i == len(buf) {
			os.Stdin.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b ; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}
	n,k:=r(),r()
	a := make([]int,0, n)
	for ;n>0;n-- {
		a = append(a, r())
	}
	Print(sort.Search(1e9, func(l int) bool {
		if l == 0 {
			return false
		}
		c := 0
		for _, v := range a {
			c += (v - 1) / l
		}
		return c <= k
	}))
}


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


int main (){
    int L, M, N;
    cin>>L>>M>>N;
    int maxof = max(L, M);
    maxof = max(maxof, N);
    int minof = min(L, M);
    minof = min(minof, N);
    cout<<maxof - minof <<endl;
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int,input().split()))
dp = [0]*N
dp[0] = 0
dp[1]=abs(h[1]-h[0])
for i in range(2,N):
  dp[i] += min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

Measured memory_bytes: 13980
#include<iostream>
#include<string>
#include<algorithm>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define repm(i, m, n) for (int i = (m); i < (n); i++)
#define rep_rev(i, n) for (int i = int (n); i >= 0; i--)
typedef long long int lli;
using namespace std;

int main() {
	int n, k;
	int h[100000];
	cin >> n >> k;
	rep(i, n)cin >> h[i];

	int cnt = 0;
	rep(i, n)if (h[i] >= k)cnt++;
	cout << cnt << endl;

	return 0;
}

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

int main() {
    int n, a_min, diff, diff_max;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];

    diff_max = -2e9;
    a_min = a[0];
    for (int i = 1; i < n; i++) {
        diff = a[i] - a_min;
        if (diff > diff_max) {
            diff_max = diff;
        }
        if (a[i] < a_min) {
            a_min = a[i];
        }
    }
    cout << diff_max << endl;
    return 0;
}


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

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 1e9+7;
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; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 

ll dp0[200][5], dp1[200][5];


int A[200];

int main() {
    string S;
    cin >> S;
    int L = S.size(), K;
    cin >> K;
    rep(i, L){
        A[i] = S[i] - '0';
        //cout << A[i];
    }
    //cout << endl;
    
    dp0[0][1] = A[0] - 1;
    dp0[0][0] = 1;
    dp1[0][1] = 1;
    reps(i, 1, L){
        //cout << "A[i] = " << A[i] << endl; 
        rep(j, 4){
            dp0[i][j + 1] += dp0[i - 1][j] * 9;
            dp0[i][j] += dp0[i - 1][j];
            
            if (A[i] == 0){
                dp1[i][j] = dp1[i - 1][j];
            } else {
                dp1[i][j + 1] = dp1[i - 1][j];
                dp0[i][j + 1] += dp1[i - 1][j] * (A[i] - 1);
                dp0[i][j] += dp1[i - 1][j];
            }
        }
    }
    cout << dp0[L - 1][K] + dp1[L - 1][K];
    return 0;
}


Measured memory_bytes: 256
h, n = map(int, input().split())
magics = [list(map(int, input().split())) for _ in range(n)]
max_a = max(a for a,b in magics)
dp = [0] * (h+max_a)

for i in range(1,h+max_a):
    dp[i] = min(dp[i-a]+b for a, b in magics)
print(dp[h])

Measured memory_bytes: 3664
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S1 = sc.nextLine();
		char[] a = S1.toCharArray();
		String S2 = sc.nextLine();
		char[] b = S2.toCharArray();
		int number = 0;
		if(a[0]==b[0]) {
			number++;
		}
		if(a[1]==b[1]) {
			number++;
		}
		if(a[2]==b[2]) {
			number++;
		}
		System.out.println(number);
	}
}

Measured memory_bytes: 21844
#include<iostream> 
using namespace std; 
int main(){ 
 int a,b,c,x,y,z;
 cin>>a>>b>>c;
 x=a;
 if(b>x){
  y=x;
  x=b;
 }else{
  y=b;
 }
 if(c>x){
  z=y;
  y=x;
  x=c;
 }else if(c>y){
  z=y;
  y=c;
 }else{
  z=c;
 }
 cout<<z<<" "<<y<<" "<<x<<endl;
  return 0; 
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
int main (){
  int kosu = 0;
  int max = 0;
  int jikan = 0;
  cin >> kosu >> max >> jikan;
  int hoge = kosu / max;
  if (kosu % max == 0){
    cout << hoge * jikan << endl;
  }else{
  cout << (hoge + 1) * jikan << endl;
    }
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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


	int N;
	cin >> N;
	pair<int, int> LN[100000], RN[100000];

	rep(i, N) {
		int L, R;
		cin >> L >> R;
		LN[i] = make_pair(L, i);
		RN[i] = make_pair(R, i);
	}
	sort(LN, LN + N);
	sort(RN, RN + N);
	reverse(LN, LN + N);

	ll best = -1e18;
	rep(k, 2) {

		int tukatta[100000] = {};

		ll kyori = 0;
		int ichi = 0;
		int Ltugi = 0;
		int Rtugi = 0;

		rep(j, N) {
			if (k || j) {
				for (int i = Ltugi; i < N; i++) {
					if (ichi < LN[i].first && tukatta[LN[i].second] == 0) {
						kyori += LN[i].first - ichi;
						ichi = LN[i].first;
						cesp(ichi);
						ce(kyori);
						tukatta[LN[i].second] == 1;
						Ltugi++;
						break;
					}
					Ltugi++;
				}
			}
			for (int i = Rtugi; i < N; i++) {
				if (ichi > RN[i].first && tukatta[RN[i].second] == 0) {
					kyori += ichi - RN[i].first;
					ichi = RN[i].first;
					cesp(ichi);
					ce(kyori);
					tukatta[RN[i].second] == 1;
					Rtugi++;
					break;
				}
				Rtugi++;
			}
		}
		kyori += abs(ichi);
		best = max(best, kyori);
	}
	co(best);

	Would you please return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define MAX_N 200005
#define LL long long
int n,m,k;
string s;
int sum[12][1005];
bool mp[12][1005];
int ans=99999999;
int a[12];

bool check(int cnt,int j,int la){  //判断需不需要切。
    int s=0;
    for(int i=1;i<=cnt;i++){
        s=sum[a[i]][j]-sum[a[i]][la]-sum[a[i-1]][j]+sum[a[i-1]][la];
        if(s>k)return 0;
    }
    return 1;
}

void work(int t){     //枚举竖着切。
    int s=t,la=0;
    a[t+1]=n;
    for(int i=1;i<=m;i++)if(!check(t+1,i,la))s++,la=i-1;
    if(check(t+1,m,m-1))ans=min(ans,s); //细节，最后1列可能超过K个，需特判。
}

void dfs(int now,int t){ //枚举横着切。
    if(now==n){
        work(t);
        return;
    }
    a[t+1]=now,dfs(now+1,t+1);
    dfs(now+1,t);
}
int main(){
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        cin>>s;
        for(int j=1;j<=m;j++)
            mp[i][j]=s[j-1]-'0',sum[i][j]=sum[i][j-1]+mp[i][j]+sum[i-1][j]-sum[i-1][j-1];
    }
    dfs(1,0);
    cout<<ans;
}

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

typedef long long LL;

const double PI = acos(-1.0);

int n, a[100050], b[100050], cur;
LL ans;

int work() {

    scanf("%d", &n);

    for (int i = 0; i <= n; ++i) scanf("%d", &a[i]);
    for (int i = 0; i < n; ++i) scanf("%d", &b[i]);


    for (int i = 0; i < n; ++i) {
        int tmp = min(b[i], a[i]);
        ans += tmp;
        b[i] -= tmp;
        tmp = min(b[i], a[i+1]);
        ans += tmp;
        a[i+1] -= tmp;
    }

    printf("%lld\n", ans);
    return 0;
}

int main() {
    work();
    //while (~scanf("%d", &n)) work();
    //scanf("%d", &T); while (T--) work();

    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int v[n], c[n];
    rep(i, n){
        cin >> v[i];
    }
    rep(i, n){
        cin >> c[i];
    }
    
    int sum=0;
    rep(i, n){
        if(v[i]-c[i]>0){
            sum += v[i] -c[i];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void C();

int main()
{
	C();
	fflush(stdout);
	return 0;
}

static void C()
{
	int N;
	get(N);

	LLONG sum = 0;
	std::vector<LLONG> ai(N, 0);
	for (int i = 0; i < N; i++) {
		get(ai[i]);
		sum += ai[i];
		sum %= MOD_NUM;
	}

	LLONG ans = 0;
	LLONG nowSum = sum;
	for (int i = 0; i < N; i++) {
		nowSum = nowSum - ai[i];
		if (nowSum < 0) nowSum += MOD_NUM;
		ans += (ai[i] * nowSum) % MOD_NUM;
		ans %= MOD_NUM;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 4840
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scan(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define lim 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}

// header
int n;
string s,t;
void input(){
    cin>>n>>s>>t;
}
void src(){
    reverse(ALL(s));
    int max=0;
    repi(i,1,n+1){
        string ss=s.substr(0,i);
        reverse(ALL(ss));
        string tt=t.substr(0,i);
        if(ss==tt){max=i;}
    }
    cout<<2*n-max;
}   
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
 
int main() {
  int D;
  cin >> D;
  if (D == 25) cout << "Christmas";
  if (D == 24) cout << "Christmas Eve";
  if (D == 23) cout << "Christmas Eve Eve";
  if (D == 22) cout << "Christmas Eve Eve Eve";
  return 0;
}

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

int main(void) {
    long long A, B;
    cin >> A >> B;
    long long x = A * B;
    long long tmp;
    if (A < B) {
        tmp = A;
        A = B;
        B = tmp;
    }
    long long r = A % B;
    while (r != 0) {
        A = B;
        B = r;
        r = A % B;
    }
    cout << (x / B) << "\n";
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i=0;i<n;++i) cin >> h[i];
  
  int ans=0;
  for (int i=0;i<1;++i){
    ans+=h[0];
  }
  for (int i=1;i<n;++i){
    if (h[i-1]<=h[i]){
      ans+=h[i]-h[i-1];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256