akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	/*if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;*/
	return ((a.x + 1)*(a.y + 1)) < ((b.x + 1)*(b.y + 1));
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k, ll p) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
 //#define int long long
const long long Inf = 4523372036854775807;
const int inf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int cost, a1, a2, a3, a4;
int solve(int x,int y,int z,int a) {
	int res = x * 10 + y * 50 + z * 100 + a * 500 - cost, sum = 0;
	while (res >= 500) res -= 500, sum++;
	while (res >= 100) res -= 100, sum++;
	while (res >= 50) res -= 50, sum++;
	while (res >= 10) res -= 10, sum++;
	return a1 - x + a2 - y + a3 - z + a4 - a + sum;
}
signed main() {
	int rep = 0;
	while (cin >> cost&& cost) {
		if (rep) cout << endl;
		cin >> a1 >> a2 >> a3 >> a4;
		int b = inf, b1 = inf, b2 = inf, b3 = inf, b4 = inf;
		for (int i = 0; i <= a1; i++) {
			for (int j = 0; j <= a2; j++) {
				for (int x = 0; x <= a3; x++) {
					for (int y = 0; y <= a4; y++) {
						if (i * 10 + j * 50 + x * 100 + y * 500 >= cost) {
							if (solve(i, j, x, y) < b) {
								b1 = i, b2 = j;
								b3 = x, b4 = y;
								b = solve(i, j, x, y);
							}
						}
					}
				}
			}
		}
		if (b1 > 0) cout << "10 " << b1 << endl;
		if (b2 > 0) cout << "50 " << b2 << endl;
		if (b3 > 0) cout << "100 " << b3 << endl;
		if (b4 > 0) cout << "500 " << b4 << endl;
		rep++;
	}
	getchar(); getchar();
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main()
{
    INIT;
    int n;
    cin >> n;
    vector<int> w(n);
    REP(i,n) cin >> w.at(i);
    int s1, s2;
    int ans = 0;
    int minmin = 10e8;
    FOR(t,1,n){
        s1 = 0;
        s2 = 0;
        for(int i = t-1; i >= 0; i--){
            s1 += w[i];
        }
        for(int i = t; i < n; i++){
            s2 += w[i];
        }
        if(minmin > abs(s1 - s2)){
            minmin = abs(s1 - s2);        }
    }
    cout << minmin << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    ll tmp = 1, sum = 0;
    while(true){
        sum += tmp;
        if(sum>=x){
            cout << tmp << endl;
            return 0;
        }
        tmp++;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N, M;
int A[10];
int dp[100001];

bool Check(int k)
{
  fill_n(dp, 100001, -1);
  dp[0] = 0;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j <= M; j++) {
      if(dp[j] >= 0) {
        dp[j] = k;
      } else if(j < A[i] || dp[j - A[i]] <= 0) {
        dp[j] = -1;
      } else {
        dp[j] = dp[j - A[i]] - 1;
      }
    }
  }
  return(dp[M] >= 0);
}


int main()
{
  while(cin >> N >> M, N) {
    for(int i = 0; i < N; i++) {
      cin >> A[i];
    }
    int low = 0, high = M;
    while(high - low > 0) {
      int mid = (low + high) >> 1;
      if(Check(mid)) high = mid;
      else low = mid + 1;
    }
    cout << low << endl;
  }
}

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

int main(){
    string S;
    cin >> S;
    bool a = false;
    bool b = false;
    for(int i=0;i<3;i++) {
        if (S.at(i)=='A') a = true;
        else b = true;
    }
    if (a & b) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
a=->q{
puts"? "+q*" "
$>.flush
gets
}
I=*1..2*N=gets.to_i
f=a[I[0,N]]
l,r=0,N
f==a[I[m=(l+r)/2,N]]?l=m:r=m while r-l>1
x=I[r,N-1]
puts"! "+I.map{|i|
a[[i]+(x.index(i)?I-I[l,N+1]:x)][0]
}*""

Measured memory_bytes: 4432
#include<stdio.h>

int main(void)
{
    int N, M, i, t=0;
    scanf("%d %d",&N, &M);

    for(i=1;i<=N; i++) {
        t += N-i;
    }

    for(i=1;i<=M; i++) {
        t += M-i;
    }

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

    return 0;
}



Measured memory_bytes: 1644
using System;
using System.Linq;

namespace AOJ000
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var a = int.Parse(str.Split(' ')[0]);
            var b = int.Parse(str.Split(' ')[1]);

            Console.WriteLine(a * b + " " +( a * 2 + b * 2));
        }
    }
}

Measured memory_bytes: 5604
M=10^9+7
n,k=readline()|>split.|>x->parse(Int,x)
j=isqrt(n)
let x=c=[(i->n÷i-n÷(i+1)).(1:n÷(j+1));fill(1,j)]
print((i->x=cumsum(reverse(x)).*c.%M).(1:k)[k][end])
end

Measured memory_bytes: 294520
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll powmod(ll n, ll k, ll m) {
ll r=1;
 for(; k>0; k >>=1) {
   if(k&1) r=(r*n)%m;
   n=(n*n)%m;
 }
  return r;
}

ll fact(ll n) {
ll a=1;
rep(i,n) {
a=a*(n-i);
}
return a;
}

ll pow(ll a, ll b) {
ll x=1;
rep(i,b) {
x=x*a;
}
return x;
}



int main() {
string S;
  cin >>S;
  
  if(S=="ABC") {
    cout<<"ARC"<<endl;
  }

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

  
}


Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define lon long long
using namespace std;
const int maxn=500010;
lon n,l,r,ans1,a[maxn],b1[maxn],c[maxn];
lon s1[maxn],s2[maxn];
lon lowbit(lon x)
{
    return x&(-x);
}
void add(lon x)
{
    for(lon i=x;i<=n;i+=lowbit(i))
    c[i]++;
}
lon getsum(lon x)
{
    lon ans=0;
    for(lon i=x;i>=1;i-=lowbit(i))
    ans+=c[i];
    return ans;
}
int main()
{
    cin>>n>>l;
    for(lon i=1;i<=n;i++) scanf("%d",&a[i]);
    for(lon i=1;i<=n;i++)
    {
        s1[i]=s1[i-1]+a[i]-l;
        b1[i]=s1[i];
        if(s1[i]<0) ans1++;
    }
    sort(s1+1,s1+n+1);
    lon t1=unique(s1+1,s1+n+1)-s1-1;
    for(lon i=1;i<=n;i++)
    {
        lon pos=lower_bound(s1+1,s1+t1+1,b1[i])-s1;
        b1[i]=pos;
    }
    for(lon i=n;i>=1;i--)
    {
        ans1+=getsum(b1[i]);
        add(b1[i]+1);
    }
    lon up=ans1;
    lon down=n*(n+1)/2;
    cout<<down - up;
    return 0;
}


Measured memory_bytes: 16768
// ConsoleApplication7.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include <stdio.h>


int main(int argc, char* argv[])
{
	int i;
	int num;
	int x[3000], y[3000];
	char temp[12];

	for (num = 0; 1; num++) {
		fgets(temp, sizeof(temp), stdin);
		sscanf(temp, "%d %d", &x[num], &y[num]);
		if (x[num] == 0 && y[num] == 0) break;
	}
	for (i = 0; i < num; i++) {
		if (x[i] < y[i]) {
			printf("%d %d\n", x[i], y[i]);
		}
		else {
			printf("%d %d\n", y[i], x[i]);
		}
	}
	
	return 0;
}

Measured memory_bytes: 2600
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[] cnt = new int[3];
		for(int i=0;i<N;i++){
			if(P[i] <= A) cnt[0]++;
			else if(P[i] <= B) cnt[1]++;
			else if(P[i] > B) cnt[2]++;
		}
		Console.WriteLine(cnt.Min());
		
	}
	int N;
	int A,B;
	int[] P;
	public Sol(){
		N = ri();
		var d = ria();
		A = d[0]; B = d[1];
		P = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

static long long N, ANS = 1,NS=1, A[100000], BIT[100010] = {}, F[100010] = {}, MOD = 1000000007;
vector<long long> V;

void init(int X) {
	F[0] = 1, F[1] = 1;
	for (int i = 2; i < X; i++) F[i] = (F[i - 1] * i) % MOD;
}

void Add(int X, long long Y) {
	for (int i = X; i <= N; i += i & -i) BIT[i] += Y;
}

long long Sum(int X) {
	long long Ret = 0;
	for (int i = X; i > 0; i -= i & -i) Ret += BIT[i];
	return Ret;
}

int main() {
	cin >> N;
	init(N);
  int b[N];
	for (int i = 1; i <= N; i++) cin >> A[N - i];
	for (int i = 0; i < N; i++) {
		ANS = (ANS + Sum(A[i]) * F[i]) % MOD;
		Add(A[i], 1);
	}
  
  for(int i=0;i<100010;i++){
    BIT[i]=0;
  }
  
  for (int i = 1; i <= N; i++) cin >> b[N - i];
	for (int i = 0; i < N; i++) {
		NS = (NS + Sum(b[i]) * F[i]) % MOD;
		Add(b[i], 1);
	}
	cout << abs(ANS-NS)<< endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for (int i = (m); i < (int)(n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define all(vec) vec.begin(), vec.end()
using namespace std;

int main(){
  int a, b;
  string c;
  cin >> a >> b >> c;

  //int ans = 0;
  string ans = "Yes";
  rep(i, a + b + 1){
    if (i != a){
      if (c[i] == '-') ans = "No";
    }
    else{
      if (c[i] != '-') ans = "No";
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

def main():
    s = input()
    w = int(input())

    print(s[::w])

main()


Measured memory_bytes: 5440
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

#define int long long
#define endl "\n"

int check(map<char,int>& array, map<char, map<int,int>> &num, string &s, int b, int e){
	int num2 = 0;
	
	if('0' <= s[b] && s[b] <= '9') return stoi(s.substr(b,e-b))+1;
	
	num2 = check(array, num, s, b+2, e-1);
	
	if(!num2 || num2 > array[s[b]] || !array[s[b]]) return 0;
	
	return num[s[b]][num2];
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	
	while(true){
		int con = 0, ans = 0;
		map<char,int> array;
		map<char, map<int,int>> num;
		
		for(;;con++){
			string s;
			
			cin>>s;
			
			if(s == ".") break;
			
			if(ans) continue;
			
			if(count(s.begin(), s.end(), '=')){
				int y = s.find('=');
				int num1 = check(array, num, s, 2, y-1);
				int num2 = check(array, num, s, y+1, s.size());
			
				if(!num2 || !num1 || num1 > array[s[0]]) ans = con+1;
				
				num[s[0]][num1] = num2;
				
			} else array[s[0]] = stoi(s.substr(2,s.size()-3));
		}
		
		if(!con) break;
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3200
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>


using namespace std;

int main()
{
  int ans=0;
  string s,t;
  cin>>s>>t;
  int x=s.size();
  for(int i=0;i<x;i++)
  {
    if(s.at(i)!=t.at(i))
    {
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3844
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
#define PI 3.14159265358979323846
using namespace std;
//
int main(){
  int N,P[100000];
  cin>>N;
  FOR(i,0,N){
    cin>>P[i];
  }
  int ans=0;
  FOR(i,0,N){
    int cnt=0;
    while(P[i]==i+1){
      i++;
      cnt++;
    }
    if(cnt){
      i--;
    }
    ans+=(cnt+1)/2;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    int x[1000];
    for(int i=0; i<n; i++){
        cin >> x[i];
    }
    int ans = 1000000;
    int sum = 0;
    for(int i=1; i<=100; i++){
        for(int j=0; j<n; j++){
            sum += (x[j]-i)*(x[j]-i);
        }
        ans = min(sum, ans);
        sum = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
main()
{
  int n, u, k, v;
  int i, j;

  scanf("%d",&n);
  int A[n][n];

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

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

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

  return 0;  
}

Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

int main() {
	string s1, s2;
	cin >> s1 >> s2;
	int ans = 0;
	rep(i, 3) {
		if (s1[i] == s2[i]) {
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3592
from fractions import gcd
 
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
 
    # divisors.sort()
    return divisors
  
def isPrime(n):
  if n < 2:
    # 2未満は素数でない
    return False
  if n == 2:
    # 2は素数
    return True
  for p in range(2, int(n**0.5)+1):
      if n % p == 0:
        # nまでの数で割り切れたら素数ではない
        return False
  # nまでの数で割り切れなかったら素数
  return True
 
A,B = list(map(int,input().split()))
 
aaa = []
 
aaa = make_divisors(gcd(A,B))
        
count = 0
 
for i in range(len(aaa)):
    if isPrime(aaa[i]) == True:
        count += 1
        
print(count+1)

Measured memory_bytes: 5308
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
//const ll big=998244353;
const ll big=1000000007LL;
const ll INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


struct edge{
    ll to,cost;
    constexpr bool operator<(const edge &a)const noexcept{
        if((*this).cost<a.cost)return true;
        else return false;
    }
    constexpr bool operator>(const edge &a)const noexcept{
        if((*this).cost>a.cost)return true;
        else return false;
    }
};

struct graph{
    ll v;
    vec<vec<edge>> g;
    vec<ll> d;

    graph(ll n) : v(n),g(n),d(n,INF){}

    void addedge(const ll s,const ll t,const ll cost){
        edge e;
        e.to=t;
        e.cost=cost;
        g[s].emplace_back(e);
    }
    //E+VlogV
    void dijkstra(ll s){//sからstartのdijkstra
        /*一度dijkstraをした時同じグラフでdijkstraしたいならこれも入れる
        rep(i,v)d[i]=INF;
        */
        d[s]=0;
        priority_queue<P,vec<P>,greater<P>> que;
        que.push(P(0,s));
        while(!que.empty()){
            P pa=que.top();que.pop();
            ll k=pa.second;
            if(d[k]<pa.first)continue;
            for(auto e:g[k]){
                if(d[e.to]>d[k]+e.cost){
                    d[e.to]=d[k]+e.cost;
                    que.push(P(d[e.to],e.to));
                }
            }
        }
    }
};

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int h,w,sx,sy,gx,gy;cin >> h >> w >> sx >> sy >> gx >> gy;
    vec<vec<char>> s(h,vec<char>(w));
    rep(i,h)rep(j,w)cin >> s[i][j] ;
    sx--;sy--;gx--;gy--;
    graph g(h*w);

    //点(i,j)は点(w*i+j)に
    //点(i,j)から右下に引けるところへ辺を張る
    rep(i,h)rep(j,w){
        if(s[i][j]=='#')continue;
        rep(k,4){
            int nx=i+dx[k],ny=j+dy[k];
            if(nx<0||ny<0||nx>=h||ny>=w)continue;
            if(s[nx][ny]=='#')continue;
            g.addedge(w*i+j,w*nx+ny,0);
        }
        rep2(k,-2,3)rep2(l,-2,3){
            if(k*k+l*l==1)continue;
            if(i+k>=h||j+l>=w||i+k<0||j+l<0)continue;
            if(s[i+k][j+l]=='#')continue;
            g.addedge(w*i+j,w*(i+k)+j+l,1);
        }
    }
    g.dijkstra(w*sx+sy);
    //rep(i,h)rep(j,w)cout << g.d[w*i+j] << endl;
    if(g.d[w*gx+gy]==INF){cout << -1 << endl;return 0;}
    cout << g.d[w*gx+gy] << endl;
}

Measured memory_bytes: 175808
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;


struct SegmentTree{

    vector<int> data;
    vector<int> lazy;
    int n;

    SegmentTree(int n_){
        n=1;
        while(n<n_)n*=2;
        data.resize(n*2-1);
        lazy.resize(n*2-1);
    }

    void eval(int k,int a,int b){
        data[k]+=lazy[k];
        if(k<n-1){
            lazy[2*k+1]+=lazy[k];
            lazy[2*k+2]+=lazy[k];
        }
        lazy[k]=0;
    }

    void add(int a,int b,int x,int k,int l,int r){
        eval(k,l,r);

        if(l>=b||r<=a)return;
        if(l>=a&&r<=b){
            lazy[k]+=x;
            eval(k,l,r);
            return;
        }
        add(a,b,x,2*k+1,l,(l+r)/2);
        add(a,b,x,2*k+2,(l+r)/2,r);
        data[k]=max(data[2*k+1],data[2*k+2]);
    }

    void add(int a,int b,int x){
        add(a,b,x,0,0,n);
    }

    int getSum(int a,int b,int k,int l,int r){
        eval(k,l,r);

        if(l>=b||r<=a)return 0;
        if(l>=a&&r<=b)return data[k];

        return max(getSum(a,b,2*k+1,l,(r+l)/2) , getSum(a,b,2*k+2,(r+l)/2,r));
    }

    int getSum(int a,int b){
        return getSum(a,b,0,0,n);
    }

};

int main(){

    int N,M;
    cin>>N>>M;
    vector< pair<int,int> > LR;
    REP(i,N){
        int L,R;
        cin>>L>>R;
        LR.push_back(make_pair(L-1,R-1));
    }
    sort(ALL(LR));
    SegmentTree seg(M);
    REP(i,M){
        seg.add(i,i+1,-1*(M-i));
    }

    int ans=N-M;
    int before=0;
    REP(i,N){
        seg.add(0,M,before-LR[i].first);
        before=LR[i].first;
        seg.add(0,LR[i].second,1);
        ans=max(ans,seg.getSum(0,M));
    }

    cout<<ans<<endl;

    return 0;
}

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

#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 RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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; }

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main(){
  int a,b,c,K;
  cin >> a >> b >> c >> K;

  bool ok=false;
  REP(i,K+1)REP(j,K+1)REP(k,K+1){
    if(i+j+k!=K)continue;
    int na = a;
    int nb = b;
    int nc = c;
    REP(l,i)na*=2;
    REP(l,j)nb*=2;
    REP(l,k)nc*=2;
    if(nc > nb && nb > na)ok = true;
  }

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

}



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

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
	long long n, a, b;
	cin >> n >> a >> b;
	cout << n/(a + b) * a + min(n % (a + b), a) << "\n";
}



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

int main() {
    long long a, b, x;
    cin >> a >> b >> x;

    long long sum = 0;
    if (a % x == 0) cout << b / x - a / x + 1 << endl;
    else cout << b / x - a / x << endl;
}

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

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

vector<ll> x[4];
ll N,W, lst; 

int main() {
	cin >> N >> W;
	F0R(i,N) {
		ll w,v; cin >> w >> v;
		if (i == 0) lst = w;
		x[w-lst].pb(v);
	}
	F0R(i,4) {
		sort(x[i].begin(),x[i].end());
		x[i].pb(-MOD);
		reverse(x[i].begin(),x[i].end());
		F0R(j,x[i].size()) {
			if (j == 0) x[i][j] = 0;
			else x[i][j] += x[i][j-1];
		}
	}
	ll ans = 0;
	F0R(i0,x[0].size()) F0R(i1,x[1].size()) F0R(i2,x[2].size()) F0R(i3,x[3].size()) {
		ll val = x[0][i0]+x[1][i1]+x[2][i2]+x[3][i3];
		ll wei = i0*lst+i1*(lst+1)+i2*(lst+2)+i3*(lst+3);
		if (wei <= W) ans = max(ans,val);
	}
	cout << ans;
}

Measured memory_bytes: 256
// std::set を用いた解
#include <iostream>
#include <set>
using namespace std;

int main() {
  int N;
  int d[110];
  std::set<int> values;
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> d[i];
  for (int i = 0; i < N; ++i){
    //setだから重複を許さず保存
    values.insert(d[i]);
  }
  // set のサイズを出力します
  cout << values.size() << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    if(a == b){
        printf("-1\n");
        return 0;
    }
    for(int i = a; i < 1000000000; i += a){
        if(i % b != 0){
            printf("%d\n", i);
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}

Measured memory_bytes: 256
def ListOfTop3Hill(l):
    l.sort()
    l.reverse()
    for i in range(3):
        print(l[i])


def main():
    # input
    N = 10
    l = [int(input()) for i in range(N)]
    # solver
    ListOfTop3Hill(l)

if __name__ == '__main__': main()



Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    if(n<105) cout<<0;
    else if(105<=n&&n<135) cout<<1;
    else if(135<=n&&n<165) cout<<2;
    else if(165<=n&&n<189) cout<<3;
    else if(189<=n&&n<195) cout<<4;
    else cout<<5;
}

Measured memory_bytes: 3640
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n;
    int w[110];
    cin >> n;
    REP(i, n)
    cin >> w[i];
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        sum += w[i];
    }
    int sum2 = 0;
    int ans = INF;
    for (int i = 0; i < n; i++)
    {   
        sum2 += w[i];
        sum -= w[i];
        ans = min(ans, abs(sum - sum2));

    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 888
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){function t(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=[],n=!0,o=!1,u=void 0;try{for(var i,l=e[Symbol.iterator]();!(n=(i=l.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(e){o=!0,u=e}finally{try{n||null==l.return||l.return()}finally{if(o)throw u}}return t}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}e.exports=function(e){var r=t(e.split("\n")[0].split(" ").map(function(e){return Number(e)}),2),n=r[0],o=r[1];if(o-n+1>=2019)console.log(0);else{for(var u=2019,i=n;i<o;i++){var l=i%2019;for(j=o;j>i;j--){var f=l*(j%2019)%2019;f<u&&(u=f)}}console.log(u)}}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
int n,ans,la;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int dx=c-a,dy=d-b;
	cout<<c-dy<<" "<<d+dx<<" "<<a-dy<<" "<<b+dx<<endl;
}


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

using namespace std;

const int N = 3e4+10; 
bool pre[N][10], suf[N][10];
bool pin[10][10][10];

void solve() {
    int n; cin >> n;
    string s; cin >> s;
    for (int i = 0; i < n; i++) {
        memcpy(pre[i+1], pre[i], sizeof pre[i+1]);
        pre[i+1][s[i]-'0'] = 1;
    }
    for (int i = n-1; i >= 0; i--) {
        memcpy(suf[i], suf[i+1], sizeof suf[i]);
        suf[i][s[i]-'0'] = 1;
    }
    for (int i = 1; i < n-1; i++) {
        int m = s[i]-'0';
        for (int l = 0; l < 10; l++) {
            for (int r = 0; r < 10; r++) {
                if (pre[i][l] && suf[i+1][r]) {
                    pin[l][m][r] = 1;
                }
            }
        }
    }
    int res = 0;
    for (int l = 0; l < 10; l++) {
        for (int m = 0; m < 10; m++) {
            for (int r = 0; r < 10; r++) {
                if (pin[l][m][r]) res++;
            }
        }
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define INF 1000000000

bool dfs(int s,vector<vector<int>> child,vector<int> X,vector<vector<int>> &dp,vector<bool> visit)
{
	int a,b,c,d,m,mm,M,MM;
	visit[s]=true;
	bool can;
	if (child[s].size()==0) {dp[s][0]=X[s];/*cout << s<<":"<<dp[s][0]<<" "<<dp[s][1] <<endl;*/return true;}
	for (int i=0;i<child[s].size();i++)
	{
		if (!visit[child[s][i]])
		{
			can=dfs(child[s][i],child,X,dp,visit);
			if (!can) return false;
		}
	}
	vector<vector<int>> dp2(child[s].size()+1,vector<int> (X[s]+1,INF));
	dp2[0][0]=0;
	for (int i=1;i<child[s].size()+1;i++)
	{
		for (int j=0;j<X[s]+1;j++)
		{
			if (j-dp[child[s][i-1]][0]>=0) dp2[i][j]=min(dp2[i][j],dp2[i-1][j-dp[child[s][i-1]][0]]+dp[child[s][i-1]][1]);
			if (j-dp[child[s][i-1]][1]>=0) dp2[i][j]=min(dp2[i][j],dp2[i-1][j-dp[child[s][i-1]][1]]+dp[child[s][i-1]][0]);
		}
	}
	int ans=INF;
	for (int i=0;i<X[s]+1;i++) ans=min(ans,dp2[child[s].size()][i]);
	if (ans==INF) return false;
	dp[s][0]=ans;dp[s][1]=X[s];
	//cout << s<<":"<<dp[s][0]<<" "<<dp[s][1] <<endl;
 	return true;
}


int main()
{
	int N;cin >> N;
	vector<int> parent(N+1,0);
	vector<vector<int>> child(N);
	vector<bool> visit(N,false);
	vector<vector<int>> dp(N,vector<int> (2,0));
	for (int i=1;i<N;i++)
	{
		cin >>parent[i];
		child[parent[i]-1].pb(i);
	}
	vector<int> X(N);
	for (int i=0;i<N;i++) cin>> X[i];
	if (dfs(0,child,X,dp,visit)) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> lc(N);
  int max_d = 0;
  int p = 0;
  for (int i = 0; i < N; i++) {
    cin >> lc[i];
    max_d += abs(lc[i]-p);
    p = lc[i];
  }
  max_d += abs(p);
  
  vector<int> cut(N,max_d);
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      if (lc[0]*(lc[0]-lc[1]) > 0) {
        cut[0] -= 2 * min(abs(lc[0]),abs(lc[0]-lc[1]));
      }
    }
    else if (i == N-1) {
      if (lc[N-1]*(lc[N-1]-lc[N-2]) > 0) {
        cut[N-1] -= 2 * min(abs(lc[N-1]),abs((lc[N-1]-lc[N-2])));
      }
    }
    else {
      if ((lc[i]-lc[i-1])*(lc[i]-lc[i+1]) > 0) {
        cut[i] -= 2 * min(abs(lc[i]-lc[i-1]),abs(lc[i]-lc[i+1]));
      }
    }
    cout << cut[i] << endl;
  }
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 233;
int  a[maxn];
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		int x;scanf("%d",&x);
		a[x] = i;
	}
	for(int i=1;i<n;i++)printf("%d ",a[i]);
	printf("%d\n",a[n]);
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

using Graph = vector<vector<int>>;

int main(){
	int n, r; cin >> n >> r;
	if(n >= 10) cout << r << endl;
	else cout << r + 100 * (10 - n) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

#define MOD 998244353
int main(){
    ll n;
    cin >> n;

    ll cnt[100010] = {};
    vector<ll> d(n);
    rep(i, n){
        cin >> d[i];
        cnt[d[i]]++;
    }
    if(d.front()!=0||cnt[0]>1){
        cout << 0;
        return 0;
    }

    ll ans = 1;
    for(ll pos = 1; pos < n; ++pos){
        if(cnt[pos]==0)continue;
        ll base = 1;
        rep(i, cnt[pos])base = (base*cnt[pos-1])%MOD;
        ans = (ans*base)%MOD;
    }
    cout << ans << endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,x,c=0;
	cin>>n>>x;
	int m[100];
	for(int i=0;i<n;i++){
		cin>>m[i];
		c+=m[i];
	}
	sort(m,m+n);
	cout<<((x-c)/m[0])+n<<endl;
	return 0;
}


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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  string s;
  cin>>s;
  int cnt=0,maxi=0;

  r(i,s.size()){
    if(s.at(i)=='A'||s.at(i)=='C'||s.at(i)=='G'
    ||s.at(i)=='T'){
      cnt++;
      maxi=max(maxi,cnt);
    }else{
      cnt=0;
    }
  }
  cout<<maxi<<endl;
return 0;}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int N,L;
int cmp(const void *a, const void *b) {
  return strncmp((const char*)a,(const char*)b,L);
}
int main() {
  char **S;
  char *SS;
  scanf("%d %d",&N,&L);
  S = (char**)malloc(sizeof(char*)*N);
  SS = (char*)malloc(sizeof(char)*(L+1)*N);
  int i;
  for (i=0; i<N; i++) {
    S[i] = &(SS[(L+1)*i]);
    scanf("%s",S[i]);
  }
  qsort(SS, N, L+1, cmp);
  for (i=0; i<N; i++) printf("%s",S[i]);
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#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>

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 gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 m, d;
int main() {
  cin >> m >> d;
  i64 ans = 0;
  for (i64 i = 2; i <= m; ++i) {
    for (i64 j = 2; j <= d; ++j) {
      i64 k = j % 10, l = j / 10;
      if (k >= 2 && l >= 2 && k * l == i) ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  bool num[1000001] = {false};
  for(int i=2; i<1000; i++){
    if(!num[i]){
      for(int j=i*i; j<1000001; j+=i){
	num[j] = true;
      }
    }
  }
  int n;
  while(cin >>n){
    int sum = 0;
    for(int i=2; i<=n; i++){
      if(!num[i]){sum++;}
    }
    cout <<sum<<endl;
  }
  return 0;
}

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

int main(){
    char st;
    cin >> st;

    if(st=='a' || st=='b' || st=='c' || st=='d' || st=='e' || st=='f' || st=='g' || st=='h' || st=='i' || st=='j' || st=='k' || st=='l' || st=='m' || st=='n' | st=='o' || st=='p' || st=='q' || st=='r' || st=='s' || st=='t' || st=='u' || st=='v' || st=='w' || st=='x' || st=='y' || st=='z'){
        cout << 'a' << endl;
    }else{
        cout << 'A' << endl;
    }
}

Measured memory_bytes: 3628
def main():
    b = input('')
    if b == 'A':
        print('T')
        return
    if b == 'T':
        print('A')
        return
    if b == 'C':
        print('G')
        return
    if b == 'G':
        print('C')
        return


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
N = int(input())
no_1 = 0
pos_1 = 0
no_2 = 0
for i in range(0, N):
    num = int(input())
    
    if no_1 <= num:
        no_2 = no_1
        no_1 = num
        pos_1 = i
        
    elif no_2 < num:
        no_2 = num
    
for i in range (0, N):
    if i == pos_1:
        print(no_2)
    else:
        print(no_1)

Measured memory_bytes: 55640
# -*- coding: utf-8 -*-
import sys
N=int(sys.stdin.readline().strip())
A=[float("inf")]+map(int, sys.stdin.readline().split())+[0]
AA=[]
for i,a in enumerate(A):
    if i==0:
        AA.append(a)
    else:
        if prev==a:
            pass
        else:
            AA.append(a)
    prev=a

KATAMUKI=[]
for i,a in enumerate(A):
    if i==0:
        pass
    else:
        if prev<a:
            KATAMUKI.append("+")
        elif prev>a:
            KATAMUKI.append("-")
    prev=a

len_AA=len(AA)

money=1000
kabu=0
for i in range(1,len_AA-1):
    kabuka=AA[i]
    #print i,kabuka
    if KATAMUKI[i-1]=="-" and KATAMUKI[i]=="+":   #買い
        kabu+=money/kabuka
        money-=(money/kabuka)*kabuka
    elif KATAMUKI[i-1]=="+" and KATAMUKI[i]=="-":   #売り
        money+=kabu*kabuka
        kabu=0

print money

Measured memory_bytes: 85428
#include <iostream>

using namespace std;

int main()
{
    int n;
    int a[100010];
    int ans = 0;

    cin >> n;

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

    for (int i = 0; i < n; i++) {
        if (i == a[a[i]-1]-1) {
            ans++;
        }
    }

    cout << ans/2 << endl;
}


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

int main() {
    int N, x; cin >> N >> x;
    vector<int> A(N);
    rep(i, N){
        cin >> A[i];
    }

    ll ans = 0;
    for (int i = 1; i < N; i++){
        int now = A[i-1] + A[i];
        if(now > x){
            int d = now - x;
            ans += d;
            if(d <= A[i]){
                A[i] -= d;
            } else {
                A[i-1] -= d-A[i];
                A[i] = 0;
            }
        }    
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,n;
    cin>>a>>b>>n;
    ll ans=0;
    n=min(n,b-1);

        ll pos=floor(a*n/b);
        ans=max(pos,ans);
    cout<<ans;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n;
    if(n <= 999) cout << "ABC" << endl;
    else cout << "ABD" << endl;
}

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

int main() {
    /* Input */
    int N;
    cin >> N;
    
    vector<long long int> A(N);
    rep (i, N) {
        cin >> A.at(i);
    }

    /* Main Logic */
    long long int ans = 1;
    
    // 予め0を検索
    rep (i, N) {
        if (A.at(i) == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    // 本処理
    rep (i, N) {       
        if (A.at(i) <= 1000000000000000000 / ans) {
            ans *= A.at(i);
        } else {
            ans = -1;
            break;
        }
    }

    /* Output */
    cout << ans << endl;
    return 0;
}

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

int main(){
  string O,E;

  cin >> O >> E;

  for(int i=0;i < O.size();i++){

    cout << O[i];
    if(( O.size() + E.size() ) % 2 == 1 && i == O.size()-1) break;
    cout << E[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 384
from math import ceil, floor

K = int(input())
A = list(map(int, input().split()))


"""
- X人いてAi人グループをつくるとき，floor(X/Ai)個のグループになる
- floor(X/Ai) * Ai = X - X mod Ai 人が残る
- fp(X) = X - X mod pとする
"""

L, R = 2, 2

# L, Rから1つ前のL, R (最小，最大)を復元する

for k in range(K - 1, -1, -1):
    # print(k, A[k])
    L = ceil(L / A[k]) * A[k]
    R = floor(R / A[k]) * A[k] + A[k] - 1
    if L > R:
        print(-1)
        exit()

print(L, R)

Measured memory_bytes: 84972
INF = 1000000007


def modmulti(a, b):
    # aとbを掛けた値をmodする(a * b mod p)
    return a * b % INF


N = int(input())

ans = 1

for i in range(1, N + 1):
    ans = modmulti(ans, i)

print(ans)


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

#define dk23      ios_base :: sync_with_stdio(false);
#define inp       freopen("input.txt","r",stdin);
#define ll        long long

int main()
{
    dk23

    double l,ans;
    cin>>l;
    ans=(l/3)*(l/3)*(l/3);
    printf("%.12lf\n",ans);

    return 0;
}


Measured memory_bytes: 256
#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>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#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 MOD (long long int)(1e9+7)
#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()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll ans = 0;
  int n,k;cin>>n>>k;

  vector<ll> ruiseki;
  ruiseki.push_back(0);
  ruiseki.push_back(0);
  reps(i,n){
    ruiseki.push_back(ruiseki.back() + i);
  }
  rep(i,n+2){
    if(i < k) continue;
    ans += (ruiseki[n+1] - ruiseki[n-i+1] - (ruiseki[i-1+1] - ruiseki[-1+1])) + 1;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5328