akhauriyash/Code-Regression huggingface dataset:
of = [[0 for i in range(10)] for j in range(12)]

n = int(input())
for i in range(n):
    b,f,r,v = map(int,input().split())
    of[3*(b-1)+f-1][r-1] += v

for i in range(12):
    if i%3 == 0 and i !=0:
        print("####################")
    for j in range(10):
        print(" ",of[i][j],sep="",end="")
    print("")

Measured memory_bytes: 7708
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1],b[n+1],c[n];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		cin>>b[i];
		ans+=b[i];
	}
	for(int i=1;i<=n-1;i++)
	{
		cin>>c[i];
	}
	for(int i=1;i<=n-1;i++)
	{
		if(a[i]==a[i+1]-1)
		{
			ans+=c[a[i]];
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
def main():
    input1 = input()
    N = int(input1)
    S = [0]*N
    result = 0
    for i in range(N):
        input2 = input()
        S[i] = str(input2)

    set_S = []
    set_S = set(S)
    result = len(set_S)
    
    print(result)

if __name__ == "__main__":
    main()

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

bool includeThree (int x) {
  bool ans = false;
  while (x > 0) {
    if (x % 10 == 3) {
      ans = true;
      break;
    } else {
      x /= 10;
    }
  }
  return ans;
}
  
  

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

  for (int x=1;x<=n;x++) {
    if (x % 3 == 0 || includeThree(x))
      cout << " " << x;
  }
  cout << endl;
}



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

const long long MOD = 1000000007;
vector<long long> dp(100001, -1);
vector<bool> broken(100001);

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

  int N, M;
  cin >> N >> M;

  for (int i = 0; i < M; i++) {
    int a;
    cin >> a;
    broken.at(a) = true;
  }

  dp.at(0) = 1;
  if(broken.at(1)){
    dp.at(1) = 0;
  } else{
    dp.at(1) = 1;
  }
  for(int i = 2; i <= N; i++){
    if(broken.at(i)){
      dp.at(i) = 0;
    } else{
      dp.at(i) = (dp.at(i - 1)+ dp.at(i - 2)) % MOD;
    }
  }
  cout << dp.at(N) <<endl;
} 


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

typedef long long ll;

int a, n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    bool ok = true;
    cin >> n;
    unordered_set<int> s;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if (s.count(a))
            ok = false;
        else
            s.insert(a);
    }

    if (ok)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}



Measured memory_bytes: 8520
N, M = gets.split.map(&:to_i)
sw = [0] * -~N
M.times do |i|
	gets.split.map(&:to_i)[1..-1].each do |s|
		sw[s-1] |= 1 << i
	end
end
#p sw
#p b

pp =  gets.tr(" ",?_).reverse.to_i(2)
res = -(pp-1 >> 20)
1.upto(N) do |n|
	N.times.to_a.combination(n) do |x|
#		p [x, sw.values_at(*x),sw.values_at(*x).inject(:^)]
		res += 1 if sw.values_at(*x).inject(:^) == pp
	end
end
p res


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll x, y;
	cin >>x >>y;
	
	ll w=x;
	rep(i, 100){
		w *=2LL;
		if(w>y){
			cout << i+1 <<"\n";
			return 0;
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
    ll A,B,F=0;cin>>A>>B;
    string S,T;cin>>S>>T;
    ll L=lcm(A,B),G=gcd(A,B);
    rep(i,G){
        if(S[A*i/G]!=T[B*i/G]){
            F=1;
        }
    }
    if(F==0){
        cout << L << endl;
    }
    else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 512
def readinput():
    n=int(input())
    a=list(map(int,input().split()))
    return n,a

def main(n,a):
    genkin=1000
    kabu=0
    for i in range(n-1):
        if a[i]>a[i+1]:
            # 売り
            genkin+=kabu*a[i]
            kabu=0
        elif a[i]<a[i+1]:
            # 買い
            kabu+=genkin//a[i]
            genkin=genkin%a[i]
    if kabu>0:
        genkin+=kabu*a[n-1]
    return genkin

if __name__=='__main__':
    n,a=readinput()
    ans=main(n,a)
    print(ans)


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

const int MAX_N = 101;
const int INF = 1e+8;
typedef pair<int,int> P;

struct edge{
	int to, d, cost;
	edge(int to_, int d_, int cost_){ 
		to = to_; d = d_; cost = cost_; 
	};
};

// 宿の数
int N;
// G[u] := ノード u と隣接するエッジのvectorを返す
vector<edge> G[MAX_N];
// 頂点 v := <宿の番号,持っているお金>, memo[v] := v の最小コスト
map<P,int> memo;

// 初期化
void init(){
	for(int i=0 ; i < MAX_N ; i++ ){
		G[i].clear();
	}
	for(int i=0 ; i < MAX_N ; i++ ){
		for(int j=0 ; j < MAX_N ; j++ ){
			memo[P(i,j)] = INF;
		}
	}
}

// 辺の追加
void add_edge(int u, int v, int d, int cost){
	edge e( v , d , cost );
	G[u].push_back( e );
	e.to = u;
	G[v].push_back( e );
}

// 探索
int bfs(int s, int L){
	// (今まで襲われた数,宿の番号,今持っているお金) の状態を持つ優先度付きキュー
	priority_queue< pair<int,P>, vector<pair<int,P> >, greater<pair<int,P> > > q;
	// 襲われた数 0, 宿 s から お金 L の状態でスタートする
	P sp(s,L);
	pair<int,P> start(0,sp);
	q.push( start );
	memo[sp] = 0;
	
	int ans = INF;
	while( !q.empty() ){
		// now_cost := 今まで襲われた数
		int now_cost = q.top().first;
		P now = q.top().second;
		q.pop();
		// v := 今いる宿
		int v = now.first;
		// l := 今持っているお金
		int l = now.second;
		
		// ゴールにいるとき
		if( v == N-1 ){
			ans = min( ans , now_cost );
			continue;
		}
		
		for(int i=0 ; i < G[v].size() ; i++ ){
			int to = G[v][i].to;
			int d = G[v][i].d;
			
			// 距離以上のお金があるとき
			if( d <= l ){
				// to : 次の宿, l-d : 持っているお金
				P next( to , l - d );
				int next_cost = now_cost + 0 ;
				if( next_cost < memo[next] ){
					memo[next] = next_cost;
					pair<int,P> p( next_cost , next );
					q.push( p );
				}
			}
			// お金を払わず進むとき
			{
				// to : 次の宿, l : 持っているお金
				P next( to , l );
				int next_cost = now_cost + G[v][i].cost;
				if( next_cost < memo[next] ){
					memo[next] = next_cost;
					pair<int,P> p( next_cost , next );
					q.push( p );
				}
			}
		}
	}
	return ans;
}

int main(){
	int M, L;
	while( cin >> N >> M >> L, N || M || L ){
		init();
		
		for(int i=0 ; i < M ; i++ ){
			int a, b, d, e;
			cin >> a >> b >> d >> e;
			a--; b--;
			add_edge( a , b , d , e );
		}
		int ans = bfs( 0 , L );
		cout << ans << endl;
	}
}

Measured memory_bytes: 1780
package main

import (
        "fmt"
        "sort"
)

func solution(n, l int, s []string) string {
        sort.Strings(s)
        ans := ""
        for _, t := range s {
                ans += t
        }
        return ans
}

func main() {
        var n, l int
        fmt.Scan(&n, &l)

        s := make([]string, n)
        for i := range s {
                var t string
                fmt.Scan(&t)
                s[i] = t
        }
        fmt.Println(solution(n, l, s))
}

Measured memory_bytes: 1280
n = gets.chomp.to_i

paper = []

n.times do
  paper << gets.chomp
end

paper.sort!
uniq = paper.uniq

ans = 0
k = 0

uniq.each do |i|
  num = 0

  while i == paper[k] do
    num += 1
    k += 1
  end

  if num % 2 == 1
    ans += 1
  end
end

puts ans


Measured memory_bytes: 18664
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++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;}

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> k(m);
	vector<vector<int>> s(m);
	REP(i,m){
		cin >> k[i];
		REP(j,k[i]){
			int in;
			cin >> in;
			s[i].push_back(in-1);
		}
	}
	vector<int> p(m);
	REP(i,m) cin >> p[i];
	
	int ans=0;
	for(int bit=0; bit<(1<<n); bit++){
		bool light = true;
		REP(i,m){
			int sum=0;
			REP(j,k[i]){
				if(bit & (1<<s[i][j])) sum++;
			}
			if(sum%2!=p[i]) light=false;
		}
		if(light) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;


int main(){
	ll a,b,k;
    cin>>a>>b>>k;
    if(a>k){
        a-=k;
    }else{
        b-=k-a;
        a=0;
        if(b<0) b=0;
    }
    cout<<a<<" "<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int n,k;
  cin >>n>>k;
  int arr[n],dp[n];
 memset(dp,INT_MAX,sizeof(dp)); 
  int i,j;
  for(i=0;i<n;i++)
    cin >>arr[i];
  dp[0]=0;
  for(i=1;i<k;i++)
  {
    if(i==n)
      break;
    dp[i]=abs(arr[i]-arr[0]);
  }
  for(i=k;i<n;i++)
  {
    dp[i]=dp[i-1]+abs(arr[i]-arr[i-1]);
    for(j=i-1;(j>=0&&j>=i-k);j--)
    {
    dp[i]=min(dp[i],dp[j]+abs(arr[i]-arr[j]));
    }
  }
               cout <<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();

        if (x < 1200) {
            System.out.println("ABC");
        } else {
            System.out.println("ARC");
        }
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){

  int cnt = 0;
  string s; cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '2') cnt++;
  }
  cout << cnt << 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 REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(a) a.begin(),a.end()
int main()
{
    int N,L;
    cin >> N >> L;
    vector<string> S(N);
    string O = "";
    REP(i,N) cin >> S[i];
    sort(S.begin(),S.end());
    REP(i,N) O += S[i];
    cout << O << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;

int main() {
#if __APPLE__
    // freopen("C.in", "r", stdin);
    // freopen("C.out", "w", stdout);
#endif

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

    vector<char> to_start(n), to_end(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        scanf("%d%d", &a, &b);
        --a, --b;
        if (a > b) swap(a, b);
        if (a == 0) to_start[b] = true;
        if (b == n - 1) to_end[a] = true;
    }

    for (int i = 1; i < n - 1; ++i) {
        if (to_start[i] && to_end[i]) {
            puts("POSSIBLE");
            return 0;
        }
    }
    puts("IMPOSSIBLE");
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST

vector<ll> all_divs(ll n){
    vector<ll> ret;
    for(ll i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    ll N,M;
    cin >> N >> M;
    // 最大公約数を X とすると
    // α X = Mとなる
    vector<ll> divs = all_divs(M);
    sort(divs.begin(), divs.end());
    ll i = 0;
    for(i=0;i<divs.size(); i++)
    {
        if(divs[i] * N > M) break;
        //cerr << divs[i] << endl;
    }
    cout << divs[i-1] << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input())
l = list(map(int, input().split()))


M = max(l)

best = float("inf")
for i in range(M+1):
  HP = 0
  for j in l:
    HP += (j-i)**2
  if HP < best:
    best = HP


print(best)

Measured memory_bytes: 38896
fun main(args: Array<String>) {
    val (n, l) = readLine()!!.split(' ').map(String::toInt)
    val sum = n * l + n * (n - 1) / 2
    println(if (-n < l && l <= 0) sum else (if (l < 0) sum - (l + n - 1) else sum - l))
}


Measured memory_bytes: 38264
import java.util.Scanner;

class Main {
    private static boolean[] calcPrimeTable(int n) {
        boolean[] table = new boolean[n + 1];
        table[0] = table[1] = true;
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (!table[i]) {
                for (int j = i + i; j <= n; j += i) {
                    table[j] = true;
                }
            }
        }
        return table;
    }
    private static void solve() {
        Scanner scanner = new Scanner(System.in);
        boolean[] table = calcPrimeTable(10000);

        while (scanner.hasNextInt()) {
            int n = scanner.nextInt();
            int counter = 0;
            for (int i = 1; i <= n; i++) {
                if (!table[i] && !table[n - i + 1]) {
                    counter++;
                }
            }
            System.out.println(counter);
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e2 + 5;
const ll mod = 998244353 ;
const double pi = acos(-1);
ll fastpow(ll b, ll e) {
    if (!e)
        return 1;
    ll ret = fastpow(b, e / 2);
    ret = (ret * ret) % mod;
    if (e % 2)
        ret = (ret * b) % mod;
    return ret;
}
ll modinv(ll x) {
    return fastpow(x, mod - 2);
}
double torad(double ang) {
    return ang * pi / 180.0;
}
int prime[N];
void sieve() {
    prime[0] = prime[1] = 1;
    for (int i = 2; i < N; i++) {
        if (!prime[i]) {
            for (int j = i; j < N; j += i)
                prime[j] = i;
        }
    }
}


int w[N], v[N];
ll dp[N][int(1e5 + 5)];
int main()
{
    ///smallest/largest case
    ///initialize
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &w[i], &v[i]);
    }
    int tot = v[n - 1];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 1e5 + 5; j++) {
            if (v[i] >= j)
                dp[i][j] = w[i];
            else
                dp[i][j] = 1e15;
        }
    }
    int res = 0;
    for (int i = n - 2; i >= 0; i--) {
        tot += v[i];
        for (int j = tot; j >= 0; j--) {
            dp[i][j] = min(dp[i][j], dp[i + 1][j]);
            if (j - v[i] >= 0)
                dp[i][j] = min(dp[i][j], dp[i + 1][j - v[i]] + w[i]);
            /*
            if (j == v[i])
                dp[i][j] = min(dp[i][j], 1ll * w[i]);
            if (j + 1 < tot)
                dp[i][j] = min(dp[i][j], dp[i][j + 1]);
            */
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= tot; j++)
            if (dp[i][j] <= m)
                res = max(res, j);
    }

    printf("%d", res);
    return 0;
}


Measured memory_bytes: 80128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    int x,n,a,b[1000]={101},y;
    scanf("%d",&n);a=0;
    for(x=0;x<=25;x++){
        for(y=0;y<=14&&4*x +7*y<=100;y++){
            b[a]=4*x + 7*y;
            a++;
        }
    }
    for(a=0;a<350;a++){
        if(b[a]==n){
            printf("Yes");
            break;
        }
        if(a==349){printf("No");
            break;
        }
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
void print_line(vector<ll> &line) {
    for (int i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;

ll calc(int n, int m, int l, vector<vector<ll> > &matrix1, vector<vector<ll> > &matrix2, int i, int j) {
    ll sum = 0;
    for (int k = 0; k < m; k++) {
        sum += matrix1[i][k] * matrix2[k][j];
    }
    return sum;
}

int main() {

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

    vector<vector<ll> > matrix1(n, vector<ll>(m, 0));
    vector<vector<ll> > matrix2(m, vector<ll>(l, 0));

    rep(i, n) {
        rep(j, m) {
            cin >> matrix1[i][j];
        }
    }

    rep(i, m) {
        rep(j, l) {
            cin >> matrix2[i][j];
        }
    }


    vector<vector<ll> > matrix3(n, vector<ll>(l, 0));

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            matrix3[i][j] = calc(n, m, l, matrix1, matrix2, i, j);
        }
    }

    for (int i = 0; i < n; i++) {
        print_line(matrix3[i]);
    }

}


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

template<class T> T in() {T a; cin >> a; return a;}
#define sim template<class c
#define ris return *this
#define dor > debug& operator<<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge {c b, e;};
sim > rge<c> range(c i, c j) {return rge<c>{i, j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() {cerr << '\n';}
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair<b, c> d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; it++) 
		*this << (it == d.b ? "" : ", ") << *it;
	ris << "]";
}
#else
sim dor(const c&) {ris;}
#endif
};
#define imie(...) " [" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cerr.tie(0);
	int n, d;
	cin >> n >> d;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		long long p, q;
		cin >> p >> q;
		if ((long long) p * p + q * q <= (long long) d * d) ans++;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3644
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
int max_v[101];
int main() {
	int N, M;
	while (cin >> N >> M, N) {
		memset(max_v, 0, sizeof(max_v));
		for (int i = 0; i < N; i++) {
			int d, v;
			cin >> d >> v;
			max_v[d] = max(max_v[d], v);
		}
		int ans = 0;
		for (int i = 1; i <= M; i++) ans += max_v[i];
		cout << ans << endl;
	}
}


Measured memory_bytes: 3068
N=int(input())
 
S=list(input())
m=0
 
a=S.count("R")
b=S.count("G")
c=S.count("B")
 
num=a*b*c
 
for i in range(N-2):
  for j in range(i+1,N-1):
    k=2*j-i #削る条件
    if k>N-1:
      break
    elif S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
      m+=1
      
print(num-m)

Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define INF (int)1e9+1
#define INFLL (int)1e18+1
#define sz(bb) (int)bb.size()
#define all(qq) qq.begin(), qq.end() 
#define Max(a, b, c) max(a, max(b, c))
#define Min(a, b, c) min(a, min(b, c))
const double PI=acos(-1);
// #define int unsigned long long int//used when x<=2^64-1 && x>0
#define int long long//used when x<=2^63-1
//bool cmp if returns true it keeps 1st as first else swaps
typedef long long  ll;

const int N=2097153;
int n;
int arr[22][22];
int dp[22][N];
int fun(int x, int mask)
{
    if(x<0)
        return (mask==(1<<n)-1);
    if(dp[x][mask]!=-1)
        return dp[x][mask];
    dp[x][mask]=0;
    for(int i=0;i<n;i++)
    {
        if(arr[x][i] && ((mask&(1<<i))==0))
        {
            dp[x][mask]+=0LL+fun(x-1, mask^(1<<i));
            dp[x][mask]%=mod;
        }
    }
    return dp[x][mask];
}
void solve()
{
    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>arr[i][j];
    for(int i=0;i<n;i++)
        for(int j=0;j<(1<<n);j++)
            dp[i][j]=-1;
    cout<<fun(n-1, 0)<<"\n";
}
int32_t main()
{
    IOS;
    int t;
    // cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 347708
using System;

namespace _20200711
{
    class Program
    {
        static int[] ReadNumList()
        {
            var line = Console.ReadLine().Split(' ');
            var numList = new int[line.Length];
            for (var i = 0; i < line.Length; ++i)
            {
                numList[i] = int.Parse(line[i]);
            }
            return numList;
        }
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var aList = ReadNumList();
            var count = 0;
            for (var i = 0; i < aList.Length; ++i)
            {
                if (i % 2 == 0 && aList[i] % 2 == 1)
                {
                    ++count;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 27540
#include "bits/stdc++.h"
using namespace std;
int n,ans;

int f(int x)
{
	int cnt=0;
	while(x) cnt++,x/=10;
	return cnt;
}

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		if(f(i)&1) ans++;
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cfloat>
#include <algorithm>
#define PB push_back
#define ll long long
#define ull unsigned long long
#define uint unsigned
#define MOD 1000000007;
using namespace std;

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

    int n {};
    cin >> n;

    int min_x {101}, max_x {0};
    vector<int> arr (n);
    for (auto &val: arr) {
    	cin >> val;
    	min_x = min(min_x, val);
    	max_x = max(max_x, val);
    }

    // cout<<"TEST: "<<min_x<<" "<<max_x<<endl;
    int ans {INT_MAX};
    for (int i {min_x}; i <= max_x; ++i) {
    	int score {};
    	for (auto const &val: arr) {
    		score += (val-i)*(val-i);
    	}
    	// cout<<"TEST: "<<score<<endl;
    	ans = min(score, ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#ifdef __GNUC__
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#endif

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>

#include <string>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <cassert>//assert();
#include <fstream>
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)

/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#define PII pair<int,int>
/////////
using namespace::std;

// 最大公約数
template<class T>
inline T gcd(T a, T b){return b == 0 ? a : gcd(b, a % b);}
// 最小公倍数
template<class T>
inline T lcm(T a, T b){return a * b / gcd(a, b);}
////////////////////////////////

inline void solve(){
	LL N;
	cin >> N;
	vector<LL> A(N+1);
	LL total=0;
	for(int i=0;i<N;++i){
		cin >> A[i];
		total += A[i];
	}
	A[N] = A[0];
	LL take1 = N*(N+1)/2;
	if( total%take1 != 0 ){
		cout << "NO" << endl;return;
	}
	LL k = total/take1;
	vector<LL> d(N);
	for(int i=0;i<N;++i){
		d[i] = A[i+1]-A[i];
		if( (d[i]-k)%N != 0 || (k-d[i]) < 0){
			cout << "NO" << endl;return;
		}
	}
	//{d[i]}<0?
	cout << "YES" << endl;
}

signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	//std::cout << std::fixed;//小数を10進数表示
	//cout << setprecision(16);//小数をいっぱい表示する。16?

	solve();
}


Measured memory_bytes: 1792
n,m=map(int,input().split())
temp=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  temp[a-1].append(b-1)
  temp[b-1].append(a-1)
for i in range(n):
  print(len(temp[i]))

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

int main()
{
    vector<int> count(26, 50);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        vector<int> count_tmp(26, 0);
        string s;
        cin >> s;
        for (auto v : s) count_tmp[v - 'a']++;
        for (int i = 0; i < 26; i++) count[i] = min(count[i], count_tmp[i]);
    }
    for (int i = 0; i < 26; i++)
        for (int j = 0; j < count[i]; j++)
            cout << (char)('a' + i);
    cout << endl;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]
odd_num = 0
odd_point = []
for i in range(H):
    for j in range(W):
        if a[i][j] % 2:
            odd_num += 1
            odd_point += [[i, j]]
            a[i][j] = 1
        else:
            a[i][j] = 0

moves = []
i, j = 0, 0
direction = 1
while len(moves) < H*W-1:
    pre_i, pre_j = i, j
    if j+1 == W and direction == 1:
        i += 1
        direction *= -1
    elif j-1 == -1 and direction == -1:
        i += 1
        direction *= -1
    else:
        j += direction
    moves += [(pre_i, pre_j, i, j)]

flag = False
ans = []
for pre_i, pre_j, i, j in moves:
    if a[pre_i][pre_j] == 1:
        if flag == False:
            flag = True
        else:
            flag = False
    if flag:
        ans += [(pre_i+1, pre_j+1, i+1, j+1)]
print(len(ans))
for pre_i, pre_j, i, j in ans:
    print(pre_i, pre_j, i, j)

Measured memory_bytes: 81740
x,n = map(int,input().split())
p = list(map(int,input().split()))
for i in range(100):
    pFlag = True
    mFlag = True
    for j in range(len(p)):
        if p[j] == x+i:
            pFlag = False
        if p[j] == x-i:
            mFlag = False
    if mFlag:
        a = (-1)* i
        break
    if pFlag:
        a = i
        break
print(x+a)

Measured memory_bytes: 9204
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll ans=0,prev=0,x;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(x-prev>0)
            ans+=x-prev;
        prev=x;
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>

using namespace std;

int main()
{
	long long b;
	long long r,l;
	long long now;
	while(true)
	{
		cin >> b;
		if(b==0)break;

		r=1;
		l=1;
		now=1;
		while(true)
		{
			if(now==b)break;
			if(now<b)
			{
				r++;
				now+=r;
			}
			if(now==b)break;
			if(now>b)
			{
				now-=l;
				l++;
			}
		}

		cout << l << " " << r-l+1 << endl;
			
	}

}


Measured memory_bytes: 3092
# include <bits/stdc++.h>
# define int long long
# define endl "\n"
using namespace std;

void solve() {

	int x1, x2, x3, x4, x5;
	cin >> x1 >> x2 >> x3 >> x4 >> x5;

	if (x1 == 0) {
		cout << 1 << endl;
		return;
	}
	if (x2 == 0) {
		cout << 2 << endl;
		return;
	}
	if (x3 == 0) {
		cout << 3 << endl;
		return;
	}
	if (x4 == 0) {
		cout << 4 << endl;
		return;
	}
	if (x5 == 0) {
		cout << 5 << endl;
		return;
	}
}

signed main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

# ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
# endif

	// int t;
	// cin >> t;
	// while (t--)
	solve();

	return 0;
}

Measured memory_bytes: 3580
def bubble_sort(l):
    flag = 1
    count = 0
    while flag == 1:
        flag = 0
        j = len(l) - 1
        while(0 < j):
            if l[j] < l[j-1]:
                swap = l[j]
                l[j] = l[j-1]
                l[j-1] = swap
                count = count + 1
                flag = 1
            j = j - 1
    return l,count


n = int(input())

l = list(map(int,input().split()))

if len(l) != n:
    print("Error")
    exit()

l,count = bubble_sort(l)

for i in range(len(l)):
    if i == (len(l) - 1):
        print(l[i])
    else:
        print(l[i],end='')
        print(" ",end='')
print(count)



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

#define endl '\n'
#define pb push_back
#define mod 1000000007
typedef int integer;
#define int long long
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 0
#endif
using namespace std;

template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << ": " << arg1 << endl;
}

template<typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const integer NN = (int) 5e5 + 2;
int ar[NN];
int n, m;


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

    cin >> n;
    string s;
    cin >> s;
    int red = 0;
    for (auto c : s){
        red += (c == 'R');
    }
    int r = red;
    for (int i = 0; i < red; i++){
        r -= s[i] == 'R';
    }
    cout << r << endl;



}


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

int main(){
	long long N, X, M;
	cin >> N >> X >> M;
	int chk[M];
	for(int i=0;i<M;i++){
		chk[i] = 0;
	}
	chk[X]++;
	long long ans = 0;
	ans += X;
	N--;
	long long tmp = X;
	while(N > 0 && tmp != 0){
		tmp = tmp * tmp;
		tmp %= M;
		if(chk[tmp] == 2){
			//cout << tmp << endl;
			long long sum = 0, cnt = 0;
			for(int i=0;i<M;i++){
				if(chk[i] > 1){
					sum += i;
					cnt++;
				}
				chk[i]++;
			}
			ans += sum * (N / cnt);
			N %= cnt;
		}
		if(N > 0){
			N--;
			ans += tmp;
			chk[tmp]++;
		}
		// cout << tmp << ":" << ans << endl;
	}
	// while(N > 0 && tmp != 0){
	// 	tmp = modmul(tmp, tmp);
	// 	if(tmp == 1){
	// 		ans += N;
	// 		N = 0;
	// 	}
	// 	if(N > 0){
	// 		N--;
	// 		ans += tmp;
	// 		chk[tmp]++;
	// 	}
	// }
	cout << ans << endl;
}

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

#define INF ((1 << 31) - 1)
unsigned int a[100000];

int main(){
	int n, q, com, x, y;
	cin >> n >> q;
	fill(a, a + n, INF);
	for (int I = 0; I < q; I++) {
		cin >> com >> x >> y;
		if (com) {
			int t = a[x];
			for (int i = x + 1; i <= y; i++) {
				if (a[i] < t) {
					t = a[i];
				}
			}
			cout << t << endl;
		}
		else {
			a[x] = y;
		}
	}

	return 0;
}

Measured memory_bytes: 3452
import numpy as np
from scipy.sparse.csgraph import csgraph_from_dense, dijkstra

INF = 10 ** 20

xs, ys, xt, yt = map(int, input().split())
N = int(input())
X = np.zeros((1, N + 2), dtype=np.float64)
Y = np.zeros((1, N + 2), dtype=np.float64)
R = np.zeros((1, N + 2), dtype=np.float64)

X[0][0] = xs
Y[0][0] = ys
X[0][N + 1] = xt
Y[0][N + 1] = yt

for i in range(N):
    X[0][i + 1], Y[0][i + 1], R[0][i + 1] = map(int, input().split())

# G[i][j]: iからjまでの距離
G = np.maximum(np.sqrt(np.square(X - X.T) + np.square(Y - Y.T)) - (R + R.T),
               np.zeros((N + 2, N + 2), dtype=np.float64))
# 対角行列をinfで塗りつぶす
G += np.diag(np.ones(N + 2, dtype=np.float64) * np.inf)
# 自己ループを消す
G = csgraph_from_dense(G, null_value=np.inf)
print(dijkstra(G, indices=0)[-1])

Measured memory_bytes: 50956
n = int(input())
b = list(map(int,input().split()))
l = [0] * n
l[0] = b[0]
for i, j in enumerate(b):
    if i == n - 2:
        l[-1] = b[-1]
    elif j < b[i + 1]:
        l[i + 1] = j
    else:
        l[i + 1] = b[i + 1]
print(sum(l))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main(){
 string s;
  cin >> s;
  if (s.at(0)==s.at(1) && s.at(0)!=s.at(2)){
    if (s.at(2)==s.at(3))
      cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else if (s.at(0)==s.at(2) && s.at(0)!=s.at(1)){
    if (s.at(1)==s.at(3))
      cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else if (s.at(0)==s.at(3) && s.at(0)!=s.at(1)){
    if (s.at(2)==s.at(1))
      cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else cout << "No" <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

const long long int mod=1000000007,INF=1099999999999999999;
void YES_OR_NO(bool check){
    if(check){cout<<"YES"<<endl;}
    else{cout<<"NO"<<endl;}
}

long long int m,k,n,a,b,res=0,sum;
long double d[3000],dres=0;
string str;
int main() {
	cout << fixed << setprecision(10);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>d[i];
        dres+=1.0/d[i];
    }
    cout<<1.0/dres<<endl;
    
    
} 


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int x;cin>>x;
    if(x>=400&&x<600)cout<<8<<endl;
    else if(x>=600&&x<800)cout<<7<<endl;
    else if(x>=800&&x<1000)cout<<6<<endl;
    else if(x>=1000&&x<1200)cout<<5<<endl;
    else if(x>=1200&&x<1400)cout<<4<<endl;
    else if(x>=1400&&x<1600)cout<<3<<endl;
    else if(x>=1600&&x<1800)cout<<2<<endl;
    else if(x>=1800&&x<2000)cout<<1<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n,t;
  cin>>n>>t;
  vector<int> ds(n);
  for(int i=0;i<n;i++) cin>>ds[i];
  sort(ds.begin(),ds.end());

  using ll = long long;
  const int mod = 1e9+7;
  ll ans=1;
  for(int i=0;i<n;i++){
    auto it=lower_bound(ds.begin(),ds.begin()+i,ds[i]-t);
    ans*=(ll)(ds.begin()+i+1-it);
    ans%=mod;
  }

  cout<<ans<<newl;
  return 0;
}



Measured memory_bytes: 3368
#include<stdio.h>
#define MAX 25
#define NIL -1

struct Node {
    int p, l, r;
};

Node T[MAX];
int D[MAX], H[MAX];

void print(int num) {
    int deg, s;
    if (T[num].l!=-1 && T[num].r!=-1) deg=2;
    else if (T[num].l==-1 && T[num].r==-1) deg=0;
    else deg=1;

    if (T[num].p==-1) s=-1;
    else if (T[T[num].p].l!=num) s=T[T[num].p].l;
    else s=T[T[num].p].r;
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", num, T[num].p, s, deg, D[num], H[num]);

    if (T[num].p==-1) printf("root\n");
    else if (T[num].l!=-1 || T[num].r!=-1) printf("internal node\n");
    else printf("leaf\n");
}

int depth_height(int num, int depth) {
    int m_d1=-1, m_d2=-1;
    D[num] = depth;
    if (T[num].l!=-1) m_d1 = depth_height(T[num].l, depth+1);
    if (T[num].r!=-1) m_d2 = depth_height(T[num].r, depth+1);
    
    if (m_d1==-1 && m_d2==-1){
        H[num] = 0;
        return depth;
    } else if (m_d1>=m_d2) {
        H[num] = m_d1-depth;
        return m_d1;
    } else {
        H[num] = m_d2-depth;
        return m_d2;
    }
}

int main() {
    int j, n, num;
    scanf("%d", &n);

    for (int i=0; i<n; i++) T[i].p=T[i].l=T[i].r=-1;

    for (int i=0; i<n; i++) {
        scanf("%d", &j);
        scanf("%d", &num);
        T[j].l = num;
        T[num].p = j;
        scanf("%d", &num);
        T[j].r = num;
        T[num].p = j;
    }

    while (T[num].p!=-1) num = T[num].p;
    j = depth_height(num, 0);

    for (int i=0; i<n; i++) {
        print(i);
    }
    return 0;
}


Measured memory_bytes: 2720
#include<iostream>
#include<cmath>
#include<stack>
#include<vector>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
const ll inf =1e17;
#define scn(a) scanf("%d",&a)
#define scd(a) scanf("%lf",&a)
#define scl(a) scanf("%lld",&a)
#define ptf(a) printf("%d\n",&a)
#define mes(a,b) memset(a,b,sizeof(a))
#define fon(s,n) for(int i=s;i<=n;i++)
#define range(i,a,b) for(int i=a;i<=b;++i)
#define rerange(i,a,b) for(int i=a;i>=b;--i)
//#define N 100010
const int S=20;
ll gcd(ll a,ll b) { return b>0 ? gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll q_pow(ll a,ll b,ll mod)
{
	ll ans=1,res=a;
	while(b){
		if(b&1) ans=ans*res%mod;
		res=res*res%mod;
		b>>=1;
	}
	return ans%mod;
}
 bool cmp(const pair<string,int> &p1, const pair<string,int> &p2) {
    return p1.second > p2.second;
}
int cnt[105]={0};
int main()
{
    int n;
        scn(n);
	for(int i = -120; i <= 120; i ++) {
		for(int j = -120; j <= 120; j ++) {
			if(pow(i,5) - pow(j,5) == n) {
				printf("%d %d\n",i,j);
				return 0;
			}
		}
	}
}


Measured memory_bytes: 4200
#include<iostream>
#include<cmath>
using namespace std;
long long t[100005],n,a[100005];
int main()
{
	cin>>n;
	t[1]=0;t[0]=100000;a[0]=100000;
	for (int i=1;i<=n;i++){
		cin >>a[i];
		if (i>=2){
			t[i]=min(t[i-1]+abs(a[i]-a[i-1]),t[i-2]+abs(a[i]-a[i-2]));
		}
	}
	cout <<t[n];
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,aa;
  cin>>a>>aa;
 /* int cnt=0;
  for(int i=0;i<3;i++)
  {
    if(a[i]==aa[i])
    {
      cnt++;
    }
  }*/
  cout<<ceil(((aa-1)*1.0)/(a-1))<<endl;
}

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

int x[10000000];
int G[20];
int v;
int w;
int cnt=0;
int m;
int n;

void sort1(int x[],int n,int g){
	for(int i=g;i<n;i++){
		v=x[i];
		w=i-g;
		while(w>=0 && x[w]>v){
			x[w+g]=x[w];
			w=w-g;
			cnt++;
		}
		x[w+g]=v;
	}
}

void sort2(int x[],int n){
	cnt=0;
	for(int h=0;h<20;h++){
		if(G[h]>n){
			m=h;
			break;
		}
	}
	cout<<m<<endl;
	for(int h=m-1;h>=0;h--){
		cout<<G[h];
		if(h){
			cout<<' ';
		}
		sort1(x,n,G[h]);
	}
	cout<<endl;
}

int main(){
	G[0]=1;
	for(int i=1;i<20;i++){
		G[i]=G[i-1]*3+1;
	}
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x[i];
	}
	sort2(x,n);
	cout<<cnt<<endl;
	for(int i=0;i<n;i++){
		cout<<x[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 6988
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <unordered_map>
using namespace std;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int dis;
	if (a <= c) {
		dis = min(b - c, d - c);
		dis = max(dis, 0);
	}
	else {
		dis = min(d - a, b - a);
		dis = max(dis, 0);
	}
	cout << dis << endl;
}

Measured memory_bytes: 256
import itertools
n,m,q = map(int,input().split())

l = list(list(map(int,input().split()))for _ in range(q))
li = [x for x in range(1,m+1)]
lis  = list(itertools.combinations_with_replacement(li,n))
point = 0
for i in lis:
    p = 0
    for j in l:
        if (i[j[1]-1] - i[j[0]-1]) == j[2]:
            p += j[3] 
    point = max(p,point)
print(point)





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

typedef long long ll;

int main(){
    string s;
    cin >> s;
    int n = (int)s.size();

    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        v[i] = s[i] - '0';
    }

    ll sum = 0;
    for (int bit = 0; bit < 1 << (n - 1); ++bit) {
        ll tmp = v[0];
        for (int i = 0; i < n - 1; ++i) {
            if (bit >> i & 1){
                sum += tmp;
                tmp = v[i + 1];
            }else{
                (tmp *= 10) += v[i+1];
            }
        }
        sum += tmp;
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, t;
int c, a;
int ans = 10000;
int main()
{
    cin >> n >> t;
    for (int i = 0; i < n; i++)
    {
        cin >> c >> a;
        if (a <= t)
            ans = min(ans, c);
    }
    if (ans > 1000)
        cout << "TLE" << endl;
    else
        cout << ans << endl;
    return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    int n;cin >> n;
    int ans=0;
    vector<int> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end(),greater<int>());
    for (int i = 0; i < n;i++){
        ans += a[i] * (-1)*((i % 2) * 2 - 1);
    }
        cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	//cout << 800 * x - 200 * (x / 15) << endl;
	printf((b-a==c-b) ? "YES\n" : "NO\n");
}

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

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

typedef pair<int, int> pint;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front

#define MOD (1000 * 1000 * 1000 + 7)

#include <bits/stdc++.h>

signed main() {
    string S;
    cin >> S;

    int N = S.length();
    vector<vector <ll>> dp(N+1, vector<ll>(4, 0));

    dp[0][0] = 1;
    REPS(i, N) {
        char s = S[i-1];
        REP(j, 4) {
            if (s == 'A') {
                if (j == 0) {
                    dp[i][j+1] += dp[i-1][j];
                    dp[i][j] += dp[i-1][j];
                } else {
                    dp[i][j] += dp[i-1][j];
                }
            } else if (s == 'B') {
                if (j == 1) {
                    dp[i][j+1] += dp[i-1][j];
                    dp[i][j] += dp[i-1][j];
                } else {
                    dp[i][j] += dp[i-1][j];
                }
            } else if (s == 'C') {
                if (j == 2) {
                    dp[i][j+1] += dp[i-1][j];
                    dp[i][j] += dp[i-1][j];
                } else {
                    dp[i][j] += dp[i-1][j];
                }
            } else {
                if (j == 3) {
                    dp[i][j] += dp[i-1][j] * 3;
                } else {
                    dp[i][j+1] += dp[i-1][j] * 1;
                    dp[i][j] += dp[i-1][j] * 3;
                }
            }
            dp[i][j] %= MOD;

            if (j < 3) {
                dp[i][j+1] %= MOD;
            }
        }
    }

    cout << dp[N][3] << endl;

    return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int MOD = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 素数
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true);
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(size_t j=2; i*j<=max; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

// べき乗の余り
ll modpow(ll a, ll n, ll mod){
    ll res = 1;
    while(n){
        if(n & 1){
            (res *= a) %= mod;
        }else{
            (a *= a) %= mod;
        }
        n >>= 1;
    }
    return res;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n, x, y;
    cin>>n>>x>>y;
    x--;
    y--;

    vector<ll> res(n, 0);
    for(ll i=0;i<n;++i){
        for(ll j=i;j<n;++j){
            ll ans = 0;
            ans = min(j - i, abs(x - i) + abs(j - y) + 1);
            res[ans]++;
        }
    }
    for(ll i=1;i<n;++i){
        cout<<res[i]<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

typedef long long ll;

ll ans, N;



int main(void) {
    scanf("%d", &N);


    REP(i, 0, N) {
      ll a;
    	scanf("%d", &a);
    	ans += a - 1;
    }
    
    

    

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

	return 0;
}


Measured memory_bytes: 256