akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

struct Doubling {
     const long long LOG;
     const int N;
     vector<vector<int>> nexted;
 
     Doubling(int N, long long log = 60) : N(N), LOG(log) {
         nexted.assign(LOG + 1, vector<int>(N + 1, -1));
     }
 
     inline void set_init_next(const int v, const int x) {
         nexted[0][v] = x;
     }
 
     void build() {
         for (int k = 0; k < LOG; k++) {
             for (int v = 0; v < N; v++) {
                 if (nexted[k][v] == -1) nexted[k + 1][v] = -1;
                 else nexted[k + 1][v] = nexted[k][nexted[k][v]];
             }
         }
     }
 
     inline int query(int v, long long p) {
         for (long long i = LOG; i >= 0; i--) {
             if (v < 0) return -1;
             if (p & (1LL << i)) {
                 v = nexted[i][v];
             }
         }
         return v;
     }
 };

void solve(long long N, long long K, std::vector<long long> P, std::vector<long long> C){
    auto f = [&](int k){
        int _k = k;
        ll _K = K;
        vector<int> flag(N);
        ll ans = 0;
        vector<ll> v;
        for(int i = 0;;i++){
            if(flag[k] == 1){
                break;
            }
            flag[k] = 1;
            ans += C[P[k]];
            v.push_back(C[P[k]]);
            k = P[k];
        }
        //cout<<ans<<endl;
        if(K <= 5000 * 4){
            ans = -1e18;
            ll curent = 0;
            for(int i = 0;i < K;i++){
                curent += v[i % (v.size())];
                ans = max(ans, curent);
            }
            return ans;
        }
        ll _N = v.size();

        if(ans >= 0){
            //cout<<ans<<endl;
            ans = (K / _N - 1) * ans;
            ll ma = -1e18;
            ll curent = 0;
            for(int i = 0;i < K % _N + _N;i++){
                curent += v[i % _N];
                ma = max(curent, ma);
            }
            ans += ma;
        }else{
            ll ma = -1e18;
            ll curent = 0;
            for(int i = 0;i < _N;i++){
                curent += v[i];
                //cout<<curent<<endl;
                ma = max(curent, ma);
            }
            ans = ma;
        }
        return ans;
    };
    ll ans = -1e18;
    for(int i = 0;i < N;i++){
        ans = max(ans, f(i));
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
        P[i]--;
    }
    std::vector<long long> C(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&C[i]);
    }
    solve(N, K, std::move(P), std::move(C));
    return 0;
}


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

/*
code credits : ਜ਼ੈਲਦਾਰ
dashan jot singh
*/
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define inf LLONG_MAX
#define p pair<ll,ll>
ll Min(ll a,ll b,ll c){
	return min(a,min(b,c));
}
ll dp[100010];
ll n;
vector<ll> nines;
vector<ll> sixes;
ll solve(ll x){
	if(x==0){
		return 0;
	}
	if(x<0){
		return INT_MAX;
	}
	if(dp[x]!=-1){
		return dp[x];
	}
	// ll ans=min(1+solve(x-1),1+solve(x-))
	ll ind1=-1;
	ll ind2=-1;
	for(ll i=sixes.size()-1;i>=0;i--){
		if(x>=sixes[i]){
			ind1=i;
			break;
		}
	}	
	for(ll i=nines.size()-1;i>=0;i--){
		if(x>=nines[i]){
			ind2=i;
			break;
		}
	}	
	ll ans=1+solve(x-1);
	if(ind1>=0){
		ans=min(ans,1+solve(x-sixes[ind1]));
	}
	if(ind2>=0){
		ans=min(ans,1+solve(x-nines[ind2]));
	}
	dp[x]=ans;
	return dp[x];
}
void init(){
	ll xx=6;
	while(xx<100010){
		sixes.pb(xx);
		xx*=6;
	}
	ll yy=9;
	while(yy<100010){
		nines.pb(yy);
		yy*=9;
	}
}
int main(){
	fast;
	cin>>n;
	init();
	// for(auto i:nines){
	// 	cout<<i<<" ";
	// }
	// cout<<"\n";
	memset(dp,-1,sizeof(dp));
	cout<<solve(n)<<"\n";
	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 200001;

int main(){
    int n; 
    string s;
    set<string>st;
    cin >> n;
    for(int i = 0; i<n; ++i){
        cin >> s;
        st.insert(s);
    }
    cout << st.size() <<"\n";
}

Measured memory_bytes: 15616
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5+7;
int f[N][3];
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		int a;
		for(int j = 0; j < 3; j++)
		{
			scanf("%d", &a);
			for(int k = 0; k < 3; k++)
			{
				if(j!=k)
				{
					f[i][j] = max(f[i][j], f[i-1][k]+a);
				}
			}
		}
	}
	printf("%d\n", max(max(f[n][0], f[n][1]), f[n][2]));
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  int ans = 0;
  for (int i = 0; i < k; i++) {
    ans += p[i];
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int l;
		int a, b, c, d;
		int dayJ = 0, dayM = 0;
		int day;
		
		l = scan.nextInt();
		a = scan.nextInt();
		b = scan.nextInt();
		c = scan.nextInt();
		d = scan.nextInt();
		
		if(a%c != 0){
			dayJ = a / c;
			dayJ++;
		}
		else dayJ = a / c;

		if(b%d != 0){
			dayM = b / d;
			dayM++;
		}
		else dayM = b / d;
		
		if(dayJ >= dayM)day = dayJ;
		else day = dayM;
		
		System.out.println((l - day));
	}
}

Measured memory_bytes: 26148
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>

using namespace std;

int main() {
	int n;
	cin >> n;
	int a[1000];
	double ave = 0;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ave += a[i];
	}
	ave = ave / n;
	for (int i = 1; i < n; i++) {
	    if (fabs(ave - a[i]) < fabs(ave - a[ans])) {
		    ans = i;
		}
	}
	cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 998244353;




int main() {


	string s;
	cin >> s;

	REP(i, s.size()) {
		if (s[i] == '?')s[i] = 'D';
	}
	cout << s << endl;

}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n;
	cin >> n;
	map<string, int> num;
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s.at(i);
		num[s.at(i)]++;
	}
	int m;
	cin >> m;
	vector<string> t(m);
	for (int i = 0; i < m; i++) {
		cin >> t.at(i);
		num[t.at(i)]--;
	}

	int ans = 0;
	for (auto i = num.begin(); i != num.end(); i++) {
		ans = max(i->second, ans);
	}

	cout << ans << endl;

 	return 0;
 }

Measured memory_bytes: 256
#include<stdio.h>
#define N 36

struct card{
  char mark;
  int value;
};

int n;

int isStable(struct card in[],struct card out[]){
  int i,j,a,b;
  for(i = 0; i < n; i++){
    for(j = i+1; j < n; j++){
      for(a = 0; a < n; a++){
	for(b = a+1; b < n; b++){
	  if((in[i].value == in[j].value) && ((in[i].value == out[b].value && in[i].mark == out[b].mark) && (in[j].value == out[a].value && in[j].mark == out[a].mark))) return 0;
	}
      }
    }
  }
  return 1;
}


void bubbleSort(struct card A[],int n){
  int i,j;
  int flag;
  struct card swap;
  flag = 1;
    i = 0;
    while(flag){
       flag = 0;
       for(j = n - 1; j >= i + 1; j--){
           if(A[j].value < A[j - 1].value){
	   swap = A[j];
	   A[j] = A[j - 1];
	   A[j - 1] = swap;
	   flag = 1;
           }
       }
       i++; 
    }
}

void selectionSort(struct card A[],int n){
  int i,j,minj;
  struct card swap;

  for(i = 0; i <= n - 1; i++){
    minj = i;
    for(j = i; j <= n - 1; j++){
      if(A[j].value < A[minj].value) {
	minj = j;
      }
    }
    swap = A[i];
    A[i] = A[minj];
    A[minj] = swap;
  }
}

int main(){
  int i;
  struct card C[N];
  struct card D[N];
  
  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf(" %c",&C[i].mark);
    scanf("%d",&C[i].value);
    D[i] = C[i];
  }
 
  
  bubbleSort(C,n);
  for(i = 0; i < n; i++){
    if(i == n - 1) printf("%c%d",C[i].mark,C[i].value);
    else
    printf("%c%d ",C[i].mark,C[i].value);
  }
  printf("\nStable\n");

  selectionSort(D,n);
  for(i = 0; i < n; i++){
    if(i == n - 1) printf("%c%d",D[i].mark,D[i].value);
    else
    printf("%c%d ",D[i].mark,D[i].value);
  }
  if(isStable(C,D) == 1) printf("\nStable\n");
  else printf("\nNot stable\n");

  return 0;
}





Measured memory_bytes: 2052
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int dp[2001][2001];

int solve(){
  int n,m;cin>>n>>m;
  vector<int> s(n+1, -1);
  vector<int> t(m+1, -1);
  rep(i,n) cin>>s[i+1];
  rep(i,m) cin>>t[i+1];

  rep(j, m+1) dp[0][j]=1;
  rep(i, 1, n+1){
    rep(j, m+1){
      if (j-1>=0) dp[i][j] += dp[i][j-1];
      if (s[i]==t[j]) dp[i][j] += dp[i-1][j-1];
      dp[i][j] %= MOD;
    }
    rep(j, m+1){
      dp[i][j] += dp[i-1][j];
      dp[i][j] %= MOD;
    }
  }
  // dump_2d(dp, n+1, m+1);

  cout << dp[n][m] << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 31616
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<utility>
using namespace std;

int main(void)
{
	int H, W, D;
	cin >> H >> W >> D;

	vector<vector<int>> A(H, vector<int>(W));
	for(int i=0; i<H; i++)
		for(int j=0; j<W; j++)
			cin >> A[i][j];

	vector<pair<int, int>> pos(H*W);
	for(int i=0; i<H; i++)
		for(int j=0; j<W; j++)
			pos[A[i][j]-1] = make_pair(j, i);

	vector<int> d(H*W, 0);
	for(int i=0; i<D; i++){
		for(int j=i+D; j<H*W; j+=D){
			d[j] = d[j-D] + abs(pos[j].first-pos[j-D].first) + abs(pos[j].second-pos[j-D].second);
		}
	}

	int Q;
	cin >> Q;

	for(int i=0; i<Q; i++){
		int L, R;
		cin >> L >> R;

		L--;
		R--;

		cout << abs(d[R] - d[L]) << endl;
	}

	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;



int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    int c=1;
    int cnt = 0;
    // source code
    int N;
    scanf("%d",&N);
    
    int a[N+1];
    inputArray(a,N);
    a[N+1] = 100001;
    rep(i,N){
        int j = i+1;
        c=1;
        while(a[i]==a[j]){
            c+=1;
            if(a[j] != a[j+1]){
                while(c>1){
                    if(c%2 == 0){
                        a[i+c-1] = a[j+1]+3;
                        cnt +=1;
                    }
                    c-=1;
                }
                i = j;
            }
            j+=1;
        }
    }

    printf("\n%d",cnt);
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int h,w;
char field[500][500];
vector<P> bl;

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

bool isSearched[500][500];

ll cntb, cntw;

void dfs(int nh, int nw, char pc){
	if(isSearched[nh][nw]) return;
	if(field[nh][nw] == pc) return;
	if(field[nh][nw] == '#') cntb++;
	else cntw++;
	isSearched[nh][nw] = true;
	for (int i = 0;i < 4;i++){
		int nexh = nh+dy[i], nexw = nw+dx[i];
		if(nexh >= 0 && nexw >= 0 && nexh < h && nexw < w) dfs(nh+dy[i], nw+dx[i], field[nh][nw]);
	}
	return;
}

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

	cin >> h >> w;
	
	for (int i = 0;i < h;i++){
		for (int j = 0;j < w;j++){
			cin >> field[i][j];
			if(field[i][j] == '#') bl.push_back(P(i,j));
		}
	}

	ll ans = 0;

	for (int bli = 0;bli < bl.size();bli++){
		if(isSearched[bl[bli].first][bl[bli].second]) continue;
		int nh = bl[bli].first, nw = bl[bli].second;
		cntb = cntw = 0;
		dfs(nh,nw,'.');
		ans += cntb*cntw;
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 8948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const int N = 100000 + 5;
int a[N];
 
ll mul_pow(ll x,ll y){
	ll ans = 1;
	while(y){
		if(y&1)
			ans = (ans*x) % mod;
		x = (x*x)%mod;
		y>>=1;
	}
	return ans;
}
 
int main()
{
	int n;
	cin >> n;
	int maxn = 0;
	int flag = 0;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		if(i == 0 && x != 0)
			flag = 1;
		a[x]++;
		maxn = max(maxn,x);
	}
	long long sum = 1;
	if(flag || a[0] != 1)
		cout << 0 << endl;
	else{
		for(int i = 2; i <= maxn; i++){
			if(a[i] == 0){
				sum = 0;
				break;
			}
			else{
				sum = sum * mul_pow(a[i-1],a[i])%mod;
			}
		}
		cout << sum << endl;
	}
	return 0;
 } 

Measured memory_bytes: 1148
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 233333;
int n,k,a[N],res=1e9;
int Abs(int x){return x>0?x:-x;}
int main() {
	read(n);read(k);rep(i,1,n)read(a[i]);
	rep(i,1,n-k+1){
		int j=i+k-1;res=min(res,a[j]-a[i]+min(Abs(a[i]),Abs(a[j])));
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

void solve()
{
    int n;
    cin >> n;
    while(n--)
	{
		double x1, y1, x2, y2, x3, y3;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double a1 = 2 * (x2 - x1);
		double a2 = 2 * (x3 - x1);
		double b1 = 2 * (y2 - y1);
		double b2 = 2 * (y3 - y1);
		double c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;
		double c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;
		double x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
		double y = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
		double r = sqrt((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y));
		printf("%.3f %.3f %.3f\n", x, y, r);
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i+=1)
using namespace std;
int main() {
  string W[ ]={"Sunny","Cloudy","Rainy"};
  string S;
  cin>>S;
  rep(i,3) if(S==W[i])
    cout<<W[(i+1)%3]<<endl;
  
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a, b, c, d, e int
	fmt.Scan(&a, &b, &c, &d, &e)
	arr := []int{a, b, c, d, e}
	sort.Sort(sort.IntSlice(arr))
	var k int
	fmt.Scan(&k)
	delta := arr[4] - arr[0]
	if delta <= k {
		fmt.Println("Yay!")
	} else {
		fmt.Println(":(")
	}
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int n; ll d;
    cin >> n >> d;
    d *= d;
    
    int cnt = 0;
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= d) {
            ++cnt;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};




int main(){
    int n;cin >> n;
    map<int,LL> m;
    vector<LL> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        m[a[i]]++;
    }
    LL ans = 0;
    for(auto p:m){
        ans += p.sc * (p.sc - 1) / 2;
    }
    for (int i = 0; i < n; i++) {
        cout << ans - (m[a[i]]-1) << endl;
    }
    return 0;
}


Measured memory_bytes: 11008
k = int(input())
k -= 1

a = (1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)

print(a[k])

Measured memory_bytes: 3060
x, n = map(int,input().split())
if n != 0:
  p = list(map(int,input().split()))
else:
  print(x)
  exit()

for j in range(100):
  if all(x-j != i for i in p):
    print(x-j)
    exit()
  elif all(x+j != i for i in p):
    print(x+j)
    exit()

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, m, L, R;
vector<int> val[N];
int lch[N << 2], rch[N << 2], Max[N << 2], lazy[N << 2];
inline void update(int x, int v) {
	lazy[x] += v; Max[x] += v;
}
inline void pushup(int x) { Max[x] = max(Max[x << 1], Max[x << 1 | 1]); }
inline void pushdown(int x) {
	if (lazy[x]) {
		update(x << 1, lazy[x]); update(x << 1 | 1, lazy[x]); lazy[x] = 0;
	}
}
void build(int x, int l, int r) {
	lch[x] = l; rch[x] = r;
	if (l == r) {
		Max[x] = l; return;
	}
	int mid = (l + r) / 2;
	build(x << 1, l, mid); build(x << 1 | 1, mid + 1, r);
	pushup(x);
}
void update(int x, int l, int r, int v) {
	if (l <= lch[x] && rch[x] <= r) {
		update(x, v); return;
	}
	pushdown(x);
	int mid = (lch[x] + rch[x]) / 2;
	if (r <= mid) update(x << 1, l, r, v);
	else if (l > mid) update(x << 1 | 1, l, r, v);
	else update(x << 1, l, mid, v), update(x << 1 | 1, mid + 1, r, v);
	pushup(x);
}
int query(int x, int l, int r) {
	if (l <= lch[x] && rch[x] <= r) {
		return Max[x];
	}
	pushdown(x);
	int mid = (lch[x] + rch[x]) / 2;
	if (r <= mid) return query(x << 1, l, r);
	else if (l > mid) return query(x << 1 | 1, l, r);
	else return max(query(x << 1, l, mid), query(x << 1 | 1, mid + 1, r));
}
int ans = 0;
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) {
		scanf("%d%d", &L, &R); val[L].push_back(R);
	}
	build(1, 0, m + 1);
	for (int i = 0; i <= m; ++i) {
		for (int j = 0; j < val[i].size(); ++j) {
			update(1, i, val[i][j], 1);
		}
		ans = max(ans, query(1, i + 1, m + 1) - m - i - 1);
	}
	printf("%d\n", max(ans, n - m));
	return 0;
}

Measured memory_bytes: 20992
def examD():
    N = I()
    s = S()
    ans = ""
    animal = [None, "S", "W"]
    ansC = ""
    for i in range(4):
        cur = ""
        if i==0:
            ansC = [1,1]
        elif i==1:
            ansC = [1,-1]
        elif i==2:
            ansC = [-1,1]
        elif i==3:
            ansC = [-1,-1]
        if (s[0]=="o" and ansC[0]==1) or (s[0]=="x" and ansC[0]==(-1)):
            cur = ansC[1]
        else:
            cur = ansC[1]*(-1)

        for j in range(1,N):
            if (s[j]=="o" and ansC[j]==1) or (s[j]=="x" and ansC[j]==(-1)):
                ansC.append(ansC[j-1])
            else:
                ansC.append(ansC[j-1]*(-1))
        if ansC[N-1]==cur and ansC[N]==ansC[0]:
            for i in ansC[:N]:
                ans = ans + animal[i]
            break
    if not ans:
        ans = int(-1)
    print(ans)


import sys
import copy
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()


Measured memory_bytes: 5348
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
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; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    double a,b,c,d;
    cin>>a>>b>>c>>d;
    if(ceil(c/b)<=ceil(a/d)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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


int main(){
  int n,i,j;
  cin >> n;
  vector<int> a(n);
  for(i=0;i<n;++i){
    cin >> a[i];
  }
  int ans=a[1]-a[0];
  int cal=a[0];
  for(i=1;i<n;++i){
    ans=max(ans,a[i]-cal);
    cal=min(cal,a[i]);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
#define ii pair<int,int>
#define ll long long
using namespace std;
const int N = 200*1000+15;


struct lap{
    int price;
    int quality;
    int pos;
};
bool fun(lap a1,lap a2){
    return a1.price<a2.price;
}
bool is(string number){
    for(int i = 0;i <number[i];i++){
        if(number[i]!='1' && number[i]!='4'){
            return false;
        }
    }
    if(number.find("444")!=number.npos){
        return false;
    }
    if(number[0] =='4'){
        return false;
    }
    return true;
}

int main() {
    int n,k;cin>>n>>k;
    vector<int>a(n);
    for(int i = 0;i <n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    int min = 1e9;
    for(int i = 0;i<=n-k;i++){
        if(a[i+k-1]-a[i]< min){
            min = a[i+k-1]-a[i];
        }
    }
    cout<<min;
}

Measured memory_bytes: 640
#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
using namespace std;
int main(){
	
	int n;
	int k,p;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>k>>p;
		if(k%p!=0)
		cout<<k%p<<endl;
		else
		cout<<p<<endl;
	}
	
	
	

}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	if (A * N > B) {
		cout << B << endl;
	}
	else {
		cout << A * N << endl;
	}
	return 0;
}

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

def main():
    N, K, *p = map(int, read().split())
    p = list(map(lambda x: (x+1)*0.5, p))
    p_sum = []
    p_sum.append(p[0])
    for i in range(1, len(p)):
        p_sum.append(p_sum[i-1] + p[i])
    result = p_sum[K-1]
    for i in range(1,N-K+1):
        result = max(result,p_sum[K-1+i] -p_sum[i-1])
    return result

if __name__ == '__main__':
    print(main())



Measured memory_bytes: 21268
#include<iostream>
#include<algorithm>
#include<vector>
#include<iterator>
using namespace std;

int main()
{
    
    long long int N, i, j, ans=0;
    cin>>N;
    vector<long long int> data (N+1);
    for(i=1;i<=N;i+=1)
    {
        data[i] = 1;
    }
    for(i=2;i<=N;i+=1)
    {
        for(j=i;j<=N;j+=i)
        {
            data[j]+=1;
        }
    }
    for(i=1;i<=N;i+=1)
    {
        ans += i*data[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 81356
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

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

    cout << N * N - A << endl;
    return 0;
}


Measured memory_bytes: 3568
a=gets.to_i
b=gets.to_i
c=gets.to_i
x=gets.to_i
ans = 0

(0..a).each do |i|
  (0..b).each do |j|
    (0..c).each do |k|
      if (500*i) + (100*j) + (50*k) == x
      ans += 1
      end
    end
  end
end

puts ans

Measured memory_bytes: 1788
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {//233
	int a,b;
	cin>>a>>b;
	int ans = 1;
	a-=b;
	while(a>0) {
		a-=b-1;
		ans++;
	}
	cout<<ans;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3656
def check(a, numlist):
	goal = a+sum(numlist)
	if goal %2 == 1:
		return False
	goal /=2
	okset ={0}
	for x in numlist:
		addset = {ok+x for ok in okset}
		okset |= addset
	return goal in okset

s = [len(x) for x in input().split('T')]
x,y = [int(i) for i in input().split()]
x = x-s[0]
sx = s[2::2]
sy = s[1::2]
if check(x,sx) and check(y,sy):
	print("Yes")
else:
	print("No")

Measured memory_bytes: 4004
#include <iostream>
#include <string>

using namespace std;

class Dice
{
public:
	enum FACE
	{
		eTop = 0,
		eFront,
		eRight,
		eLeft,
		eBack,
		eBottom,
		eFACEMax
	};

	Dice(int v[6])
	{
		for (int i = eTop; i < eFACEMax; i++)
		{
			DV[i] = v[i];
		}
	}

	void ComE()
	{
		int		top = DV[eTop];

		DV[eTop] = DV[eLeft];
		DV[eLeft] = DV[eBottom];
		DV[eBottom] = DV[eRight];
		DV[eRight] = top;
	}

	void ComW()
	{
		int		top = DV[eTop];

		DV[eTop] = DV[eRight];
		DV[eRight] = DV[eBottom];
		DV[eBottom] = DV[eLeft];
		DV[eLeft] = top;
	}

	void ComN()
	{
		int		top = DV[eTop];

		DV[eTop] = DV[eFront];
		DV[eFront] = DV[eBottom];
		DV[eBottom] = DV[eBack];
		DV[eBack] = top;
	}

	void ComS()
	{
		int		top = DV[eTop];

		DV[eTop] = DV[eBack];
		DV[eBack] = DV[eBottom];
		DV[eBottom] = DV[eFront];
		DV[eFront] = top;
	}

	void ComRot()
	{
		int		front = DV[eFront];

		DV[eFront] = DV[eRight];
		DV[eRight] = DV[eBack];
		DV[eBack] = DV[eLeft];
		DV[eLeft] = front;
	}

	int		GetDV(FACE face)
	{
		return (DV[face]);
	}

	void	SearchTop(int t)
	{
		for (int i = 0; i < 4; i++)
		{
			if (t == DV[eTop])
			{
				return;
			}
			ComN();
		}

		for (int i = 0; i < 4; i++)
		{
			if (t == DV[eTop])
			{
				return;
			}
			ComE();
		}
	}

	void	SearchFront(int f)
	{
		for (int i = 0; i < 4; i++)
		{
			if (f == DV[eFront])
			{
				return;
			}
			ComRot();
		}
	}

private:
	int		DV[eFACEMax];
};

int main()
{
	int v[Dice::eFACEMax];

	cin >> v[Dice::eTop] >> v[Dice::eFront] >> v[Dice::eRight] >> v[Dice::eLeft]>> v[Dice::eBack] >> v[Dice::eBottom];
	cin.ignore();

	Dice	d(v);
	int		q;
	cin >> q;
	cin.ignore();

	for (int i = 0; i < q; i++)
	{
		int		t, f;

		cin >> t >> f;
		cin.ignore();
		d.SearchTop(t);
		d.SearchFront(f);

		cout << d.GetDV(Dice::eRight) << "\n";
	}

	return 0;
}

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

int main() {

  string s,t;cin >> s >> t;
  
  int a = stoi(s+t);

  bool flag=0;
  for(int i=0;i<1000;i++){
    if(i*i == a) flag=1;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL N, M, T;
  cin >> N >> M >> T;
  VL xs(N+2);
  xs[0] = -M;
  REP(i,N) cin >> xs[i+1];
  xs.back() = T+M;

  LL ans = 0;
  REP(i,N+1)
	ans += max(0LL, xs[i+1] - xs[i] - 2*M);

  cout << ans << endl;
  

  return 0;
}

Measured memory_bytes: 3128
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	static final int INF = 2000000;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if(w == 0 && h == 0){
				break;
			}
			
			LinkedList<Point> list = new LinkedList<Point>();
			TreeMap<Integer, LinkedList<Point>> map = new TreeMap<Integer, LinkedList<Point>>();
			
			Point start = null, goal = null;
			int max = 0;
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					String s = sc.next();
					if(s.equals("S")){
						start = new Point(0, i, j);
						LinkedList<Point> temp = new LinkedList<Point>();
						temp.add(start);
						map.put(0, temp);
					}else if(s.equals("G")){
						goal = new Point(INF, i, j);
					}else if(s.matches("[0-9]+")){
						int num = Integer.parseInt(s);
						max = max < num ? num : max;
						if(map.containsKey(num)){
							map.get(num).add(new Point(INF, i, j));
						}else{
							LinkedList<Point> temp = new LinkedList<Point>();
							temp.add(new Point(INF, i, j));
							map.put(num, temp);
						}
						list.add(new Point(num, i, j));
					}
				}
			}
			LinkedList<Point> temp = new LinkedList<Point>();
			temp.add(goal);
			map.put(max + 1, temp);
			System.out.println(fm(map));
		}
		sc.close();
	}
	static int fm(TreeMap<Integer, LinkedList<Point>> map){
		int m = 1;
		LinkedList<Point> from = map.get(0);
		LinkedList<Point> to = null;
		while(true){
			if(!map.containsKey(m)){
				break;
			}
			to = map.get(m);
			for(Point p : to){
				for(Point s : from){
					int temp = Math.abs(p.x - s.x) + Math.abs(p.y - s.y);
					p.n = p.n > temp + s.n ? temp + s.n : p.n;
				}
			}
			from = to;
			m++;
		}		
		return map.get(m - 1).get(0).n;
	}
	static int func(LinkedList<Point> list, Point from, Point goal, int idx){
		int res = 2000000;
		boolean flg = false;
		for(int i = idx; i < list.size(); i++){
			Point p = list.get(i);
			System.out.println(p.n);
			if(from.n + 1 == p.n){
				int dist = Math.abs(from.x - p.x) + Math.abs(from.y - p.y);
				res = Math.min(func(list, p, goal, i) + dist, res);
				flg = true;
			}else if(from.n + 1 < p.n){
				break;
			}
		}
		if(!flg){
			return Math.abs(from.x - goal.x) + Math.abs(from.y - goal.y);
		}
		return res;
	}
}
class Point implements Comparable<Point>{
	int n;
	int x;
	int y;
	Point(int n, int y, int x){
		this.n = n;
		this.x = x;
		this.y = y;
	}
	@Override
	public int compareTo(Point p) {
		// TODO Auto-generated method stub
		return n - p.n;
	}
}

Measured memory_bytes: 69064
#include<bits/stdc++.h>
using namespace std;
const int N=100010;
struct Job{
	int a,b;
	bool operator <(const Job &x)const{return b>x.b;}
}job[N];
int f[N];
int n,m;
const int findf(int x){return f[x]==x?x:(f[x]=findf(f[x]));}
int main(){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d %d",&job[i].a,&job[i].b);
	sort(job+1,job+n+1);
	for(int i=0;i<=m;i++)f[i]=i;
	int tot=0;
	for(int i=1;i<=n;i++){
		int pos=m-job[i].a+1;
		if(pos<0)continue;
		pos=findf(pos);
		if(pos)tot+=job[i].b,f[pos]=findf(pos-1);
	}
	printf("%d\n",tot);
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 2e5+5;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n,k;
    cin>>n>>k;
    int e = (n-1)*(n-2)/2;
    if(k>e) {
    	cout<<-1;
    	return 0;
    }
    
    vector<pair<int,int>> edges;
    for(int i=2;i<=n;i++)
    	edges.push_back({1,i});
    for(int i=2;i<=n;i++) {
		if(e==k)
			break;
		for(int j=i+1;j<=n;j++) {
			if(e==k)
				break;
			edges.push_back({i,j});
			e--;
		}
	}

	cout<<edges.size()<<'\n';
	for(auto x:edges)
		cout<<x.first<<' '<<x.second<<'\n';

	return 0;
}

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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll A, B;
ll tmp;
ll ret = 0;

void input() {
  IN(A);
  IN(B);
}

void solve() {
  ret = (B-1)/(A-1);
  if ((B-1)%(A-1) != 0) ret += 1;
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define eb emplace_back
#define PI 3.14159265
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double ld;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k, ans = 0;
    cin >> n >> k;
    for (ll i = k; i <= n + 1; i++)
    {
        ll ch = n * i - i * (i - 1) + 1;
        ans = (ans + ch) % mod;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3648
n , k = map(int,input().split())
b = 1 / n
ans = 0

for i in range(n):
    a = i + 1
    for j in range(30):
        if a < k:
            a *= 2
        else:
            c = (1 / 2) ** j
            ans += b * c
            break
        
print(ans)

Measured memory_bytes: 3060
N=int(input())
lst= [int(s) for s in input().split()]
ans=0
record=0
for i in range(1,N):
  if lst[i-1]>=lst[i]:
    record+=1
  else:
    ans=max([ans,record])
    record=0
ans=max([ans,record])
print(ans)
  

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}
//BEGIN CUT HERE
template<typename T>
struct VoronoiMST{
  int n;
  using E = pair<int, T>;
  using P = pair<T, int>;
  vector<vector<E> > G;
  VoronoiMST(vector<T> &x){
    n=x.size();
    G.assign(n<<1,vector<E>());
    for(int i=0;i<n;i++) G[i].emplace_back(n+i,x[i]);
  }
  void add_edge(int u,int v,T c){
    G[u+n].emplace_back(v+n,c);
    G[v+n].emplace_back(u+n,c);
  }  
  vector<vector<E> > build(){
    priority_queue<P, vector<P>, greater<P> > pq;
    const T INF = numeric_limits<T>::max();    
    vector<T> dist(n<<1,INF);
    vector<int> from(n<<1,-1);
    for(int i=0;i<n;i++){
      dist[i]=0;from[i]=i;
      pq.emplace(dist[i],i);
    }
    while(!pq.empty()){
      T d;
      int v;
      tie(d,v)=pq.top();pq.pop();
      if(dist[v]<d) continue;
      for(E e:G[v]){
        int u=e.first;
        T c=e.second;
        if(dist[u]<=dist[v]+c) continue;
        dist[u]=dist[v]+c;
        from[u]=from[v];
        pq.emplace(dist[u],u);
      }
    }
    vector<vector<E> > H(n);
    for(int v=0;v<(n<<1);v++){
      for(E e:G[v]){
        int u=e.first;
        T c=e.second;
        if(from[v]==from[u]) continue;
        int x=from[v],y=from[u];
        T z=dist[v]+dist[u]+c;
        H[x].emplace_back(y,z);
        H[y].emplace_back(x,z);
      }
    }
    return H;
  }
};
//END CUT HERE



template<typename T>
struct Kruskal{
  
  struct edge{
    int from,to;
    T cost;
    int used;
    edge(){}
    edge(int from,int to,T cost):
      from(from),to(to),cost(cost),used(0){}
    bool operator<(const edge& e) const{
      return cost<e.cost;
    }
  };

  int n;
  vector<int> p,r;
  vector<edge> edges;

  Kruskal(){}
  Kruskal(int n):n(n){}

  void init(int n){
    r.assign(n,1);
    p.resize(n);
    iota(p.begin(),p.end(),0);
  }
  
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }

  bool same(int x,int y){
    return find(x)==find(y);
  }

  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }

  void add_edge(int u,int v,T c){
    edges.emplace_back(u,v,c);
  }
  
  T build(){
    sort(edges.begin(),edges.end());
    init(n);
    T res=0;
    for(auto &e:edges){
      if(!same(e.from,e.to)){
        res+=e.cost;
        unite(e.from,e.to);
        e.used=1;
      }
    }
    return res;
  }
};


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE

signed main(){
  int n;
  cin>>n;
  vector<Int> x(n);
  for(int i=0;i<n;i++) cin>>x[i];
  VoronoiMST<Int> vo(x);
  for(int i=1;i<n;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    vo.add_edge(a,b,c);
  }
  auto G=vo.build();
  Kruskal<Int> ks(n);
  for(int v=0;v<n;v++){
    for(auto e:G[v]){
      int u=e.first;
      Int c=e.second;
      if(v<u) ks.add_edge(v,u,c);
    }
  }
  cout<<ks.build()<<endl;
  return 0;
}


Measured memory_bytes: 71316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
// const ll MOD = 1000000007;

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

	cout<<fixed<<setprecision(12);
	int n,x;
	cin>>n;

	int c1=0,c2=0,c3=0;
	for(int i=0;i<n;i++){
		cin>>x;
		if(x == 1)
			++c1;
		else if(x == 2)
			++c2;
		else
			++c3;
	}

	ld dp[n+1][n+1][2];
	dp[0][0][0] = 0;
	int r = 0;
	for(int k=0;k<=c3;k++){
		ld pk = k*1.0/n;
		for(int j=0;j<=n-k;j++){
			ld pj = j*1.0/n;
			for(int i=0;i<=n-j-k;i++){
				if(i+j+k == 0)
					continue;
				ld pi = i*1.0/n;
				ld sum=1,total=0;
				if(i > 0){
					sum += pi*dp[i-1][j][r];
					total += pi;
				}

				if(j > 0){
					sum += pj*dp[i+1][j-1][r];
					total += pj;
				}

				if(k > 0){
					sum += pk*dp[i][j+1][1-r];
					total += pk;
				}

				dp[i][j][r] = sum/total;
			}
		}
		r = 1-r;
	}

	cout<< dp[c1][c2][1-r] <<endl;
}


Measured memory_bytes: 3072
#include<iostream>
using namespace std;
int n,r,a,b;
int t[100];
int u[100],size;
int main(){
  while(cin>>n>>r&&n&&r){
    for(int i=0;i<n;i++)t[i]=n-i;
    for(int i=0;i<r;i++){
      cin>>a>>b;
      for(int j=0;j<b;j++)u[j]=t[j+a-1];
      for(int j=a-2;j>=0;j--)t[j+b]=t[j];
      for(int j=0;j<b;j++)t[j]=u[j];
    }
    cout<<t[0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
  int n;
  scanf("%d",&n);
  int x,y;
  scanf("%d %d",&x,&y);
  int a,b,c,d;
  a=b=x+y;
  c=d=x-y;
  for(int i=2;i<=n;i++) {
    scanf("%d %d",&x,&y);
    a=min(a,x+y);
    b=max(b,x+y);
    c=min(c,x-y);
    d=max(d,x-y);
  }
  printf("%d",max(abs(a-b),abs(c-d)));
  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  string s, t;
  ll n;
  cin >> s >> t;
  bool flag = true;
  rep(i, 0, (ll)s.size()) {
    if(s[i]!=t[i]) flag = false;
  }
  
  
  cout << ( flag ?"Yes" :"No") << "\n";

}

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

int main(void){
	char a[11], b[11], c[11];		//a,b,cは10文字以下

	int a_len, b_len;

	scanf("%s %s %s", a, b, c);
	a_len = strlen(a);
	b_len = strlen(b);

	if( (a[a_len - 1] == b[0]) && (b[b_len - 1] == c[0])){

		printf("YES\n");
	}else{
		printf("NO\n");
	}

	printf("\n");
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;


int main() {
	int n, h, w;
	cin >> n >> h >> w;

	cout << (n - h + 1)*(n - w + 1) << endl;



	return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,cnt=0,i;
  cin >> a >> b;
  for(i=a; i<=b; i++){
    if(i%10==i/10000 && (i/10)%10==(i/1000)%10){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256