akhauriyash/Code-Regression huggingface dataset:
//Written by Rhitwik Saha//
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vb          vector<bool>
#define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define ub(x)       upper_bound(x)
#define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N            1e5+5
#define M           1000000007
#define MAX         100005
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
int i,j,k;
void Anon_mouS(){
    int n;
    cin>>n;
    map <string,int> m;
    for(i=0;i<n;i++){
        string s;
        cin>>s;
        m[s]++;
    }
    int ma=0;
    for(auto s:m){
        ma=max(ma,s.S);
    }
    vector <string> ans;
    for(auto s:m){
        if(s.S==ma)ans.pb(s.F);
    }
    sort(all(ans));
    for(string s:ans)cout<<s<<endl;
}
int32_t main(){
    fastio;
    // file;
    // sieve();
    int q=1;
    // cin>>q;
    while(q--)Anon_mouS();
    return 0;
}


Measured memory_bytes: 25584
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD=1000000007;

int main() {
    int R,G,B,N; cin>>R>>G>>B>>N;
    int count=0;
    for(int i=0;i<=N/R;i++){   //R
        for(int j=0;j<=(N-R*i)/G;j++){   //G
            int k=(N-(R*i+G*j))/B;
            if(N==R*i+G*j+B*k)count++;
        }
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 256
//@Kevin090228,don't look at my code!
#include<bits/stdc++.h>
#define int long long
#define maxn 1010
using namespace std;
int n,k;
int x[maxn][3];
main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
		for(int j=0;j<3;j++)
			cin>>x[i][j];
	int mx=0;
	for(int mask=0;mask<8;mask++)
	{
		vector<int> v;
		for(int i=0;i<n;i++)
		{
			int t=mask,val=0;
			for(int j=0;j<3;j++)
			{
				if(t&1)
					val+=x[i][j];
				else
					val-=x[i][j];
				t/=2; 
			}
			v.push_back(val);
		}
		sort(v.rbegin(),v.rend());
		int sum=0;
		for(int i=0;i<k;i++)
			sum+=v[i];
		mx=max(mx,sum);
	}
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 256
N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
total_votes = sum(A)
threshold = total_votes / (4 * M)
uppers = [int(i >= threshold) for i in A]
if sum(uppers) >= M:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let A: i64 = read();
    let B: i64 = read();
    let N: i64 = read();
    let ans = if N > B - 1 {
        A * (B - 1) / B
    } else {
        A * N / B
    };
    println!("{}", ans)
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
#include <atcoder/mincostflow>

using namespace std;
using namespace atcoder;

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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "[";
  REP(i, SZ(v)) {
    if (i) os << ", ";
    os << v[i];
  }
  return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  return os << "(" << p.first << " " << p.second << ")";
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = 10000000000L;
const ld eps = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n, k;
  cin >> n >> k;
  vvll a(n, vll(n));
  REP(i, n) {
    REP(j, n) {
      cin >> a[i][j];
    }
  }

  mcf_graph<ll, ll> flow(2*n+2);

  REP(i, n) {
    flow.add_edge(0, 1+i, k, 0);
    flow.add_edge(1+n+i, 2*n+1, k, 0);
  }

  REP(i, n) {
    REP(j, n) {
      flow.add_edge(1+i, 1+n+j, 1, INF - a[i][j]);
    }
  }

  flow.add_edge(0, 2*n+1, n*k, INF);

  auto val = flow.flow(0, 2*n+1, n*k);
  //cout << val << endl;

  cout << -val.second + (ll)INF * n * k << endl;

  vector<string> ans(n);
  REP(i, n) {
    REP(j, n) {
      ans[i] += '.';
    }
  }

  auto g = flow.edges();
  for(auto &e: g) {
    if(e.flow == 0) continue;
    if(!(1 <= e.from && e.from <= n)) continue;

    int i = e.from - 1, j = e.to - n - 1;
    ans[i][j] = 'X';
  }

  REP(i, n) {
    cout << ans[i] << endl;
  }



}

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

string s[8]={"","SAT","FRI","THU","WED","TUE","MON","SUN"},t;

int main()
{
	cin>>t;
	for(int i=1;i<=7;++i) if(s[i]==t) printf("%d",i);
	return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0])
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
class Dice:

    def __init__(self, faces):
        self.faces = tuple(faces)

    def roll_north(self):
        self.faces = (self.faces[1], self.faces[5], self.faces[2],
                      self.faces[3], self.faces[0], self.faces[4])

    def roll_south(self):
        self.faces = (self.faces[4], self.faces[0], self.faces[2],
                      self.faces[3], self.faces[5], self.faces[1])

    def roll_west(self):
        self.faces = (self.faces[2], self.faces[1], self.faces[5],
                      self.faces[0], self.faces[4], self.faces[3])

    def roll_east(self):
        self.faces = (self.faces[3], self.faces[1], self.faces[0],
                      self.faces[5], self.faces[4], self.faces[2])

    def number(self, face_id):
        return self.faces[face_id - 1]

    def checksame(self, faces):
        self_opposite_face = dict(zip([self.number(i) for i in range(1, 7)],
                                      [self.number(i) for i in range(6, 0, -1)]))
        other_opposite_face = dict(zip([faces.number(i) for i in range(1, 7)],
                                       [faces.number(i) for i in range(6, 0, -1)]))
        if self_opposite_face != other_opposite_face:
            return False
        if self.number(2) in (faces.number(3), faces.number(4)):
            faces.roll_west()
        while self.number(2) != faces.number(2):
            faces.roll_north()
        while self.number(1) != faces.number(1):
            faces.roll_west()
        return self.number(3) == faces.number(3)

dice1 = Dice(list(map(int, input().split())))
dice2 = Dice(list(map(int, input().split())))

print("Yes" if dice1.checksame(dice2) else "No")

Measured memory_bytes: 6804
#include <iostream>
#include <algorithm>
#include <map>
#include <tuple>
using namespace std;

struct State {
	int a[10][10];
};

char c[10][10]; int p[10][10], H, W, mindep, cnts;

int range(int sx, int sy, int gx, int gy) {
	int cnt = 0;
	for (int i = sx; i < gx; i++) {
		for (int j = sy; j < gy; j++) {
			if (c[i][j] == '0') cnt++;
		}
	}
	return cnt;
}
int range2(int sx, int sy, int gx, int gy, State G) {
	int cnt = 0;
	for (int i = sx; i < gx; i++) { if (G.a[i][sy] == 0) cnt++; }
	for (int i = sy; i < gy; i++) { if (G.a[sx][i] == 0) cnt++; }
	return cnt;
}

State nurie(State P, int cx, int cy) {
	for (int i = cx; i < cx + p[cx][cy]; i++) {
		for (int j = cy; j < cy + p[cx][cy]; j++) P.a[i][j] = 1;
	}
	return P;
}

long long hash_value(State I) {
	long long mod = 2555555555555555555LL, II = 0, J = 1;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (I.a[i][j] == 1) II += J; J *= 2;
			if (II >= mod) II -= mod;
			if (J >= mod) J -= mod;
		}
	}
	return II;
}

map<tuple<int, int, int, long long>, int>M;

void dfs(int cx, int cy, int depth, State S) {
	long long K = hash_value(S);
	if (M[make_tuple(cx, cy, depth, K)] == 1) return;
	M[make_tuple(cx, cy, depth, K)] = 1;
	cnts++;
	if (depth == mindep) return;
	if (cx == H) {
		mindep = min(mindep, depth);
		return;
	}
	int nx = cx, ny = cy + 1; if (ny == W) { ny = 0; nx++; }
	if (c[cx][cy] == '0') {
		dfs(nx, ny, depth, S);
	}
	else {
		if (S.a[cx][cy] == 0) {
			State V = nurie(S, cx, cy);
			dfs(nx, ny, depth + 1, V);
		}
		else if (range2(cx, cy, cx + p[cx][cy], cy + p[cx][cy], S) == 0) {
			dfs(nx, ny, depth, S);
		}
		else {
			dfs(nx, ny, depth, S);
			State V = nurie(S, cx, cy);
			dfs(nx, ny, depth + 1, V);
		}
	}
}

int main() {
	while (true) {
		cin >> W >> H; M.clear(); mindep = (1 << 30); if (H == 0 && W == 0) break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) cin >> c[i][j];
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				for (int k = 1; k <= min(H - i, W - j); k++) {
					if (range(i, j, i + k, j + k) >= 1) break;
					p[i][j] = k;
				}
			}
		}
		State S; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) S.a[i][j] = 0; }
		dfs(0, 0, 0, S);
		cout << mindep << endl;
	}
	//cout << "Totalcount : " << cnts << endl;
	return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll h,w;
  cin >> h >> w;
  vector<vl> cost(10,vl(10,0));
  vector<vl> routing(10,vl(10,1e9));
  REP(i,10){
    REP(j,10){
      cin >> cost[i][j];
      CHMIN(routing[i][j],cost[i][j]);
    }
  }
  REP(t,10){
    REP(i,10){
      REP(j,10){
        REP(k,10){
          CHMIN(routing[i][j],routing[i][k]+routing[k][j]);
          CHMIN(routing[j][i],routing[j][k]+routing[k][i]);
        }
      }
    }
  }
  //cout << "routing" << endl;
  //REP(i,10){
  //  REP(j,10){
  //    cout << routing[i][j] << " ";
  //  }
  //  cout << endl;
  //}
  ll ans = 0;
  REP(i,h){
    REP(j,w){
      ll a;
      cin >> a;
      if(a!=-1) ans += routing[a][1];
    }
  }

  cout << ans << endl;
  return 0;
}


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

int main() {
  int N, a, b, c, d;
  cin >> N;
  a = N /1000;
  b = (N-a*1000)/100;
  c = (N-a*1000-b*100)/10;
  d = (N-a*1000-b*100-c*10);
  // cout << a*1000+b*100+c*10+d <<endl;

  if ((a == b && b == c)||(c == d && b == c)) {
    cout << "Yes" << endl;
  }

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

}

Measured memory_bytes: 256
Q,H,S,D=map(int,input().split())
N=int(input())
q1=Q
q2=min(2*q1,H)
q4=min(2*q2,S)
q8=min(2*q4,D)
if N%2==0:
  print(N//2*q8)
else:
  print(N//2*q8+q4)

Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc160_a
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().ToCharArray();
            Console.WriteLine(s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");
            Console.Read();
        }
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

struct Prime {
  int max_check;
  int max_prime;
  int prime_number;
  vector<int> primes;
  map<int, int> prime_id;
  Prime() {};
  Prime(int m) {
    initialize(m);
  };
  void initialize(int m) {
    sieve(m);
    prime_number = (int)primes.size();
    max_check = m;
  }

  void sieve(int m) {
    max_prime = 2;
    deque<bool> is_prime(m+1, true);
    is_prime[0] = is_prime[1] = false;
    int i;
    for (i = 2; i <= m; ++i) {
      if (!is_prime[i]) {
        continue;
      }
      if (i * i > m) {
        break;
      }
      for (int j = i+1; j <= m; ++j) {
        if (j % i == 0) {
          is_prime[j] = false;
        }
      }
      prime_id[i] = (int)primes.size();
      primes.push_back(i);
      max_prime = i;
    }
    for (int j = i; j <= m; ++j) {
      if (!is_prime[j]) {
        continue;
      }
      prime_id[j] = (int)primes.size();
      primes.push_back(j);
      max_prime = j;
    }
  }

  map<int, int> prime_factor(ll x) {
    map<int, int> ret;
    if ((ll)max_check * (ll)max_check < x) {
      return ret;
    }
    for (int i = 0; i < prime_number; ++i) {
      while (x % primes[i] == 0) {
        x /= primes[i];
        ret[primes[i]] += 1;
      }
    }
    if (x != 1) {
      ret[x] += 1;
    }
    return ret;
  }
};

int mod = 1e9+7;

ll po(ll k, ll x) {
  if (x == 0) {
    return 1;
  }
  if (x == 1) {
    return k % mod;
  }
  ll y = po(k, x/2);
  y = y * y % mod;
  if (x % 2 == 1) {
    y = y * k % mod;
  }
  return y;
}

int main() {
  int n;
  scanf("%d", &n);
  Prime pr(32);

  map<int, int> mps;
  FOR (i, 2, n+1) {
    auto appends = pr.prime_factor(i);
    for (auto append : appends) {
      mps[append.first] += append.second;
    }
  }

  ll ans = 1;
  for (auto m : mps) {
    ans = ans * (m.second + 1) % mod;
  }
  printf("%lld\n", ans);

  return 0;
}


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

int main() {
    int k, x; cin >> k >> x;

    int l = x - k + 1;
    int r = x + k - 1;

    for (int i = max(l, -1000000); i <= min(r, 1000000); i++) {
        cout << i << ' ';
    }

    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pi>
#define vpl vector<pl>
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005

int a[4];

int32_t main(){
	ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
#ifdef LOCAL_DEFINE
	ifstream cin("input.in");
#endif
	
	for(int i=0;i<4;i++) cin >> a[i];
	sort(a,a+4);
	if(a[0]==1 && a[1]==4 && a[2]==7 && a[3]==9) cout << "YES";
	else cout << "NO";
	
#ifdef LOCAL_DEFINE
	cerr << "\nTime elapsed: " << 1.0*clock()/CLOCKS_PER_SEC << " \n";
#endif
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np
from itertools import combinations 
INF = int(1e9)*15
def main():
    n, k = map(int, readline().split()) 
    a = np.array(readline().split(), np.int64)
    c = np.array([int(i) for i in range(1, n)])
    ans = INF
    for comb in combinations(c, k-1):
        mx = a[0]
        cost = 0
        for i in range(n):
            if i in comb:
                if a[i] > mx:
                    mx = a[i]
                    continue
                else:
                    mx += 1
                    cost += mx-a[i] 
                    continue
            mx = max(mx, a[i])
        ans = min(cost, ans)
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 12256
a = [int(i) for i in input().split()]
ball = [int(i) for i in input().split()]
num, kind = a[0], a[1]
ball.sort()
count = []
c = 0 
ans = 0

s = ball[0]
for i in range(num):
    if s == ball[i]:
        c += 1
    else:
        s = ball[i]
        count.append(c)
        c = 1
count.append(c)
count.sort()

for i in range(len(count)-kind):
    ans += count[i]

print(ans)

Measured memory_bytes: 25768
#include<bits/stdc++.h>
//#include "stdc++.h"
using namespace std;
 
#define int long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
int MOD=1000000007;


int power(int x, int y, int p) 
{ 
    int res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res%MOD; 
}







int32_t main(){
  fast;
  int t=1;
  while(t--){
    
    int n;
    cin>>n;
    string s[n];
    int time[n];
    unordered_map<string,int> mp;
    for(int i=0;i<n;++i){
      cin>>s[i];
      cin>>time[i];
      mp[s[i]]=i;
    }
    string x;
    cin>>x;
    int temp=mp[x];
    int sum=0;
    for(int i=temp+1;i<n;++i){
      sum+=time[i];
    }
    cout<<sum<<'\n';






  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main ()
{
    int a=0,b=0,i;
    char s[4];
    scanf("%s",s);
    for (i=0; i<4; i++)
    {
        if (s[i]=='A')
        {
            a++;
        }
        else if (s[i]=='B')
        {
            b++;
        }
    }
    if (a>=1 && b>=1)
    {
        printf ("Yes\n");
    }
    else
    {
        printf ("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
using System;
using System.IO;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(Solve());
        Console.Out.Flush();
    }

    static object Solve() {
        var input = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int N = input[0], L = input[1];
        var S = new string[N];
        for (int i = 0; i < N; i++) {
            S[i] = Console.ReadLine();
        }
        Array.Sort(S, StringComparer.OrdinalIgnoreCase);
        return string.Join("",S);
    }
}

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

int main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    int n,m;
    cin >> n >> m;

    int t;
    t = 100*n + 1800 * m;

    int ans = t * pow(2,m);

    


    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int solve(int a[], int n,int flag){
  if(flag == 1) return -1;

  if(n == 1){
    if(a[1] == -1) return 0;

    else return a[1];
  }

  if(n == 2){
    if(a[1] == 0) return -1;

    if(a[1] == -1) a[1] = 1;
    if(a[2] == -1) a[2] = 0;

    return 10*a[1] + a[2];
  }

  if(n == 3){
    if(a[1] == 0) return -1;

    if(a[1] == -1) a[1] = 1;
    if(a[2] == -1) a[2] = 0;
    if(a[3] == -1) a[3] = 0;

    return 100*a[1] + 10*a[2] + a[3];
  }
}

int main(){
  int n,m;
  int i;
  int a[4];
  int s,c;
  int flag = 0;

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

  for(i = 1;i <= n;i++) a[i] = -1;

  for(i = 0;i < m;i++){
    scanf("%d %d", &s, &c);

    if(a[s] != -1 && a[s] != c) flag = 1;

    a[s] = c;
  }

  printf("%d\n", solve(a,n,flag));

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

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 T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll n, m,ans=0,t;
	cin >> n >> m;
	vll k(m),p(m);
	vector<vll> s(n);
	rep(i, 0, m) {
		cin >> k[i];
		rep(j, 0, k[i]) {
			cin >> t;
			s[t-1].push_back(i);
		}
	}
	rep(i, 0, m) {
		cin >> p[i];
	}

	rep(i, 0, (1 << n)) {
		vll u(m, 0);
		rep(j, 0, n) {
			if (i & (1 << j)) {
				rep(k, 0, s[j].size()) {
					u[s[j][k]]++;
				}
			}
		}
		bool flg = true;
		rep(j, 0, m) {
			if (u[j] % 2 != p[j]) {
				flg = false;
			}
		}
		if (flg) {
			ans++;
		}
	}

	outn(ans);
	return 0;

}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#define Rint register int
#define mem(a,b) memset(a,(b),sizeof(a))
using namespace std;
typedef long long LL;
template<typename T>inline void read(T &x){
    x=0;T w=1,ch=getchar();
    while(!isdigit(ch)&&ch!='-')ch=getchar();
    if(ch=='-')w=-1,ch=getchar();
    while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^'0'),ch=getchar();
    x=x*w;
}
inline void File(){
    freopen("fuck.in","r",stdin);
    freopen("fuck.out","w",stdout);
}

const int maxn=100+10;
int n,m;
bool G[maxn][maxn],vis[maxn][maxn];
int dir[4][2]={{0,1},{0,-1},{1,0},{-1,0}};

inline int dfs(int x,int y,int dep){
	int maxdep=1;
	vis[x][y]=1;
	for(Rint i=0;i<4;i++){
		int x1=x+dir[i][0],y1=y+dir[i][1];
		if(vis[x1][y1])continue;
		if(G[x1][y1]==1)maxdep=max(maxdep,dfs(x1,y1,dep+1)+1);
	}
	if(dep==1&&maxdep<2)vis[x][y]=0;
	return maxdep;
}

int main(){
    //File();
	read(n);read(m);
	for(Rint i=1;i<=n;i++){
		for(Rint j=1;j<=m;j++){
			char ch=getchar();
			while(ch!='.'&&ch!='#')ch=getchar();
			if(ch=='#')G[i][j]=1;
			else G[i][j]=0;
		}
	}
	for(Rint i=1;i<=n;i++){
		for(Rint j=1;j<=m;j++){
			if(G[i][j]==1&&!vis[i][j]){
				dfs(i,j,1);
			}
		}
	}
	for(Rint i=1;i<=n;i++){
		for(Rint j=1;j<=m;j++){
			//cout<<vis[i][j];
			if(G[i][j]==1&&!vis[i][j]){
				printf("No\n");
				return 0;
			}
		}
		//cout<<endl;
	}
	printf("Yes\n");
	return 0;
}


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int N; cin >> N;
    vector<pair<int, ll>> nodes[N];
    rep(i, N-1){
        int u, v; ll w;
        cin >> u >> v >> w;
        nodes[u-1].push_back(make_pair(v-1, w));
        nodes[v-1].push_back(make_pair(u-1, w));
    }
    bool visited[N] = {false};
    int color[N] = {1};
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int op = q.front();
        q.pop();
        rep(i, nodes[op].size()){
            pair<int, ll> temp = nodes[op][i];
            if(!visited[temp.first]){
                if(temp.second % 2 == 0) color[temp.first] = color[op];
                else color[temp.first] = -color[op];
                visited[temp.first] = true;
                q.push(temp.first);
            }
        }
    }
    rep(i, N){
        if(color[i] == 1) cout << 1 << endl;
        else cout << 0 << endl; 
    }
    return 0;
}

void solve(){}

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

neg_cnt = 0
zero_cnt = 0

max_neg_v = -float("inf")
min_pos_v = float("inf")

for i in range(len(a)):
    if a[i] < 0:
        neg_cnt += 1
        max_neg_v = max(max_neg_v, a[i])
    elif a[i] == 0:
        zero_cnt += 1
    else:
        min_pos_v = min(min_pos_v, a[i])

if neg_cnt % 2 == 0 or zero_cnt > 0:
    print(sum(list(map(abs, a))))
else:
    print(max(sum(list(map(abs, a)))-2*min_pos_v, sum(list(map(abs, a)))+2*max_neg_v))




Measured memory_bytes: 14496
#include<iostream>
using namespace std;
int main(){
    int a,b,x,y,z,w;
    char op;
    while(true){
        cin>>a>>op>>b;
        if(op=='?'){
            break;
        }
        else{
           if(op=='+'){
               x=a+b;
               cout<<x<<endl;
           } 
           else if(op=='-'){
               y=a-b;
               cout<<y<<endl;
           }
           else if(op=='*'){
               z=a*b;
               cout<<z<<endl;
           }
           else if(op=='/'){
               w=a/b;
               cout<<w<<endl;
           }
        }
    }
    return 0;
}


Measured memory_bytes: 3076
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

T = ri()
P = []
for i in range(T):
    P.append(rl())

import heapq

def solve(N, A, B, C, D):
    heap = []
    heapq.heappush(heap, (0, N))
    visited = {}

    while heap:
        #print(heap)
        c, n = heapq.heappop(heap)
        if n == 0:
            return c
        cands = [(A, 2), (B, 3), (C, 5), (D, 1)]
        for cost, div in cands:
            ncs = []
            if div == 1:
                next_n = 0
                next_c = D*n
                ncs.append((next_n, next_c))
            elif n % div == 0:
                next_n = n // div
                next_c = cost
                ncs.append((next_n, next_c))
            else:
                r = n % div
                next_n = (n-r) // div
                next_c = cost + r*D
                ncs.append((next_n, next_c))
                next_n = (n+r) // div
                next_c = cost + (div-r)*D
                ncs.append((next_n, next_c))
            for next_n, next_c in ncs:
                next_c += c
                if next_n in visited:
                    if visited[next_n] <= next_c:
                        continue
                visited[next_n] = next_c
                heapq.heappush(heap, (next_c, next_n))
    return -1

for p in P:
    ans = solve(*p)
    print(ans)


Measured memory_bytes: 78524
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var inputs = Console.ReadLine().Split(' ').Select(int.Parse).OrderBy(x => x).ToArray();
            Console.WriteLine(inputs[inputs.Length - 1] - inputs[0]);

        }
    }
}

Measured memory_bytes: 13396
a,b=map(int,input().split())
p=0
if a==1:
  p+=300000
elif a==2:
  p+=200000
elif a==3:
  p+=100000

if b==1:
  p+=300000
elif b==2:
  p+=200000
elif b==3:
  p+=100000
if p==600000:
  p+=400000
print(p)
  

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

#define pb push_back
#define mk make_pair
#define sc second
#define fr first

using namespace std;

typedef long long ll;

const long long N = (long long) 1e6 + 5;
const long long mod = (long long) 1e9 + 7;

pair<long long,long long> a[N];

long long n;
long long mn,mn1 = mod,mx,mx1,mnn,res,mxx;

int main () {
        ios_base::sync_with_stdio(false);

        cin >> n;

        for (long long i = 1; i <= n; i ++) {
                cin >> a[i].fr >> a[i].sc;
                if(a[i].fr > a[i].sc)
                        swap (a[i].fr,a[i].sc);
                mn1 = min (mn1,a[i].sc);
                mx1 = max (mx1,a[i].sc);
        }

        sort (a + 1,a + n + 1);

        mn = a[1].fr; mx = a[n].fr;

        res = (mx - mn) * 1ll * (mx1 - mn1);

        for (long long i = 1; i < n; i ++) {
                if(i > 1) mnn = min (mnn,a[i].sc);
                else mnn = a[i].sc;
                mxx = max (mxx,a[i].sc);

                res = min (res,(mx1 - mn) * 1ll * (max(mxx,a[n].fr) - min(a[i + 1].fr,mnn)));
        }
        cout << res << endl;
        return 0;
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
int main()
{
  int t;
  cin>>t;
  set<string> s;
  for(int i=0;i<t;i++)
  {
    string x;
    cin>>x;
    s.insert(x);
  }
  cout<<s.size()<<endl;
}


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

    cin>>ara[0]>>ara[1]>>ara[2];
	sort(ara,ara+3);

	while(ara[1]!=ara[2]){
        ara[0]++;
        ara[1]++;
        count++;
	}
	while(ara[0]<ara[1]){
        ara[0]+=2;
        count++;
	}
	if(ara[0]>ara[1]) count++;
	cout<<count<<endl;
}


Measured memory_bytes: 256
x = int(input())
a = [list(map(int,input().split(" "))) for i in range(x)]
ans = 0
for i in range(x):
    for j in range(x):
        if i!=j:
            ans += ((abs(a[i][0]-a[j][0])**2+abs(a[i][1]-a[j][1])**2))**0.5
print(ans/x)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
    out << '(' << p.first << ',' << p.second << ')';
        return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
    in >> p.first >> p.second;
        return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
    for (T &x : v)
        in >> x;
    return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
    for (const vector<T> &x : v)
        out << x << '\n';
    return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
    for (const T &x : v)
        out << x << ' ';
    return out;
}
 
template <class T>
ostream& operator << (ostream& out,const set<T> &s)
{
    for (const T &x : s)
        out << x << ' ';
    return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define epsilon 0.00000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl "\n"
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main()
{
    fast();
    string s;
    cin>>s;
    ll sum=0;
    for(ll i=0;i<sz(s);i++)
    {
        sum+=s[i]-'0';
    }
    if(sum%9==0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}


Measured memory_bytes: 3756
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**9
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    a = LI()
    b = []
    c = []
    for i in range(n):
        heapq.heappush(b, a[i])
        heapq.heappush(c, -a[i+n*2])
    sb = sum(b)
    sc = sum(c)
    ba = {}
    ba[n-1] = sb
    for i in range(n):
        t = heapq.heappop(b)
        if a[n+i] > t:
            sb -= t
            heapq.heappush(b, a[n+i])
            sb += a[n+i]
        else:
            heapq.heappush(b, t)
        ba[n+i] = sb

    ca = {}
    ca[n*2-1] = sc
    for i in range(n-1,-1,-1):
        t = heapq.heappop(c)
        if -a[n+i] > t:
            sc -= t
            heapq.heappush(c, -a[n+i])
            sc -= a[n+i]
        else:
            heapq.heappush(c, t)
        ca[n+i-1] = sc


    r = -inf
    for k in ba.keys():
        tr = ba[k] + ca[k]
        if tr > r:
            r = tr

    return r



print(main())



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

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i = 0;i < n;i++){
        cin >> d.at(i);
    }
    /**/
    sort(d.begin(),d.end());
    int k;
    k = d.at(n/2) - d.at(n/2 - 1);
    cout << k << endl;
    return 0;
}

Measured memory_bytes: 640
program sample
    implicit none
  
    integer(8) :: i,j,m,n
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n
    if(n>=30)then
        write(*,*)'Yes'
    else
    write(*,*) 'No'
    end if  
    stop
end program sample
  



Measured memory_bytes: 2864
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[3][2]={0,1,0,1,0,1};
	while(n--)
	{
		a[0][0]=a[1][0];
		a[0][1]=a[1][1];
		a[1][0]=a[2][0];
		a[1][1]=a[2][1];
		cin>>a[2][0]>>a[2][1];
		if(a[0][0]==a[0][1]&&a[1][0]==a[1][1]&&a[2][0]==a[2][1])
		{
			cout<<"Yes";
			return 0; 
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
using namespace std;

typedef long long LL;
typedef vector<LL> VLL;
const LL LLMAX = numeric_limits<LL>::max();

LL search(const VLL &s, const VLL &t, LL start, int depth) {
  if (depth == 0)
    return 0LL;

  LL min_dist = LLMAX;
  int i = lower_bound(s.begin(), s.end(), start) - s.begin();
  for (int j = i - 1; j <= i; ++j) {
    if (j < 0 || j >= s.size())
      continue;
    LL dist = abs(s[j] - start) + search(t, s, s[j], depth - 1);
    min_dist = min(min_dist, dist);
  }

  return min_dist;
}

LL solve(const VLL &s, const VLL &t, LL start) {
  return min(search(s, t, start, 2), search(t, s, start, 2));
}

int main()
{
  // Read inputs
  
  int A, B, Q;
  cin >> A >> B >> Q;

  VLL s(A), t(B), x(Q);
  for (int i = 0; i < A; ++i) cin >> s[i]; sort(s.begin(), s.end());
  for (int i = 0; i < B; ++i) cin >> t[i]; sort(t.begin(), t.end());
  for (int i = 0; i < Q; ++i) cin >> x[i];
  
  // Solve each cases
  for (int i = 0; i < Q; ++i) {
    cout << solve(s, t, x[i]) << endl;
  }

  return 0;
}


Measured memory_bytes: 3712
/* include */
#include"bits/stdc++.h"
/* namespace */
using namespace std;
/* typedef */
/* long系 */
typedef long long ll;	// long long
typedef long double ld;	// long double
/* vector系 */
typedef vector<int> vint;	// intのvector
typedef vector<double> vdouble;	// doubleのvector
typedef vector<ll> vll;	// llのvector
typedef vector<ld> vld;	// ldのvector
typedef vector<pair<int, int>> vi_i;	// i_iのvector
typedef vector<pair<double, double>> vd_d;	// d_dのvector
typedef vector<pair<ll, ll>> vl_l;	// l_lのvector
typedef vector<pair<ld, ld>> vld_ld;	// ld_ldのvector
typedef vector<string> vstring;	// stringのvector
/* pair系 */
typedef pair<int, int> i_i;	// int同士のpair
typedef pair<double, double> d_d;	// double同士のpair
typedef pair<ll, ll> l_l;	// ll同士のpair
typedef pair<ld, ld> ld_ld;	// ld同士のpair
/* define */
#define pb push_back	// push_back
#define all(v) v.begin(),v.end()	// コンテナ全体
#define PI (acos(-1))  // 円周率pi
/* 変数入出力 read, write */
template <typename T>	// 1変数
void read(T& x) {
    cin >> x;
}
template <typename T, typename T0>	// 2変数
void read(T& x, T0& y) {
    cin >> x >> y;
}
template <typename T, typename T0, typename T1>	// 3変数
void read(T& x, T0& y, T1& z) {
    cin >> x >> y >> z;
}
template <typename T, typename T0, typename T1, typename T2>	// 4変数
void read(T& x, T0& y, T1& z, T2& w) {
    cin >> x >> y >> z >> w;
}
template <typename T>	// 1変数
void write(T& x) {
    cout << x << endl;
}
template <typename T, typename T0>	// 2変数
void write(T& x, T0& y) {
    cout << x << " " << y << endl;
}
template <typename T, typename T0, typename T1>	// 3変数
void write(T& x, T0& y, T1& z) {
    cout << x << " " << y << " " << z << endl;
}
template <typename T, typename T0, typename T1, typename T2>	// 4変数
void write(T& x, T0& y, T1& z, T2& w) {
    cout << x << " " << y << " " << z << " " << w << endl;
}
// vectorの出力
template <typename T>
void printvec(const vector<T> &data) {
for (const auto elm : data) {
    cout << elm << " ";
}
cout << endl;
}


int main(int argc, char const *argv[])
{
    vint ls{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; read(k); k--;
    cout << ls[k] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int m,d;
    cin>>m>>d;
    int ans = 0;
    rep(i,d+1){
        int x = i%10;
        int y = i/10;
        if(x>=2&&y>=2&&x*y<=m)++ans;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,string> tp;
//typedef vector<tp> vt;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
//http://tsutaj.hatenablog.com/entry/2017/03/30/224339
typedef ll SegT;
const SegT defvalue=0;
struct LSTree{
public:
	int n;
	vector<SegT>node,lazy;
	SegT combine(SegT a,SegT b){return a+b;}
	LSTree(const vector<SegT> &v) {
		n=1;
		while(n<v.size())n<<=1;
		node=vector<SegT>(2*n,defvalue);
		lazy=vector<SegT>(2*n,defvalue);
		for(int i=n-1+v.size()-1;i>=0;i--){
			if(n-1<=i)node[i]=v[i-(n-1)];
			else node[i]=combine(node[i*2+1],node[i*2+2]);
		}
	}
	void eval(int k,int l,int r) {
		if(lazy[k]!= 0){
			node[k]+=lazy[k];
			if(r-l>1) {
				lazy[2*k+1]+=lazy[k]/2;
				lazy[2*k+2]+=lazy[k]/2;
			}
			lazy[k]=0;
		}
	}
	void update(int a,int b,SegT x,int k=0,int l=0,int r=-1){
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return;
		if(a<=l&&r<=b){
			lazy[k]+=(r-l)*x;
			eval(k,l,r);
		}else{
			update(a,b,x,2*k+1,l,(l+r)/2);
			update(a,b,x,2*k+2,(l+r)/2,r);
			node[k]=combine(node[2*k+1],node[2*k+2]);
		}
	}
	SegT query(int a,int b,int k=0,int l=0,int r=-1){
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return 0;
		if(a<=l&&r<=b)return node[k];
		else return combine(query(a,b,2*k+1,l,(l+r)/2),query(a,b,2*k+2,(l+r)/2,r));
	}
};
int main() {
	int n,q;
	cin>>n>>q;
    LSTree st(vector<ll>(n,0));
	while(q--){
		int a,s,t,x;
		cin>>a>>s>>t;
		if(!a)cin>>x;
		if(!a)st.update(s-1,t,x);
		else cout<<st.query(s-1,t)<<endl;
	}
}

Measured memory_bytes: 9804
#include <bits/stdc++.h>  
using namespace std;
using Int = int;

int main(){
  Int N,M,K;
  cin >> N >> M >> K;
  auto A = vector<Int>(M+1);
  auto B = vector<Int>(M+1);
  for(int i=1; i<=M; i++) {
    cin >> A[i] >> B[i];
  }
  auto C = vector<Int>(K+1);
  auto D = vector<Int>(K+1);
  for(int i=1; i<=K; i++) {
    cin >> C[i] >> D[i];
  }
  
  auto adj = vector<vector<int>>(N+1);
  for(int i=1; i<=M; i++) {
    auto a = A[i];
    auto b = B[i];
    adj[a].push_back(b);
    adj[b].push_back(a);
  }

  auto blocks = vector<vector<int>>(N+1);
  for(int i=1; i<=K; i++) {
    auto c = C[i];
    auto d = D[i];
    blocks[c].push_back(d);
    blocks[d].push_back(c);
  }
  
  auto group = vector<int>(N+1, 0);
  int groupn = 0;
  for(int s = 1; s <= N; ++s) {
    if (group[s] != 0) continue;
    groupn++;
    auto q = queue<int>();
    q.push(s);
    while (!q.empty()) {
      auto n = q.front();
      q.pop();
      group[n] = groupn;
      for(auto&& to : adj[n]) {
        if (group[to] != 0) continue;
        q.push(to);
      }
    }
  }
  
  auto gset = vector<unordered_set<int>>(groupn+1);
  for(int i=1; i<=N; i++) {
    auto g = group[i];
    gset[g].emplace(i);
  }
  
  for(int i=1; i<=N; ++i) {
    auto g = group[i];
    auto& gs = gset[g];
    int ans = gs.size() - 1;
    ans -= adj[i].size();
    auto& bs = blocks[i];
    int bn = 0;
    for(auto b : bs) {
      if (gs.find(b) != gs.end()) {
        bn++;
      }
    }
    ans -= bn;
    if (i != 1) cout << " ";
    cout << ans;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 21404
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
N, H, W = map(int, input().split())
P = [-1 for i in range(H+W)]
C = [1] * (H+W)
arr = []
for _ in range(N):
    r, c, a = map(int, input().split())
    arr.append((a, r-1, c+H-1))
arr = sorted(arr)

ans = 0
def find(a):
    if P[a] < 0: return a
    t = find(P[a])
    P[a] = t
    return t

def unite(r, c):
    fr, fc = find(r), find(c)
    if fr == fc:  return 0
    C[fr] = C[fc] = C[fr] + C[fc]
    if P[fr] == P[fc]:
        P[fc] = fr
        P[fr] -= 1
    elif P[fr] > P[fc]:
        P[fc] = fr
    else:
        P[fr] = fc
    
while arr:
    a, r, c = arr.pop()
    unite(r, c)
    fr = find(r)
    if C[fr]:
        ans += a
        C[fr] -= 1
print(ans)


Measured memory_bytes: 54528
"""
author : halo2halo
date : 8, Jan, 2020
problem : ABC149
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A, B, K = map(int, read().split())

x = min(A, K)
A -= x
K -= x

x = min(B, K)
B -= x

print(A, B)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>

using namespace std;

long long abso(long long n){
    if(n < 0){
        n = -1 * n;
    }
    return n;
}

int main(){

    int N;
    cin >> N;

    vector <int> a(N);
    long long ans = 0, sum1 = 0, sum2 = 0;
    for (int i = 0; i < N; i++){
        cin >> a[i];
        ans += abso(a[i]);
        sum1 += a[i];
    }

    for (int i = N - 1; i >= 1; i--){
        sum1 -= a[i];
        sum2 += a[i];

        if (ans > abso(sum1 - sum2)){
            ans = abso(sum1 - sum2);
        }
    }
    
    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  ll N,K;
  cin>>N>>K;
  vector<pair<ll,ll>>a(N);
  for(int i=0;i<N;i++)cin>>a[i].first>>a[i].second;
  sort(rng(a));
  for(int i=0;i<N;i++){
    K-=a[i].second;
    if(K<=0){
      cout<<a[i].first<<endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 1792
program a
  implicit none
  integer :: p,q,r,pq,qr,pr,s1,s2

  read(*,*) p,q,r
  pq=p+q
  pr=p+r
  qr=q+r
  s1=min(min(pq,pr),qr)
  write(*,'(i0)') s1

end program a



Measured memory_bytes: 640