akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}



int main(){
	int q;
	cin>>q;
	vector<string> s0(q),t0(q);
	rep(i,q){
		cin>>s0[i]>>t0[i];
	}
	rep(i,q){

	string s,t;
	s=s0[i];
	t=t0[i];
	vector<vector<int>> a(s.size());
	rep(i,s.size()){
		a[i].resize(t.size());
		rep(j,t.size()){
			if(i==0 && j==0){
				if(s[0]==t[0]) a[0][0]=1;
				else a[0][0]=0;
			}else if(j==0){
				if(s[i]==t[0]) a[i][0]=1;
				else a[i][0]=a[i-1][0];
			}else if(i==0){
				if(s[0]==t[j]) a[0][j]=1;
				else a[0][j]=a[0][j-1];
			}else{
				if(s[i]==t[j]) a[i][j]=a[i-1][j-1]+1;
				else a[i][j]=max(a[i][j-1],a[i-1][j]);
			}
		}
	}
	cout<<a[s.size()-1][t.size()-1]<<endl;
	}
}


Measured memory_bytes: 6796
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <math.h>
#define eps 1e-8

using namespace std;
typedef pair<double, string> P;

int n;
string l[55];
int p[55], a[55], b[55], c[55], d[55], e[55], f[55], s[55], m[55];
P seed[55];

bool comp(P x, P y)
{
  if(x.first < y.first - eps) return true;
  if(fabs(x.first-y.first) < eps && x.second < y.second) return true;
  return false;
}

int main(void)
{
  while(cin >> n, n){
    for(int i = 0; i < n; i++){
      cin >> l[i] >> p[i] >> a[i] >> b[i] >> c[i] >> d[i] >> e[i] >> f[i] >> s[i] >> m[i];
      seed[i] = make_pair(-(double)(s[i]*m[i]*f[i]-p[i]) / (double)(a[i]+b[i]+c[i]+m[i]*(d[i]+e[i])), l[i]);
    }
    sort(seed, seed+n, comp);
    for(int i = 0; i < n; i++){
      cout <<  seed[i].second << endl;
    }
    cout << "#" << endl;
  }
  return 0;
}



Measured memory_bytes: 3120
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;



int n, m, a, w;
int p[100005], cnt[100005];
string s[100005];
bool flag[100005];

int main() {

	cin >> n >> m;
	rep(i, m) {
		cin >> p[i] >> s[i];
	}

	REP(i, 1, n + 1)flag[i] = true;

	rep(i, m) {
		if (s[i] == "WA") {
			if (flag[p[i]])cnt[p[i]]++;
		}
		else {
			if (flag[p[i]]) {
				flag[p[i]] = false;
				w += cnt[p[i]];
				a++;
			}
		}
	}

	cout << a << " " << w << endl;

	return 0;
}

Measured memory_bytes: 6528
#include "bits/stdc++.h"
using namespace std;
multiset < string > s;
int a , b , c;
int main(){
	cin >> a >> b >> c;
	for(int i = 0 ; i < a ; ++i){
		s.insert("a");
	}
	for(int i = 0 ; i < b ; ++i){
		s.insert("b");
	}
	for(int i = 0 ; i < c ; ++i){
		s.insert("c");
	}
	while(s.size() > 1){
		string str = (*s.begin()) + (*prev(s.end()));
		s.erase(s.begin());
		s.erase(prev(s.end()));
		s.insert(str);
	}
	cout << *(s.begin()) << endl;
}

Measured memory_bytes: 256
# import math
# import statistics
# import itertools
# a=int(input())
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#     c.append(int(i))
N,L= map(int,input().split())
# f = list(map(int,input().split()))
# g = [input().split for _ in range(a)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen

azi2=[]
azi=[L+i for i in range(N)]
for i in azi:
    azi2.append(abs(i))
if 0 in azi:
    print(sum(azi))
else:
    mi=azi2.index(min(azi2))
    del azi[mi]
    print(sum(azi))
    


Measured memory_bytes: 9180
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

constexpr int N_MAX = 2000000;

ll fact[N_MAX+1], rfact[N_MAX+1];

ll perm(ll n, ll k) {
    if(n-k < 0LL) return 0LL;
    return (fact[n] * rfact[n-k]) % MOD;
}

ll comb(ll n, ll k) {
    if(n-k < 0LL) return 0LL;
    return (perm(n, k) * rfact[k]) % MOD;
}

ll modpow(ll a, ll p) {
    ll ret = 1LL;
    while(p) {
        if(p & 1) {
            ret = (ret * a) % MOD;
        }
        a = (a * a) % MOD;
        p >>= 1;
    }
    return ret;
}

void init_fact(ll n) {
    fact[0] = fact[1] = 1;
    rfact[0] = rfact[1] = 1;
    for(ll i=2;i<=n;++i) {
        fact[i] = (fact[i-1] * i) % MOD;
        rfact[i] = modpow(fact[i], MOD-2);
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int k;
    cin >> k;
    string s;
    cin >> s;
    init_fact(N_MAX);

    ll ans = 0LL;
    for(int i=0;i<=k;++i ){
        ll tmp = (i == 0 ? 1 : comb(s.length()+i-1, i));
        tmp = (tmp * modpow(25, i)) % MOD;
        tmp = (tmp * modpow(26, k-i)) % MOD;
        ans += tmp;
        ans %= MOD;
    }

    cout << ans << endl;

}


Measured memory_bytes: 35688
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  vector<pair<lint, lint>> LR(N);
  lint Rmin = 1e10;
  lint idx = -1;
  REP(i, N) {
    lint L, R;
    cin >> L >> R;
    LR[i] = make_pair(L, R);
    if(R < Rmin) {
      Rmin = R;
      idx = i;
    }
  }
  vector<pair<lint, lint>> LR2;
  REP(i, N) if(i != idx) LR2.push_back(LR[i]);
  sort(ALL(LR2), [](auto const &a, auto const &b) { return a.first > b.first;});
  lint maxlen = 0;
  FOR(i, 1, N-1) {
    if(LR2[i].second-LR2[i].first+1 > maxlen) maxlen = LR2[i].second-LR2[i].first+1;
  }
  multiset<lint> L1;
  multiset<lint> R1;
  REP(i, N) {
    L1.insert(LR[i].first);
    R1.insert(LR[i].second);
  }
  lint ans = maxlen + max(0LL, *(R1.begin()) - *(prev(L1.end(), 1)) + 1); 
  multiset<lint> L2;
  multiset<lint> R2;
  REP(i, N-1) {
    L1.erase(L1.find(LR2[i].first));
    R1.erase(R1.find(LR2[i].second));
    L2.insert(LR2[i].first);
    R2.insert(LR2[i].second);
    lint tmp = max(0LL, *(R1.begin()) - *(prev(L1.end(), 1)) + 1) + max(0LL, *(R2.begin()) - *(prev(L2.end(), 1)) + 1);
    if(tmp > ans) ans = tmp;
  }
  cout << ans << endl;
}

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

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
char s[64][64];
int H, W;

int main() {

	cin >> H >> W;
	for(int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++) {
			cin >> s[i][j];
		}
	}

	bool flag = true;
	for(int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++) {
			if(s[i][j] == '#') {
				int cnt = 0;
				for(int k = 0; k < 4; k++) {
					int ny = i + dy[k];
					int nx = j + dx[k];
					if(ny >= 0 && ny < H && nx >= 0 && nx < W && s[ny][nx] == '#') {
						cnt++;
					}
				}
				if(cnt == 0) {
					flag = false;
					break;
				}
			}
		}
		if(!flag) break;
	}
	
	cout << (flag ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
int main(){
  int bun,index = 65,n,i,alp[26] = {0};
  scanf("%d",&bun);
  while((bun = getchar()) != EOF){
    if(isalpha(bun)){
    bun = tolower(bun);
      i = bun - 97;
      alp[i] ++;
    }else if(isspace){
    }else{
      break;
    }
  }
  for(n = 0;n < 26;n++){
    printf("%c : %d\n",index+n+32,alp[n]);
  }
  return 0;
}

Measured memory_bytes: 1024
// AOJ 1001: Binary Tree Intersection And Union
// 2017.12.14 bal4u@uu

#include <stdio.h>
#include <string.h>

typedef struct { int l, r, c; } T;
T node[310]; int sz;
char buf[1210], *p;
char ans[610], *q;

char *parse(char *p, int i)
{
	node[i].c++; p++;
	if (*p != ',') {
	    if (node[i].l == 0) node[i].l = sz++;
		p = parse(p, node[i].l);
	}
	p++;
	if (*p != ')') {
		if (node[i].r == 0) node[i].r = sz++;
	    p = parse(p, node[i].r);
	}
	return p+1;
}

char *act(char *q, int i, int k)
{
	if (node[i].c < k) return q;
	*q++ = '(';
	if (node[i].l > 0) q = act(q, node[i].l, k);
	*q++ = ',';
	if (node[i].r > 0) q = act(q, node[i].r, k);
	*q++ = ')';
	return q;
}

int main()
{
	int op;
	char *a, *b;

	while (fgets(p=buf, 1210, stdin) != NULL) {
		memset(node, 0, sizeof(node));

		op = *p, p+=2;
		a = p; while (*p != ' ') p++; *p++ = 0;
		b = p;
		sz = 1;
		parse(a, 0);
		parse(b, 0);

		q = act(ans, 0, op == 'i' ? 2 : 1), *q = 0;
		puts(ans);
	}
	return 0;
}

Measured memory_bytes: 1748
#include <iostream>
#include <bitset>

using namespace std;

int main(){
  int s;
  cin >> s;
  int count=2;
  bitset<1000000> bits(0);
  bits[s]=true;
  while(true){
    int temp;
    if(s%2==0){
      temp=s/2;
    }else{
      temp=3*s+1;
    }
    
    if(bits[temp]){
      cout << count << endl;
      return 0;
    }else{
      s=temp;
      bits[s]=true;
      count++;
    }
  }
  return 0;
}

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

int main()
{
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if (s < t)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace  std;
typedef long long ll;
int main(){
	ll n,m;	cin>>n>>m;
	ll ret=min(n,m/2);//既存のSを使用
	n-=ret;	m-=2*ret;
	if(n==0){
		ret+=m/4;
	}
	cout<<ret<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000;

int main()
{
	//freopen("task.inp", "r", stdin);
	int n;
	int a[maxn];
	cin >> n;
	for (int i = 1; i <= n * 2; ++i) cin >> a[i];
	sort(a + 1, a + n * 2 + 1);
	int sum = 0;
	for (int i = 1; i <= n * 2 - 1; i += 2) sum += a[i];
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve(){
	int x;
	cin>>x;
	cout<<8-(x-400)/200<<endl;
}

int main() {
	ios_base::sync_with_stdio(0);
	int i,t=1;
	//	cin>>t;
	for(i=1;i<=t;i++){
		solve();
	}
	return 0;
}

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = ((ll)result * base) % mod;
		base = ((ll)base * base) % mod;
		exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}




Measured memory_bytes: 10692
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define xx first
#define yy second
pii a[100009];
int main()
{
    int n,i,j;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> a[i].xx;
        a[i].yy=i;
    }
    sort(a,a+n);
    int ans=0;
    for(i=0;i<n;i++)
    {
        if(abs(a[i].yy-i)%2)
            ans++;
    }
    cout << ans/2 << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;


struct NODE{
	int num;//team number
	vector<int> wrong;
	ll score;
	int solve;
	NODE(){}
	NODE(int num, int p):num(num), wrong(p, 0){score = 0; solve = 0;}
	
	bool operator<(const NODE r){
		if(solve != r.solve) return solve < r.solve;
		else if (score != r.score) return score > r.score;
		else return num > r.num;
	}
};

int main() {
	
	int n;
	while(cin >> n, n){
		
		vector<vector<int>> p(n);
		rep(i, n){
			int m;
			cin >> m;
			p[i].resize(m);
			rep(j, m){
				cin >> p[i][j];
			}
		}
		
		int k;
		cin >> k;
		vector<int> l(k);
		rep(i, k) cin >> l[i];
		
		int cnt = 0;
		int num;
		rep(i, n){
			bool flag = true;
			rep(j, k){
				if(find(p[i].begin(), p[i].end(), l[j]) == p[i].end()) flag = false;
			}
			if(flag){
				cnt++;
				num = i+1;
			}
		}
		
		
		if(cnt != 1) cout << -1 << endl;
		else cout << num << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3148
import sys
sys.setrecursionlimit(100000)
n = int(input())
G = [[] for i in range(n)]
for i in range(n-1):
    x, y = map(int, input().split())
    G[x-1].append(y-1)
    G[y-1].append(x-1)
p = 10**9+7
Q = [0]
V = [False for i in range(n)]
C = [[] for i in range(n)]
while Q:
    x = Q.pop()
    V[x] = True
    for y in G[x]:
        if not V[y]:
            C[x].append(y)
            Q.append(y)
DP = [[None, None] for i in range(n)]
def dp(i, c):
    if DP[i][c] != None:
        return DP[i][c]
    tmp = 1
    for j in C[i]:
        if c == 0:
            tmp = (tmp*(dp(j, 0)+dp(j, 1))) % p
        else:
            tmp = (tmp*dp(j, 0)) % p
    DP[i][c] = tmp
    return DP[i][c]
print((dp(0, 0)+dp(0, 1))%p)


Measured memory_bytes: 122732
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        HashMap<Integer,Integer> count = new HashMap<>();
        for (int i = 0; i < N; i++) {
            int a =ni();
            count.putIfAbsent(a, 0);
            count.put(a, count.get(a)+1);
        }
        ArrayList<Integer> keylist = new ArrayList<>();
        for (Integer integer : count.keySet()) {
            keylist.add(integer);
        }
        Collections.sort(keylist);
        int ans = 0;
        for (int i = 0; i < keylist.size(); i++) {
            int res = count.get(keylist.get(i));
            if(i>0 && keylist.get(i-1)==keylist.get(i)-1) res += count.get(keylist.get(i-1));
            if(i<keylist.size()-1 && keylist.get(i+1)==keylist.get(i)+1) res += count.get(keylist.get(i+1));
            ans = Math.max(ans, res);
        }
 
        out.println(ans);
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);
    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

int main(){
	// sengen
	int n;
	// nyuryoku
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	// keisan
	int left = 0,right = n-1;
	while(right - left > 0){
		while(s[left] == 'R'){
			left++;
			if(left >= right){
				break;
			}
		}
		while(s[right] == 'W'){
			right--;
			if(right <= left){
				break;
			}
		}
		if(right - left > 0){
			char c = s[left];
			s[left] = s[right];
			s[right] = c;
			ans++;
		}
	}
	// syutsuryoku
	cout << ans << endl;
}

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

#define llong long long 
#define len(x) ((int)x.size())
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )
#define rand __rand
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());  // or mt19937_64
template<class T = int> T rand(T range = numeric_limits<T>::max()) { return (T)(rng() % range); }

#define CONCAT_(x, y) x##y/*{{{*/
#define CONCAT(x, y) CONCAT_(x, y)
#ifdef LOCAL_DEBUG   
int __db_level = 0;
bool __db_same_line = false;
#define clog cerr << string(!__db_same_line ? __db_level * 2 : 0, ' ')
struct debug_block {
    function<void()> fn;
    void print_name() { __db_same_line = true; fn(); clog << endl; __db_same_line = false;  }
    debug_block(function<void()> fn_): fn(fn_) { clog << "{ "; print_name(); ++__db_level; }
    ~debug_block() { --__db_level; clog << "} "; print_name(); }
};
#define DB(args...) debug_block CONCAT(dbbl, __LINE__)([=]{ clog << args; })
#define deb(...)  if (1) { (clog << "[" #__VA_ARGS__ "] = [" << __VA_ARGS__) << "]"; if (!__db_same_line) clog << endl; }
#else
#define clog if (0) cerr
#define DB(...)
#define deb(...)
#endif
template<class T>
ostream& operator,(ostream& out, const T& thing) { return out << ", " << thing; }
template<class U, class V>
ostream& operator<<(ostream& out, const pair<U, V>& p) { return (out << "(" << p.first, p.second) << ")"; }
template<class A, class B>
ostream& operator<<(ostream& out, const tuple<A, B>& t) { return (out << "(" << get<0>(t), get<1>(t)) << ")"; }
template<class A, class B, class C>
ostream& operator<<(ostream& out, const tuple<A, B, C>& t) { return (out << "(" << get<0>(t), get<1>(t), get<2>(t)) << ")"; }
template<class T> ostream& operator<<(ostream& out, const vector<T>& container) { 
    out << "{";
    if (len(container)) out << container[0];
    rep1(i, len(container) - 1) out, container[i];
    return out << "}";
}
template<class x> vector<typename x::value_type> $v(const x& a) { return vector<typename x::value_type>(a.begin(), a.end()); }
#define ptrtype(x) typename iterator_traits<x>::value_type
template<class u> vector<ptrtype(u)> $v(u a, u b) { return vector<ptrtype(u)>(a, b); }/*}}}*/
// ACTUAL SOLUTION BELOW ////////////////////////////////////////////////////////////

string s;
int main(void) {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s;
    
    rep(i, len(s) - 1) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << ' ' << i + 2 << endl;
            return 0;
        }
    }
    
    rep(i, len(s) - 2) {
        if (s[i] == s[i + 1] or s[i] == s[i + 2] or s[i + 1] == s[i + 2]) {
            cout << i + 1 << ' ' << i + 3;
            return 0;
        }
    }
    cout << "-1 -1";

    return 0;
}

// Remember:
// - Multitest? REFRESHING the data!!!
// - Constrains for each set of data may differs. Should NOT USE the same max constant (maxn)
//   for all of them.
// vim: foldmethod=marker


Measured memory_bytes: 3788
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())

def zettaiti(A):
    if A>=0:
        return A
    else:
        return -1*A

X=zettaiti(B-A)
H=V-W
if H*T>=X:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 9176
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

#include <ext/rope> //header with rope
using namespace std;
using namespace __gnu_cxx; //namespace with rope and some additional stuff
using namespace __gnu_pbds;

#define rep(i, a, b) for(int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair <int, int> ii;

const ll mod = 1000000007;
const int INF = 0x3f3f3f3f;




int main(){
		
	int a; cin >> a;
	cout << 48-a << '\n';

	
	return 0;
	
}

Measured memory_bytes: 256
S = input()
RL = []
LR = [0]
for i in range(len(S)-1):
  if S[i]=="R" and S[i+1]=="L":
    RL.append([i, i+1])
  elif S[i]=="L" and S[i+1]=="R":
    LR.append(i+1)
LR.append(len(S))

ANS = []
for j in range(len(RL)):
  i_R, i_L = RL[j]
  start = LR[j]
  end = LR[j+1]
  children = end - start
  C = ["0"] * children
  if children % 2 == 0:
    C[i_R - start] = str(children // 2)
    C[i_L - start] = str(children // 2)
  else: #children % 2 == 1:
    howmany_R = i_L - start
    if howmany_R % 2 == 0: #howmany_L % 2 == 1:
      C[i_R - start] = str(children // 2)
      C[i_L - start] = str((children//2) + 1)
    else: #howmany_R % 2 == 1 #howmany_L % 2 == 0:
      C[i_R - start] = str((children//2) + 1)
      C[i_L - start] = str(children // 2)
  ANS += C

ans = " ".join(ANS)
print(ans)

Measured memory_bytes: 20340
def main():
    x, y = map(int, input().rstrip().split(' '))
    for i in range(x + 1):
        # print(i * 2 + (x - i)* 4)
        if i * 2 + (x - i)* 4 == y:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9076
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  ll ans = 0;
  rep (i, n) {
    while (a[i] % 2 == 0) {
      a[i] /= 2;
      ans++;
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

        int n = in.nextInt();

        int[][] array = new int[2][n];
        for (int i = 0; i < 2; i++)
            for (int j = 0; j < n; j++)
                array[i][j] = in.nextInt();

        for (int j = n - 2; j >= 0; j--)
            array[1][j] += array[1][j + 1];
        array[0][n - 1] += array[1][n - 1];
        for (int j = n - 2; j >= 0; j--)
            array[0][j] += Math.max(array[1][j], array[0][j + 1]);
        System.out.println(array[0][0]);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n,m;cin>>n>>m;
	vector<vector<int>> G(n);
	for(int i=0;i<m;i++){
		int a,b;cin>>a>>b;--a;--b;
		G[a].push_back(b);
	}
	vector<double> dp(n);
	for(int i=n-2;i>=0;i--){
		double s=G[i].size();
		for(auto& e:G[i]){
			dp[i]+=(dp[e]+1.0);
		}
		dp[i]/=s;
	}
	vector<double> d(n);
	double res=dp[0];
	for(int i=0;i<n-1;i++){
		if(G[i].size()==1){
			continue;
		}
		int to;
		double ma=0;
		for(auto &e:G[i]){
			if(ma<dp[e]){
				ma=dp[e];
				to=e;
			}
		}
		for(int j=n-2;j>=0;j--){
			d[j]=0;
			double s=G[j].size();
			if(i==j){
				--s;
			}
			for(auto &e:G[j]){
				if(i==j&&to==e){
					continue;
				}
				d[j]+=(d[e]+1.0);
			}
			d[j]/=s;
		}
		chmin(res,d[0]);
	}
	cout<<fixed<<setprecision(10)<<res<<endl;
}


Measured memory_bytes: 1408
# -*- coding:utf-8 -*-
import numpy as np

N = int(input())
a = list( map(int, input().split()) )
b = np.asarray(a, np.float)

ave = np.average(b)
ave_floor = np.floor(ave)
ave_ceil = np.ceil(ave)

cost1 = np.sum((b-ave_floor)**2)
cost2 = np.sum((b-ave_ceil)**2)
min_cost = int( np.min([cost1, cost2]) )

print(min_cost)




Measured memory_bytes: 12500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second
 
ll mod = 1e9+7;
 
ll max(ll a, ll b ) {
	if(a>b)
		return a;
	else return b;
}
ll min(ll a, ll b ) {
	if(a<b)
		return a;
	else return b;
}

int main() {
	ll ttt;
	//cin>>ttt;
	ttt = 1;
	while(ttt--) {
		ll n; cin>>n;
		ll sum = 0;
		ll a[n+1]; for(int i=1; i<=n; i++) { cin>>a[i]; sum += a[i]; }
		ll pre[n+1]; pre[0] = 0;
		sum = sum%mod;
		pre[1] = (sum - a[1]+mod)%mod;
		for(int i=2; i<=n; i++) {
			pre[i] = (pre[i-1] - a[i]+mod)%mod;
		}
		ll ans = 0;
		for(int i=1; i<=n-1; i++) {
			ans = (ans + (a[i]*pre[i]) % mod) %mod;
		}
		cout<<ans;
	}
	return 0;
}


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

#define nax 3009
#define FOR(i,n,m) for(int i =(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef vector<ll> vi;

ll dp[nax][nax];
vi a;

ll f(int ini,int fin,ll s){
	if(ini == fin){
		return s*a[ini];
	}
	if(dp[ini][fin]!=0) return dp[ini][fin];

	if(s==1LL) return dp[ini][fin] = max(f(ini+1,fin,-1LL*s)+s*a[ini],
				f(ini,fin-1,-1LL*s)+s*a[fin]);
	else return dp[ini][fin] = min(f(ini+1,fin,-1LL*s)+s*a[ini],
				f(ini,fin-1,-1LL*s)+s*a[fin]);
}

int main(){
	ll n; cin>>n;
	a.resize(n);
	REP(i,n) cin>>a[i];

	cout<<f(0,n-1,1);

	return 0;
}

Measured memory_bytes: 70272
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <numeric>

constexpr long long MOD = 1000000007;

int main()
{
  int N;
  std::cin >> N;
  std::cout << 180 * (N - 2) << std::endl;
  return 0;
}



Measured memory_bytes: 256
#https://atcoder.jp/contests/dp/tasks/dp_b
#2019-01-13
N, K = map(int, input().split())
h = list(map(int, input().split()))

DP = [0]
for i in range(N-1):
    act = float("inf")
    for k in range(K):
        if i-k < 0 : continue
        act = min(DP[-1-k] + abs(h[i-k]-h[i+1]) , act)
    DP += [act]

print(DP[-1])

Measured memory_bytes: 57952
#include<stdio.h>

void insertionSort(int *,int,int);
void shellSort(int *,int);
int cnt,mcnt=0;
int main()
{
  int i,n;
  int A[2000000];

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);

  shellSort(A,n);

  for(i=0;i<n;i++)printf("%d\n",A[i]);

  return 0;
}

void shellSort(int *A,int n)
{
  int m,i,j;
  int G[100];
  cnt=0;
  m=99;
  for(i=m;i>=0;i--)
    {
    G[i]=1+(m-i)*6;
    if(G[i]<=n)mcnt++;
  }
    
  
  for(i=0;i<m+1;i++) insertionSort(A,n,G[i]);
    
  printf("%d\n",mcnt);
  for(i=m-mcnt+1;i<m;i++) printf("%d ",G[i]);
  printf("%d\n%d\n",G[i],cnt);
}

void insertionSort(int *A,int n,int g)
{
  int v,j,i;
  for(i=g;i<n;i++)
    {
    v=A[i];
    j=i-g;
    while(j>=0 && A[j]>v)
      {
      A[j+g]=A[j];
      j=j-g;
      cnt++;
    }
    A[j+g]=v;
  }
}



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

const int N = 2e6 + 5;

int a[N];
int c[N];

int n, m;
int check(int lim) {
	vector<int> cnt(2);
	for(int i = 1;i <= m;i ++) {
		c[i] = a[i] >= lim;
		cnt[c[i]] ++;
	}
	int mid = m / 2 + 1, dis0 = 0x3f3f3f3f, dis1 = 0x3f3f3f3f;
	for(int i = mid;i < m;i ++) {
		if(c[i] == c[i + 1]) {
			if(c[i]) dis1 = min(dis1, i - mid);
			else dis0 = min(dis0, i - mid);
		}
	}
	for(int i = mid;i > 1;i --) {
		if(c[i] == c[i - 1]) {
			if(c[i]) dis1 = min(dis1, mid - i);
			else dis0 = min(dis0, mid - i);
		}
	}
	if(dis1 == 0x3f3f3f3f && dis0 == dis1) {
		return cnt[1] >= cnt[0];
	}
	else return dis1 <= dis0;
}

int main() {
	ios::sync_with_stdio(false);
	int maxn = 0;
	cin >> n;
	m = 2 * n - 1;
	for(int i = 1;i <= m;i ++) cin >> a[i], maxn = max(maxn, a[i]);
	int l = 0, r = maxn, mid, ans;
	while(l <= r) {
		mid = l + r >> 1;
		if(check(mid)) ans = mid, l = mid + 1;
		else r = mid - 1;
	}
	cout << ans << endl;
	return 0;
}

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

def main():
    N = int(input())
    ind = [0 for _ in range(N)]
    for i in range(N):
        A = int(input())
        ind[A-1] = i

    ans = 0
    count = 0
    for i in range(N-1):
        if ind[i] < ind[i+1]:
            count += 1
        else:
            ans = max(ans,count)
            count = 0
        ans = max(ans,count)

    print(N-ans-1) 

if __name__ == "__main__":
    main()

Measured memory_bytes: 11048
#include<iostream>
#include<vector>
#include<math.h>
 
using namespace std;
 
int main() {
        int count;
        cin >> count;
 
        if(count <= 0)
                return 0;
 
        vector<int> heights(count);
 
        for(int& cur : heights)
                cin >> cur;
 
        vector<int> table (count);
        table[0] = 0; 
        table[1] = table[0] + abs(heights[0] - heights[1]);
 
        for(int i = 2; i < count; i++)
        {
                table[i] = min(table[i - 1] + abs(heights[i - 1] - heights[i]), table[i - 2] + abs(heights[i - 2] - heights[i]));
        }
 
  		cout << table[table.size() - 1];
  
        return 0;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ans=0;
  rep(i,n){
    if(i%2==0&&a[i]%2==1) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(void) {
int a,b;
scanf("%5d",&a);
scanf("%5d",&b);
 if(a>b){
   printf("a > b\n",a,b);
 }
 if(a<b){
   printf("a < b\n",a,b);
 }
 if(a==b){
   printf("a == b\n",a,b);
 }
}


Measured memory_bytes: 2672
using System;
using CompLib.Util;

public class Program
{
    private int N, K;
    private int[] A;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        K = sc.NextInt();
        A = sc.IntArray();

        for (int i = 0; i < K; i++)
        {
            var next = new int[N + 1];
            for (int j = 0; j < N; j++)
            {
                next[Math.Max(0, j - A[j])]++;
                next[Math.Min(N, j + A[j] + 1)]--;
            }

            for (int j = 0; j < N; j++)
            {
                next[j + 1] += next[j];
            }

            bool flag = true;

            for (int j = 0; j < N; j++)
            {
                A[j] = next[j];
                if (A[j] != N) flag = false;
            }

            if (flag) break;
        }

        Console.WriteLine(string.Join(" ", A));
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 61840
a,b,c,d,e = [int(input()) for _ in range(5)]
k = int(input())

if abs(a-b) >k or abs(a-c) >k or abs(a-d) >k or abs(a-e) >k or abs(b-c) >k or abs(b-d) >k or abs(e-b) >k or abs(c-d) >k or abs(c-e) >k or abs(d-e) >k :
  print(":(")
else:
  print("Yay!")


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

int N, T;

int main(){
	scanf("%d%d", &N, &T);
	int end = 0, sum = 0;
	for(int i = 0; i < N; i++){
		int var;
		scanf("%d", &var);
		if(var >= end) sum += T;
		else sum += var + T - end;
		end = var + T;
	}
	printf("%d\n", sum);
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

template <class T> int getbit(T s, int i) { return (s >> i) & 1; }
template <class T> T onbit(T s, int i) { return s | (T(1) << i); }
template <class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template <class T> ll cntbit(T s) { return __builtin_popcntll(s); }

#define all(a) (a).begin(), (a).end()
#define ms(a, x) memset(a, x, sizeof(a))
#define forv(v, it) for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); it++)
#define print(x) cout << "L" << __LINE__ << " -- " << #x << " = " << x << endl
#define clear(x) v.clear(); vector<T>(v).swap(v)

#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define eps 1e-12

#define div ___div
#define next ___next
#define prev ___prev
#define left ___left
#define right ___right
#define y0 ___y0
#define y1 ___y1

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

  string n;
  cin >> n;

  if((n[0] == n[1] && n[1] == n[2]) ||
     (n[1] == n[2] && n[2] == n[3])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }


  return 0;
}

Measured memory_bytes: 256
use std::collections::VecDeque;

fn main() {
    let (n, m) = {
        let nm = read_vec::<usize>();
        (nm[0], nm[1])
    };
    let mut graph: Vec<Vec<usize>> = vec![Vec::new(); n];
    for _ in 0..m {
        let ab = read_vec::<usize>();
        let a = ab[0] - 1;
        let b = ab[1] - 1;
        graph[a].push(b);
        graph[b].push(a);
    }

    let mut sign: Vec<usize> = vec![usize::max_value(); n];
    bfs(&graph, &mut sign);

    println!("Yes");
    for i in 1..n {
        println!("{}", sign[i] + 1);
    }
}

fn bfs(graph: &Vec<Vec<usize>>, sign: &mut Vec<usize>) {
    let mut queue: VecDeque<(usize, usize)> = VecDeque::new();
    queue.push_back((0, 0));
    while !queue.is_empty() {
        let (cur, par) = queue.pop_front().unwrap();
        if sign[cur] != usize::max_value() {
            continue;
        }
        sign[cur] = par;
        for chi in graph[cur].iter() {
            queue.push_back((*chi, cur));
        }
    }
}

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()
}


Measured memory_bytes: 17196
#include<bits/stdc++.h>
#define ll long long
#define nl "\n"
using namespace std;

void solve()
{
	ll n, m, k,x;
	cin>>n>>m>>k;
	vector<ll> a(n+1),b(m+1);
	a[0] = 0, b[0] = 0;
	for(ll i = 1; i<=n; i++)
	{
		cin>>x;
		a[i] = a[i-1] + x;
	}
	for(ll i = 1; i<=m; i++)
	{
		cin>>x;
		b[i] = b[i-1] + x;
	}
	ll ans = 0;
	for(ll i = 0; i<=n && a[i] <= k; i++)
	{
		ll tm = k - a[i];
		auto low = lower_bound(b.begin(), b.end(), tm);
		ll idx = low - b.begin();
//		cout<<tm<<" "<< idx<<nl;
		if(idx<= m&&b[idx] <= tm) 
			ans = max(ans, i+idx);
		else
			ans = max(ans, i+idx-1);
	}
	cout<<ans<<nl;
}
int main()
{
	solve();
	return 0;
}

Measured memory_bytes: 6436
#include <bits/stdc++.h>
using namespace std;
 
#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

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

    int ans = 0;
    int hole = 1;

    while(hole < B) {
        ans++;
        hole += A-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
<?php
$n = intval(fgets(STDIN));
$str = trim(fgets(STDIN));
$Q = intval(fgets(STDIN));

$seg = new SegTree($n);
function op($a, $b){return $a | $b;}

for($i = 0; $i < $n; $i++){
  $seg->set($i, 1<<(ord($str[$i])-97));
}
while($Q--){
  list($q, $a, $b) = explode(" ", trim(fgets(STDIN)));
  if($q == "1"){
    $seg->set($a-1, 1<<(ord($b)-97));
  }else{
    $ret[] = popcount($seg->get($a-1, $b));
  }
}
echo implode("\n", $ret);


class SegTree{
  public $tree;
  public $bits;
  function __construct($n){
    $this->bits = max(1, ceil(log($n)/log(2)));
    for($i = 0; $i < $this->bits; ++$i){
      $this->tree[$i] = array_fill(0, 2**($this->bits-$i), 0);
    }
  }
  function set($i, $amount){
    $this->tree[0][$i] = $amount;
    for($j = 1, $J = $this->bits; $j < $J; ++$j){
      $this->tree[$j][$i>>$j] = $this->tree[$j-1][$i>>$j<<1] | $this->tree[$j-1][($i>>$j<<1) + 1];
    }
  }
  function get($f, $t){
    $sum = 0;
    $tree = $this->tree;
    for($i = 0; $i < $this->bits ; ++$i){
      $treei = $tree[$i];
      $ff = $f>>$i+1<<$i+1;
      if($f!=$ff){
        $sum |= $treei[$f>>$i];
        $f+=1<<$i;
      }
      $tt = $t>>$i+1<<$i+1;
      if($t!=$tt){
        $sum |= $treei[($t>>$i)-1];
        $t-=1<<$i;
      }
      if($f==$t)break;
    }
    return $sum;
  }
}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}
//ビットカウント-1の数を数える
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}


Measured memory_bytes: 39544
H, W, K = map(int, input().split())

area = [input() for _ in range(H)]
ans = float('inf')
S = []
for w in range(W):
    s = [0, ]
    for h in range(H):
        if area[h][w] == '1':
            s.append(s[-1]+1)
        else:
            s.append(s[-1])
    S.append(s)

for i in range(1 << H-1):
    flag = False
    tmp_ans = 0

    tmp = 0
    flag1 = [False for _ in range(H)]
    flag1[-1] = True
    for j in range(H):
        if i >> j & 1 == 1:
            tmp_ans += 1
            flag1[j] = True
    T = tmp_ans+1
    counter = [0 for _ in range(T)]

    for w in range(W):
        tmp_counter = []
        before = 0
        for k, f in enumerate(flag1):
            if f:
                tmp_counter.append(S[w][k+1] - S[w][before])
                before = k+1
        
        for tmp in tmp_counter:
            if tmp > K:
                flag = True
        if flag:
            tmp_ans = float('inf')
            break

        for k, tmp in enumerate(tmp_counter):
            if counter[k]+tmp > K:
                tmp_ans += 1
                counter = tmp_counter
                break
            else:
                counter[k] += tmp
    ans = min(ans, tmp_ans)

print(ans)


Measured memory_bytes: 48092
#include <bits/stdc++.h>
#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

typedef long long ll;

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<vector<int>> edge(n + 1);

    rep(i,n - 1){
        int a,b;
        cin >> a >> b;

        edge[a].pback(b);
        edge[b].pback(a);
    }

    queue<pair<int,int>> q;

    vector<int> f(n + 1, INT_MAX);
    vector<int> s(n + 1, INT_MAX);

    q.push(mpair(1, 0));

    while(!q.empty()){
        int node = q.front().first;
        int step = q.front().second;

        if(step < f[node]){
            f[node] = step;

            rep(i, edge[node].size()){
                q.push(mpair(edge[node][i], step + 1));
            }
        }

        q.pop();
    }

    q.push(mpair(n, 0));

    while(!q.empty()){
        int node = q.front().first;
        int step = q.front().second;

        if(step < s[node]){
            s[node] = step;

            rep(i, edge[node].size()){
                q.push(mpair(edge[node][i], step + 1));
            }
        }

        q.pop();
    }

    int fcount = 0;
    int scount = 0;

    rep(i,n){
        int idx = i + 1;

        if(f[idx] <= s[idx]){
            fcount++;
        }else{
            scount++;
        }
    }

    if(fcount > scount){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }


    return 0;
}


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

n=int(input())
lst=list(map(int,input().split()))
for i in range(n):
    lst[i]=[lst[i]]
for i in range(n):
    lst[i].append(i)
lst=sorted(lst,key=lambda x:x[0])
ans=[]
for i in lst:
    ans.append(i[1]+1)
print(" ".join(map(str,ans)))

Measured memory_bytes: 112456
fun main() {
    a()
}

fun a() {
    val N = readLong()
    val otsuri = (1000 - N%1000)%1000
    println("${otsuri}")
}

fun readLong() = readLine()!!.toLong()
fun readLongList() = readLine()!!.split(" ").map { it.toLong() }

Measured memory_bytes: 34576
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec; }
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

// FAIL
void fail(){ print(-1); std::exit(0); }
//void fail(){ print("No"); std::exit(0); }

int main()
{
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll A, B;
  std::cin >> A >> B;

  ll a = 0LL;
  for (ll x = A - 1; x % 4 != 3 && x >= 0; x--) {
    a ^= x;
  }

  ll b = 0LL;
  for (ll x = B; x % 4 != 3 && x >= 0; x--) {
    b ^= x;
  }

  ll ans = b ^ a;
  print(ans);

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int main(){
  int n,a,b,an=0;
 scanf("%d%d%d",&n,&a,&b);
 for(int i=0;i<n;i++){
  int x;scanf("%d",&x);
  if(x<a||x>=b)an++;
 }
 printf("%d\n",an);
 return 0;
}

Measured memory_bytes: 128