akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll arr[200005], rev[200005], pre[200005], suf[200005];
int main()
{
	int len, n;
	scanf("%d%d", &len, &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", arr + i);
	}
	arr[++n] = len;
	for (int i = 0; i <= n; i++) {
		rev[n - i] = len - arr[i];
	}
	for (int i = 0; i <= n; i++) {
		pre[i] = (i ? pre[i - 1] : 0) + arr[i];
		suf[i] = (i ? suf[i - 1] : 0) + rev[i];
	}
	ll ans = 0;
	for (int i = 0, j = n - 1; i < n; i++, j--) {
		auto calc = [&] (int t) {
			ll res = pre[i] - (i >= t ? pre[i - t] : 0);
			res += suf[j] - (j >= t ? suf[j - t] : 0);
			return res << 1;
		};
		ans = max(ans, calc(min(i, j + 1)) - arr[i]);
		ans = max(ans, calc(min(i + 1, j)) - rev[j]);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll d,n,ans=1;
  cin >> d >> n;
  for(int i = 0;i < d;i++) ans*=100;
  cout << (n != 100 ? ans * n : ans * (n+1) ) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N;
        cin >> N;

        vector<string> S(N);
        int mid = 0;
        int n = 0, m = 0, k = 0;

        rep(i, 0, N) {
            cin >> S[i];
            for (int j = 0; j + 1 < S[i].size(); ++j) {
                string tmp = "";
                tmp += S[i][j];
                tmp += S[i][j + 1];
                if (tmp == "AB") mid++;
            }
            if (S[i].front() == 'B' && S[i].back() == 'A') {
                k++;
            } else if (S[i].front() == 'B') {
                n++;
            } else if (S[i].back() == 'A') {
                m++;
            }
        }

        int ans = mid;
        if (n + m > 0) {
            ans += min(n, m);
            ans += k;
        } else if (k > 0) {
            ans += k - 1;
        }
        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


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

int main(){
	string s;
	cin >> s;
	vector<char> ans;
	rep(i,s.size()){
		if(s[i] == '1' || s[i] == '0') ans.push_back(s[i]);
		if(s[i] == 'B' && ans.size()) ans.pop_back();
	}
	for(auto x : ans){
			cout << x;
	}
	cout << endl;
}

Measured memory_bytes: 3540
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define RREP(i, a, n) for(int i=n-1; i>=a; i--)
#define MOD 1000000007

int main()
{
	int N, A, B;
	string s;
	cin >> N >> A >> B >> s;

	int path = 0, pathB = 0;
	REP(i, 0, N) {
		if (s[i] == 'c') cout << "No" << endl;
		else if (s[i] == 'a' && path < A + B) {
			cout << "Yes" << endl;
			path++;
		}
		else if (s[i] == 'b') {
			if (path < A + B && pathB < B) {
				cout << "Yes" << endl;
				path++;
			}
			else {
				cout << "No" << endl;
			}
			pathB++;
		}
		else cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 896
#include<cstdio>
#include<cmath>

using namespace std;

int main(){
    int k;
    scanf("%d", &k);
    int ans;

    if(k % 2 == 0){
        ans = pow(k / 2, 2);    
    }else{
        ans = (k / 2) * (k / 2 + 1);    
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int n,s,a,b;
	cin>>n;
	a=n;
	b=n;
	s=0;
	while(1){
		a=b%10;
		b=b/10;
		s=s+a;
		if(b==0) break;
	}
	if(n%s==0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){
    int n,x; cin>>n>>x;
    int a=x,b=(n-x),sum=n;
    if(a>=b) swap(a,b);
    while(b%a){
        sum+=b/a*2*a;
        int t=a;
        a=b%a;
        b=t;
    }
    sum+=b*2-a;
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

#define N 105
ll n;
struct point{
    ll x;ll y;
    dd k;
};
bool comp(point a,point b){
    return a.k>b.k;
}
point p[N];
ll ans=0;
void cal(){
    ll px=0,py=0;
    vector<point>up,dw;
    rep(i,0,n-1){
        if(p[i].x<=0&&p[i].y>=0){
            px+=p[i].x;
            py+=p[i].y;
        }else if(p[i].x>=0&&p[i].y<=0){
            
        }else if(p[i].x>0){
            p[i].k=(dd)p[i].y/(dd)p[i].x;
            up.pb(p[i]);
        }else{
            p[i].k=(dd)p[i].y/(dd)p[i].x;
            dw.pb(p[i]);
        }
    }
    sort(up.begin(),up.end(),comp);
    sort(dw.begin(),dw.end(),comp);
    ll us=up.size();
    ll ds=dw.size();
    point dp[us+1][2],ep[ds+1][2];
    rep(j,0,1)rep(i,0,us)dp[i][j].x=dp[i][j].y=0;
    rep(j,0,1)rep(i,0,ds)ep[i][j].x=ep[i][j].y=0;
    rep(i,0,us-1){
        dp[i+1][0].x=dp[i][0].x+up[i].x;
        dp[i+1][0].y=dp[i][0].y+up[i].y;
    }
    for(ll i=us-1;i>=0;i--){
        dp[i][1].x=dp[i+1][1].x+up[i].x;
        dp[i][1].y=dp[i+1][1].y+up[i].y;
    }
    rep(i,0,ds-1){
        ep[i+1][0].x=ep[i][0].x+dw[i].x;
        ep[i+1][0].y=ep[i][0].y+dw[i].y;
    }
    for(ll i=ds-1;i>=0;i--){
        ep[i][1].x=ep[i+1][1].x+dw[i].x;
        ep[i][1].y=ep[i+1][1].y+dw[i].y;
    }
    /*rep(i,0,1){
        rep(j,0,us){
            cout<<dp[j][i].x<<" "<<dp[j][i].y<<endl;
        }
    }*/
    rep(k,0,1){
        rep(l,0,1){
            rep(i,0,us){
                rep(j,0,ds){
                    ll nx=px+dp[i][k].x+ep[j][l].x;
                    ll ny=py+dp[i][k].y+ep[j][l].y;
                    Max(ans,nx*nx+ny*ny);
                    //cout<<nx*nx+ny*ny<<endl;
                }
            }
        }
    }
}

int main(){fastio
    cin>>n;
    rep(i,0,n-1){
        cin>>p[i].x>>p[i].y;
    }
    cal();
    rep(i,0,n-1)p[i].x*=-1;cal();
    rep(i,0,n-1)p[i].y*=-1;cal();
    rep(i,0,n-1)p[i].x*=-1;cal();
    dd sq=(dd)sqrt((dd)ans);
    cout<<setprecision(15)<<sq<<endl;
    
    return 0;
}


Measured memory_bytes: 256
let () =
  Scanf.scanf "%d %d %d %d %d" @@ fun a b c x y ->
  let m = min x y in
  let p1 = min (a+b) (2*c) * m
  and p2 = min a (2*c) * (x-m)
  and p3 = min b (2*c) * (y-m)
  in Printf.printf "%d\n" (p1+p2+p3)

Measured memory_bytes: 384
n = input().split()
p = []

for i in range(int(n[0])):
    p.append(int(n[1]))

for i in range(int(n[2])):
    a = input()
    a = int(a)
    p[a - 1] += 1

for i in p:
    i -= int(n[2])
    if 0 < i:
        print("Yes")
    else:
        print("No")

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

#define ll long long

ll min(ll x, ll y){
  if (x>y){
    return y;
  }else{
    return x;
  }
}

ll max(ll x, ll y){
  if (x<y){
    return y;
  }else{
    return x;
  }
}



int main(void){
  ll H,W;

  scanf("%lld%lld",&H,&W);

  if(H%3==0 || W%3==0){
    printf("0\n");
    return 0;
  }

  ll ans;
  ans = min(H,W);

  ll s1,s2,s3;
  ll mx,mn;
  for(ll r = 1; r < W; r++){
    s1 =   r   *   H    ;
    s2 = (W-r) * (H/2)  ;
    s3 = (W-r) * (H-H/2);

    mx = max(max(s1,s2),s3);
    mn = min(min(s1,s2),s3);

    ans = min(ans,mx-mn);
  }

  ll tmp;
  tmp = H; H = W; W = tmp;
  for(ll r = 1; r < W; r++){
    s1 =   r   *   H    ;
    s2 = (W-r) * (H/2)  ;
    s3 = (W-r) * (H-H/2);

    mx = max(max(s1,s2),s3);
    mn = min(min(s1,s2),s3);

    ans = min(ans,mx-mn);
  }

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

  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

const int MaxN = 1e5;
int n, a[5][MaxN + 5];
LL num[5][MaxN + 5], sum[5][MaxN + 5];

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= 3; i++) {
		for(int j = 1; j <= n; j++) scanf("%d", &a[i][j]);
		sort(a[i] + 1, a[i] + n + 1);
	}
	for(int j = 1; j <= n; j++) num[1][j] = 1, sum[1][j] = sum[1][j - 1] + num[1][j];
	for(int i = 2; i <= 3; i++) {
		int pos = 1;
		for(int j = 1; j <= n; j++) {
			while(a[i - 1][pos] < a[i][j] && pos <= n) pos++;
			num[i][j] = sum[i - 1][pos - 1];
		}
		for(int j = 1; j <= n; j++) sum[i][j] = sum[i][j - 1] + num[i][j];
	}
	printf("%lld\n", sum[3][n]);
}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll n,m;
    cin >>n>>m;
    
    cout << (n-1)*(m-1) << endl;


    return 0;
    

}

Measured memory_bytes: 3596
n,m,x = map(int,input().split())
B=[list(map(int,input().split())) for i in range(n)]
ANS = 1 << 100
for i in range(1 << n):
    SCORE = [0] * m
    MONEY = 0
    for j in range(n):
        if (1 << j) & i != 0:
            MONEY+=B[j][0]
            for k in range(m):
                SCORE[k] += B[j][k+1]
    if min(SCORE) >= x:
        ANS = min(ANS,MONEY)
if ANS == 1 << 100:
    print(-1)
else:
    print(ANS)

Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
const long long int sMod = 998244353;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n;
    cin >> n;
    vector<PLL> vp(n);
    rp(i,n){
        ll a,b;
        cin >> a >> b;
        vp[i]=mp(b,a);
    }
    sort(all(vp));
    ll time=0;
    rp(i,n){
        time+=vp[i].se;
        if(vp[i].fi<time){
            print("No");
            return;
        }
    }
    print("Yes");
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    string N_str; cin>>N_str;
    int sum = 0;
    rep(i,N_str.size()){
        sum += charToInt(N_str.at(i));
    }
    if(sum%9==0){
        cout<<"Yes"<<endl;

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

    return 0;
}

Measured memory_bytes: 3708
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#define int long long
using namespace std;
signed main() {
	//std::map<long long, long long>test;
	int n, k, a = 100000000000000, b = 0; string s; cin >> n;
	for (int h = 0; h < n; h++) {
		cin >> k;
		if (a > k) {
			a = k; b = h + 1;
		}
	}
	
	cout << b << endl;
}


Measured memory_bytes: 3112
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    k = int(input())
    tmp = 7
    cnt = 0
    if k%2 == 0 or k%5 == 0:
        print(-1)
        return

    while 1:
        tmp %= k
        cnt += 1
        if tmp == 0:
            break
        tmp = 10*tmp%k
        tmp += 7
    print(cnt)



if __name__ == '__main__':
    main()

Measured memory_bytes: 9188
g=[[] for _ in xrange(100)]
i=-1
while 1:
    i+=1
    try:
        g[i]=map(int,raw_input().split(","))
    except:
        dp=[[0]*101 for _ in xrange(101)]
        dp[0][0]=g[0][0]
        for j in xrange(1,i):
            for k in xrange(len(g[j])):
                if j<=i/2:
                    dp[j][k]=max(dp[j-1][k-1],dp[j-1][k])+g[j][k]
                else:
                    dp[j][k]=max(dp[j-1][k],dp[j-1][k+1])+g[j][k]
        print(dp[i-1][0])
        break

Measured memory_bytes: 6404
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;
const int mod=1e9+7;
ll m,n,a,b,c=1,d=1e9,e;

int main()
{
    std::ios::sync_with_stdio(0); std::cin.tie(0);
	cin>>m;
	if(m<=1000000000) cout<<0<<" "<<0<<" "<<0<<" "<<1<<" "<<m<<" "<<0;
	else if(m==1000000000000000000) cout<<0<<" "<<0<<" "<<1000000000<<" "<<0<<" "<<0<<" "<<1000000000; 
	else
	{
		n=m/1000000000;
		a=m/1000000000+1;
		b=a*1000000000-m;
		cout<<0<<" "<<0<<" "<<a<<" "<<b<<" "<<1<<" "<<1000000000;
	}
	return 0;
}


Measured memory_bytes: 3640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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



int main()
{
  ll N,Q; cin>>N>>Q;
  vector<vector<ll>> graph(N,vector<ll>(0));
  rep(i,N-1){
    ll a,b; cin>>a>>b; a--; b--;
    graph.at(a).push_back(b);
    graph.at(b).push_back(a);
  }
  vector<ll> counter(N,0);
  rep(i,Q){
    ll p,x; cin>>p>>x; p--;
    counter[p]+=x;
  }
  
  //bfs
  vector<int> checked(N,0);
  queue<ll> que;
  que.push(0);
  
  while(!que.empty()){
    ll v=que.front(); que.pop();
    checked.at(v)=1;
    for(auto nv:graph.at(v)){
      if(checked[nv]) continue;
      counter[nv]+=counter[v];
      que.push(nv);
    }
  }
  
  rep(i,N){
    if(i!=0) cout<<" ";
    cout<<counter[i];
  }
  cout<<endl;
  
  return 0;
}

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

int main() {
    int n;
    cin>>n;
    double sum=0;
    while(n--){
        double x;
        string y;
        cin>>x>>y;
        if(y=="JPY")sum+=x;
        else sum+=380000*x;
    }
    cout<<sum;
}

Measured memory_bytes: 256
#define ENABLE_LL
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;

#ifdef ENABLE_LL
#define int long long
#endif

#ifdef ENABLE_LL
#define I "%lld"
#define II "%lld%lld"
#define III "%lld%lld%lld"
#define IIII "%lld%lld%lld%lld"
#define IN "%lld\n"
#define IIN "%lld%lld\n"
#define IIIN "%lld%lld%lld\n"
#define IIIIN "%lld%lld%lld%lld\n"
#else
#define I "%d"
#define II "%d%d"
#define III "%d%d%d"
#define IIII "%d%d%d%d"
#define IN "%d\n"
#define IIN "%d%d\n"
#define IIIN "%d%d%d\n"
#define IIIIN "%d%d%d%d\n"
#endif

#ifdef __LOCALE__
#define see(a) std::cout << #a << "=" << a << std::endl
#define ses(a) std::cout << #a << "=" << a << " " 
#else
#define see(a) //std::cout << #a << "=" << a << std::endl
#define ses(a)
#endif
#define repe(a,b) for (int a=0;a<(int)b.size();a++)
#define rep(i,n) for (int i=0;i<n;i++)
#define repa(i,n) for (int i=1;i<=n;i++)
#define repi(i,a,b) for (int i=a;i<=b;i++) 
#define repb(i,a,b) for (int i=a;i>=b;i--)
typedef pair < int , int > pr;
typedef pair < pr  , int > prr;
#define L first
#define R second
template <class T> inline bool checkMin(T& a , T b) { return (a > b ? a=b,1 : 0); }
template <class T> inline bool checkMax(T& a , T b) { return (a < b ? a=b,1 : 0); }
class Scanner{ private: istream& ist;public: Scanner(istream& in):ist(in){} string next(){ string r; ist >> r; return r; } string nextLine(){ string r; getline(ist,r); return r; } int nextInt(){ int r; ist >> r; return r; } double nextDouble(){ double r; ist >> r; return r; }};
Scanner sc(cin);

const int N = 100005;
const int MOD = 1e9 + 7;
int a[N];
int n;

void init() {
    scanf(I,&n);
    rep (i,n) scanf(I,&a[i]); 
}

void solve() {
    vector < int > v[3];
    rep (i,3) v[i].push_back(-1);
    int ans = 1;
    rep (_,n) {
        int cnt=0; rep (i,3) if (v[i].back()+1 == a[_]) cnt++;
        (ans *= cnt) %= MOD;
        rep (i,3) if (v[i].back()+1 == a[_]) { v[i].push_back(a[_]); break; }  
    }
    printf(IN,ans);
}


#ifdef ENABLE_LL
#undef int
#endif
int main(){
    init();
    solve();
    return 0;
}


Measured memory_bytes: 2296
A,B,C=map(int,input().split())
if A==B==C and A%2==0: print(-1)
else:
    k=0
    while all(x%2==0 for x in [A,B,C]):
        A,B,C=(B+C)//2,(C+A)//2,(A+B)//2
        k+=1
    print(k)

Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let N: i32 = read();
    let i: i32 = read();
    let answer = N - (i - 1);
    println!("{}", answer);
}



Measured memory_bytes: 4352
import java.util.*;
public class Main {
    public static void main(String[] args) {	
	Main main = new Main();
    	main.solveB();
    }
    
    private void solveA() {
	Scanner sc = new Scanner(System.in);
    	int A = sc.nextInt();
    	int B = sc.nextInt();
	String s;
	if (A>=9 || B>=9){
	    s = ":(";
	}
	else{
	    s = "Yay!";
	}
    	System.out.println(s);
    }

    private void solveB() {
	Scanner sc = new Scanner(System.in);
	int D = sc.nextInt();
    	int N = sc.nextInt();
	int p = 1;

	for (int i=0;i < D;i++){
	    p *=100;
	}

	if (N==100) N = 101;
	
	System.out.println(p*N);
    }
}

Measured memory_bytes: 23636
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a[100];
	int n,l;
	cin>>n>>l;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n-1;i++){
		for(int j=0;j<n-1;j++){
			if(a[j]>=a[j+1]){
				string temp;
				temp=a[j+1];
				a[j+1]=a[j];
				a[j]=temp;
			}
		}
	}
	for(int i=0;i<n;i++){
		cout<<a[i];
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()

max_c = 0

for i in range(1, n):
    part1 = s[:i]
    part2 = s[i:]

    intersection = set(part1) & set(part2)

    count_intersection = len(intersection)

    if count_intersection >= max_c:
        max_c = count_intersection

print(max_c)


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

int main(){

ll a,b,c,d;
cin >> a >> b >> c >> d;
ll ans = max(a*c, max(a*d, max(b*c,b*d)));
cout << ans << endl;

}

Measured memory_bytes: 3596
from collections import defaultdict

n, x, y = map(int, input().split())
x -= 1
y -= 1

ctr = defaultdict(int)

for i in range(n):
    for j in range(i + 1, n):
        v = min(j - i, abs(x - i) + 1 + abs(j - y))
        ctr[v] += 1

for i in range(1, n):
    print(ctr[i])

Measured memory_bytes: 3948
from heapq import heappop, heappush
n = int(input())
g = [[] for _ in range(n)]

for _ in range(n-1):
    a, b, c = map(int, input().split())
    g[a-1].append((b-1, c))
    g[b-1].append((a-1, c))


def dijkstra(s,n,g):
    # g[i][j] : the cost of i→j  or g[i] = [(target, cost), ...]
    # must import heapq
    d = [10**18] * n
    d[s] = 0
    q = [(0,s)]
    while q:
        dist_u, u = heappop(q)
        if d[u] < dist_u:
            continue
        for v, c in g[u]:  # 'in g[u]' if g is an adj list.
            if d[v] > dist_u + c:
                d[v] = dist_u + c
                heappush(q, (d[v], v))
    return d




q, k = map(int, input().split())
d = dijkstra(k-1, n, g)

for _ in range(q):
    x, y = map(int, input().split())
    print(d[x-1]+d[y-1])


Measured memory_bytes: 90400
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	c := scanInts(n)

	p := []int{}
	pre := -1
	for i := 0; i < n; i++ {
		if pre == c[i] {
			continue
		}

		p = append(p, c[i])
		pre = c[i]
	}

	debug(p)
	cnt := map[int]int{}
	ans := 1
	
	for i := 0; i < len(p); i++ {
		ans = ans+cnt[p[i]]
		ans %= mod
		cnt[p[i]] = ans
	}

	fmt.Fprintln(wr, ans)
}

const mod = 1000000007


Measured memory_bytes: 16256
from math import gcd
n, k = map(int, input().split())
a = list(map(int, input().split()))
if max(a) < k:
    print("IMPOSSIBLE")
    exit()
if k in a:
    print("POSSIBLE")
    exit()
a_gcd = a[0]
for i in range(1, n):
    a_gcd = gcd(a_gcd, a[i])

if k % a_gcd == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 85024
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  int A,B;
  cin >> A >> B;
  if(A+B >= 24){
    cout << A+B-24 << endl;
  }
  else{
    cout << A+B << endl;
  }
}


Measured memory_bytes: 256
/* ***************************************
Author        :Scau.ion
Created Time  :2016/10/15 19:59:15 UTC+8
File Name     :ion.cpp
*************************************** */

#include <bits/stdc++.h>

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

using namespace std;

int main()
{
    IOS;
	int n;
    cin>>n;
    LL a=1,b=1;
    for (int j=1;j<=n;++j)
    {
        LL x,y;
        cin>>x>>y;
        LL cs=1;
        cs=max(cs,(a+x-1)/x);
        cs=max(cs,(b+y-1)/y);
        a=cs*x;
        b=cs*y;
    }
    cout<<a+b<<endl;
	return 0;
}


Measured memory_bytes: 256
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()
 
show_flg=False
show_flg=True

ans=0

n,x=LI()
if x==1 or x==2*n-1:
    print('No')
    exit()
print('Yes')
a=[i for i in range(2,2*n-1) if i!=x]
ans=a[:n-2]+[1,x,2*n-1]+a[n-2:]

for i in range(2*n-1):
    print(ans[i])

Measured memory_bytes: 58732
/*
 * ABC094_A.cpp
 *
 *  Created on: May 21, 2018
 *      Author: 13743
 */
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}



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

	int A,B,X;
	cin >> A >> B >> X;
	if(X-A < 0 || X-A > B) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
}






Measured memory_bytes: 256
//#pragma GCC optimize(2) 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define clr(a,b) memset(a,b,sizeof(a))
ll n,m,k,ans;
ll f[100005];
ll mod=1000000007;
ll pow1(ll x,ll y){
	ll a=1,b=x;while(y){if(y&1)a=(a*b)%mod;b=(b*b)%mod;y>>=1;}
	return a;
}
int main(){
	//freopen("P1429_6.in","r",stdin);
	//freopen("match.out","w",stdout);
    ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k;
	for(ll i=k;i>=1;i--){
		f[i]=pow1(k/i,n);
		for(int j=2;i*j<=k;j++){
			f[i]=(f[i]-f[i*j]+mod)%mod;
		}
		ans=(ans+i*f[i])%mod;
	}
	cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 4336
length = int(input())
li = list(map(int,input().split()))

judge = True

for i in range(length):
  a = li[i]
  if a % 2 == 0:
      if not (a % 3 == 0 or a % 5 == 0):
          judge = False
          break;
  
if judge:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 38384
#include <stdio.h>

int abs(int);
int main(void){
    int N,L,a[105],o=0;
    
    scanf("%d%d",&N,&L);
    
    int s=N*(N+1)/2+(L-1)*N;
    
    for(int i=1;i<=N;i++){
        if(0==L+i-1){
            o=1;
            break;
        }
    }
    
    if(o==1){
        printf("%d",s);
    }else if(L<0){
        printf("%d",s+1-L-N);
    }else{
        printf("%d",s-L);
    }
    return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

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

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

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

    ll N, M; cin >> N >> M;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    sort(all(a));
    ll x = a[0]/2;
    rep(i, N) {
        x = lcm(x, a[i]/2);
    }
    ll y = x, cnt = 1, ans = 0, k = 0;
    ll p = 0, q = 0;
    while (y <= M) {
        y = cnt * x + k;
        cnt++;
        rep(i, N) {
            if ((y - a[i]/2) % a[i] != 0) break;
            if (i == N - 1) {
                ans++;
                if (ans == 1) p = y;
                else if (ans == 2) q = y;
                // if (ans <= 100) cout << y << endl;
            }
        }
        if (q != 0 && k == 0) {
            k = x;
            x = q - p;
            cout << ((M - k) +(x - 1)) / x << endl;
            break;
        }
    }
    if (ans <= 1) {
        cout << ans << endl;
    }
    // cout << ans << endl;
}

Measured memory_bytes: 1024
s = list(input())
ans = "Yes"
for i in range(0, len(s), 2):
    if s[i] == "L":
        ans = "No"
        break

for j in range(1, len(s), 2):
    if s[j] == "R":
        ans = "No"
        break
    
print(ans)


Measured memory_bytes: 38384
N = int(input())
X = list(map(int,input().split()))
Y = sorted(X)
med = (Y[N//2] + Y[N//2-1])/2
for i in range(N):
    if X[i] <= med:
        print(Y[N//2])
    else:
        print(Y[N//2-1])

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

long long solve(long long, long long, int);

long long solve2(long long A, long long B, int n) {
    assert (A <= B);
    assert (B < 2LL << n);
    if (1LL << n <= A) return 2LL << n;
    if (B < 1LL << n) return (1LL << n) + solve2(A, B, n-1);
    return solve(0, A, n-1) + solve(B - (1LL << n), (1LL << n) - 1, n - 1);
}

long long solve(long long A, long long B, int n = 60) {
    //cerr << A << " " << B << " " << n << endl;
    assert(A <= B);
    if (A == B) return 1;
    if (A == 0) {
        while (((B >> n) & 1) == 0) n--;
        return 2LL << n;
    }
    while (B < 1LL<<n) n--;
    if (B == (2LL << n) - 1)
        return (((2LL << n) - 1) ^ A) + 1;
    if (A >= 1LL << n)
        return solve(A - (1LL << n), B - (1LL << n), n - 1);
    B -= 1LL << n;
    if (B >= A - 1)
        return (1LL << n) + solve(A, (1LL << n) - 1, n - 1);
    else
        return solve2(B, A, n-1) + solve(A, (1LL << n) - 1, n - 1);
}

int bruteforce(int A, int B) {
    int N = 1;
    while (B >= N) N *= 2;
    vector<bool> p(N, false);
    p[0] = true;
    for (int i = A; i <= B; i++) {
        for (int j = 0; j < N; j++) {
            if (p[j]) p[j|i] = true;
        }
    }
    return count(p.begin(), p.end(), true) - 1;
}

int main() {
    long long a, b; cin >> a >> b;
    cout << solve(a, b) << endl;

    // for (int a = 1; a < 300; a++)
    //     for (int b = a; b <= 300; b++) {
    //         long long ans = solve(a, b), expect = bruteforce(a, b);
    //         if (ans != expect)
    //             cerr << "WA " << a << " " << b << " expect " << expect << ", got " << ans << endl;
    //     }
}


Measured memory_bytes: 3168
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> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let _: u32 = read();
    let k: u32 = read();
    let x: Vec<u32> = read_vec();

    let s = x.into_iter()
        .map(|x| if x < k - x { x } else { k - x })
        .map(|x| x * 2)
        .fold(0, |s, x| s + x);
    println!("{}", s);
}

Measured memory_bytes: 4352
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int cap = a - b;
        if (cap > c) {
            System.out.println("0");
        }else {
            System.out.println(c - cap);
        }
    }
}


Measured memory_bytes: 23892
/**
 *    author:  ismail
 *    created: 20.01.2020  22:00:58
 **/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define sz(a) a.size()
#define all(a) a.begin(), a.end()
#define w(a) std::cerr << #a << " : " << (a) << "\n";

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, ans = 1;
  cin >> n >> m;
  for (int i = 1, d; i < n; i++) {
    cin >> d;
    if (d <= m) {
      ans++;
      m = d;
    }
  }
  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <string>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, ans;
  cin >> n;
  ans = ((n + 1000 - 1) / 1000) * 1000 - n;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
using D = pair<double, double>;
const int mod2 = 998244353;
const int mod = (int)1e9 + 7, inf = (int)1e16;
const string sp = " ";

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] *= fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	int ans= fact[n] * modpow(fact[n - r], mod - 2) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

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

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

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int>factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

class unionfind {
private:
	int par[200010], rankth[200010], sizeth[200020];
public:
	void init(int n) {
		rep(i, n) {
			par[i] = i;
			rankth[i] = 0;
			sizeth[i] = 1;
		}
	}
	int root(int x) {
		while (par[x] != x) {
			x = par[x] = par[par[x]];
		}
		return x;
	}

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

	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (rankth[x] < rankth[y]) {
			par[x] = y;
			sizeth[y] += sizeth[x];
		}
		else {
			par[y] = x;
			if (rankth[x] == rankth[y]) rankth[x]++;
			sizeth[x] += sizeth[y];
		}
	}
};


signed main() {
	string s;
	cin >> s;
	int n = s.size();
	rep(i, n) {
		if (i & 1) {
			if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D') continue;
			cout << "No" << endl;
			return 0;
		}
		else {
			if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D') continue;
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
/*-------------------------------------------------
|  __                                       __    |
| |  |--.-----.---.-.----.----.-----.-----.|  |_  |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _| |
| |_____|_____|___._|____|____|_____|   __||____| |
|                                   |__|          |
-------------------------------------------------*/
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>
typedef long long lint; using namespace std;
#define rep(counter, limit) for (int counter = 0; counter < (limit); counter++)
#define INF 1000000000000
#define MOD 10000007
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){cin.tie(0);ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}setupios;
int main() {

  int a,b;
  cin>>a>>b;
  int num=1;
  int ans=0;
  while(num<b){
    num--;
    num+=a;
    ans++;
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 256
#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 DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
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 namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int main(void){
    int n; cin >> n;
    vi a(n, -1);
    int res = 0;
    rep(i, n){
        int v; cin >> v; v--;
        if(a[v] == i) res++;
        a[i] = v;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 640
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		String S = sc.next();

		int ans = 0;

		switch(S) {
		case "SSS":
			ans = 0;
			break;
		case "SSR":
			ans = 1;
			break;
		case "SRS":
			ans = 1;
			break;
		case "SRR":
			ans = 2;
			break;
		case "RSS":
			ans = 1;
			break;
		case "RSR":
			ans = 1;
			break;
		case "RRS":
			ans = 2;
			break;
		case "RRR":
			ans = 3;
			break;
		}
		System.out.println(ans);

	}
}


Measured memory_bytes: 35676
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) REP(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
typedef long long ll;

int main() {
    int h, w;
    cin >> h >> w;
    int map[h][w];
    char bom[h][w];
    int dx[] = {1, 1, -1, -1, 1, 0, -1, 0};
    int dy[] = {1, -1, -1, 1, 0, 1, 0, -1};
    rep(i, h) rep(j, w) map[i][j] = 0;
    rep(i, h) {
        string s;
        cin >> s;
        rep(j, w) {
            bom[i][j] = s[j];
            if (s[j] == '#') {
                rep(k, 8) {
                    int y = i + dy[k];
                    int x = j + dx[k];
                    if (y < 0 || x < 0 || y >= h || x >= w)
                        continue;
                    map[y][x] += 1;
                }
            }
        }
    }
    rep(i, h) {
        rep(j, w) {
            if (bom[i][j] == '#')
                cout << "#";
            else
                cout << map[i][j];
        }
        cout << endl;
    }
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        String s = scan.next();
        scan.close();

        String[] str = s.split("");

        int[] strCount = new int[3];
        for (String a : str) {
            if (a.equals("R")) {
                strCount[0] += 1;
            } else if (a.equals("G")) {
                strCount[1] += 1;
            } else {
                strCount[2] += 1;
            }
        }

        long count = (long)strCount[0] * strCount[1] * strCount[2];
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int k = 2 * j - i;
                if (k < n) {
                    if (str[i].equals(str[j])) {
                        continue;
                    }
                    if (str[j].equals(str[k])) {
                        continue;
                    }
                    if (str[k].equals(str[i])) {
                        continue;
                    }
                    count--;
                }
            }
        }

        System.out.println(count);
    }

}


Measured memory_bytes: 36636
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int[] x = new int[N];
        
        for(int i = 0; i < N; i++)
            x[i] = Math.abs(sc.nextInt() - X);
            
        int min = x[0];
        for(int i = 1; i < N; i++){
            int a = Math.max(x[0], x[i]);
            int b = Math.min(x[0], x[i]);
            int r;
            while((r = a % b) != 0){
                a = b;
                b = r;
            }
            if(min > b)
                min =b;
        }
        System.out.println(min);
    }
}


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

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

   int h[n];
   for(int i=0;i<n;i++) cin>>h[i];

   int dp[n];	
   
   dp[1] = abs(h[1]-h[0]);
   dp[0] = 0;
   
   for(int i=2;i<n;i++) 
   	   dp[i] = min(abs(h[i]-h[i-1]) + dp[i-1],abs(h[i]-h[i-2]) + dp[i-2]);

   cout<<dp[n-1];
   	
return 0;	
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int c[] = new int[26];
        int s[][] = new int[n][26];
        
        for(int i = 0; i < 26; i++){
            c[i] = stdIn.nextInt();
        }
        
        for(int i = 0; i < n; i++){
            int max = 0;
            int index = 0;
            for(int j = 0; j < 26; j++){
                s[i][j] = stdIn.nextInt();
                
                if(s[i][j] > max){
                    max = s[i][j];
                    index = j;
                }
            }
            System.out.println(index + 1);
        }
        
        //System.out.println("XXXXXXXX");
    }
}


Measured memory_bytes: 47096