akhauriyash/Code-Regression huggingface dataset:
class Node:
	def __init__(self):
		self.parent = None
		self.left = None
		self.right = None

def restoreTree(preList, inList):
	root = preList[0]
	index = inList.index(root)
	leftin = inList[:index]
	# print(leftin)
	rightin = inList[index + 1:]
	# print(rightin)
	num_left = len(leftin)
	num_right = len(rightin)
	if num_left != 0:
		leftpre = preList[1:1 + num_left]
		# print(leftpre)
		left_root = leftpre[0]
		T[root].left = left_root
		T[left_root].parent = root
		restoreTree(leftpre, leftin)
	if num_right != 0:
		rightpre = preList[1 + num_left:]
		# print(rightpre)
		right_root = rightpre[0]
		T[root].right = right_root
		T[right_root].parent = root
		restoreTree(rightpre, rightin)


def postOrder(root):
	if T[root].left is not None:
		postOrder(T[root].left)
	if T[root].right is not None:
		postOrder(T[root].right)
	L.append(str(root))

if __name__ == "__main__":
	n = int(input())
	T = []
	for _ in range(n + 1):
		T.append(Node())
	preList = list(map(int, input().split()))
	inList = list(map(int, input().split()))
	root = preList[0]
	restoreTree(preList, inList)
	L = []
	postOrder(root)
	print(" ".join(L))


Measured memory_bytes: 5620
H,W = map(int,input().split())
sy,sx = map(int,input().split())
gy,gx = map(int,input().split())
sy,sx = sy-1,sx-1
gy,gx = gy-1,gx-1
S = [input() for i in range(H)]

import heapq
INF = float('inf')
dist = [[INF]*W for i in range(H)]
dist[sy][sx] = 0
hq = [(0,sx+sy*W)]
heapq.heapify(hq)
while hq:
    d,v = heapq.heappop(hq)
    y,x = divmod(v,W)
    for dx in range(-2,3):
        for dy in range(-2,3):
            if dx == dy == 0: continue
            nx,ny = x+dx,y+dy
            if not 0 <= nx < W: continue
            if not 0 <= ny < H: continue
            if S[ny][nx] == '#': continue
            if abs(dx)+abs(dy) <= 1:
                if dist[ny][nx] <= dist[y][x]: continue
                dist[ny][nx] = dist[y][x]
                heapq.heappush(hq, (d,nx+ny*W))
            else:
                if dist[ny][nx] <= dist[y][x] + 1: continue
                dist[ny][nx] = dist[y][x] + 1
                heapq.heappush(hq, (d+1, nx+ny*W))
print(-1 if dist[gy][gx]==INF else dist[gy][gx])

Measured memory_bytes: 100740
#include<bits/stdc++.h>
using namespace std;
void change(int &a, int &b){
	int t = a; a = b; b = t;
}

int main(){

	int n;
	cin >> n;

	int a[101];
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}

	int count = 0;
	for (int i = 0; i < n; i++){
		int minj = i;
		for (int j = i; j < n; j++){
			if (a[j] < a[minj]){ minj = j; }
		}
		if (a[i] != a[minj]){ count++; }
		change(a[i], a[minj]);
	}

	for (int i = 0; i < n; i++){
		printf("%d%c", a[i], i == n - 1 ? '\n' : ' ');
	}
	cout << count << endl;

	return 0;
}


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

int main(){
    
    int N,M,K,S; cin >> N >> M;
    vector<vector<int>> bulb(M);
    vector<int> re(M);
    for(int i=0;i<M;i++){
        cin >> K;
        for(int j=0;j<K;j++){
            cin >> S; S--;
            bulb[i].push_back(S);
        }
    }
    
    for(int i=0;i<M;i++){ cin >> re[i]; }
    
    ll ans = 0;
    for (int bits = 0; bits < (1 << N); bits++) {  //スイッチの個数
        bool ok = true;
        for (int i = 0; i < M; i++) {  //電球の個数
            int sum = 0;
            for (auto v : bulb[i]) {    //電球の個数が違うので拡張for文
                if (bits & (1<<v)) ++sum;   //ビットが立っているところはカウント
            }
            if (sum % 2 != re[i]) ok = false; //すべての電球に対してスイッチの偶奇が等しいか確認
        }
        if(ok) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define MODNUM (INT(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

template <typename T>
int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T>
void chmax(T& m, T x) {
	m = max(m, x);
}

template <typename T>
void chmin(T& m, T x) {
	m = min(m, x);
}

template <typename T>
T square(T x) {
	return x * x;
}

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main() {
	string s, t, u;
	int a, b;
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;
	cout << (s == u ? a - 1 : a) << ' ' << (s == u ? b : b - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  int st1, st2, st3;
  cin >> S;
  st1 = S[0];
  st2 = S[1];
  st3 = S[2];
  if(S[0] == S[1] && S[1] == S[2]){
    cout << "No" << endl;

  }else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <iostream>

using namespace std;

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

const int limitation = 2005;
long C[limitation][limitation]; // C[n][k] = n! / (k! * (n - k)!)

long calc(int i, int j) {
    if (C[i][j] != 0) return C[i][j];

    if (i < j) {
        return 0;
    } else if (i == j) {
        C[i][j] = 1;
        return 1;
    } else if (j == 0) {
        C[i][j] = 1;
        return 1;
    } else {
        C[i][j] = (calc(i - 1, j - 1) + calc(i - 1, j)) % 1000000007;
        return C[i][j];
    }
}

int main() {
    // 1 <= K <= N <= 2000
    int N; // ボール数
    int K; // 青いボール数
    cin >> N >> K;

    REP(0, i, limitation) REP(0, j, limitation) C[i][j] = 0;

    REP(1, i, K + 1) {
        cout << (calc(N - K + 1, i) * calc(K - 1, i - 1)) % 1000000007 << endl;
    }

    return 0;
}


Measured memory_bytes: 31744
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication32
{
    class Program
    {  
      static void Main()
      {
       var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
       Console.WriteLine("{0} {1}",a[0]*a[1],(a[0]+a[1])*2);
      }
      }
      }

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

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

  int vec_a[n][m];
  int vec_b[m];

  // vec_a[]への入力
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin >> vec_a[i][j];
    }
  }

  // debug: vec_a[]の出力
  // for(int i=0;i<n;i++){
  //   for(int j=0;j<m;j++){
  //     cout << vec_a[i][j] << " ";
  //   }
  //   cout << endl;
  // }


  // vec_b[]への入力
  for(int i=0;i<m;i++){
    cin >> vec_b[i];
  }

  // debug: vec_b[]の出力
  // for(int i=0;i<m;i++){
  //   cout << vec_b[i] << endl;
  // }


  // vec_c[]へ代入
  int vec_c[n];
  // vec_c[]を初期化
  for(int i=0;i<n;i++){
    vec_c[i] = 0;
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      vec_c[i] += vec_a[i][j] * vec_b[j];
    }
  }

  // vec_c[]を出力
  for(int i=0;i<n;i++){
    cout << vec_c[i] << endl;
  }
}



Measured memory_bytes: 3128
N, A, B = map(int, input().split())
S = input()
all = 0
foreign = 0

for i in range(len(S)):
  if S[i] == 'a' and all < A + B:
    print('Yes')
    all += 1
    continue
  if S[i] == 'b' and all < A + B and foreign < B:
    print('Yes')
    all += 1
    foreign += 1
    continue
  print('No')

Measured memory_bytes: 9308
main :: IO ()
main = do
  let
    f :: Int -> Int -> Int
    f k m = (2 * k) `min` (m - 1)
  [n, k] <- map read . words <$> getLine :: IO [Int]
  ds <- getLine :: IO String
  let
    (m, s) = foldl step (1, 0) . (zipWith (==) <$> id <*> tail) $ ds :: (Int, Int)
      where
        step :: (Int, Int) -> Bool -> (Int, Int)
        step (m, s) b | b         = (m, s + 1)
                      | otherwise = (m + 1, s)
  print $ (s + 2 * k) `min` (n - 1)


Measured memory_bytes: 7960
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key){x=x->left;}
    else{x=x->right;}
  }
  
  z->parent=y;

  if(y==NIL){root=z;}
  else if(z->key<y->key){y->left=z;}
  else {y->right=z;}
  
}

Node treeSearch(Node u, int k){
  if(u==NIL||k==u->key){return u;}
  
  if(k<u->key){return treeSearch(u->left,k);}
  else {return treeSearch(u->right,k);}
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);   
  }
}
void preorder(Node u){
  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right); 
  }
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d",&n);

  for ( i = 0; i < n; i++ )
    {
      scanf("%s",com);

      if ( com[0] == 'i' )
	{
	  scanf("%d",&x);
	  insert(x);
	}
      else if ( com[0] == 'p' )
	{
	  inorder(root);
	  printf("\n");
	  preorder(root);
	  printf("\n");
	} 
      else if ( com[0] == 'f' ){
	scanf("%d",&x);
	Node t = treeSearch(root, x);
	if ( t != NIL ) printf("yes\n");
	else printf("no\n");
      }
    }

  return 0;
}



Measured memory_bytes: 20456
#include <bits/stdc++.h>
#define pb push_back
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
#define INF 300000000000001
#define ll_max 9000000000000000000
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long int ll;
typedef long double ld;
typedef vector<pair<ll,ll> > vll;
typedef vector<int> vi;
typedef pair<ll,ll> pll;
const ll mod = 1000000007;
const ll N = 200001;
const ll M = log2(N);

struct point {
    ll x, y, i;
};

void debug(stringstream &s){}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cerr << word << " = " << a << endl;
    debug(s, args...);
}

ll fast_exp(ll x, ll n)
{
    if(n == 0) return 1;
    if(n & 1) return fast_exp(x, n - 1) * x % mod;
    else
    {
        ll ans = fast_exp(x, n / 2);
        return ans * ans % mod;
    }
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, m, x, y, ans = 0, s, l;
        cin >> n >> m >> x;
        ans = m / x - (n - 1) / x;
        cout << ans << "\n";
    }
    return 0;
}


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

const int MAXN = 1005, MOD = 1e9 + 7;
long long cnt[MAXN], n;
bool p[MAXN];

int main() {
	cin >> n;
	if (n == 1)
		return cout << 1, 0;
	for (int i = 2; i <= n; i++)
		if (!p[i])
			for (int j = i; j <= n; j += i) {
				p[j] = 1;
				int tmp = j;
				while (tmp % i == 0)
					tmp /= i, cnt[i]++;
			}
	long long ans = 1;
	for (int i = 0; i < MAXN; i++) 
		ans *= cnt[i] + 1, ans %= MOD;
	cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
    long long int r, d, x, n, i, j, ans=0;
    scanf("%lld %lld %lld", &r, &d, &x);
    for(i=0; i<10; i++){
        x = x*r - d;
        printf("%lld\n", x);
    }
}

Measured memory_bytes: 128
n,m = map(int,input().split())
li = [0] * m
for i in range(n):
    a = list(map(int,input().split()))
    for j in range(len(a)):
        if j == 0:
            continue
        else:
            li[a[j]-1] += 1
cnt = 0
for i in li:
    if i == n:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
bool a[100001]={false};
int main()
{
	int n,cnt;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int l,r;
		cin>>l>>r;
		for(int j=l;j<=r;j++)
			a[j]=true;
	}
	for(int i=1;i<=100000;i++)
		if(a[i])
			cnt++;
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
	
	static int k(char a) {
		if(a == '0') {
			return 0;
		}
		else if(a == '1') {
			return 1;
		}
		else if(a == '2') {
			return 2;
		}
		else if(a == '3') {
			return 3;
		}
		else if(a == '4') {
			return 4;
		}
		else if(a == '5') {
			return 5;
		}
		else if(a == '6') {
			return 6;
		}
		else if(a == '7') {
			return 7;
		}
		else if(a == '8') {
			return 8;
		}
		else {
			return 9;
		}
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		List <String> a = new ArrayList<String>();
		String tmp;
		do {
			tmp = stdIn.next();
			a.add(tmp);
		}while(!tmp.equals("0"));
		
		for(int i = 0; i < a.size()-1; i++) {
			tmp = a.get(i);
			int tmpk = 0;
			for(int j = 0; j < tmp.length(); j++) {
				tmpk += k(tmp.charAt(j));
			}
			System.out.println(tmpk);
		}
		
		

	}

}

Measured memory_bytes: 17200
from queue import Queue as queue
import numpy as np
n = int(input())
e = [[] for i in range(n + 1)]
for i in range(n - 1):
    u, v, w = map(int, input().split())
    e[u].append([v, w])
    e[v].append([u, w])

q = queue()
donelist = [0 for i in range(n + 1)]

ans = [False for i in range(n + 1)]

for i in e[1]:
    q.put([i, False])
    donelist[1] = 1

while not q.empty():
    nx = q.get()
    donelist[nx[0][0]] = 1
    if not nx[0][1] % 2:
        ans[nx[0][0]] = nx[1]
    else:
        ans[nx[0][0]] = not nx[1]
    for i in e[nx[0][0]]:
        if donelist[i[0]]:
            continue
        q.put([i, ans[nx[0][0]]])

del ans[0]

for i in ans:
    if i:
        print(0)
    else:
        print(1)


Measured memory_bytes: 54960
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int R, G, B, N;
	cin >> R >> G >> B >> N;

	int cnt = 0;
	for (int i = 0; i <= N/R; i++) {
		for (int j = 0; j <= (N - i * R)/G; j++) {

			if ((N - R * i - G * j) % B == 0) cnt++;

		}
	}

	cout << cnt << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){

  int N;
  int L;
  cin>>N>>L;
  vector<string>S(N);
  for(int i=0;i<=N-1;i++){
  
    cin>>S[i];
  }
  sort(S.begin(),S.end());
  for(int i=0;i<=N-1;i++){
  
    cout<<S[i];
  }
}

Measured memory_bytes: 3588
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

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

int main(){
   long long int x,y,sum,n2=1;
   cin>>x>>y;
   sum=y*1900+(x-y)*100;
   for(int i=0;i<y;i++){
       n2=n2*2;
   }
   cout<< sum*n2<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
#include <map>
#include<cmath>
#include<queue>

typedef long long ll;
using namespace std;
#define mod 10007
#define rep(i,n) for(ll i=0;i<n;i++)

int main(void){
  string s;
  cin >> s;
  int ans=0;
  for(char c:s){
    if(c=='+')ans++;
    if(c=='-')ans--;
  }

  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<cmath>
const int N=2e5+9;
using namespace std;
char a[N];
int f[N][30],g[N][30],l[N][30];
int ans[N];
int main()
{
   scanf("%s",&a);
   int len=strlen(a);
   for(int i=len;i>=1;--i) a[i]=a[i-1];
   
   for(int i=len;i>=0;--i)
   {
      for(int j=1;j<=26;++j)
	   f[i][j]=f[i+1][j],g[i][j]=g[i+1][j];
	  
	  int now;
	  if(i!=len)
	  {
	  now=a[i+1]-'a'+1;
      f[i][now]=1;
      g[i][now]=i+1;
	  }
	  
	  for(int j=1;j<=26;++j)
	  {
	  	if(f[i][j]==0) {l[i][j]=1;continue;}
	    if(j==now) 
	     {
	     	int minn=10000000;
	     	for(int k=1;k<=26;++k) minn=min(minn,l[i+1][k]);
	     	l[i][j]=minn+1;
		    continue;
		 }
		l[i][j]=l[i+1][j];
	  }
   }	
//for(int i=0;i<=len;++i)
// for(int j=1;j<=26;++j)
//  printf("f[%d][%d]:%d\n",i,j,f[i][j]);
   int tot=0;
   int pos=0;
   while(pos<=len)
   {
   	 int minn=1000000,where;
   	 for(int j=1;j<=26;++j)
      {
      	if(l[pos][j]<minn)
      	{
      	   where=j;minn=l[pos][j];	
		}
	  }
	  
    ans[++tot]=where;
    if(minn==1) break;
	pos=g[pos][where];
   }
   
  for(int i=1;i<=tot;++i)  putchar(ans[i]-1+'a');

  return 0;
}
/*
abcdefghijklmnopqrstuvwxyzb
*/

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

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

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

    return arr

s=factorization(a) 
ans=0
for i in s:
    if i[0]>1:
        tmp=0
        count=0
        while True:
            tmp+=count
            if i[1]<tmp:
                count-=1
                break
            else:
                count+=1
                
        ans+=count
            
print(ans)

Measured memory_bytes: 9492
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);

int main(){
	int x,y;cin>>x>>y;
    for(int i=0;i<=x;i++){
        int j = x-i;
            if(2*i+4*j==y){
                cout<<"Yes"<<endl;
                return 0;
            }
        
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

static const int N = 501;
static const int INFTY = (1<<21);

int main(){
  int M[N][N],n,u,k,v,i,j;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      M[i][j] = 0;
    }
  }

  for(i = 0;i < n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j = 0;j < k;j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }

  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      if(j > 0) printf(" ");
      printf("%d",M[i][j]);
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2112
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#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 CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void){
  int a, b, c;

  cin >> a >> b >> c;
  int ans = 0;
  for(int i=a;i<=b;i++){
    if(c%i == 0) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<sstream>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; ++i)
#define per(i, a, n)  for(int i=n-1; i>=a; --i)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 1000000007
using namespace std;
typedef long long ll;

int main(){
  int a, b; cin >> a >> b;
  int ans = 0;
  rep(i, 0, 2){
    if(a>b){
      ans += a;
      a--;
    }else{
      ans += b;
      b--;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(l.begin(), l.end());
    int ans = 0;
    for (int a = 0; a < n; ++a) {
        for (int b = a + 1; b < n; ++b) {
            int idx = lower_bound(l.begin(), l.end(), l[a] + l[b]) - l.begin() - 1;
            ans += (idx - b);
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int n; cin >> n;
  vector<int> nums(n);
  rep_i(i, n){
    cin >> nums[i];
  }
  int q; cin >> q;
  int b, e;
  rep_i(i, q){
    cin >> b >> e;
    reverse(&nums[b], &nums[e]);
  }
  for (vector<int>::iterator itr = nums.begin(); itr != nums.end(); itr++){
    if(itr == nums.begin()){
      cout << *itr;
      continue;
    }
    cout << " " << *itr;
  }
  cout << endl;
}


Measured memory_bytes: 3088
N,K=map(int, input().split())
A=list(map(int, input().split()))

from collections import Counter

AL=Counter(A)
AL= sorted(AL.items(), key=lambda x:x[1])
n=len(set(A))-K

sum=0
for i in range(n):
  sum+=AL[i][1]
print(sum)

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

int main(){
    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    int ans = ((n-1)+(k-1)-1)/(k-1);
    
    cout << ans << endl;
    
    

}


Measured memory_bytes: 640
#include <stdio.h>



int main(){

	

        int m,n;

	

	int a,b,c;

	

	scanf("%d %d",&m,&n);

	

	int large[m][n];

	

	int small[n];

	

	/*

	printf("%d %d\n",n,m); ここはおk

	*/



	for(a=0;a<=m-1;a++){

	  /*

		scanf("%*c");

	  */	

	  /*

		printf("a=%d\n",a);

		*/



		for(b=0;b<=n-1;b++){

			

			scanf("%*c%d",&large[a][b]);



			/*

			printf("large[%d][%d]=%d\n",a,b,large[a][b]);

			printf("b=%d\n",b);

			*/



		}



		

		

	}

	

	/*

	printf("large end!\n");

	*/



	for(c=0;c<=n-1;c++){

		

		scanf("%*c%d",&small[c]);

		

	}

	

	int d,e;

	

	int answer[m];

	

	for(d=0;d<=m-1;d++){

		

		answer[d]=0;

		

		for(e=0;e<=n-1;e++){

			

			answer[d]+=large[d][e]*small[e];

			

		}

		

	}

	

	int f;

	

	for(f=0;f<=m-1;f++){

		

		printf("%d\n",answer[f]);

		

	}



	return 0;

	

}

Measured memory_bytes: 640
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
#def MXI(): return [LI() for i in range(n)]　
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

s=I()
if s==10**18:
    print(0,0,0,10**9,10**9,0)
else:
    print(0,0,10**9,1,10**9-s%(10**9),1+s//(10**9))

    
            
    
    

Measured memory_bytes: 64908
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}

int main(void) {
  
  ll a, b;
  cin >> a >> b;
  if(a>=13) pt(b);
  else if(a>=6) pt(b/2);
  else pt(0);
  
  
  
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int ans = 0;
            for (int i = 1; i <= n; i++) {
                int x = i;
                int c = 0;
                while (x > 0) {
                    x /= 10;
                    c++;
                }
                if (c % 2 == 1)
                    ans++;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21332
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
//MACROS
#define _crt_secure_no_warnings
#define FREEELO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define INF 0x3F3F3F3F
#define MAX 1001
#define MOD 1000000007
#define ALPHABET 128
#define loop(i, n) for (int i = 1; i <= (n); i++)
#define loop0(i, n) for (int i = 0; i < (n); i++)
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll> llll;
typedef pair<int, int> ii;
typedef unordered_map<int, int> umii;
typedef unordered_map<ll, ll> umll;
typedef unordered_set<int> usi;
typedef unordered_multiset<int> usmi;

int main() {
    int n; cin >> n;
    vector<ii> v(n + 1);
    loop(i, n) {
        cin >> v[i].first >> v[i].second;
    }
    int flag = 0;
    for (int i = 3; i <= n; i++){
        if (v[i - 2].F == v[i - 2].S && v[i - 1].F == v[i - 1].S && v[i].F == v[i].S) flag = 1;
    }
    if (flag == 1) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,P,Q;
int C[555555];

signed main(){
    scanf("%lld%lld%lld",&N,&P,&Q);

    rep(i,N)scanf("%lld",&C[i]);

    int val=accumulate(C,C+N,0ll);
    int ans=val;
    vector<int>dif;
    rep(i,N){
        dif.pb((Q-i)*P-C[i]);
    }
    sort(all(dif));reverse(all(dif));

    for(int i=0;i<N;i++){
        val+=dif[i];
        chmax(ans,val+i*(i+1)*P);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 10972
/*
*	author:		richardjcy
*	created:	2020/09/26/07:51.07
*/

#include <bits/stdc++.h>
using namespace std;



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

    int n, k;
    string s;
    cin >> n >> k >> s;
    s[k - 1] = (char)(s[k - 1] - 'A' + 'a');
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner src = new Scanner(System.in);
		
		
		//H,Wが両方とも0になるまで繰り返す
		while(true) {
			
			
			//縦、横の高さ
			int H  = src.nextInt();
			int W  = src.nextInt();
			
	      //HW両方が0になった場合終了
	     if((W == 0) && (H == 0)) {
	    	 break;
	     }  
			
			//縦の列の繰り返し
	        for (int i = 1; i <= H; i++) {
	        	
	        	
	        	//横の列の繰り返し
	            for (int j = 1; j <= W; j++) {
	                System.out.print("#");
	            }
	            
	            //縦に１列進む
	            System.out.println();
			}
	        
	        System.out.println();
	        

		}
	}
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 A;
  string bs;
  cin >> A >> bs;
  string b("");
  REP(i, bs.size()) if (bs[i] != '.') b += bs[i];
  int64 B = stoi(b);
  cout << A*B/100 << endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sort stable_sort
#define all(x) (x).begin(),(x).end()
#define rep(i,x) for ((i)=(1);(i)<=(x);(i)++)
#define rep2(i,x) for ((i)=(x);(i)>=(1);(i)--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
using namespace std;
int n,i,a[105];
vector<int> ans;
void solve(int n){
	if (!n) return;
	int i,j=-1;
	rep(i,n) if (a[i]==i) j=i;
	if (j==-1){puts("-1");exit(0);}
	ans.pb(j);
	for (i=j;i<n;i++) a[i]=a[i+1];
	solve(n-1);
}
int main(){
	scanf("%d",&n);
	rep(i,n) scanf("%d",&a[i]);
	solve(n);reverse(all(ans));
	foreach(it,ans) cout<<*it<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
void fin(int n){
  cout<<n<<endl;
  exit(0);
}
//template
//main
signed main(){
  string s,t;cin>>s>>t;
  int N=s.size(),M=t.size();
  std::vector<int> v(26,0),w(26,0);
  for(int i=0;i<N;i++)v[s[i]-'a']++;
  for(int i=0;i<M;i++)w[t[i]-'a']++;
  for(int i=0;i<26;i++)if(v[i]==0&&w[i])fin(-1);
  std::vector<int> edge[26];
  for(int i=0;i<N;i++)edge[s[i]-'a'].push_back(i);
  int ans=0,now=-1;
  for(int i=0;i<M;i++){
    int a=t[i]-'a';
    int l=-1,r=edge[a].size()-1;
    if(edge[a][r]<=now){
      ans++;
      now=edge[a][0];
      continue;
    }
    while(r-l>1){
      int m=(l+r)/2;
      if(edge[a][m]>now)r=m;
      else l=m;
    }
    now=edge[a][r];
    //cout<<ans<<" "<<now<<endl;
  }
  cout<<ans*N+now+1<<endl;
}


Measured memory_bytes: 1852
#include <stdio.h>
#include <string.h>

int main() {
    char k, s[101], i;

    scanf("%d", &k);
    scanf("%s", s);

    if(strlen(s) > k) {
        s[k] = '\0';
        printf("%s...", s);
    }
    else puts(s);

    return 0;
}

Measured memory_bytes: 1684
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  int n , r;
  cin >> n >> r;
  cout << (n >= 10 ? r : r + 100 * (10 - n)) << endl;
  return 0;
}


Measured memory_bytes: 256
import statistics
import math

ans1 = 0
ans2 = 0
n = int(input())
m = list(map(int, input().split()))
x = math.floor(statistics.mean(m))
y = math.ceil(statistics.mean(m))
for i in range(n):
    num = (m[i]-x)**2
    ans1 = ans1 + num
for i in range(n):
    num = (m[i]-y)**2
    ans2 = ans2 + num

if ans1 > ans2:
    ans = ans2
else:
    ans = ans1
print(ans)

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll N, D; cin >> N >> D;
	ll cnt = 0;
	for (int i = 0; i < N; i++) {
		ll X, Y; cin >> X >> Y;
		if (X*X + Y*Y <= D*D) cnt++;
	}
	cout << cnt << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2e5+10;
struct edge{
	int to,next,len;
}e[N*4]; 
int tot,m,n,first[N],dep[N],fa[N],num;
void add(int u,int v){
	e[++tot].next=first[u],first[u]=tot;
	e[tot].to=v;
}
void bfs(){
	queue<int>q;
	q.push(1);
	while(!q.empty()){
		int now=q.front();q.pop();num++;
		for(int i=first[now];i;i=e[i].next){
			int u=e[i].to;
			if(dep[u]!=-1)continue;
			dep[u]=dep[now]+1;fa[u]=now;
			q.push(u);
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,u,v;i<=m;i++){
		scanf("%d%d",&u,&v);
		add(u,v);add(v,u);
	}
	memset(dep,-1,sizeof(dep));
	dep[1]=0;
	bfs();
	if(num!=n)return puts("No"),0;
	puts("Yes");
	for(int i=2;i<=n;i++)printf("%d\n",fa[i]);
}

Measured memory_bytes: 10144
n, a, b = map(int, input().split())
t, o = 0, 0
s = input()
for i in range(n):
    if s[i]=="a":
        t += 1
        if t <= a+b:
            print("Yes")
        else:
            print("No")
    elif s[i]=="b":
        o += 1
        if o <= b and t < a+b:
            t += 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 4016
import numpy as np
def min_mod2019(L, R):

    mod_list = [i for i in range(2019)]

    imin=0
    jmin=0
    
    if L%2019 < R%2019 and R < L+2019:
        mod_list = mod_list[L%2019:R%2019 + 1]
        min_mod = 2019
        for i in range(len(mod_list)-1):
            for j in range(i+1, len(mod_list)):
                if min_mod > (mod_list[i]*mod_list[j])%2019:
                    #imin=mod_list[i]
                    #jmin=mod_list[j]
                    min_mod=(mod_list[i]*mod_list[j])%2019
        return min_mod
    return 0

if __name__ == '__main__':
    L, R =map(int,input().split(' '))
    print(min_mod2019(L, R))

Measured memory_bytes: 12468
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
	int n,d; string s;
	cin>>n>>d;
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= d; ++j) {
			string t = to_string(j);
			if (t.size() >= 2) {
				int a = (int)(t[0]-'0'); int b = (int)(t[1]-'0');
				if (a >= 2 && b>=2) {
					if (a*b == i) ans++;
				}
			}	
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int H, A;
  cin >> H >> A;

  cout << H / A + min(1, H % A) << endl;
  return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

/**
 * for (int i = 0; i < N; i++) {}
 * System.out.println();
 * HashMap<Integer, Integer> hm = new HashMap<>();
 * int[] s = new int[M];
 * ArrayDeque<Integer> deq = new ArrayDeque<>();
 *
 */
public class Main implements Runnable { //クラス名はMain1

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
		new Thread(null, new Main(), "", 1024 * 1024 * 1024).start(); //16MBスタックを確保して実行
	}

	public void run() {
		FastScannerMain1 sc = new FastScannerMain1(System.in);

		try {
			//String S = sc.nextLine().trim();
			int N = sc.nextInt();
			Robot[] r = new Robot[N];

			//long l = sc.nextLong();
			//ArrayList<Integer> arr = new ArrayList<Integer>();

			for (int i = 0; i < N; i++) {
				int start = sc.nextInt();
				int length = sc.nextInt();
				int end = start + length;
				Robot robot = new Robot();
				robot.start = start - length;
				robot.length = length;
				robot.end = end;
				r[i] = robot;
			}

			Arrays.sort(r, new Comparator<Robot>() {
				public int compare(Robot robot1, Robot robot2) {
					return robot1.end - robot2.end;
				}
			});

			int end = Integer.MIN_VALUE;
			int ans = 0;
			for (int i = 0; i < N; i++) {
				//System.out.println(r[i].start + " " + r[i].length + " " + r[i].end);
				if (r[i].start >= end) {
					end = r[i].end;
					ans++;
				}
			}

			System.out.println(ans);

		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}

class Robot {
	int start;
	int length;
	int end;
}

//高速なScanner
class FastScannerMain1 {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerMain1(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


Measured memory_bytes: 48876
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long A,B;
  cin>>A>>B;
  int K;
  cin>>K;
  vector<long long> ans;
  for(int i=0;i<K;i++){
    bool ok = true;
    if(A<=B){
      for(int j=0;j<ans.size();j++){
        if(A==ans.at(j)){
          ok = false;
        }
      }
      if(ok){
        ans.push_back(A);
        A++;
      }
    }
  }
  for(int i=0;i<K;i++){
    bool ok = true;
    if(A<=B){
      for(int j=0;j<ans.size();j++){
        if(B==ans.at(j)){
          ok = false;
        }
      }
      if(ok){
        ans.push_back(B);
        B--;
      }
    }
  }
  sort(ans.begin(),ans.end());
  for(int i=0;i<ans.size();i++){
    cout<<ans.at(i)<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
  int n,count=0;
  int a=0,b=0,c=0;
  scanf("%d",&n);
  char s[n];
  int r[n],g[n],d[n];
  scanf("%s",&s);
  for(int i=0;i<n;i++){
    if(s[i]=='R'){
      r[a++]=i;
    }
    if(s[i]=='G'){
      g[b++]=i;
    }
    if(s[i]=='B'){
      d[c++]=i;
    }
  }
  int A,B,C;
  for(int i=1;i<=(n-1)/2;i++){
    for(int j=1;(j+2*i)<=n;j++){
      A=j-1;
      B=A+i;
      C=B+i;
      if(s[A]!=s[B] && s[B]!=s[C] && s[C]!=s[A]){
        count++;
      }
    }
  }
  printf("%ld",a*b*c-count);
  return 0;
}

Measured memory_bytes: 1740
#include <cstdio>
typedef long long ll;
inline int rd(){
    int x=0,p=1;
    char a=getchar();
    while((a<48||a>57)&&a!='-')a=getchar();
    if(a=='-')p=-p,a=getchar();
    while(a>47&&a<58)x=(x<<1)+(x<<3)+(a&15),a=getchar();
    return x*p;
}
const int N=100002;
struct Edge{
	int to,next;
}edge[N<<1];
int head[N],cnt;
int n,m;
int h[N],ans=0;
inline void add(int f,int t){
	edge[++cnt].next=head[f];
	edge[cnt].to=t;
	head[f]=cnt;
}
int main(){
	n=rd(),m=rd();
	for(int i=1;i<=n;i++)h[i]=rd();
	for(int i=1;i<=m;i++){
		int u=rd(),v=rd();
		add(u,v),add(v,u);
	}
	for(int u=1;u<=n;u++){
		int flag=1;
		for(int i=head[u];i;i=edge[i].next){
			int v=edge[i].to;
			if(h[v]>=h[u])flag=0;
			if(!flag)break;
		}
		ans+=flag;
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3932
import sys
import random
import time
my_input = sys.stdin.readline

start = time.time()
D = int(input())
C = list(map(int, my_input().split()))
S = [list(map(int, my_input().split())) for _ in range(D)]


def main():
    cnt = 0
    best_ans, best_score = generate_first_ans()
    while time.time() - start < 1.8:
        cnt += 1
        ans = best_ans[:]
        si = random.randint(0, 364)
        sj = random.randint(max(0, si - 10), min(364, si + 10))
        if si == sj:
            continue
        #si, sj = random.randint(0, 364), random.randint(0, 364)
        ans[si], ans[sj] = ans[sj], ans[si]
        score = calc_score(ans)
        if score > best_score:
            best_score = score
            best_ans = ans

    #print(best_score, cnt)
    for a in best_ans:
        print(a + 1)


def generate_first_ans():
    best_ans = []
    best_score = 0
    last_day = [-1] * 26
    for d in range(365):
        d_ans = -1
        d_score = -float('inf')
        d_last_day = [-1] * 26
        for t in range(26):
            d_tmp_score = 0
            d_tmp_score += S[d][t]
            d_tmp_last_day = last_day[:]
            d_tmp_last_day[t] = d
            for c, ld in zip(C, d_tmp_last_day):
                d_tmp_score -= c * (d - ld)

            if d_tmp_score > d_score:
                d_ans = t
                d_score = d_tmp_score
                d_last_day = d_tmp_last_day[:]

        best_ans.append(d_ans)
        best_score += d_score
        last_day = d_last_day[:]

    return best_ans, best_score


def calc_score(T):
    score = 0
    last_day = [-1] * 26
    for d, t in enumerate(T):
        score += S[d][t]
        last_day[t] = d
        for c, ld in zip(C, last_day):
            score -= c * (d - ld)
    return score


if __name__ == "__main__":
    main()


Measured memory_bytes: 87448
import sys
def S(): return sys.stdin.readline().rstrip()

N,Y = map(int,S().split())

for i in range(N+1):
    for j in range(N+1-i):
        if Y == 10000*i+5000*j+1000*(N-i-j):
            print(*[i,j,N-i-j])
            exit()

print('-1 -1 -1')

Measured memory_bytes: 40812