akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (ll)(v).size()
#define int long long
#define mod 1000000007

void solve() {
        int a, b; cin >> a>> b;
        double x= ceil((a)/ 0.08);
        double y= ceil((b)/ 0.1);
        double tx= ((a+ 1)/ 0.08);
        double ty= ((b+ 1)/ 0.1);
        for (double i= x; i< tx; i++){
                if (i>= y&& i< ty) {
                        cout << (int)i<< endl;
                        return;
                }
        }
        cout << -1;
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if((a+b)>(c+d))cout<<"Left"<<endl;
  else if((a+b)<(c+d))cout<<"Right"<<endl;
  else cout<<"Balanced"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main ()
{
	int A, B, X;
	scanf("%d%d%d",&A,&B,&X);
	if(X<=A+B && X>A || X==A)
	{
		printf("YES");
	}
	else
	{
		printf("NO");
	}
	return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <limits>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int solve()
{
    int N;
    std::cin >> N;

    vector<int> B(N);
    for (int i = 0; i < N - 1; ++i)
        std::cin >> B[i];

    vector<int> A(N);
    A[0] = A[1] = B[0];

    for (int i = 1; i < N - 1; ++i)
    {
        if (B[i] < B[i - 1])
        {
            A[i] = A[i + 1] = B[i];
        }
        else
        {
            A[i + 1] = B[i];
        }
    }

    int sum = 0;
    for (int i: A)
        sum += i;

    return sum;
}

int main()
{
    std::cout << solve() << std::endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        long n = 0;
        public void Solve()
        {
            var cin = new Scanner();
            n = cin.nextLong();
            dfs("0");
            Console.WriteLine(ans);
        }

        long ans = 0L;
        void dfs(string ns)
        {
            var i = long.Parse(ns);
            if (i > n) return;
            var set = new HashSet<char>();
            foreach (var c in ns.ToCharArray()) set.Add(c);
            if (set.Contains('3') && set.Contains('5') && set.Contains('7')) ans++;
            dfs(ns + "3");
            dfs(ns + "5");
            dfs(ns + "7");
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

const int maxx=1e6+5;
ll a[maxx];
int n,i,ans,j,x;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	scanf("%d",&n);
	while(n--){
		scanf("%d",&x);
		a[x]++;
	}
	vector<bool> dv(maxx,true);
	
	for(i=1;i<=maxx;i++){
		if(!a[i]) continue;
		if(a[i]==1&&dv[i]) ans++;
		for(j=2;i*j<maxx;j++) dv[i*j]=false;
	}
	
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 11744
from collections import deque
H,W=map(int,input().split())
b=deque()
ans=[]
for i in range(H):
    s=input()
    t=[]
    for j in range(W):
        if s[j]=='#':
            b.append((i,j))
            t.append('#')
        else:
            t.append(0)
    ans.append(t)
while b:
    y,x=b.popleft()
    for i in range(-1,2):
        for j in range(-1,2):
            if i==0 and j==0:
                continue
            if 0<=y+i<H and 0<=x+j<W and ans[y+i][x+j]!='#':
                ans[y+i][x+j]+=1
for s in ans:
    print(*s,sep='')

Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;
struct grid{ int y1; int x1; int y2; int x2;};
int main() {
    int h, w, n;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w, 0));
    rep(i,h){
        rep(j,w) cin >> a[i][j]; 
    }
    vector<grid> ans;
    rep(i,h-1){
        rep(j,w){
            if(a[i][j]%2){
                a[i+1][j]++;
                a[i][j]--;
                ans.push_back((grid){i+1, j+1, i+2, j+1});
            }
        }
    }
    rep(i,w-1){
        if(a[h-1][i]%2){
            a[h-1][i+1]++;
            a[h-1][i]--;
            ans.push_back((grid){h, i+1, h, i+2});
        }
    }
    cout << ans.size() << endl;
    rep(i,ans.size()){
        cout << ans[i].y1 << " " << ans[i].x1 << " " << ans[i].y2 << " " << ans[i].x2 << endl;
    }
    return 0;
}

Measured memory_bytes: 6384
#include <iostream>
#include <algorithm>
#define Int long long int
using namespace std;

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

  Int g, x, y, z;
  g = c / __gcd(c, d)*d;
  x = b / c - (a-1) / c;
  y = b / d - (a-1) / d;
  z = b / g - (a-1) / g;

  cout << (b - a + 1) - x - y + z << endl;

  return 0;

}


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

int main(){
  int k,m,n;
  cin>>k>>m>>n;
  cout<<((k+m+n)>21?"bust":"win")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mk make_pair
#define pi pair<int, int>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;
int main()
{
   IOS;
   ll a,b,c,d;
   cin >> a >> b >> c >> d;
   ll res1,res2,res3,res4;
   res1 = a*c;
   res2 = a*d;
   res3 = b*c;
   res4 = b*d;
   ll ans = -0x3f3f3f3f3f3f3f3f;
   ans = max(ans,res1);
   ans = max(ans,res2);
   ans = max(ans,res3);
   ans = max(ans,res4);
   if((a <= 0 && b >= 0) || (c <= 0 && d >= 0))
   ans = max(ans,1LL*0);
   cout << ans;
}


Measured memory_bytes: 3608
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = (0 until 2).map { readLine()!!.split(' ').map { it.toInt() }.toIntArray() }.toTypedArray()
    var ans = 0
    for (k in 0 until n) {
        var cnt = 0
        var i = 0
        for (j in 0 until n) {
            cnt += a[i][j]
            if (j == k) {
                i++
                cnt += a[i][j]
            }
        }
        ans = Math.max(cnt, ans)
    }
    println(ans)
}


Measured memory_bytes: 38344
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


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

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define PI 3.141592654
#define deb1(x) cout << #x <<"="<< x <<endl;
#define deb2(x,y) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<endl;
#define deb3(x,y,z) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<<endl;
#define deb4(x,y,z,a) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<< ", "<<#a <<"="<<a << endl;
#define debarr(x) cout << #x<<"::"<<endl;for(int i : x){cout << i <<" ";} cout <<endl;

inline void add(int& a, int b){a = (a+b); if(a>=mod)a-=mod;}
inline void sub(int& a, int b){a = a-b; if(a<0)a+=mod;}
inline void mul(int& a, int b){a = (a*b)%mod;}



void mymain(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vi R,G,B;
    for(int i=0;i<n;i++){
        if(s[i]=='R')
            R.pb(i);
        else if(s[i]=='G')
            G.pb(i);
        else
            B.pb(i);
    }
    int ans=0;

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
             if(s[i]!=s[j]){
                    set<char> ss;
                    ss.insert(s[i]); ss.insert(s[j]);


                if(ss.count('B')==0){
                    int it = B.end() - upper_bound(all(B),j);
                    if(2*j-i < n && s[2*j-i] == 'B')
                        it--;
                    ans += it;
                }else if(ss.count('G')==0){
                    int it = G.end() - upper_bound(all(G),j);
                    if(2*j-i < n && s[2*j-i] == 'G')
                        it--;
                    ans += it;

                }else{
                    int it = R.end() - upper_bound(all(R),j);
                    if(2*j-i < n && s[2*j-i] == 'R')
                        it--;
                    ans += it;
                }
             }
        }
    }
    cout << ans <<endl;
}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
///cin>>t;

for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
}
return 0;
}
/*

*/


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

using namespace std;

int main(){
  int tmp,a[10];
  for(int i=0;i<10;++i){
    cin >> a[i];
  }
  for(int b=0;b<9;++b){
    for(int c=0;c<9;++c){
      if(a[c]>a[c+1]){
	tmp = a[c+1];
	a[c+1] = a[c];
	a[c] = tmp;
      }
    }
  }
  cout << a[9] << endl <<  a[8] << endl <<  a[7] << endl;
  return 0;
}



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

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

    int ans = 0;
    int sum = accumulate(a.begin(), a.end(), 0);
    rep(i,n){
        if(abs(a[i] * n - sum) < abs(a[ans]*n - sum)){
            ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb emplace_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
using namespace std;

ll gcd(ll n1,ll n2){
    if(!n1)return n2;
    if(!n2)return n1;
    if(n1%n2==0)return n2;
    return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
    base%=mod;
    ll ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent/=2;
    }
    ans%=mod;
    return ans;
}
int arr[upperlimit+1];
int main()
{
    int n,i,j,k;
    sd(n);sd(k);
    int g=0;
    int sum=0;
    for(i=1;i<=n;i++){
        sd(arr[i]);
        sum=max(sum,arr[i]);
        g=gcd(g,arr[i]);
    }    
    if(k%g==0 && k<=sum)printf("POSSIBLE");
    else printf("IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 640
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
const long double eps = 1e-12;
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*2
#define REP(a,b) for(long long a = 0;a < b;++a)
int main(){
	long long s, t, p, q, m;
	cin >> s >> t >> p >> q >> m;
	long long y;
	cin >> y;
	t ^= s;
	//xor a1,...,a(10^8)
	cout << (y ^ t) << endl;
	return 0;
}


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

int main() {
	string S;
	cin >> S;
	int N = S.length();

	int ans = 0;
	bool HasAns = true;
	for (int i = 2; i < N; i+=2) {
		HasAns = true;
		for (int j = 0; j < (N - i) / 2; j++) {
			if (S[j] != S[j + (N - i) / 2]) {
				HasAns = false;
				break;
			}
		}
		if (HasAns) {
			ans = N-i;
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
// ABC 107 D
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cassert>
const int MAXN = 1e5 + 10;
typedef int IntAr[MAXN];
typedef long long LL;

int N;
IntAr A, B, C, D;
LL tot;

namespace FastIO {
	template <typename T>
	void read(T & x) {
		x = 0; register char ch = getchar();
		for (; ch < '0' || ch > '9'; ch = getchar());
		for (; ch >= '0' && ch <= '9'; x = (x << 3) + (x << 1) + (ch ^ '0'), ch = getchar());
	}
}
LL count(int);
void merge(int l, int r);

// #define DEBUG_MD_

int main() {
	using FastIO::read;
	read(N);
	for (int i = 0; i < N; i++) scanf("%d", &A[i]);
	memcpy(B, A, sizeof(int) * N);
	std::sort(B, B + N);
	int lb = -1, mid, ub = std::unique(B, B + N) - B - 1;
	LL pos = (LL(N) * (N + 1) >> 2) + 1;
#ifdef DEBUG_MD_
	printf("pos=%lld\n", pos);
#endif 
	for (; ub - lb > 1; ) { // (lb, ub]
		mid = lb + ub >> 1;
		assert(mid >= 0);
		if (count(B[mid]) >= pos) ub = mid;
		else lb = mid;
	}
	// return 0;
	printf("%d\n", B[ub]);
	return 0;
}

LL count(int key) {
	C[0] = 0;
	for (int i = 1; i <= N; i++) C[i] = C[i - 1] + (A[i - 1] > key ? -1 : 1);
	tot = 0;
	merge(0, N + 1);
#ifdef DEBUG_MD_
	printf("key=%d, tot=%lld\n", key, tot);
#endif 
	return tot;
}

void merge(int l, int r) {
	// merge sort interval [l, r)
	if (r - l <= 1) return;
	int mid = l + r >> 1;
	merge(l, mid);
	merge(mid, r);
#ifdef DEBUG_MD_
	printf("[%d, %d)\n", l, r);
#endif
	int i, j, k;
	for (i = l, j = mid, k = l; i < mid && j < r; )
		if (C[i] < C[j]) {
			D[k++] = C[i++];
			tot += r - j;
		}
		else D[k++] = C[j++];
	for (; i < mid; ) D[k++] = C[i++];
	for (; j < r; ) D[k++] = C[j++];
	memcpy(C + l, D + l, sizeof(int) * (r - l));
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000001

int main(){
	int N,K;

	cin>>K>>N;
	
	vector ok(K+1,vector<int>(N+1,0));
	ok[0][0] = 1;

	vector ng = ok;
	
	for(int i=1;i<=K;i++){
		for(int j=0;j<=N;j++){
			ok[i][j] = ok[i-1][j];
			if(j!=0)ok[i][j] = mod(ok[i][j] + ok[i][j-1]);
			
			ng[i][j] = mod(2*ng[i-1][j]);
			if(j!=0)ng[i][j] = mod(ng[i][j] + ng[i][j-1]);
		}
		for(int j=0;j<=N;j++){
			ng[i][j] = mod(ng[i][j] - ng[i-1][j]);
		}
	}
	
	for(int i=2;i<=2*K;i++){
		int OK = 0,NG = 0;
		for(int j=1;j<=K;j++){
			int x = j;
			int y = i-x;
			if(y<=0||y>K){
				OK++;
			}
			else{
				if(x<y){
					NG++;
				}
			}
		}
		
		int ans = 0;
		for(int j=0;j<=N;j++){
			ans = mod(ans + mod(ok[OK][j] * ng[NG][N-j]));
		}
		if(i%2==0){
			for(int j=0;j<=N-1;j++){
				ans = mod(ans + mod(ok[OK][j] * ng[NG][N-1-j]));
			}
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 34948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep2(i, s, n) for (int i = s; i < (int)n; i++)
#define all(obj) obj.begin(), obj.end()
#define debug(x) cerr << #x << ":" << x << "\n"
#define vdebug(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	int n, m;
	int a, b;		
	while (true) {
		cin >> n >> m;
		if (!(n || m)) break;
		vvi f(n + 1);		
		rep(i, m) {
			cin >> a >> b;
			f.at(a).push_back(b);
			f.at(b).push_back(a);			
		}
		set<int> s;		
		for (int x : f.at(1)) {
			s.insert(x);
			for (int y : f.at(x)) {
				if (y != 1) s.insert(y);
			}
		}		
		cout << s.size() << endl;
	}
}


Measured memory_bytes: 3284
#include<cstdio>

int n, k, a[300010], lst, dis[300010];

template <class I> inline I abs(I x) {return x >= 0 ? x : -x;}
template <class I> inline I max(I a, I b) {return a > b ? a : b;}

inline bool cmp(int a, int b) {
	return abs(a - b) > k;
}

int main(void) {
	scanf("%d%d", & n, & k);
	for (int i = 1; i <= n; ++i)
		scanf("%d", & a[i]);
	for (int i = 1; i <= n; ++i) {
		dis[i] = 1;
		for (int j = i - 1; i - j <= 100 && j >= 1; --j)
			if (abs(a[i] - a[j]) <= k && dis[j] + 1 > dis[i])
				dis[i] = dis[j] + 1;
	}
	for (int i = 1; i <= n; ++i)
		lst = max(lst, dis[i]);
	printf("%d\n", lst);
	return 0;
}

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

int main() {
  int r, D, x2000;
  cin >> r >> D >> x2000;
  int ans = x2000;
  for (int i = 1; i <= 10; ++i) {
    ans = r * ans - D;
    cout << ans << endl;
  }
}

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

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

    if(b-a<=0) {
        cout << "delicious" << endl;
        return 0;
    }

    if(b-a<=x){
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }

    return 0;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int> v(3);
	for (int i = 0; i < 3; i++) {
		cin >> v.at(i);
	}
	if ((v.at(0) == v.at(1) && v.at(1) == v.at(2))
			|| (v.at(0) != v.at(1) && v.at(1) != v.at(2) && v.at(0) != v.at(2))) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
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;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

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

    ll n, k;
    cin >> n >> k;
    vll cnt(n, 0);
    rep(i, k) {
        ll d; cin >> d;
        rep(j, d) {
            ll x; cin >> x;
            x--;
            cnt[x]++;
        }
    }
    ll ans = 0;
    rep(i, n) if(cnt[i] == 0) ans++;
    cout << ans << endl;
}


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

int main(void){
    long long e, x1, xmin;
    while(cin >> e){
        xmin=0;
        if(e == 0)  break;
        for(long i = 0; i*i <= e; i++){
        for(long j = 0; i*i+j*j*j <= e; j++){
            x1 = e - i*i - j*j*j;
            if(x1 < 0)  break;
            if(xmin == 0 || xmin > (x1 + i + j))
            xmin = x1 + i + j;
        }
        }
        cout << xmin << endl;
    }
    return 0;
}



Measured memory_bytes: 3072
import sys
import numba
import numpy as np
from numba import jit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@jit
def main(a):
  ans = 0
  for i, j in enumerate(a):
    if i == 0 or j >= a[i-1]:
      continue
    else:
      ans += a[i-1] - j
      a[i] = a[i-1]
  return ans

n= int(readline().strip())
a = np.array(readline().split(), np.int64)
print(main(a))

Measured memory_bytes: 111028
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (a, b, c) = (v[0], v[1], v[2]);
    if a + b < c && 4 * a * b < (c - a - b) * (c - a - b) {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

int main(void) {
	ll n, l;
	cin >> n >> l;

	cout.precision(20);
	R cap = 0.0;
	ll total = 0LL;

	using state = pair<R, ll>;
	deque<state> q;

	{
		ll t, v;
		cin >> t >> v;
		state cur = state(1.0 * t * v, v);

		cap += cur.first;
		total += cur.second;

		q.push_front(cur);
		cout << fixed << t << endl;
	}

	rep(i, 1, n) {
		ll t, v;
		cin >> t >> v;

		while (!q.empty() and total > l - v) {
			state tmp = q.back();
			q.pop_back();

			const ll tvol = min(tmp.second, total - l + v);
			const R  tcap = tmp.first * tvol / tmp.second;

			cap -= tcap;
			total -= tvol;

			tmp.first -= tcap;
			tmp.second -= tvol;

			if (tmp.second != 0) q.push_back(tmp);
		}


		state cur = state(1.0 * t * v, v);
		q.push_front(cur);

		cap += cur.first;
		total += cur.second;

		while(q.size()>=2){
			state fst = q.front(); q.pop_front();
			state snd = q.front(); q.pop_front();

			// cur.first / cur.second < front.first / front.second
			if (fst.first * snd.second < snd.first * fst.second) {
				state in = state(fst.first + snd.first, fst.second + snd.second);
				q.push_front(in);
			}else {
				q.push_front(snd);
				q.push_front(fst);
				break;
			}
		}

		//cerr << cap << " " << total << endl;

		

		
		cout << fixed <<  1.0 * cap / l << endl;
	}

	return 0;
}

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

static const int N = 1000;

int lcs(string X, string Y){
    int c[N+1][N+1];
    int m = X.size();
    int n = Y.size();
    int maxl = 0;
    X = ' ' + X;
    Y = ' ' + Y;
    for(int i=1; i<=m; i++) c[i][0] = 0;
    for(int j=0; j<=n; j++) c[0][j] = 0;
    
    for(int i=1; i<=m; i++){
        for(int j=1; j<=n; j++){
            if(X[i]==Y[j]){
                c[i][j] = c[i-1][j-1] + 1;
            }else{
                c[i][j] = max(c[i-1][j], c[i][j-1]);
            }
            maxl = max(maxl,c[i][j]);
        }
    }
    
    return maxl;
}

int main(){
    string s1,s2;
    int n;
    cin >> n;
    
    for(int i=0; i<n; i++){
        cin >> s1 >> s2;
        cout << lcs(s1,s2) << endl;
    }
}

Measured memory_bytes: 7128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%2019;
        a = (a*a)%2019;
        b >>= 1;
    }
    return prod;
}
int main()
{
    string s;
    cin >> s;

    int n = s.size();
    int t[n + 1] = {0};
    for(int i = n-1 ; i >= 0 ; i--){
        t[i] = (t[i + 1] + (s[i] - '0')*power(10 , n-i-1))%2019;
    }

    map<int,int> m;
    m[0] = 1;
    int ans = 0;
    for(int i = 0 ; i < n ; i++){
        // debug(t[i]);
        ans = (ans + m[t[i]])%mod;
        m[t[i]]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4492
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}




int main() {
  int N,M;
  cin >> N >> M;
  vector<int> v(N,1);
  vector<bool> f(N);f[0] = true;
  rep(i,M){
    int x,y;
    cin >> x >> y;x--,y--;
    if(v[x] == 1 && f[x] == true){
      f[x] = false;
      f[y] = true;
      v[x]--;v[y]++;
    }
    else if(v[x] > 1 && f[x] == true){
      f[y] = true;
      v[x]--;v[y]++;
    }
    else v[x]--,v[y]++;
  }
  int ans = 0;
  rep(i,N) if(f[i]) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 888
class Solver(object):
    def __init__(self):
        self._input()
        self._solve()

    def _input(self):
        self.n = int(input())
        self.h_s = list(map(int, input().split(" ")))

    def _solve(self):
        counter = 0
        while True:
            watered = False
            watering = False
            for i in range(self.n):
                if self.h_s[i] > 0:
                    if not watering:
                        watered = True
                        watering = True
                        counter += 1
                    self.h_s[i] -= 1
                else:
                    if watering:
                        watering = False
            if watered == False:
                break
        print(counter)


if __name__ == "__main__":
    Solver()

Measured memory_bytes: 3064
import sys
readline = sys.stdin.readline
from collections import deque
directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]

def main():
    H, W = map(int, readline().rstrip().split())
    mat = [list(readline().rstrip()) for _ in range(H)]

    start = []
    for h in range(H):
        for w in range(W):
            if mat[h][w] == '#':
                start.append((h, w))
    
    res = 0
    que = deque(start)
    while que:
        next_que = deque()
        for h, w in que:
            for dh, dw in directions:
                if not (0 <= h+dh < H and 0 <= w+dw < W):
                    continue
                if mat[h+dh][w+dw] == '#':
                    continue
                mat[h+dh][w+dw] = '#'
                next_que.append((h+dh, w+dw))

        res += 1
        que = next_que

    print(res - 1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 134352
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools,pdb
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N, K = LI()
D = LI()
nums = [str(i) for i in range(0, 10) if i not in D]

"""
使える数字の中で一番低いものから試していく
見つかったら各桁試していく

"""

all_nums = []
for i in range(N, 99999):
    # 全数字の列挙
    all_nums.append(i)
for num in all_nums:
    if num >= N:
        if all(i in nums for i in str(num)):
            print(num)
            exit()





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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n;
	ll a, b;
	cin>>n;
	ll sum=0, mi=1e9;
	bool can=false;
	REP(i, n){
		cin>>a>>b;
		if(a!=b){
			can=true;
		}
		sum+=a;
		if(a>b){
			CHMIN(mi, b);
		}
	}
	cout<<(can ? sum-mi : 0)<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
using namespace std;

int main(){
  set<int> st;
  int n;  cin >> n;
  rep(i, 0, n){
    int a;
    cin >> a;
    if(st.find(a) == st.end()){
      st.insert(a);
    }
    else{
      st.erase(a);
    }
  }
  cout << st.size() << endl;
  return 0;
}


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

#define FasterIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main(){
    FasterIO;

    int n;

    while(cin>>n){
        int data[n];
        int mn = INT_MAX;

        for(int i=0; i<n; i++){
            cin>>data[i];
            mn = min(mn, data[i]);
        }

        int gcd = data[0];

        for(int i=1; i<n; i++){
            gcd = __gcd(gcd, data[i]);
        }

        cout<<gcd<<endl;
    }

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};

int main() {

	string t;
	cin>>t;
	rep(i,t.size()){
		if(t[i]=='?')cout<<"D";
		else cout<<t[i];
	}
	cout<<endl;

	return 0;
}


Measured memory_bytes: 3728
#include <cstdio>
#include <algorithm>
using namespace std;
int n,k;
long long arr[105][100005];
int main(){
    scanf("%d%d",&n,&k);
    int w;
    long long v;
    for (int x=1;x<=n;x++){
        scanf("%d%lld",&w,&v);
        for (int y=0;y<=k;y++){
            arr[x][y]=arr[x-1][y];
            if (y>=w)arr[x][y]=max(arr[x-1][y],arr[x-1][y-w]+v);
        }
    }
    printf("%lld\n",arr[n][k]);
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
int main() {
    int w, h, x, y, r; cin >> w >> h >> x >> y >> r;
    if (x + r <= w && x - r >= 0 && y + r <= h && y - r >= 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3072
n = int(input())
p = list(map(int, input().split()))
a = [3 * (i + 1) * pow(10, 4) for i in range(n)]
b = list(a)
b.reverse()
p.reverse()
for i in range(n):
    a[p[i] - 1] -= i
print(" ".join(map(str, a)))
print(" ".join(map(str, b)))

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

int main() {
    int b1,b2,b3; cin >> b1 >> b2 >> b3;
    if ((b1 == 1 and b2 == 1) or (b3 == 1)) {
        cout << "Open" << endl;
    }
    else cout << "Close" << endl;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int K;
int64 A[MAXN];
int64 check(int64 x) {
    for(int i = 1 ; i <= K ; ++i) {
	x -= x % A[i];
    }
    return x;
} 
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    read(K);
    for(int i = 1 ; i <= K ; ++i) read(A[i]);
    int64 L = 2,R = 1e18;
    while(L < R) {
	int64 mid = (L + R) >> 1;
	if(check(mid) >= 2) R = mid;
	else L = mid + 1;
    }
    if(check(R) != 2) {puts("-1");return 0;}
    out(R);space;
    R = 1e18;
    while(L < R) {
	int64 mid = (L + R + 1) >> 1;
	if(check(mid) <= 2) L = mid;
	else R = mid - 1;
    }
    out(R);enter;
}


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

int main() {
  int N ;
  std::cin >> N;

  std::vector<int> vec(N);
  for (size_t i = 0; i < N; i++) {
    std::cin >> vec.at(i);/* code */
  }

  sort(vec.begin(),vec.end());
reverse(vec.begin(),vec.end());
int ans=1;
for (size_t i = 0; i < N-1; i++) {
  if (vec.at(i)>vec.at(i+1)) {
    ans+=1;/* code */
  }/* ode */
  else{ans+=0;}
}
std::cout << ans << '\n';
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int a, b;

    cin >> a >> b;

    int now = 1;
    int cnt = 0;
    while(now < b){
        if(now + a - 1 >= b){
            cnt++;
            break;
        } else {
            now--;
            now += a;
            cnt++;
        }
    }

    cout << cnt << endl;
}

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

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

  const int M = 300000;

  int dp[M] = {};

  for(int i = 0; i < N; ++i) {
    int a, b;
    cin >> a >> b;
    ++dp[a + b];
  }

  for(int i = 0; i < M - 1; ++i) {
    if(dp[i] & 1) cout << i << " " << 0 << endl;
    dp[i + 1] += dp[i] / 2;
  }
}

Measured memory_bytes: 4240
a,b = input().split()
r = int(b[0:3])-int(a[0:3])+1
if int(a[3:5]) > int(a[0:2][::-1]):
  r -= 1
if int(b[3:5]) < int(b[0:2][::-1]):
  r -= 1
print(r)

Measured memory_bytes: 3060
// 最小の集合場所の座標はどこかわからないので、
// 総当たりで場所を探し一番コストが少ない場所を集合場所の座標とする

// inputに入力データ全体が入る
function Main(inputString) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    let inputLineArray = inputString.split("\n");

    // 住んでる座標の文字列配列
    let livingPointStringArray = inputLineArray[1].split(" ");

    // 想定される最小の移動コスト
    let minRequiredPhysicalStrength = 999999;

    // 住んでる座標の文字列配列を数値配列に変換する
    let livingPointArray = [];
    livingPointStringArray.forEach( element => {
        let livingPoint = parseInt( element, 10)
        livingPointArray.push(livingPoint); 
    });

    // 住んでる座標のうち、最小値と最大値を求める
    let minLivingPoint = Math.min.apply( null, livingPointArray);
    let maxLivingPoint = Math.max.apply( null, livingPointArray);

   // 移動コストが最小の座標を求める
    for( i = minLivingPoint; i <= maxLivingPoint; i++ ){
        let tmpMeetingPoint = i;
        let beforeMinRequiredPhysicalStrength = minRequiredPhysicalStrength;
        minRequiredPhysicalStrength = requiredPhysicalStrengthFunction(livingPointArray, tmpMeetingPoint, minRequiredPhysicalStrength);
        // 関数実行前後で値が変わっていなければこれ以上やっても意味ないのでbreakする
        if ( beforeMinRequiredPhysicalStrength === minRequiredPhysicalStrength) {
            break;
        }
    }
    console.log('%d', minRequiredPhysicalStrength);
}

    // 必要な体力を計算する関数
function requiredPhysicalStrengthFunction(in_livingPointArray, in_meetingPoint, in_minRequiredPhysicalStrength){
    // 必要な体力の合計値
    let tmpAllRequiredPhysicalStrength = 0;

    // 住んでる座標の配列
    in_livingPointArray.forEach( livingPoint => {
        //必要な体力は(住んでる座標 - 集合場所の候補の座標)の2乗
        let requiredPhysicalStrength = Math.pow(( livingPoint - in_meetingPoint ) , 2);
        tmpAllRequiredPhysicalStrength += requiredPhysicalStrength;
    });
    // 一番小さいと思っている消費コストより今回の座標の消費コストの方が小さければそれを最小値とする
    if(in_minRequiredPhysicalStrength > tmpAllRequiredPhysicalStrength){
        return tmpAllRequiredPhysicalStrength;
    } else {
        return in_minRequiredPhysicalStrength;
    }
}

    //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
    Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
fun main(args: Array<String>) {
  val n = readLine()!!
  val array = readLine()!!.split(" ").map(String::toInt)
  val evens = array.filter{it%2 == 0}
  val denied =  evens.filter{it%3 != 0 && it%5 != 0}
  println(if(denied.size > 0) "DENIED" else "APPROVED")
}

Measured memory_bytes: 37908
N,W=map(int,input().split())
nap=[]
for i in range(N):
    nap.append(list(map(int,input().split())))
list_dp=[0]*(W+1)
for i in range(W):
    for j,k in nap:
        if i+k>W:continue
        else:list_dp[i+k]=max(list_dp[i+k],list_dp[i]+j)
print(list_dp[W])


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

int main() {
    string s;
    cin >> s;
    int N = s.size();
    long long int sum =0;

    for(int bit=0; bit < (1<< N-1); bit++){
        // 1桁目をintで取得する sumに足す前で巨大になりうる
        long long int t = s[0] - '0';

        // 各桁に＋が入るかを判定して処理
        for(int i=0; i<N-1; i++){
            if (bit & (1 << i) ){ // 1が立っていれば＋記号を入れる場所とする 1<<i == 2^i であるからbitの各桁で1が立っているもののみ見ている
                sum += t;
                t = s[i+1] - '0';
            }
            else{
                t *=10;
                t += s[i+1] - '0';
            }

        }
        sum += t;
    }

    cout << sum << endl;
}


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

int main(){
	int N;
	cin >> N;
	vector<int> H(N);
	int ans = 0;
	rep(i, N)cin >> H.at(i);
	int i = 0;
	int count = 0;
	while(i<N-1) {
		if (H.at(i) >= H.at(i + 1)) { 
			++i;
			++count; 
			if(i==N-1&& ans < count)ans = count;
		}

		else {
			if (ans < count) {
				ans = count;
			}
			count = 0;
			++i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main (){
    int N,M,C,i,sum=0,x,ans=0;
    cin >> N >> M >> C;
    sum = C;

    vector<int> v(M);
    for(i=0;i<M;i++){
        cin >> v.at(i);
    }


    for(int j=0;j<N;j++){
        for(i=0;i<M;i++){
        cin >> x;
        sum += x*v.at(i); 
        }
        
        if(sum > 0){
            ans++;
        }
        sum = C;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int k = 0, r = 0;
    for (int i = 0; i < n; i++) {
        int d1, d2;
        cin >> d1 >> d2;

        if (d1 == d2) {
            k++;
        } else {
            k = 0;
        }
        r = max(r, k);
    }

    cout << (r >= 3 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;


LL mod = 1000000007;

int main()
{
	LL h, n;
	cin >> h >> n;
	
	
	LL s = 0;
	LL x;
	
	for (LL i = 0; i < n; ++i) {
		cin >> x;
		s += x;
	}

	if (s >= h) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}

	
}

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

int n,ans;
int a[100100],f[100100];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if (a[i]==i) f[i]=1;
	}
	
	for (int i=1;i<=n;i++)
		if (f[i] && f[i+1])
		{
			f[i]=f[i+1]=0;
			ans++;
		}
	for (int i=1;i<=n;i++)
		if (f[i])
			ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n = 10 ** 10
    print("?", n)
    # 値順ではn>ansが確定なので、辞書順で前か後かが分かる
    # Yならば辞書順で前なのでn=10の累乗で確定
    if input() == "Y":
        # 2,20,200…と質問していく
        # 辞書順でn>ansが確定なので、値順でn>ansとなったときにYが返って答えが分かる
        n = 2
        while 1:
            print("?", n)
            if input() == "Y":
                print("!", n // 2)
                exit()
            n *= 10
    # Nならば最上位が2以上であることが確定
    else:
        # 100000000,10000000,1000000…と質問していく
        # 辞書順でn<=ansが確定なので値順もn<=ansとなったときにnが下限となる
        # n*10が上限
        n = 10 ** 8
        while 1:
            print("?", n)
            if input() == "Y": break
            n //= 10
        # 例えば下限が1000なら答えは1001~9999
        # ここから二分探索
        # 5971を質問したいときは59710と聞けば値順ではn>ansが確定
        # 辞書順でもn>ansならば（つまり5971>ansならば）Yが返る
        # Nならばn<=ans（つまり5971<=ans）ということ
        l = n
        r = 10 * n
        while l + 1 < r:
            m = (l + r) // 2
            print("?", m * 10)
            if input() == "Y":
                r = m
            else:
                l = m
        print("!", r)

main()


Measured memory_bytes: 3404