akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

int main(void){
	int n,m;
	int k,s;
	vector<vector<int>> swi;
	cin>>n>>m;
	rep(i,m){
		cin>>k;
		swi.push_back(vector<int>());
		rep(j,k){
			cin>>s;
			swi[i].push_back(s-1);
		}
	}

	int inp;
	vector<int> p;
	rep(i,m){
		cin>>inp;
		p.push_back(inp);
	}
	ll ans = 0;
	rep(x,1<<n){
		bool ok = true;
		rep(i,m){
			int count = 0;
			rep(j,swi[i].size()){
				if((x>>swi[i][j])&1){
					count++;
				}
			}
			//cout<<count<<endl;
			if(count%2 != p[i]){
				ok = false;

				break;
			}
		}
		if(ok) ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int n;
  cin >> n;
  vector<string> S(n);
  rep(i, n) cin >> S[i];

  vector<int> cnt(26, INF);
  rep(i, n) {
    vector<int> temp(26);
    rep(j, S[i].size()) {
      temp[S[i][j] - 'a']++;
    }

    rep(c, 26) {
      chmin(cnt[c], temp[c]);
    }
  }

  rep(c, 26) {
    rep(i, cnt[c]) {
      cout << (char)(c + 'a');
    }
  }

  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<string>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<string>
#define UP(i,l,h) for(int i=l;i<h;i++)
#define DOWN(i,h,l) for(int i=h-1;i>=l;i--)
#define W(a) while(a)
#define MEM(a,b) memset(a,b,sizeof(a))
#define LL long long
#define INF 0x3f3f3f3f
#define MAXN 50050
#define MOD 1000000007
#define EPS 1e-3
#define int LL
using namespace std;
struct Node {
    int val,num;
    bool operator < (const Node b) const {
        return (double)num/val>(double)b.num/b.val;
    }
};

main() {
    Node nodes[10];
    MEM(nodes,0);
    nodes[0].num=1;
    nodes[1].num=2;
    nodes[2].num=4;
    nodes[3].num=8;
    int n;
    scanf("%lld%lld%lld%lld%lld",&nodes[0].val,&nodes[1].val,&nodes[2].val,&nodes[3].val,&n);
    sort(nodes,nodes+4);
    n*=4;
    int ans=0;
    UP(i,0,4) {
//        cout<<nodes[i].num<<" "<<nodes[i].val<<endl;
        int buy=n/nodes[i].num;
        ans+=(buy*nodes[i].val);
        n=n%nodes[i].num;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(int argc, char *argv[])
{
  for(;;) {
    int n;
    cin >> n;
    if(n == 0) break;
    vector<int> ss(26, 0);
    bool done = false;
    for(int i = 0; i < n; i++) {
      char c;
      cin >> c;
      ss[c-'A']++;
      int mx = 0;
      int idx = -1;
      int mx2 = 0;
      for(int j = 0; j < 26; j++) {
        if(mx <= ss[j]) {
          idx = j;
          mx2 = mx;
          mx = ss[j];
        } else if(mx2 <= ss[j]) {
          mx2 = ss[j];
        }
      }
      if(!done && (mx - mx2) > (n - 1 - i)) {
        cout << (char)('A' + idx) << " " << (i+1) << endl;
        done = true;
      }
    }
    if(!done) {
      cout << "TIE" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

int main() {
    ll N,M;
    cin >> N >> M;
    vector<ll> vec(M);
    for(int i = 0;i < M;i++) {
        cin >> vec.at(i);
    }
    ll sum = 0;
    for(int i = 0;i < M;i++) {
        sum += vec.at(i);
    }
    if(sum > N) {
        cout << -1 << endl;
    }
    else {
        cout << N - sum << endl;
    }
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define MAXN 200 + 5
const long long INF = 1LL << 60;
const int inf = 1 << 30;

void printVec(std::vector<int> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int main(){
  int n,m; cin >> n >> m;
  int ans = n * (n - 1) / 2;
  ans +=m * (m - 1) / 2;
  cout << ans << endl;
  return 0;
}
     


Measured memory_bytes: 256
function combinations(n, arr) {
  if (n === 0) return [[]];
  if (arr.length === 0) return [];
  const tail = arr.slice(1);
  return combinations(n - 1, tail).map(comb => [arr[0]].concat(comb)).concat(combinations(n, tail));
}

const range = (n) => Array.from({ length: n }, (_, k) => k);

function Main(input) {
  const lines = input.split('\n');
  const [N, D] = lines[0].split(' ').map(s => parseInt(s));
  const points = lines.slice(1).map(line => line.split(' ').map(s => parseInt(s)));

  const ans =
    combinations(2, range(N))
      .map(pair => {
        const p1 = points[pair[0]];
        const p2 = points[pair[1]];
        return Math.sqrt(range(D).map(k => Math.pow(p1[k] - p2[k], 2)).reduce((x, y) => x + y));
      })
      .filter(Number.isInteger)
      .length;

  console.log(ans);

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7628
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    char S[100001];

    scanf("%s", S);

    int len = strlen(S);

    int t = 0;

    while(true){
        if(S[t] == 'd' && S[t+1] == 'r' && S[t+2] == 'e' && S[t+3] == 'a' && S[t+4] == 'm' && S[t+5] == 'e' && S[t+6] == 'r' && S[t+7] != 'a'){
            t += 7;
        }else if(S[t] == 'd' && S[t+1] == 'r' && S[t+2] == 'e' && S[t+3] == 'a' && S[t+4] == 'm'){
            t += 5;
        }else if(S[t] == 'e' && S[t+1] == 'r' && S[t+2] == 'a' && S[t+3] == 's' && S[t+4] == 'e' && S[t+5] == 'r' && S[t+6] != 'a'){
            t += 6;
        }else if(S[t] == 'e' && S[t+1] == 'r' && S[t+2] == 'a' && S[t+3] == 's' && S[t+4] == 'e'){
            t += 5;
        }else{
            break;
        }
    }

    if(t == len){
        printf("YES\n");
    }else{
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 1748
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int t = scan.nextInt();
		int goal = scan.nextInt();
		
		int[] height = new int[n];
		double ans = Integer.MAX_VALUE;
		int x = 0;
		for (int i = 0; i < height.length; i++) {
			double ave = t - scan.nextInt() * 0.006;
			if (ans > Math.abs(goal - ave)) {
				ans = Math.abs(goal - ave);
				x = i + 1;
			}
		}
		System.out.println(x);
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;
#define pii pair<int, int>

bool operator<(pii a, pii b) {
    if (a.second < b.second)return true;
    else if (a.second > b.second)return false;
    else return a.first < b.first;
}

int dp[3010][3010];

int main() {
    int n, t, ans = 0;
    cin >> n >> t;
    vector<pii > d(n);
    for (int i = 0; i < n; i++)cin >> d.at(i).first >> d.at(i).second;
    sort(d.begin(), d.end());
    for (int j = 0; j <= t; j++)dp[0][j] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < t; j++) {
            if (j >= d.at(i).first)dp[i + 1][j] = max(dp[i][j - d.at(i).first] + d.at(i).second, dp[i][j]);
            else dp[i + 1][j] = dp[i][j];
            ans = max(ans, dp[i][j] + d.at(i).second);
        }
    }
    cout << ans << endl;
}

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


int main(){
    string s, ans = "";
    cin >> s;
    rep(i, (int)s.size()){
        if(i&1) continue;
        ans += s[i];
    }
    cout << ans << endl;
}



Measured memory_bytes: 512
from collections import Counter
n=int(input())
a = Counter(list(map(int,input().split())))
q=int(input())

last = sum([v*a[v] for v in a])
for _ in range(q):
  b,c = map(int,input().split())
  last = last - b*a.get(b,0) + c*a.get(b,0)
  a[b],a[c] = 0, a.get(c,0)+a.get(b,0)
  print(last)
  
  
  

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

using namespace std;

#define N 2025

int main() {
	int k, s;

	cin >> k >> s;
	int cnt = 0;

	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			if (x + y <= s && x + y + k >= s) {
				cnt++;
			}
		}
	}

	cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
const ll ARR = 1e5 + 2;
const ll MOD = 1e9+7;
const ll INF = MOD;
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define gof for(long long int i = 0 ; i < n ; i++)

ll power(ll x, ll y)  
{  
    ll res = 1;     
    x = x % MOD; 
    if (x == 0) return 0; 
  
    while (y > 0)  
    {
        if (y & 1)  
            res = (res*x) % MOD;   
        y = y>>1;
        x = (x*x) % MOD;  
    }  
    return res;  
}  

ll gcd(ll a,ll b) { if (a == 0) return b; return gcd(b%a, a);}
ll max(ll a,ll b){if(a>b) return a; else return b;}
ll min(ll a,ll b){if(a<b) return a; else return b;}
ll max(ll a[], ll n){ll ans = 0; for(ll i = 0 ; i < n ; i++) ans = max(ans,a[i]); return ans;}

ll min(ll a[], ll n){ll ans = INF; for(ll i = 0 ; i < n ; i++) ans = min(ans,a[i]); return ans;}  
bool isPrime(ll N){ for(int i=2;i*i<=N;++i){if(N%i==0) return false;}return true;}


void solve(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
 
    vector<int> dp(n, INF); 
    dp[0] = 0; 
 
    for (int i = 0; i < n; i++) { 
        for (int j = i + 1; j <= i + k; j++) { 
            if (j < n)
                dp[j] = min(dp[j], dp[i] + abs(a[j] - a[i]));
        }
    }
    cout << dp[n - 1];
    return;
}

int main(){
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 1024
from functools import reduce
X,Y = (int(x) for x in input().split())
def route(x,y):
    d = min(x,y) - ((x+y)//3)
    if d == 0:
        return 1
    else:
        return (route(x-2,y-1) + route(x-1,y-2))%1000000007
def modmul(a,b):
    return a * b % 1000000007
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0
def modinv(a, m):
    g, x, y = xgcd(a, m)
    return x % m
def comb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(modmul, range(n, n - r, -1))
    under = reduce(modmul, range(1,r + 1))
    return over * modinv(under, 1000000007)
if (X+Y) % 3 != 0 or min(X,Y) < (X+Y) // 3:
    print('0')
else:
    d = min(X,Y) - ((X+Y)//3)
    if d == 0:
        print('1')
    else:
        t = (X+Y) // 3
        print((comb(t-1,d)+comb(t-1,d-1))%1000000007)

Measured memory_bytes: 3684
x1, y1, x2, y2 = map(int, input().split())

def dot0(x, y, v):
    return (x - v[1], y + v[0])
    
vector = (x2 - x1, y2 - y1)
x3, y3 = dot0(x2, y2, vector)
x4, y4 = dot0(x1, y1, vector)

print(x3, y3, x4, y4)

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

map<pair<int, int>, int> dp;
int dx[] = {1, 1, 0, -1, -1, 0};
int dy[] = {0, 1, 1, 0, -1, -1};


int main() {
    int t, n;   // ターン数 t, 障害物の数 n
    while (cin >> t >> n, t) {
        dp.clear();
        while (n--) {
            int x, y; cin >> x >> y;
            dp[{x, y}] = -1;
        }
        int sx, sy; cin >> sx >> sy;
        queue<pair<pair<int, int>, int>> q;
        q.emplace(make_pair(sx, sy), t);
        while (!q.empty()) {
            auto p = q.front(); q.pop();
            int cx = p.first.first, cy = p.first.second, t = p.second;
            if (dp[make_pair(cx, cy)] != 0) continue;
            if (t < 0) continue;
            dp[make_pair(cx, cy)] = 1;
            for (int i = 0; i < 6; i++) {
                q.emplace(make_pair(cx + dx[i], cy + dy[i]), t - 1);
            }
        }
        int cnt = 0;
        for (auto p : dp) if (p.second == 1) cnt++;
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3376
#include <stdio.h> 
int main(){
  int n;
  while(scanf("%d",&n)!=EOF){
    int a,b,c,d,k=0;
    for(a=0;a<=9;a++){
      for(b=0;b<=9;b++){
	for(c=0;c<=9;c++){
	  for(d=0;d<=9;d++){
	    if(a+b+c+d==n)k++;
	  }
	}
      }
    }
    printf("%d\n",k);
  }
  return 0;
}



Measured memory_bytes: 1976
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
bool comp(ll a,ll b)
{
	return (a>b);
}
int main()
{
	ll x,y,a,b,c,i,tas=0;
	cin>>x>>y>>a>>b>>c;
	ll red[a],gr[b],cl[c];
	for(i=0;i<a;i++)
	cin>>red[i];
	for(i=0;i<b;i++)
	cin>>gr[i];
	for(i=0;i<c;i++)
	cin>>cl[i];
	sort(red,red+a,comp);
	sort(gr,gr+b,comp);
	sort(cl,cl+c,comp);
	ll size=min(x+y,c);
	ll mega[x+y+size];
	for(i=0;i<x;i++)
		mega[i]=red[i];
	for(;i<x+y;i++)
		mega[i]=gr[i-x];
	for(;i<x+y+size;i++)
		mega[i]=cl[i-x-y];
	sort(mega,mega+x+y+size,comp);
	for(i=0;i<x+y;i++)
	tas+=mega[i];
	cout<<tas;
	return 0;
}
	


Measured memory_bytes: 4736
#include"bits/stdc++.h"
using namespace std;


int main() {
	string s;
	cin >> s;
	int a, z;

	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'A') {
			a = i;
			break;
		}
	}
	reverse(s.begin(), s.end());
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'Z') {
			z = s.length() - i;
			break;
		}
	}
	cout << z - a << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int main()
{
    int n,ans = 0,i;
    char s[100000];

    scanf("%d %s",&n,s);
    
    for (i = 0; i < n - 1; i++)
    {
        if(s[i] != s[i + 1])ans++;
    }
    printf("%d",ans + 1);
}


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

int main(){
    int n;
    cin>>n;
    vector<pair<ll,ll>> vec(n);
    rep(i,n){
        ll x,y;
        cin>>x>>y;
        vec[i]=make_pair(x,y);
    }
    sort(vec.begin(),vec.end());
    map<pair<ll,ll>,int> mp;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            mp[make_pair(vec[j].first-vec[i].first,vec[j].second-vec[i].second)]+=1;
        }
    }

    int cnt=0;
    for(auto x:mp){
        cnt = max(cnt,x.second);
    }

    cout<<n-cnt<<endl;

    return 0;
}

Measured memory_bytes: 384
import collections

N, p = map(int, input().split())
if N == 1:
    print(p)
    exit()

def prime_decomposition(n):
    # 素因数分解
    if n < 2:
        return []
    prime_factors = []
    while n % 2 == 0:
        prime_factors.append(2)
        n >>= 1

    while n % 3 == 0:
        prime_factors.append(3)
        n //= 3

    a = 5
    b = 7
    while a ** 2 <= n:
        if n % a == 0:
            prime_factors.append(a)
            n //= a
        elif n % b == 0:
            prime_factors.append(b)
            n //= b
        else:
            a += 6
            b += 6
    if n > 1:
        prime_factors.append(n)
    return prime_factors

res = 1
pf = collections.Counter(prime_decomposition(p))
for v, c in pf.items():
    while c >= N:
        res *= v
        c -= N
print(res)


Measured memory_bytes: 3316
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]
k = int(input())
print(ls[k-1])

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << ' ' << max(0, a + b - n) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;  
using namespace std;

typedef long long ll;

typedef tree<
pair <int, int>,
null_type,
less<pair <int, int>>,
rb_tree_tag,
tree_order_statistics_node_update>
os;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}
const int N = 55;

int g[N][N];

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

int get(int x, int y) {
  int tot = 0;
  for(int i = 0; i < 4; i++) {
    tot += g[x + dx[i]][y + dy[i]];
  }
  return tot;
}

int main() {
  int h, w; cin >> h >> w;
  for(int i = 1; i <= h; i++) {
    for(int j = 1; j <= w; j++) {
      char x; cin >> x;
      g[i][j] = (x == '#');
    }
  }
  for(int i = 1; i <= h; i++) {
    for(int j = 1; j <= w; j++) {
      if(g[i][j] == 0) continue;
      if(get(i, j) == 0) {
        print("No");
        return 0;
      }
    }
  }
  print("Yes");
}

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

int main()
{
	int a,b,d,r;
	double f;
	cin >> a >> b;
	d = a/b;
	r = a%b;
	f = double(a)/double(b);
	cout << d << " " << r << " " << fixed << f <<"\n";
	return 0;
}

Measured memory_bytes: 3236
//#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
#include<bits/stdc++.h>

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FIXED cout << fixed << setprecision(12)
#define RANDOM srand(94385)
#define all(a) a.begin(), a.end()
#define shuffle(a) \
    for (int i = 0; i < sz(a); ++i) \
        swap(a[i], a[rand() % sz(a)]);
#define enter putchar('\n')
#define space putchar(' ')
#define Mem(a, x) memset(a, x, sizeof(a))
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

void debug_out() { cerr << '\n'; }

template<typename T, typename ...R>
void debug_out(const T &f, const R &...r) {
    cerr << f << " ";
    debug_out(r...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__);

inline ll read() {
    ll x = 0;
    int f = 0;
    char ch = getchar();
    while (ch < '0' || ch > '9') f |= (ch == '-'), ch = getchar();
    while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
    return x = f ? -x : x;
}

inline void write(ll x) {
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[23];
    int l = 0;
    while (x != 0)s[l++] = x % 10 + 48, x /= 10;
    while (l)putchar(s[--l]);
}

int lowbit(int x) { return x & (-x); }

template<class T>
T big(const T &a1, const T &a2) { return a1 > a2 ? a1 : a2; }

template<typename T, typename ...R>
T big(const T &f, const R &...r) { return big(f, big(r...)); }

template<class T>
T sml(const T &a1, const T &a2) { return a1 < a2 ? a1 : a2; }

template<typename T, typename ...R>
T sml(const T &f, const R &...r) { return sml(f, sml(r...)); }

template<class T, class U>
inline void checkMin(T &x, U y) { if (y < x) x = y; }

template<class T, class U>
inline void checkMax(T &x, U y) { if (y > x) x = y; }

template<class T, class U>
inline bool ifMax(T &x, U y) {
    if (y > x) return x = y, true;
    return false;
}

template<class T, class U>
inline bool ifMin(T &x, U y) {
    if (y < x) return x = y, true;
    return false;
}

const int M = 212345;// 2e5+5
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1000000007;// 1e9+7

// HAVE FREE OPEN IN MAIN FUNCTION

int m, d;

void init() {
    m = read();
    d = read();
    int ans = 0;
    for (int i = 22; i <= d; ++i) {
        int x1 = i / 10, x2 = i % 10;
        if(x1<2||x2<2)continue;
        if (x1 * x2 <= m && x1 * x2 >= 1)ans++/*, debug(i, x1 * x2)*/;
    }
    printf("%d\n", ans);


}

void solve() {

}

int main() {
    init();

    solve();

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
ll A[200010],B[200010];
ll cntA[200010],cntB[200010];
int main(){
    cin>>N;
    for(ll i=0;i<N;i++) cin>>A[i];
    for(ll i=N-1;i>=0;i--) cin>>B[i];

    for(ll i=0;i<N;i++){
        cntA[A[i]]++; cntB[B[i]]++;
    }
    for(ll i=0;i<N;i++){
        if(A[i]==B[i]){
            if(cntA[A[i]]+cntB[B[i]]>N){
                cout<<"No"<<endl;
                return 0;
            }
            ll bs=i;
            while(B[bs]==A[i])bs++;
            ll as=i;
            while(A[as]==A[i])as++;
            ll start=max(as,bs);

            ll e=i;
            while(A[e]==B[e])e++;

            ll index=i;
            if(A[i-1]==A[i]){
                for(ll j=0;A[j]!=A[i] && index<e;j++){
                    swap(B[j],B[index]);
                    index++;
                }
            }else{
                for(ll j=0;B[j]!=A[i] && index<e;j++){
                    swap(B[j],B[index]);
                    index++;
                }
            }
            for(ll j=start;A[index]==A[i];j++){
                swap(B[j],B[index]);
                index++;
            }
            break;
        }
    }
    cout<<"Yes"<<endl;
    for(ll i=0;i<N;i++) cout<<B[i]<<" ";
    cout<<endl;
    return 0;

    return 0;
}

Measured memory_bytes: 9816
#pragma warning(disable  4996)
#define _CRT_SECURE_NO_WARNINGS
//#include<bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include<cstring>
#include<map>
#include<set>
#include<string>
#include <climits>
#include <vector>
#include<stack>
#include<bitset>
#include<queue>
#include<iomanip>
#define endl '\n';
#define all(v) ((v).begin()),((v).end())
typedef long long ll;
typedef unsigned long long ull;
typedef double dl;
using namespace std;

int main()
{
	
	string s, s1, p;
	cin >> s;
	int q;
	cin >> q;
	while (q--){
		cin >> s1;
		if (s1 == "replace"){
			int	a, b;
			cin >> a >> b >> p;
			int k = 0;
			for (int i = a; i <= b; i++){
				s[i] = p[k];
				k++;
			}
		}
		else if (s1 == "reverse"){
			int	a, b;
			cin >> a >> b;
			int j = b;
			for (int i = a; i <j; i++){
				swap(s[j],s[i]);
				j--;
			}
		}
		else{
			int	a, b;
			cin >> a >> b;
			for (int i = a; i <= b; i++){
				cout << s[i];
			}
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3176
import math

N, D = map(int, input().split())
x_list = []
y_list = []
for i in range(N):
    x, y = map(int, input().split())
    x_list.append(x)
    y_list.append(y)

count = 0
for i in range(N):
    q = math.sqrt(x_list[i]**2 + y_list[i]**2)
    if q <= D:
        count += 1
print(count)

Measured memory_bytes: 24792
import sys
sys.setrecursionlimit(500000)

N, Q = map(int, input().split())
G = [set() for _ in range(N)]
cnt = [0]*N
visited = [0]*N

def dfs(start_node):
    for i in G[start_node]:
        if visited[i]==0:
            visited[i]=1
            cnt[i] += cnt[start_node]
            dfs(i)

for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].add(b)
    G[b].add(a)

for i in range(Q):
    node, x = map(int, input().split())
    node -= 1
    cnt[node] += x

visited[0]=1
#dfs(0)
st = [0]
while st:
    v = st.pop()
    for u in G[v]:
        if visited[u]: continue
        visited[u] = 1
        cnt[u] += cnt[v]
        st.append(u)    

ans = map(str, cnt)
print(' '.join(ans))

Measured memory_bytes: 91508
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2")
//#pragma GCC optimize ("trapv")

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

#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);
//#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define rep(i, a, b) for(lli i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) lli((x).size())
#define what_is(x) cerr << #x << " is " << x << endl;
#define wis cout<<endl<<"I already speak english, bitch"<<endl<<endl;

typedef long long int lli;
typedef vector<lli> vi;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef pair<ii,lli> iii;
typedef long double C;

#define trace(args...) { string  _s =#args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
void err(istream_iterator<string> it){}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args){
    cout <<  *it  << " : " << a << endl;
    err(++it, args...);
}
int main(){
	int a,b,c; cin>>a>>b>>c; 
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<n; i++)
#define all(v) v.begin(), v.end()
using pint = pair<int, int>;
using tint = tuple<int, int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef int64_t lint;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
const int mod = 1000000007;
struct mint {
	lint x;
	mint(lint x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
	mint operator+(const mint a) const { return mint(*this) += a;}
	mint operator-(const mint a) const { return mint(*this) -= a;}
	mint operator*(const mint a) const { return mint(*this) *= a;}
	mint pow(lint t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod-2);}
	mint& operator/=(const mint a) { return *this *= a.inv();}
	mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
	int H, W;
	cin >> H >> W;
	vector<string> v(H);
	rep(i, H) {
		cin >> v.at(i);
	}

	int a=0, b=0, c=0, x, y, z;
	vector<vector<mint>> dp(H, vector<mint>(W));
	dp[0][0] = 1;
	rep(i, H) {
		rep(j, W) {
			if (i != H-1) if (v.at(i+1).at(j) == '.') dp[i+1][j] += dp[i][j];
			if (j != W-1) if (v.at(i).at(j+1) == '.') dp[i][j+1] += dp[i][j];
		}
	}
	cout << dp[H-1][W-1] << '\n';
}


Measured memory_bytes: 13004
#include <bits/stdc++.h>
using namespace std;
	
int main(){
	long n,i,j,a,b,c,ans;
	cin >> n;
	vector<vector<long>> dp(n+1,vector<long> (3));
	for(i=1; i<=n; i++){
		cin >> a >> b >> c;
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c;
	}
	ans=max(dp[n][0],dp[n][1]);
	ans=max(ans,dp[n][2]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
using namespace std;

int main(){
	char n[4];
	
	cin >> n;

	if (n[0] == n[1]) {
		if (n[0] == n[2]) {
			cout << "Yes";
		} else {
			cout << "No";
		}
	} else {
		if (n[1] == n[2]) {
			if (n[1] == n[3]) {
				cout << "Yes";
			} else {
				cout << "No";
			}
		} else {
			cout << "No";
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	a*=100;
	b*=100;
	int aa=0,bb=0,cc=0,dd=0;
	double conc=-1;
	for(int an=0;a*an<=f;an++){
		for(int bn=0;a*an+b*bn<=f;bn++){
			for(int cn=0;a*an+b*bn+c*cn<=f;cn++){
				for(int dn=0;a*an+b*bn+c*cn+d*dn<=f;dn++){
					if(an+bn>0 && 100*(c*cn+d*dn)<=e*(a*an+b*bn)){
						if(conc<(double)(c*cn+d*dn)/(a*an+b*bn)*100){
							conc=(double)(c*cn+d*dn)/(a*an+b*bn)*100;
							aa=an;bb=bn;cc=cn;dd=dn;
						}
					}
				}
			}
		}
	}
	cout << a*aa+b*bb+c*cc+d*dd << ' ' << c*cc+d*dd << endl;
	return 0;
}


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

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

int an[a];
int bn[b];
for(int i=0;i<a;i++)cin>>an[i];
for(int i=0;i<b;i++)cin>>bn[i];

int mini=5000000;
for(int i=0;i<m;i++){
int x,y,c;
cin>>x>>y>>c;
mini=min(mini,(an[x-1]+bn[y-1]-c));
}

sort(an,an+a);
sort(bn,bn+b);

mini=min(mini,an[0]+bn[0]);

cout <<mini<<endl;


}






Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int n,a,s,i,d,c,j,x,g;
	while(1){
		scanf("%d %d",&a,&s);
		if(a==0&&s==0) break;
		if(a<s){
			n=a;
			a=s;
			s=n;
		}
		c=0;
		while(s!=0){
			a=a%s;
			g=a;
			a=s;
			s=g;
			c++;
		}	
		printf("%d %d\n",a,c);
	}
	return 0;
}

Measured memory_bytes: 1028
n, m = map(int,input().split())
a = []
for i in range(m):
    a.append(int(input()))

dp = [0 for _ in range(n + 2)] #i-1段目に登る方法の数
dp[0] = 0
dp[1] = 1
tmp = 0
if m != 0:
    for i in range(n):
        if i + 1 != a[tmp]:
            dp[i + 2] = (dp[i] + dp[i + 1]) % (pow(10, 9) + 7)
        elif i + 1 == a[tmp]:
            if tmp < m - 1:
                tmp += 1
            dp[i + 2] = 0
elif m == 0:
    for i in range(n):
        dp[i + 2] = (dp[i] + dp[i + 1]) % (pow(10, 9) + 7)
#print(dp)
print(dp[n + 1])

Measured memory_bytes: 7864
#include <iostream>
#include <string>
using namespace std;
int graph[6][2] = {
	{1, 2},
	{-1, 3},
	{1, -1},
	{4, 5},
	{5, 2},
	{2, 1},
};
bool solve(const string& p) {
	int pos = 0;
	for (unsigned i = 0; i < p.size(); i++) {
		pos = graph[pos][p[i] - '0'];
		if (pos == -1) return false;
	}
	return pos == 5;
}
int main () {
	string p;
	while (cin >> p, p != "#") {
		cout << (solve(p) ? "Yes" : "No") << endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N ;
    cin >> N ;
    vector<pair<ll,ll> > students;
    
    rep(i, N){
        ll inp; cin >> inp;
        students.pb(mp(inp, i + 1));
    }
    
    sort(all(students), [](pair<ll,ll> &a, pair<ll,ll> &b){
        return a.first < b.first;
    });
    
    rep(i, N){
        cout << students[i].second << " ";
    }
    cout << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 2544
#include <bits/stdc++.h>
using namespace std;
map<pair<string,string>,int>g;
int n;
char s[100005];
long long ans,tmp;
int main(){
	cin>>n;tmp=1<<n;
	scanf("%s",s);
	for(int i=0;i<tmp;i++){
		string a,b;
		for (int j=0;j<n;j++){
			if ((i>>j)&1)a+=s[j];
			else b+=s[j];
		}
		g[{a,b}]++;
	}
	for(int i=0;i<tmp;i++){
		string a,b;
		for(int j=0;j<n;j++){
			if((i>>j)&1)a+=s[2*n-1-j];
			else b+=s[2*n-1-j];
		}
	//	reverse(a.begin(),a.end());
	//	reverse(b.begin(),b.end());
		ans+=g[{a,b}];
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

string shuffle(string str, int h){
  string head=str.substr(0,h);
  string tail=str.substr(h,str.size()-h);
  return tail+head;
}
int main(){
  string cards;
  int m,h;

  
  while(1){
    cin>>cards;
    if(cards =="-") break;
    cin>>m;
    for(int i=0;i<m;i++){
      cin>>h;
      cards=shuffle(cards,h);
    }
    cout<<cards<<endl;
  }

  return 0;
}
    



Measured memory_bytes: 3212
import Control.Monad

main :: IO ()
main = do
  loop 0

loop :: Int -> IO ()
loop count = do
  n <- readLn
  if n == 0
    then return ()
    else do
      sss <- replicateM n getLine
      let ss = map words sss
          ts = map tupleToStr $ scoreSort $ map listToTuple ss
      if count == 0
        then return ()
        else putStrLn ""
      mapM_ putStrLn ts
      loop (count+1)

listToTuple :: [String] -> (String,Int)
listToTuple [n,w,l,d] = (n,(read w)*3+(read d))

scoreSort :: [(String,Int)] -> [(String,Int)]
scoreSort [] = []
scoreSort ((n,s):xs) = (scoreSort higher) ++ [(n,s)] ++ (scoreSort lower)
  where higher = [t | t <- xs, (snd t) > s]
        lower = [t | t <- xs, (snd t) <= s]

tupleToStr :: (String,Int) -> String
tupleToStr (name,score) = name ++ "," ++ (show score)

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

int main()
{
	string S;
	string T;
	cin >> S >> T;
	rep(i, S.size())
	{
		if (S[i] != T[i])
		{
			cout << "No"; return 0;
		}
	}
	cout << "Yes";
	return (0);
}

Measured memory_bytes: 3528
#include<bits/stdc++.h>
using namespace std;
int t[9],d;
bool used[11];
bool C(void){
  int r=(t[0]+t[1]+t[2])%t[9];
  return ((t[3]+t[4]+t[5])%t[9]==r&&(t[6]+t[7]+t[8])%t[9]==r&&(t[0]+t[3]+t[6])%t[9]==r&&(t[1]+t[4]+t[7])%t[9]==r&&(t[2]+t[5]+t[8])%t[9]==r&&(t[0]+t[4]+t[8])%t[9]==r&&(t[2]+t[4]+t[6])%t[9]==r);
}
 
int dfs(int d){
  if(d==10)return C()?1:0;
  if(t[d]!=0)return dfs(d+1);
  int res = 0;
  for(int i=1;i<=10;i++){
    if(!used[i]){
      t[d] = i;
      used[i] = true;
      res+=dfs(d+1);
      used[i] = false;
      t[d] = 0;
    }
  }
  return res;
}
main(){
  while(1){
    memset(used,0,sizeof(used));
    for(int i=0;i<10;i++){
      cin>>t[i];
      if(t[i]>0)used[t[i]]=1;
    }
    if(t[0]==-1)break;
    cout<<dfs(0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 2964
n,m = map(int,input().split())
place = []
check = []
gap = []
g = 0
for i in range(n):
    place.append(list(map(int,input().split())))
for j in range(m):
    check.append(list(map(int,input().split())))
for i in range(n):
    for j in range(m):
        g = abs(place[i][0] - check[j][0]) + abs(place[i][1] - check[j][1])
        gap.append(g)
    print(gap.index(min(gap)) + 1)
    gap = []

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 7;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans /= (i + 1);
        ans %= mod;
    }
    return ans;
}

int main(){
    ll n,m,c = 0;
    cin >> n >> m;
    rep0(i, m){
        ll a;
        cin >> a;
        c += a;
    }
    if(c > n)pf(-1);
    else pf(n - c);
    return 0;
}



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

int main(){
  ll n,i,j,k;
  cin >> n;
  ll d[n];
  for(i=1;i<=n;i++){
    cin >> d[i];
  }
  k=0;
  for(i=2;i<=n;i++){
    for(j=1;j<i;j++){
      k+=d[i]*d[j];
    }
  }
  cout << k;
}

Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n), c(n);
    rep(i, n)
    {
        cin >> p[i];
        p[i]--;
    }
    rep(i, n)
    {
        cin >> c[i];
    }
    ll ans_t = -LINF;
    rep(i, n)
    {
        ll ss = 0;
        ll cur = p[i];
        ll score = c[p[i]];
        ll count = 1;
        while (cur != i)
        {
            count++;
            score += c[p[cur]];
            cur = p[cur];
        }
        if (score >= 0 && k > count * 2)
        {
            ss = score * (k / count - 1);
        }
        ll kk = k;
        if (k > count * 2)
        {
            kk = count + k % count;
        }
        ll sum1 = 0;
        ll now = i;
        rep(j, kk)
        {
            sum1 += c[p[now]];
            now = p[now];
            chmax(ans_t, sum1 + ss);
        }
    }
    cout << ans_t << "\n";
}


Measured memory_bytes: 3740
#include <stdio.h>

int main(void)
{
    int n;
    int sum = 0;
    int i;

    scanf("%d", &n);

    i = n;
    while (i != 0)
    {
        sum += i % 10;
        i /= 10;
    }

    if (n % sum == 0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String M =sc.next();
    if(M.equals("AAA")){System.out.println("No");}
    else if(M.equals("BBB")){System.out.println("No");}
            else{System.out.println("Yes");}
  }
}

Measured memory_bytes: 21844
s = input()
K = int(input())

ss = sorted(s)
uego = list(set([ss[i] for i in range(len(ss))][:5]))

la = []
for i in range(len(s)):
  if s[i] in uego:
    for j in range(5):
      if i+j >= len(s):
        break
      la.append(s[i:i+j+1])
la = list(set(la))
la.sort()
print(la[K-1])

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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl

typedef pair<int, int> P;
typedef long long ll;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, h, w; cin>>n>>h>>w;
    vector<pair<int,int>> p(n);
    int ans = 0;
    REP(i,n){
        cin>>p[i].first>>p[i].second;
        if (p[i].first>=h && p[i].second>=w) ans++;
    } 
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

main()
{
	double n,k,j;
	cin>>n>>k>>j;
//	cout<<(n/j)<<endl;
	if((n/j)<=k)
	cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

}

Measured memory_bytes: 3716
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>

using namespace std;  //このネームスペースを使う

int main(){
  int N;
  int sum;
  cin >> N ;
  
  if(N%2 == 0){
    sum = N/2 * N/2;
  }
  else{
  	sum = (N+1)/2;
  	sum = sum * (N-sum);
  }


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



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

void fnInput(int& rnTrgSu, int& rnTrgKin)
{
  cin >> rnTrgSu >> rnTrgKin;
}

int fnRcsSch(int nPos, int nTrgSu, int nTrgKin, vector<int>& rvnNumMoney)
{
  vector<int> vnMoney{10000, 5000, 1000};

  if (nTrgKin < 0)  return -1;
  if (nPos == rvnNumMoney.size())
    if (nTrgKin)
      return 0;
    else
      return 1;

  if (nPos == 2)
  {
    rvnNumMoney[nPos] = nTrgSu;
    return fnRcsSch(nPos + 1, nTrgSu - nTrgSu, nTrgKin - vnMoney[nPos] * nTrgSu, rvnNumMoney);
  }
  else
    for (int i = 0; i <= nTrgSu; i++)
    {
      rvnNumMoney[nPos] = i;
      int nRtn = fnRcsSch(nPos + 1, nTrgSu - i, nTrgKin - vnMoney[nPos] * i, rvnNumMoney);
      if      (nRtn == -1)  return 0;
      else if (nRtn)        return 1;
    }

  return 0;
}

int fnExhSch(int nTrgSu, int nTrgKin)
{
  vector<int> vnNumMoney(3);

  if (fnRcsSch(0, nTrgSu, nTrgKin, vnNumMoney))
    cout << vnNumMoney[0] << " " << vnNumMoney[1] << " " << vnNumMoney[2] << endl;
  else
    cout << -1 << " " << -1 << " " << -1 << endl;
}

int main()
{
  int nTrgSu, nTrgKin;
  
  fnInput(nTrgSu, nTrgKin);
  fnExhSch(nTrgSu, nTrgKin);

  return 0;
}
 

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
ans = 'Yes'

for i in range(1,N):
    if H[i-1] > H[i]:
        ans = 'No'
        break
    else:
        H[i] = max(H[i-1], H[i]-1)

print(ans)

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


int main(){
int res,res1,res2;
int a, b;
cin>>a>>b;
res1=a*b;
res=a-b;
res2=a+b;
cout<<max(res,max(res1,res2));






return 0;

}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

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

int main() {
  long x;
  cin >> x;
  long h = 0;

  // 500円玉について
  int a = x/500;
  x -= a*500;
  h += a * 1000;

  // 5円玉について
  a = x/5;
  h += a * 5;

  
  cout << h << endl;

}


Measured memory_bytes: 256
program main
    implicit none
    integer n,m
    integer, allocatable, dimension(:) :: a
    integer i,sum, d, count
    read(*,*) n,m
    allocate(a(n))
    read(*,*) a

    sum = 0
    count = 0
    do i = 1,n
        sum = sum + a(i)
    end do

    d = sum/(4*m)

    if (mod(sum, 4*m) == 0) then
        d = d-1
    end if

    do i = 1,n
        if(a(i) > d) then
            count = count + 1
        end if
    end do

    if(count >= m) then
        write(*,*) "Yes"
    else
        write(*,*) "No"
    end if

end program

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	char s[100],sc[100],p[100];
	int sl,pl,f=0;
	scanf("%s",s);
	scanf("%s",p);
	strcpy(sc,s);
	sl=strlen(s);
	pl=strlen(p);
	for(int j=0;j<sl;j++){
		sc[0]=s[sl-1];
		for(int i=0;i<(sl-1);i++){
			sc[i+1]=s[i];
		}
		if(strncmp(sc,p,pl)==0){
			f=1;
			break;
		}
		strcpy(s,sc);
	}
	if(f==1){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 2668
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int a,b,c;
int k1,k2,k3;

int main(){
  cin >> a >> b;
  int ans = max(a+b,a-b);
  ans = max(ans,a*b);
  cout << ans << endl;
  
  return 0;
}



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

int n, k, h[100005], d[100005];

int main(){
    scanf("%d %d", &n, &k);
    for(int i = 1; i <= n; i++) scanf("%d", &h[i]);
    for(int i = 2; i <= n; i++){
        d[i] = 1e9 + 7;
        for(int j = max(1, i - k); j <= i - 1; j++)
            d[i] = min(d[i], d[j] + abs(h[j] - h[i]));
    }
    printf("%d", d[n]);
    return 0;
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}

int main() {
  int count=0,ans=0;
  string s;
  cin>>s;
  rep(i,s.size()){
    if(s[i]=='S'){
      count++;
    }else{
      if(count>0){
        count--;
        ans++;
      }
    }
  }
  cout<<s.size()-2*ans<<endl;
}

Measured memory_bytes: 640