akhauriyash/Code-Regression huggingface dataset:
/**
 *
 * Contest - Problem X: Nome (link)
 *
 * Abridge version.
 *
 * Solution: text
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;
using iii = pair<ii, ll>;

#define REP(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define REPN(i, N) for (int (i) = 0; (i) < N; (i)++)
#define DEC(i, b, a) for (int (i) = (b); (i) >= (a); (i)--)
#define DECN(i, N) for (int (i) = N - 1; (i) >= 0; (i)--)

#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))
#define LOGM(msg) (cerr << (msg))
#define LOGV(vec, sep) { cerr << #vec << " ="; for (const auto& v : (vec)) cerr << " " << v; cerr << (sep); }
#define LOGA(arr, N, sep) { cerr << #arr << " ="; for (int i = 0; i < N; ++i) cerr << " " << (arr)[i]; cerr << (sep); }
#define LOGA2(arr, N, M, sep) { cerr << #arr << " =\n"; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) cerr << (arr)[i][j] << " "; cerr << endl; } cerr << (sep); }

ostream& operator<<(ostream& os, const ii& p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

ostream& operator<<(ostream& os, const iii& p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

const int MAX { 2000010 };
const ll oo { 1LL << 62 };
const int MOD { 1000000007 };

int MSB(int L)
{
    auto ans = 0;

    for (auto i = 0; i <= 20; ++i)
        if (L & (1 << i))
            ans = i;

    return ans;
}

void solve(int L)
{
    auto paths = L, w = 0;
    auto msb = MSB(L);
    auto N = msb + 1;
    vector<iii> es;

    auto base = 1;
//LOG(N, '\n');
    REP(u, 2, N)
    {
        es.push_back(iii(ii(u - 1, u), 0));
        es.push_back(iii(ii(u - 1, u), base));
        base <<= 1;
    }

    paths -= (1 << msb);
 
//LOG(paths, '\n');

    while (paths)
    {
        w |= (1 << msb);
        msb = MSB(paths);

//LOGM("Adding more "); LOG((1 << msb), '\n');

        auto v = msb + 1;
        es.push_back(iii(ii(v, N), w));

        paths -= (1 << msb);
    }

/*
LOG(v, ' '); LOG(vbase, ' '); LOG(w, '\n');
    {
        w |= vbase;

        auto u = v - 1;
        auto base = vbase >> 1;

        while (u > 1)
        {
            if ((L - 1) & (1 << (u - 1)))
                break;

            --u;
            base >>= 1;
        }

LOG(v, ' '); LOG(u, ' '); LOG(w, '\n');

        es.push_back(iii(ii(max(u - 1, 1), N), w));

        v = u;
        vbase = base;
    } 
*/
    cout << N << " " << es.size() << endl;

    for (const auto& e : es)
        cout << e.first.first << " " << e.first.second << " " << e.second << endl;
}

int main()
{
    ios::sync_with_stdio(false);

    int L;
    cin >> L;

    solve(L);

    return 0;
}


Measured memory_bytes: 256
from bisect import bisect_right

N, K = map(int, input().split())
x = list(map(int, input().split()))
zero_pos = bisect_right(x, 0)
start = max(zero_pos - K, 0)
end = min(zero_pos, N - K)
m = 10**10
for i in range(start, end + 1):
    left = x[i]
    right = x[i+K-1]
    _m = max(abs(left), abs(right))
    if left*right < 0:
        _m += min(abs(left), abs(right))*2
    m = min(m, _m)
print(m)


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

int main()
{
    int n;
    long long sum = 0;
    cin >> n;
    vector<long long> b(n-1);
    vector<long long> a(n);
    for (int i = 0; i < n-1;i++){
        cin >> b.at(i);
    }
    a.at(0) = b.at(0);
    for (int i = 1; i < n-1;i++){
        a.at(i) = min(b.at(i - 1), b.at(i));
    }
    for (int i = 0; i < n;i++){
        sum += a.at(i);
    }
    sum += b.at(n - 2);
    cout << sum << endl;
}


Measured memory_bytes: 256
n , q = map(int,input().split())
s = input()
t = [0]*(n+1)
for i in range(n):
    t[i+1] = t[i] +(1 if s[i:i+2]=='AC' else 0)
for i in range(q):
    l, r = map(int,input().split())
    print(t[r-1] -t[l-1])

Measured memory_bytes: 7748
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <bits/stdc++.h>
using namespace std;

int main(){
    string S;
    cin >> S;
    if(S[0] == S[1] || S[1] == S[2] || S[2] == S[3]){
        cout << "Bad" << endl;
    }else{
        cout << "Good" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
//int dx[]={+1,-1,+0,+0};///Four Directions
//int dy[]={+0,+0,+1,-1};///Four directions
//int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions
//int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions

//int mark[10007];vi prime;void seive(){for(int i=2;i<10000;i++){if(mark[i]==0){prime.pb(i);for(int j=i+i;j<=10000;j+=i)mark[j]=1;}}}

//freopen("input.txt", "r", stdin);

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

   string t; cin>>t;

   if(t=="ABC") cout<<"ARC"<<endl;
   else cout<<"ABC"<<endl;

   End;
}


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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1000000000;
const LL MOD = 1000000007;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

int main() {
  int N;
  cin >> N;
  
  VI A(N);
  REP(i,N) {
    cin >> A.at(i);
  }
  
  VI B(N);
  REP(i,N) {
    B.at(A.at(i)-1) = i+1;
  }
  
  REP(i,N) {
    cout << B.at(i) << " ";
  }
  cout << endl;
  return 0;
}
  
  

Measured memory_bytes: 1664
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (H, W) = nextIntList()
    val A = Array(H) { next().toCharArray() }
    val X = A.transposed().mapIndexed { i, array -> if (array.all { it == '.' }) -1 else i }.filter { it >= 0 }
    val Y = A.mapIndexed { i, array -> if (array.all { it == '.' }) -1 else i }.filter { it >= 0 }
    for (y in Y) {
        for (x in X) {
            print(A[y][x])
        }
        println()
    }
}

fun Array<CharArray>.transposed(): Array<CharArray> {
    val A = Array(this[0].size) { CharArray(this.size) }
    for (y in this.indices) {
        for (x in this[0].indices) {
            A[x][y] = this[y][x]
        }
    }
    return A
}

Measured memory_bytes: 37800
#include <stdio.h>

int main(void)
{
	int N;//N個のボール
	int K;
	unsigned int number=1;
	int i;

	scanf("%d %d", &N, &K);

	
		if (N == 1)
		{
			printf("%d", K);
		}
		else
		{
			for (i = 1;i < N;i++)
			{
				number = number * (K - 1);
			}
			number = number * K;
			printf("%u", number);
		}
}

Measured memory_bytes: 1720
#include<cstdio>
int n,m,c,t,ans=1001;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&c,&t);
		if(t<=m)
			if(c<ans)
				ans=c;
	}
	if(ans==1001)
		printf("TLE\n");
	else
		printf("%d\n",ans);
}

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

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> ans(n + 1);
	for (int x = 1; x * x <= n; ++x) {
		for (int y = x; y * y <= n; ++y) {
			for (int z = y; z * z <= n; ++z) {
				int t = x * x + y * y + z * z + x * y + y * z + z * x;
				if (t > n) break;
				if (x == y && y == z) ++ans[t];
				else if (x == y || y == z) ans[t] += 3;
				else ans[t] += 6;
			}
		}
	}
	for (int i = 1; i <= n; ++i) cout << ans[i] << endl;

	return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>

#define SIZE 100
#define INF 1000000
using namespace std;

int main(){

  int i,j,k;
  int n,m;
  int a,b,c,d;
  int s,g,x,y;
  int cost[SIZE][SIZE];

  cin>>n;
  cin>>m;

  for(i=1;i<n+1;i++){
    for(j=1;j<n+1;j++){
      cost[i][j]=INF;
    }
  }

  for(i=0;i<m;i++){
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);

    cost[a][b]=c;
    cost[b][a]=d;
  }

  for(i=1;i<n+1;i++){
    for(j=1;j<n+1;j++){
      for(k=1;k<n+1;k++){
	cost[j][k]=min(cost[j][k],cost[j][i]+cost[i][k]);
      }
    }
  }

  scanf("%d,%d,%d,%d",&s,&g,&x,&y);

  x-=cost[s][g]+cost[g][s]+y;
  printf("%d\n",x);

  return 0;
}

Measured memory_bytes: 1240
// KNOW NOTHING!
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fall(a) a.begin(),a.end()
#define sz(x) (int)x.size()
#define szs(x) (int)s.length()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef queue<int> qin;
typedef deque<ll> dqll;
typedef deque<int> dqint;
typedef priority_queue<ll> pqll;
typedef priority_queue<int> pqin;
typedef map<ll,ll> mpll;
typedef map<int,int> mpin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
const ll MOD=1000000007;
const long double PI=3.1415926535897932384626433832795;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}

int main()
{
/*
freopen ("input.txt","r","stdin");
freopen ("output.txt","w","stdout");
*/
ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
ll n; cin>>n;
ll res=0;
F (i,1,n+1,1) {
	ll m = n/i;
	res+=(((m*(m+1))/2)*i);
}
cout<<res;
return 0;
}
/* What we know is a drop , but what we don't know is an ocean !*/

Measured memory_bytes: 3640
#include <bits/stdc++.h>
int main() {
  long long n, m; std::cin >> n >> m;
  if (n > m) std::swap(n, m);
  std::cout << (n == 1 && m == 1
    ? 1
    : n == 1
    ? m - 2
    : (n - 2) * (m - 2) 
  ) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define MAX_N 100000
//#define DBG_PRINT printf
#define DBG_PRINT(format, ...)

int bit[MAX_N + 1], n;

int sum(int i) {
	int s = 0;
	while (i > 0) {
		DBG_PRINT("sum : i = %d, bit[i] = %d, s = %d", i, bit[i], s);
		s += bit[i];
		i -= i & -i;
	}
	DBG_PRINT("\n");
	return s;
}

void add(int i, int x) {
	while (i <= n) {
		bit[i] += x;
		i += i & -i;
	}
}

int getSum(int x, int y) {
	return sum(y) - sum(x);
}

void printv(int v[], int len) {
	for (int i = 0; i < len; i++)
		DBG_PRINT("%d ", v[i]);
	DBG_PRINT("\n");
}

int main() {
	fill_n(bit, MAX_N + 1, 0);
	int q, com, x, y;
	cin >> n >> q;
	while (q-->0) {
		printv(bit, n + 1);
		cin >> com >> x >> y;
		if (com == 0)
			add(x, y);
		else
			cout << getSum(x - 1, y) << endl;;
	}
	return 0;
}

Measured memory_bytes: 1552
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] list = new long[n];
    for(int i = 0; i < n; i++) {
      int j = sc.nextInt();
      list[i] = j;
    }
    sc.close();
    List<Long> result = new ArrayList<Long>();


    result.add(getMin(list));
    result.add(getMax(list));
    result.add(getSum(list));
    System.out.println(result.get(0) + " " + result.get(1) + " " + result.get(2));
  }

  public static long getMax(long[] list) {
    long max = list[0];
    for(int i = 0; i < list.length; i++) {
      if(max < list[i]) {
        max = list[i];
      }
    }
    return max;
  }

  public static long getMin(long[] list) {
    long min = list[0];
    for(int i = 0; i < list.length; i++) {
      if(min > list[i]) {
        min = list[i];
      }
    }
    return min;
  }

  public static long getSum(long[] list) {
    long sum = 0;
    for(int i = 0; i < list.length; i++) {
      sum += list[i];
    }
    return sum;
  }
}


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

namespace Amida_the_City_of_Miracle
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] strs = Console.ReadLine().Split(' ');
                int n = int.Parse(strs[0]);
                int m = int.Parse(strs[1]);
                int a = int.Parse(strs[2]);
                if (n == 0 && m == 0 && a == 0) break;
                    
                List<Line> lines = new List<Line>();
                for (int i = 0; i < m; i++)
                {
                    strs = Console.ReadLine().Split(' ');
                    int height = int.Parse(strs[0]);
                    int number1 = int.Parse(strs[1]);
                    int number2 = int.Parse(strs[2]);
                    lines.Add(new Line(height, number1, number2));                    
                }
                Amida amida = new Amida(lines);
                Console.WriteLine(amida.Play(a));
            }

        }
    }

    public class Amida
    {
        List<Line> lines;

        public Amida(List<Line> lines)
        {
            this.lines = lines;
            this.lines.Sort();
        }

        public int Play(int a){
            foreach (Line line in lines){
                a = line.Check(a);
            }
            return a;
        }
    }

    public class Line : IComparable{
        
        private int height;
        private int number1;
        private int number2;

        public Line(int height, int number1, int number2){
            this.height = height;
            this.number1 = number1;
            this.number2 = number2;
        }

        public int Check(int number){
            if (number == number1) return number2;
            if (number == number2) return number1;
            return number;
        }
   
        public int CompareTo(object obj)
        {
            if (obj.GetType() == typeof(Line)){
                Line line = (Line)obj;
                if (height < line.height) return 1;
                if (height > line.height) return -1;
                return 0;
            }
 	        throw new ArgumentException();
        }
    }
}

Measured memory_bytes: 6172
#include<stdio.h>
int main(void){
int i,a,b,sum=0;
for(i=1;i<1000;i*=10){
scanf("%d%d",&a,&b);
sum+=a*i;
sum+=b*5*i;
}
if(sum>=1000) printf("1\n");
else printf("0\n");
return 0;}

Measured memory_bytes: 584
# -*- coding: utf-8 -*-
n = int(input())
tests  = [[] for _ in range(n)]
for i in range(n):
    a = int(input())
    tests[i].extend([tuple(map(int, input().split())) for _ in range(a)])

rst = 0
chk = 2 ** n
for h in list(range(chk))[::-1]:
    h_list = ("{:0>"+str(n)+"}").format(bin(h)[2::])
    flag = True
    for i, a in enumerate(h_list):
        if a == '0':
            continue

        for x, y in tests[i]:
            ys = str(y)
            if h_list[x-1] == ys:
                continue
            else:
                flag = False
                break
        
        if not flag:
            break
    
    if flag:
        rst = h_list.count('1')
        break

print(rst)


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

int main(){
	//Make the code faster
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	//Declaring the vars
	string s;
	cin >> s;
	
	
	if(s == "SUN"){
		cout << "7";
	}else if(s == "MON"){
		cout << "6";
	}else if(s == "TUE"){
		cout << "5";
	}else if(s == "WED"){
		cout << "4";
	}else if(s == "THU"){
		cout << "3";
	}else if(s == "FRI"){
		cout << "2";
	}else{
		cout << "1";
	}
}

Measured memory_bytes: 256
n = int(input())
s = input()
x,y,ans = [[s[0]]],[[s[-1]]],0
for i in range(1,n-1):
	if s[i] in x[-1]: x.append(x[-1])
	else: x.append(x[-1]+[s[i]])
s = s[::-1]
for i in range(1,n-1):
	if s[i] in y[-1]: y.append(y[-1])
	else: y.append(y[-1]+[s[i]])
y = y[::-1]
for i in range(n-1): ans = max(ans,len(x[i])+len(y[i])-len(set(x[i]+y[i])))
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
  
  	if(abs(a-c) <= d){
		cout << "Yes" << endl;
    }else{
		if(abs(a-b) > d || abs(c-b) > d){
			cout << "No" << endl;
        }else{
			cout << "Yes" << endl;
        }
    }

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
 
#define mod(cans) cans%10**9+7
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define cin_pl(n,x) rep(i,n){cin>>x[i];}
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define prians(Answer) cout<<Answer<<"\n"
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int> > matrix;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef greater<int> gi;
typedef vector<unsigned> vu;


ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
bool is_prime(const unsigned n){
    switch(n){
        case 0:
        case 1: return false;
        case 2: return true;
    }
 
 
    for(unsigned i=2;i<n;++i){
        if(n%i == 0) return false;
    }
 
    return true;
}

int main()
{
    ll n;
    cin>>n;
    ll count=0,ans=0;
    while(n>=1)
    {
        n=n/2;
        count++;
    }
    rep(i,count)
    {
        ans+=pow(2,i);
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

#define LL long long
const int maxn = 10;
int ten[maxn];
int a, b;

bool judge(int x) {
    int dig = 0;
    int xx = x;
    while(xx != 0) {
        xx /= 10;
        ++dig;
    }
    for(int i = 0; i < dig; ++i) {
        if((x / ten[i]) % 10 != (x / ten[dig - i - 1]) % 10) {
            return false;
        }
    }
    return true;
}

int main() {
    #ifdef LOCAL
        freopen("test.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    #endif // LOCAL
    ios::sync_with_stdio(false);

    ten[0] = 1;
    for(int i = 1; i < maxn; ++i) {
        ten[i] = ten[i - 1] * 10;
    }
    while(scanf("%d%d", &a, &b) != EOF) {
        int cnt = 0;
        for(int i = a; i <= b; ++i) {
            if(judge(i)) {
                ++cnt;
            }
        }
        printf("%d\n", cnt);
    }

    return 0;
}


Measured memory_bytes: 384
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N = INT()

i = 0
while  2**i <= N:
	i += 1

print(2**(i-1))

Measured memory_bytes: 5196
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int d[] = new int[N];
    for(int i=0;i<N;i++){
      d[i]=sc.nextInt();
    }
    Arrays.sort(d);
    int answer =1;
    for(int i=0;i<N-1;i++){
      if(d[i]!=d[i+1]){
        answer=answer+1;
      }
    }
    System.out.println(answer);
  }
  

  
}

Measured memory_bytes: 21972
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const ll mod = 1000000007;
int main(){
  ll N, C;
  cin >> N >> C;
  vector<ll> s(200001), t(200001), c(200001);

  rep(i, N) {
    cin >> s[i] >> t[i] >> c[i];
  }
  
  vector<ll> sm(200001);
  for(ll i = 1; i <= C; ++i){
    vector<ll> time(200001, 0);

    for(ll j = 0; j < N; ++j){
      if(c[j] == i){
        time[s[j] * 2 - 1]++;
        time[t[j] * 2]--;
      } 
    }

    ll m = 0;
    /*
    for(ll j = 1; j < 200001; ++j) time[j] += time[j - 1];
    for(ll j = 0; j < 200001; ++j) if(time[j] > 0) sm[j]++;
    */
    
    for(ll j = 0; j < 200001; ++j){
      m += time[j];
      if(m > 0) sm[j]++;
    }
  }

  ll ans = 0;
  for(ll i = 0; i < 200001; ++i){
    ans = max(ans, sm[i]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    int a,b;
    cin >> a >> b;

    if(a <= 9 && b <= 9){
        cout << a * b << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<utility>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,ans,a,b;
    cin >> n >> m;
    ans = 0;
    vector<P> h(n+1);
    FOR(i,1,n){
        cin >> h[i].first;
        h[i].second = 1;
    }
    REP(i, m){
        cin >> a >> b;
        if(h[a].first < h[b].first){
            h[a].second = 0;
        }else if(h[a].first > h[b].first){
            h[b].second = 0;
        }else{
            h[a].second = 0;
            h[b].second = 0;
        }
    }
    FOR(i,1,n){
        if(h[i].second == 1){
            ans++;
        }
    }
    cout << ans <<"\n";
	return 0;
}

Measured memory_bytes: 4784
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ret = sum(b)
for i in range(n-1):
    if a[i+1] == a[i]+1:
        ret += c[a[i] - 1]
print(ret)

Measured memory_bytes: 61616
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll s[51],p[51];
ll f(ll N,ll X){
	if(N==0)return 1;
	else if(X==1)return 0;
	if(1<X&&X<=1+s[N-1])return f(N-1,X-1);
	else if(X==2+s[N-1])return p[N-1]+1;
	else if(2+s[N-1]<X && X<=2+2*s[N-1]) return p[N-1]+1+f(N-1,X-2-s[N-1]);
	else if(X==3+2*s[N-1])return 2*p[N-1]+1;
}
int main(void){
	ll N,X;
	cin >> N >> X;
	ll ans = 0;
	s[0] = 1;
	p[0] = 1;
	for(int i=1;i<=N;i++){
		s[i] = 2*s[i-1]+3;
		p[i] = 2*p[i-1]+1;
	}
	ans = f(N,X);
	cout << ans << endl;
}	

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const int md = 1e9+7;
int n, a[22][22];
long long dp[1<<22] = {1};

int main(){
	scanf("%d", &n);
	rep(i,n)rep(j,n)scanf("%d", a[i]+j);
	for(int i = 1; i < 1<<n; i++){
		int t = __builtin_popcount(i);
		rep(j,n) if(a[t-1][j] && (i>>j&1)) (dp[i] += dp[i-(1<<j)]) %= md;
	}
	printf("%lld\n", dp[(1<<n)-1]);
}

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

void Main()
{
  int n; cin >> n;
  int cnt = 0;
  for (int i = 3; i <= n; i++) {
    int div = 0;
    for (int j = 1; j <= i; j++) {
      if (i%j == 0) div++;
      j++; // 奇数にする
    }
    if (div == 8) cnt++;
    i++; // 奇数にする
  }
  cout << cnt << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
VI a(3);
for (int i = 0; i < 3; i++)
{
    cin>>a.at(i);

}
sort(	ALL(a) );
cout<<a.at(0)+a.at(1)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a, b;
	int i;
	int k=-1;
	scanf("%d%d", &a, &b);
	if ( b < 10) {
		i = 10 * a+b;
	}
	else if (b<100&&b >= 10) {
		i = 100 * a + b;
	}
	
	
	else if (b == 100) {
		i = 1000 * a + b;
	}

	for (int j = 1; j < 400; j++) {
		if (i == j * j) {
			k = j;
		}
		

	}

	if (k == -1) {
		printf("No");
	}
	else {
		printf("Yes");
	}
	return 0;

}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner in = new Scanner(System.in)) {
			final int N = in.nextInt();
			int d = 8*N + 1;
			int dr = (int)Math.sqrt(d);
			if (dr * dr != d) {
				System.out.println("No");
				return;
			}

			final int k = (1 + dr) / 2;
			List<Integer>[] sets = new List[k];
			for (int i = 0; i < k; ++i) {
				sets[i] = new ArrayList<>(k);
			}

			int n = 1;
			for (int i = 1; i < k; ++i) {
				for (int j = 0; j < i; ++j) {
					sets[j].add(n);
					sets[i].add(n);
					++n;
				}
			}

			System.out.println("Yes");
			System.out.println(k);
			for (int i = 0; i < k; ++i) {
				System.out.print(sets[i].size());
				for (int v : sets[i]) {
					System.out.printf(" %d", v);
				}
				System.out.println();
			}
		}
	}
}


Measured memory_bytes: 105292
n, x, *a = map(int, open(0).read().split())
a.sort()
cnt = 0
for i in range(n):
    if i == n-1:
        if x == a[i]:
            cnt += 1
        break
        
    if x >= a[i]:
        x -= a[i]
        cnt += 1
    else:
        break

print(cnt)

Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
using namespace std;
int s[3010][3010];
int a[2][1010][1010];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		int x,y;
		char c;
		cin>>x>>y>>c;
		if(c=='B')
		{
			y+=k;
		}
		x%=2*k;
		y%=2*k;
		s[x][y]++;
		s[x+k][y+k]++;
		s[x][y+k]--;
		s[x+k][y]--;
	}
	for(int i=0;i<3*k;i++)
	{
		for(int j=0;j<3*k;j++)
		{
			s[i][j+1]+=s[i][j];
		}
	}
	for(int i=0;i<3*k;i++)
	{
		for(int j=0;j<3*k;j++)
		{
			s[i+1][j]+=s[i][j];
		}
	}
	int ans=0;
	for(int i=0;i<3*k;i++)
	{
		for(int j=0;j<3*k;j++)
		{
			int p=(i/k+j/k)%2;
			a[p][i%k][j%k]+=s[i][j];
		}
	}
	for(int p=0;p<2;p++)
	{
		for(int i=0;i<k;i++)
		{
			for(int j=0;j<k;j++)
			{
				ans=max(ans,a[p][i][j]);
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 43648
# 2019-11-15 13:51:51(JST)
import sys
# import collections
import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 




mod = 2019

def main():
    l, r = [int(x) for x in sys.stdin.readline().split()]

    if l + 2019 <= r:
        m = l + 2018
    else:
        m = r
    
    minimum = 2018
    for i in range(l, m):
        for j in range(i+1, m+1):
            minimum = min(minimum, i * j % mod)
    
    print(minimum)

if __name__ == "__main__":
    main()


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

int main(){
  int n,p[100],maxi= -100,v=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> p[i];
    if(p[i]>maxi){
      maxi=p[i];
    }
    v+=p[i];
  }
cout << v-(maxi/2) << endl;

}


Measured memory_bytes: 256
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

A = list(itertools.permutations(range(1, N+1)))

for a in range(len(A)):
    if A[a] == P:
        p = a
    if A[a] == Q:
        q = a

print(abs(p - q))


Measured memory_bytes: 13816
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (998244353ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	a %= MOD;
}

int a[334];
ll dp[2][181818];

int main(void){
	int n,i,j,p=0,q=1,s=0;
	ll ans=332748118ll;
	cin >> n;
	for(i=0; i<n; ++i){
		ans *= 3;
		ans %= MOD;
		cin >> a[i];
		s += a[i];
	}
	dp[0][90909] = 1ll;
	for(i=0; i<n; ++i){
		for(j=0; j<181818; ++j){
			dp[q][j] = 0ll; 
		}
		for(j=0; j<181818; ++j){
			if(0 <= j+a[i] && j+a[i] < 181818){
				dp[q][j+a[i]] += dp[p][j];
				dp[q][j+a[i]] %= MOD;
			}
			if(0 <= j-a[i] && j-a[i] < 181818){
				dp[q][j-a[i]] += (dp[p][j]*2)%MOD;
				dp[q][j-a[i]] %= MOD;
			}
		}
		swap(p,q);
	}
	for(j=90909; j<181818; ++j){
		ans += (MOD-dp[p][j]);
		ans %= MOD;
	}
	p = 0; q = 1;
	for(j=0; j<90909; ++j){
		dp[p][j] = 0ll; 
	}
	dp[p][0] = 1ll;
	for(i=0; i<n; ++i){
		for(j=0; j<90909; ++j){
			dp[q][j] = 0ll; 
		}
		for(j=0; j<90909; ++j){
			dp[q][j] += dp[p][j];
			dp[q][j] %= MOD;
			dp[q][j+a[i]] += dp[p][j];
			dp[q][j+a[i]] %= MOD;
		}
		swap(p,q);
	}
	if(!(s%2)){
		ans += dp[p][s/2];
		ans %= MOD;
	}
	ans *= 3ll;
	ans %= MOD;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3072
n = int(raw_input())
num_list = [int(raw_input()) for i in xrange(n)]

minv = num_list[0]
maxv = -1000000000

for i in xrange(1, n):
  tmp = num_list[i] - minv
  maxv = tmp if tmp > maxv else maxv
  minv = num_list[i] if minv > num_list[i] else minv
  # print "i = %d, tmp = %d, maxv = %d, minv = %d" % (i, tmp, maxv, minv)

print maxv

Measured memory_bytes: 12532
import sys
input = sys.stdin.readline

n = int(input())
s = [int(input()) for _ in range(n)]
s.sort()

ans = sum(s)

if ans % 10 != 0:
    print(ans)
    sys.exit()
else:
    for i in s:
        if i % 10 != 0:
            print(ans - i)
            sys.exit()
print(0)


Measured memory_bytes: 38384
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
const int mm=1e6;
double d[mm];
int main()
{
	ll n,m,i,j,a,b,c;
	cin>>n>>m; double s=0,k; ll  ss=0;
	for(i=0;i<n;i++)
	{
	cin>>d[i];s+=d[i];
    }
    k=s/4/m;
    for(i=0;i<n;i++)
    {
    	if(d[i]>=k)
    	ss++;
	}
	if(ss>=m)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int *r, *c;
int cache[105][105];

int main() {
  int n, i;

  scanf("%d", &n);

  r = (int *) malloc(sizeof(int)*n);
  c = (int *) malloc(sizeof(int)*n);
  memset(cache, -1, sizeof(cache));

  for(i = 0; i < n; i++) {
    scanf("%d %d", &r[i], &c[i]);
  }

  printf("%d\n", cost(0, n-1));

  free(r);
  free(c);

  return 0;
}

int cost(int a, int b) {
  if (a == b) {
    return 0;
  }
  if (cache[a][b] == -1) {
    int total, m;
    cache[a][b] = 100000000;

    for(m = a; m < b; m++) {
      total = cost(a, m) + cost(m+1, b) + r[a]*c[m]*c[b];
      if (total < cache[a][b])
        cache[a][b] = total;
    }
  }
  return cache[a][b];
}



Measured memory_bytes: 2040
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	int n, m;
	ll k;
	cin >> n >> m >> k;
	vector<int> a(n), b(m);
	vector<ll> acca(n), accb(m);
	ll suma = 0;
	rep(i, n)
	{
		cin >> a[i];
		suma += a[i];
		acca[i] = suma;
	}
	ll sumb = 0;
	rep(i, m)
	{
		cin >> b[i];
		sumb += b[i];
		accb[i] = sumb;
	}
	int ans = 0;
	rep(i, n)
	{
		ll rest = k - acca[i];
		int cnt = i + 1;
		if (rest < 0)
		{
			break;
		}
		else
		{
			int ite = upper_bound(all(accb), rest) - accb.begin();
		
				cnt += ite;
			
			ans = max(ans, cnt);
		}
	}
	rep(i, m)
	{
		ll rest = k - accb[i];
		int cnt = i + 1;
		if (rest < 0)
		{
			break;
		}
		else
		{
			int ite = upper_bound(all(acca), rest) - acca.begin();

				cnt += ite;
			
			ans = max(ans, cnt);
		}
	}
	cout << ans << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


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

int main()
{
    long a,b;
    cin >> a >> b;
    if(a==0||b==0){
        cout << "Zero" << endl;
    }else if(a<0&&b>0){
        cout << "Zero" << endl;
    }else if(a>0&&b>>0){
        cout << "Positive" << endl;
    }else{
        a+=2147483647;
        b+=2147483647;
        if((a%2+b%2)%2){
            cout << "Positive" << endl;
        }else{
            cout << "Negative" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
//abc151E
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b) {
  return *(int*) a - *(int*) b;
}

long long gya(long long a) { //逆元を求める
  long long m=1000000007, b=m, u=1, v=0, c, t;
  while(b){
    t=a / b; //何これ
    a-=t * b, u-=t * v; //何これ
    c=a, a=b, b=c, c=u, u=v, v=c; //swap
  }
  return (u + m) % m;
}
long long xa=1, ya=1, ret=1;
long long com(int x, int y) { //xCy
  int i;
  long long mod=1000000007;
  if(y > x - y) y=x - y;
  for(i=0; i < y; i++)
    xa=xa * (x - i) % mod, ya=ya * (i + 1) % mod;
  //printf("xa=%lld, gya(%lld)=%lld\n",xa,ya,gya(ya));
  ret=xa * gya(ya) % mod;
  return ret;
}

long long com2(int x, int y) { //xCy+alpha
  long long mod=1000000007;
  ret=ret * x % mod * gya((x - y)) % mod;
  //printf("com2 ret=%lld\n",ret);
  return ret;
}

int main(void) {

  int n, k, i;
  long long ans=0, mod=1000000007;
  scanf(" %d %d", &n, &k);
  int a[n];
  for(i=0; i < n; i++)
    scanf(" %d", &a[i]);
  qsort(a, n, sizeof(int), compare_int);

  //ans=(ans + (a[k - 1] - a[n - k]) * com(k - 1, k - 1)) % mod;
  ans=(ans + (a[k - 1] - a[n - k])) % mod;
  //printf("%lld\n",com(k - 1, k - 1));

  for(i=1; i < n - k + 1; i++)
    ans=(ans + (a[i + k - 1] - a[n - k - i]) * com2(i + k - 1, k - 1)) % mod;

  printf("%lld", ans);
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int a, b;
	cin >> a >> b;
	int cnt = 0;
	int now = 1;
	while (now < b) {
		now = now - 1 + a;
		++cnt;
	}
	cout << cnt  << '\n';
	return 0;
}


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

int main(void) {
	char S[1024];
	if (scanf("%1023s", S) != 1) return 1;
	printf("%s%s\n", S, S[strlen(S) - 1] == 's' ? "es" : "s");
	return 0;
}


Measured memory_bytes: 1736
//Author - Rahil Malhotra
#include "bits/stdc++.h"
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int n,x,m;
int arr[100005];
int32_t main()
{
    IOS;
    cin>>n>>x>>m;
    int sum=x;
    int last=x;
    map<int,int>mp;
    arr[1]=x;
    mp[1]=x;
    int ind1=0,ind2=0;
    for(int i=2;i<=n;i++)
    {
        last=(last*last)%m;
        if(mp.find(last)==mp.end())
            mp[last]=i;
        else
        {
            ind1=mp[last];
            ind2=i;
            break;
        }
        sum+=last;
        arr[i]=last;
        arr[i]+=arr[i-1];
    }
    if(ind1==0)
        print(sum);
    else
    {
        int cylength=ind2-ind1;
        int lefttotake=n-ind2+1;
        int full=lefttotake/cylength;
        int moded=lefttotake%cylength;
        sum+=(arr[ind2-1]-arr[ind1-1])*full;
        sum+=(arr[ind1+moded-1]-arr[ind1-1]);
        print(sum);
    }
}   


Measured memory_bytes: 7068
/* Bismillahir Rahmanir Rahim */
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#include<string>
#include<stdlib.h>
#define   mod          1000000007
#define   lp(i,a,b)    for(ll i=a;i<=b;i++)
#define   ll           long long int
#define   ull          unsigned long long int
#define   tst          int t;cin>>t;while(t--)
#define   pb           push_back
#define   vi(v)        vector<int>v;
#define   vl(v)        vector<ll>v;
#define   vs           vector<string>v
#define   rslt(x)      cout<<x<<endl;
#define   mp(x,y)      make_pair(x,y)
#define   yes          rslt("YES");
#define   no           cout<<"NO"<<endl;
#define   srt(v)       sort(v.begin(),v.end())
#define   rvs(v)       reverse(v.begin(),v.end());
#define   AR           ios::sync_with_stdio(false);cin.tie(0);
#define   gcd(a,b)     __gcd(a,b)
#define   lcm(a,b)     (a/gcd(a,b))*b
#define   max          1000007
#define   str          int s[200000];
#define   coutv(v)     for(auto it:v)cout<<it<<' ';cout<<endl;
#define   cinv(v)      for(auto &it:v)cin>>it;
using namespace std;
int main()
{
    string s;
    cin>>s;
    ll cnt=0;
    lp(i,0,2)
    if(s[i]=='R')
        cnt++;
    ll cnt1=1;
    lp(i,0,1)
    {
        if(s[i]=='R' && s[i+1]=='R')
            cnt1++;
    }
    if(cnt>0)
cout<<cnt1<<endl;
else cout<<0<<endl;





    return 0;

}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];


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

    rep(i,S.size()){
        cout << "x" ;
    }
    cout << endl;

}

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

int main()
{
    string s; cin>>s;
    map<char, int> a;
    for(auto& c: s) ++a[c];
    for(auto& c: s) if (a[c]!=2) {
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e3+1;
vector<int>graph[N];
int dp[N];
int visited[N]={0};
ll int mod=1e9+7;
vector<string>mat;
ll int solve(int n,int m){
   ll int dp[n+1][m+1];
    for(int i=0;i<n;i++){

        for(int j=0;j<mat[i].length();j++){

            if(i==0 || j==0){
                if(mat[i][j]=='#'){
                    dp[i][j]=0;
                }
                else{
                    if(i==0){
                        if(dp[i][j-1]==0){
                            dp[i][j]=0;
                        }
                        else{
                            dp[i][j]=1;
                        }
                    }
                    else{
                        if(dp[i-1][j]==0){
                            dp[i][j]=0;

                        }
                        else{
                            dp[i][j]=1;
                        }
                    }
                }
                continue;
            }

            else if(mat[i][j]=='#'){
                dp[i][j]=0;
            }

            else{

                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            }

        }

    }

//    for(int i=0;i<n;i++){
//        for(int j=0;j<m;j++)
//        {
//            cout<<dp[i][j]<<" ";
//        }
//        cout<<endl;
//    }
    return (dp[n-1][m-1])%mod;



}
int main()
{
    int n,m;
    cin>>n>>m;

   for(int i=0;i<n;i++){
       string s;
       cin>>s;
       mat.push_back(s);
   }
//    for(int i=0;i<n;i++){
//        for(int j=0;j<mat[i].length();j++){
//            cout<<mat[i][j]<<" ";
//        }
//        cout<<endl;
//    }
  cout<<solve(n,m)<<endl;

    return 0;
} 


Measured memory_bytes: 9216
l, r = map(int, input().split())
if r - l >= 2019:
    print(0)
    exit()
res = float('inf')
for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
        res = min(res, (i * j) % 2019)
print(res)

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
MOD = 10**9+7
N,K = map(int,input().split())
edge = [[] for _ in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)

ans = 1
def dfs(now, par,num):
    global ans
    ans = ans*num%MOD
    num = K-1
    if par != -1:
        num -= 1
    for ch in edge[now]:
        if ch != par:
            dfs(ch,now,num)
            num -= 1

dfs(0,-1,K)
print(ans)

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