akhauriyash/Code-Regression huggingface dataset:
h,w=map(int,input().split())
hw=[[]]
ans=[]
for i in range(h):
    ht=[0]+list(map(int,input().split()))
    hw.append(ht)
for i in range(1,h+1):
    for j in range(1,w):
        if hw[i][j]%2==1:
            ans.append([i,j,i,j+1])
            hw[i][j+1]+=1

for k in range(1,h):
    
    if hw[k][-1]%2==1:
        ans.append([k,w,k+1,w])
        hw[k+1][-1]+=1
print(len(ans))
for i in ans:
    for j in range(len(i)):
        i[j]=str(i[j])
    print(" ".join(i))

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

int main() {
  ll n;
  cin >> n;
  vector<ll> s(5);

  ll mn         = (1LL << 60);
  int min_index = 0;
  for (int i = 0; i < 5; i++) {
    cin >> s[i];
    if (s[i] < mn) {
      mn        = s[i];
      min_index = i;
    }
  }
  ll min_cost = s[min_index];
  int t1      = 4;

  ll c = ceil(double(n) / double(min_cost));
  if (n <= min_cost) {
    c  = 0;
    t1 = 5;
  };
  cout << c + t1 << endl;
}

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


int main() {
   string s;
  cin >> s;
  if(s == "Sunny"){
    cout << "Cloudy";
  }
  if(s == "Cloudy"){
    cout << "Rainy";
  }
  if(s == "Rainy"){
    cout << "Sunny";
  }
  return 0;
}

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

using namespace std;

using ll = long long;

int main() {
	ll n, num, prenum;
  ll h = 0;
  cin >> n;
  cin >> num;
  n--;
  prenum = num;
  while(n--) {
  	cin >> num;
    if(num < prenum) {
    	h += prenum-num;
      num = prenum;
    }
    prenum = num;
  }
  cout << h;
	return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N,A,x;
  	cin >> N >> A;
  	x= N%500;
    if (x<=A) {
    cout << "Yes" << endl;
    }
  	else if (x > A) {
    cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int ta,th,aa,ah;
    cin>>th>>ta>>ah>>aa;
    int flag=1;
    while(1)
    {
        if(flag)
        {
            ah-=ta;
        }
        else
        {
            th-=aa;
        }
        flag=!flag;
        if(ah<=0)
        {
            cout<<"Yes"<<endl;
            break;
        }
        else if(th<=0)
        {
            cout<<"No"<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using piii = pair<int, pair<int, int>>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

struct edge {
    int from, to, cost;
};

struct UnionFind {
    vector<int> par, rnk;
    UnionFind(int N) : par(N), rnk(N) {
        for (int i = 0; i < N; ++i)
            par[i] = i;
    }

    int root(int x) {
        return par[x] == x ? x : par[x] = root(par[x]);
    }

    bool issame(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 (rnk[x] < rnk[y])
            swap(x, y);
        if (rnk[x] == rnk[y])
            rnk[x]++;
        par[y] = x;
    }
};

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

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

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    auto cmp = [&](edge a, edge b) {
        if (a.cost == b.cost)
            return a.from == b.from ? a.to < b.to : a.from < b.from;
        else
            return a.cost > b.cost;
    };
    priority_queue<edge, vector<edge>, decltype(cmp)> que(cmp);
    for (int i = 0; i < N - 1; ++i) {
        {
            int a = x[i].second, b = x[i + 1].second;
            int c = x[i + 1].first - x[i].first;
            que.push({a, b, c});
        }
        {
            int a = y[i].second, b = y[i + 1].second;
            int c = y[i + 1].first - y[i].first;
            que.push({a, b, c});
        }
    }

    ll ans = 0;
    UnionFind uf(N);
    while (!que.empty()) {
        edge e = que.top();
        que.pop();
        if (uf.issame(e.from, e.to))
            continue;
        ans += e.cost;
        uf.unite(e.from, e.to);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6516
#include <stdio.h>
#include <string>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, h, w, min = 1e15, num = 0;
  scanf("%lld%lld", &h, &w);
  ll a[h][w], b[h][w];
  string ans;
  for(i = 0; i < h; ++i) for(j = 0; j < w; ++j) scanf("%lld", &a[i][j]), b[i][j] = a[i][j];
  for(i = 0; i < h; ++i) {
    for(j = 0; j < w; ++j) {
      if(b[i][j] % 2) {
        if(i != h - 1) b[i + 1][j]++;
        else if(j != w - 1) b[i][j + 1]++;
        if(i != h - 1 || j != w - 1) ++num;
      }
    }
  }
  printf("%lld\n", num);
  for(i = 0; i < h; ++i) {
    for(j = 0; j < w; ++j) {
      if(a[i][j] % 2) {
        if(i != h - 1) printf("%lld %lld %lld %lld\n", i + 1, j + 1, i + 2, j + 1), a[i + 1][j]++;
        else if(j != w - 1) printf("%lld %lld %lld %lld\n", i + 1, j + 1, i + 1, j + 2), a[i][j + 1]++;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 5888
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

typedef pair<ll,int> Q;
vector<ll> dijkstra(int s, const vector<vector<pair<int,int> > >& G){
    priority_queue< Q, vector<Q>, greater<Q> > que;
    vector<ll> d(G.size(), LINF);
    d[s] = 0;
    que.push(Q(0, s));
    while(!que.empty()){
        int curr  = que.top().second;
        ll  dcurr = que.top().first;
        que.pop();
        if(d[curr] < dcurr) continue;
        int i;
        for(i=0; i<(int)G[curr].size(); i++){ 
            int next = G[curr][i].first;
            ll  dist = G[curr][i].second;
            if(d[next] > d[curr] + dist){
                d[next] = d[curr] + dist;
                que.push(Q(d[next], next));
            }
        }
    }
    return d;
}

void solve()
{
    int n, m, s;
    scanf("%d%d%d", &n, &m, &s);
    vector<int> u(m), v(m), a(m), b(m);
    int i,j;
    for (i = 0; i < m; i++) {
        scanf("%d%d%d%d", &u[i], &v[i], &a[i], &b[i]);
        u[i]--; v[i]--;
    }
    vector<int> c(n), d(n);
    for (i = 0; i < n; i++) {
        scanf("%d%d", &c[i], &d[i]);
    }

    int N = n * 5001;
    vector < vector<pair<int, int> > > g(N);   // to,cost
#define P(i,j) ((i)*5001+(j))
    for (i = 0; i < n; i++) {
        for (j = 0; j < 5001; j++) {
            if (j < 5000) {
                int j2 = MIN(5000, j + c[i]);
                g[P(i, j)].push_back(make_pair(P(i, j2), d[i]));
            }
            if (j > 0) {
                g[P(i, j)].push_back(make_pair(P(i, j - 1), 0));
            }
        }
    }
    for (i = 0; i < m; i++) {
        for (j = 0; j < 5001; j++) {
            int j2 = j-a[i];
            if (j2 >= 0) {
                g[P(u[i], j)].push_back(make_pair(P(v[i], j2), b[i]));
                g[P(v[i], j)].push_back(make_pair(P(u[i], j2), b[i]));
            }
        }
    }
    
    s = MIN(s, 5000);
    vector<ll> dist = dijkstra(P(0, s), g);
    for (i = 1; i < n; i++) {
        ll ans = LINF;
        for (j = 0; j < 5001; j++) {
            ll ans0=dist[P(i, j)];
            ans = MIN(ans, ans0);
        }
        printf("%lld\n", ans);
    }

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 32792
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
//#define int long long

void solve() {
	int n; cin >> n;
    vector<int> a(n);
    int x[20][20], y[20][20];
    rep(i, 20) rep(j, 20) x[i][j] = y[i][j] = 0;
    rep(i, n) {
        cin >> a[i];
        rep(j, a[i]) {
            cin >> x[i][j] >> y[i][j];
            --x[i][j];
        }
    }
    int ans = 0;
    for(int bit = 0; bit < (1<<n); bit++) {
        int cnt = 0;
        rep(i, n) if((1<<i) & bit) ++cnt;
        bool flag = true;
        rep(i, n) {
            rep(j, a[i]) {
                if((1<<i) & bit) {
                    if((((1<<x[i][j]) & bit) > 0) != y[i][j]) {
                        flag = false;
                    }
                }
            }
        }
        if(flag) chmax(ans, cnt);
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cmath>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

	int tmp = 0;
	int num = 1;
	int count = 0;
	rep(i, N) {
		cin >> tmp;
		if (tmp == num) {
			num++;
		}
		else {
			count++;
		}
	}

	if (num != 1) {
		cout << count<< endl;
	}
	else {
		cout << -1 << endl;
	}
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import math

n = int(raw_input())
for i in range(n):
    x1, y1, r1, x2, y2, r2 = map(float, raw_input().split())
    d = math.sqrt(math.pow(x2-x1, 2) + math.pow(y2-y1, 2))
    if r2+d < r1:
        print '2'
    elif r1+d < r2:
        print '-2'
    elif r1+r2 >= d:
        print '1'
    else:
        print '0'

Measured memory_bytes: 6524
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint a(N);
    REP(i,N) cin>>a[i];

    int ans=1e9;
    for(int i=-100;i<=100;i++){
        int cost=0;
        REP(j,N) cost+=(i-a[j])*(i-a[j]);
        ans=min(ans,cost);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
num=[0]*n
for i in range(n):
    num[i]=a[i]-(i+1)
num.sort()
b=num[-1*(-(n//-2))]
ans=0
for i in range(n):
    ans+=abs(num[i]-b)
print(ans)


Measured memory_bytes: 30904
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll r, d, x;
  cin >> r >> d >> x;
  rep(i, 10) {
    x = r*x - d;
    cout << x << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;

int A,B,C,D;

int main(){
	cin>>A>>B>>C>>D;
	while(true){
		C-=B;
		if(C<=0){
			puts("Yes");
			return 0;
		}
		A-=D;
		if(A<=0){
			puts("No");
			return 0;
		}
	}
}


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll N; cin >> N;
    ll res = 0;
    REP(i, N + 1){
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        res += i;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String[] temp = scanner.nextLine().split(" ");
		int n = Integer.parseInt(temp[0]);

		String[] numb      = scanner.nextLine().split(" ");
		int[] list = new int[n];

		for(int i = 1; i < n; i++) {

			list[Integer.parseInt(numb[i]) - 1] = i;

		}


		for(int x : list) {

			System.out.println(x + 1);
		}

	}
}


Measured memory_bytes: 59696
#include "bits/stdc++.h"

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

template <class T>
inline bool chmax(T &a, const T &b) noexcept {
    return b > a && (a = b, true);
}

template <class T>
inline bool chmin(T &a, const T &b) noexcept {
    return b < a && (a = b, true);
}

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(size_t, N, K);

    vector<intmax_t> a(N);
    input(a);

    const auto updiv = [](intmax_t n, intmax_t d) { return (n + d - 1) / d; };
    output(1 + updiv(N - K, K - 1));

    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{

  public static void main(String[] ards){
    // Nは整数で受け取るのが前提条件
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    double number = N;
    double print = number / 2 ;

    System.out.println(Math.round(print));
  }


  




}

Measured memory_bytes: 22608
line = gets
line.chomp!

/(\d+)\s*(\d+)\s*(\d+)/ =~ line
a = $1.to_i
b = $2.to_i
k = $3.to_i

if a < b then
  c = a
  a = b
  b = c
end

def gcd (m,n)
  r = m % n
  m1 = m
  n1 = n
  # print m1, " % ", n1, " = ", r
  # puts ""
  while r > 0
    m1 = n1
    n1 = r
    r = m1 % n1
    # print m1, " % ", n1, " = ", r
    # puts ""
  end
  return n1
end

c = gcd(a,b)

count = 1

while count < k do
  c -= 1
  if a % c == 0 and b % c == 0
    count += 1
  end
end

print c

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

class Program
{
    static void Main(string[] args)
    {
        // 入力
        var n = int.Parse(Console.ReadLine());
        ulong[] t = new ulong[n];
        for (int i = 0; i < n; i++)
        {
            t[i] = ulong.Parse(Console.ReadLine());
        }

        ulong[] tmp = t.Distinct().ToArray();
        ulong ans = tmp[0];
        for (int i = 1; i < tmp.Length; i++)
        {
            ans = Lcm(ans, tmp[i]);
        }

        Console.WriteLine(ans);
    }

    // 最小公倍数
    public static ulong Lcm(ulong a, ulong b)
    {
        //return a * b / Gcd(a, b);
        return a / Gcd(a, b) * b;
    }

    // ユークリッドの互除法 
    public static ulong Gcd(ulong a, ulong b)
    {
        if (a < b)
            // 引数を入替えて自分を呼び出す
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }
}


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

using namespace std;

int main() {
    int N, X, Y;

    scanf("%d %d %d", &N, &X, &Y);

    vector<vector<int>> dist(N + 1, vector<int>(N + 1));
    for (int i = 1; i < N; i++) {
        for (int j = i; j <= N; j++) {
            if (i == j) {
                dist[i][j] = 0;
                continue;
            }
            dist[i][j] = min(j - i, abs(i - X) + abs(j - Y) + 1);
        }
    }

    vector<int> ds(N + 1, 0);
    for (int i = 1; i < N; i++)
        for (int j = i + 1; j <= N; j++)
            ds[dist[i][j]]++;

    for (int i = 1; i < N; i++)
        printf("%d\n", ds[i]);

    return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

#include <vector>
#include <string>

class rolling_hash {
public:
	using u64 = std::uint_fast64_t;
	using size_type = std::uint_fast32_t;

	static constexpr u64 MOD = (1uL << 61) - 1;
	static constexpr u64 base = 20200213;

	std::string str;
	std::vector<u64> hash_, pow;

private:
	static constexpr u64 mask30 = (1ul << 30) - 1;
	static constexpr u64 mask31 = (1ul << 31) - 1;

	u64 mul(u64 a, u64 b) const {
		u64 au = a >> 31;
		u64 ad = a & mask31;
		u64 bu = b >> 31;
		u64 bd = b & mask31;
		u64 mid = ad * bu + au * bd;
		u64 midu = mid >> 30;
		u64 midd = mid & mask30;
		return apply(au * bu * 2 + midu + (midd << 31) + ad * bd);
	}
	u64 apply(u64 val) const {
		val = (val & MOD) + (val >> 61);
		if(val >= MOD) val -= MOD;
		return val;
	}
	size_type xorshift(size_type x) const {
		x ^= x << 13;
		x ^= x >> 17;
		x ^= x << 5;
		return x;
	}

public:
	rolling_hash(const rolling_hash &) = default;
	rolling_hash(rolling_hash&&) = default;

	rolling_hash() : str() {};
	rolling_hash(const std::string & str) : str(str) {
		hash_.resize(str.size() + 1, 0);
		pow.resize(str.size() + 1, 1);
		for(size_type i = 0; i < str.size(); i++) {
			hash_[i + 1] = mul(hash_[i], base) + xorshift(str[i] + 1);
			pow[i + 1] = mul(pow[i], base);
			if(hash_[i + 1] >= MOD) hash_[i + 1] -= MOD;
		}
	}

	u64 hash() const { return hash_.back(); }
	u64 hash(size_type l, size_type r) const {
		u64 ret = MOD + hash_[r] - mul(hash_[l], pow[r - l]);
		return ret < MOD ? ret : ret - MOD;
	}
	
	size_type size() const { return str.size(); }
};

int main() {
	std::string s; cin >> s;

	rolling_hash hash(s);
	for(int i = (int)s.size(); i > 0; i--) {
		int A = i;
		int B = (int)s.size() - 3 * A;
		if(A <= 0 or B <= 0 or B & 1) continue; B /= 2;

		i64 X = hash.hash(0, A);
		i64 Y = hash.hash(A, A + B);
		if(X != hash.hash(A + B, A + B + A)) continue;
		if(Y != hash.hash(A + B + A, A + B + A + B)) continue;
		if(X != hash.hash(A + B + A + B, A + B + A + B + A)) continue;

		printf("Love %s!\n", s.substr(0, A + B).c_str());
		return 0;
	}
	printf("mitomerarenaiWA\n");
	return 0;
}



Measured memory_bytes: 20040
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp8
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[2]);


            if (input[1] == "+")
            {
                Console.WriteLine(a+b);
            }
            else
            {
                Console.WriteLine(a-b);
            }
        }
    }
}


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

int main() {
	long long X, K, D;
	cin >> X >> K >> D;
	if(X < 0) X = -X;
	long long d = X / D;
	if(d > K) {
		X -= K * D;
	} else {
		if((K - d) & 1) X = D - X % D;
		else X %= D;
	}
	cout << X;
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define FORR(x, arr) for (auto& x : arr)
#define ITR(x, c) for (__typeof(c.begin()) x = c.begin(); x != c.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
//-------------------------------------------------------

int N, W;
ll dp[11451];

void solve() {
    cin >> N >> W;
    REP(i, 11451) { dp[i] = 1LL << 60; }
    dp[0] = 0;

    REP(i, N) {
        int v, w;
        cin >> v >> w;

        for (int j = 11451; j >= v; j--) {
            dp[j] = min(dp[j], dp[j - v] + w);
        }
    }

    int ans = 0;
    REP(i, 11451) {
        if (dp[i] <= W) {
            ans = i;
        }
    }

    cout << ans << endl;
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}



Measured memory_bytes: 3308
import copy
n, k = map(int, input().split())
P = list(map(int, input().split()))
U = [0]*n

for i in range(n):
    U[i] = (P[i]+1)/2

ans = sum(U[:k])
t = copy.copy(ans)

for i in range(n-k):
    t =  t+U[k+i]-U[i]
    ans = max(ans, t)
    
print(ans)


Measured memory_bytes: 33240
#include <bits/stdc++.h>
#define INF 1e9
#define endl '\n'
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define FORE(i, a, b) for (int i = (a), e = (b); i < e; ++i)
#define RFORE(i, a, b) for (int i = (b)-1, e = (a); i >= e; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, K;
    cin >> N >> K;
    vector<int> l(N);
    for (int i = 0; i < N; i++) {
        cin >> l.at(i);
    }
    SORTR(l);
    cout << accumulate(l.begin(), l.begin() + K, 0) << endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x[10000], y[10000];
    for(int i=0;i<10000;i++){
        cin>> x[i]>>y[i];
        if(x[i]==0 && y[i]==0) break;
    }
    for(int i=0;i<10000;i++){
        if(x[i]==0 && y[i]==0) break;
        else{
            if(x[i]>y[i]){
                int tmp=x[i];
                x[i]=y[i];
                y[i]=tmp;
            }
        }
        cout <<x[i]<<" "<<y[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3104
n = int(input())
a = [0] * n
b = 1
for i in range(n):
    a[i] = list(map(int, input().split()))
for i in range(n - 1):
    for j in range(i + 1, n):
        for k in range(4):
            t = a[i][0]
            a[i][0] = a[i][1]
            a[i][1] = a[i][5]
            a[i][5] = a[i][4]
            a[i][4] = t
            for u in range(4):
                v = a[i][1]
                a[i][1] = a[i][2]
                a[i][2] = a[i][4]
                a[i][4] = a[i][3]
                a[i][3] = v
                if a[i] == a[j]:
                    b = 0
        for k in range(4):
            t = a[i][0]
            a[i][0] = a[i][2]
            a[i][2] = a[i][5]
            a[i][5] = a[i][3]
            a[i][3] = t
            for u in range(4):
                v = a[i][1]
                a[i][1] = a[i][2]
                a[i][2] = a[i][4]
                a[i][4] = a[i][3]
                a[i][3] = v
                if a[i] == a[j]:
                    b = 0
if b:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5612
points_count, lines_count = gets.chomp.split(" ").map(&:to_i)
points = (1..points_count).to_a
lines = []
lines_count.times do
  lines << gets.chomp.split(" ").map(&:to_i)
end

valid_count = 0
(2..points_count).to_a.permutation do |path|
  used_lines = []
  valid = true
  [1, path].flatten.each_cons(2) do |from, to|
    # p [from, to], lines.include?([from,to]) if path == [3, 4, 5, 6, 7, 2]

    if (!lines.include?([from, to]) && !lines.include?([to, from])) ||
      used_lines.include?([from, to]) || used_lines.include?([to, from])
      valid = false
      break
    end

    used_lines << [from, to]
  end

  valid_count += 1 if valid
end

puts valid_count


Measured memory_bytes: 2044
#include <stdio.h>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];
int d[MAX];

void dijkstra(int s) {
    int p[n];
    int color[n];
    
    for(int i=0; i<n; i++) {
        color[i] = WHITE;
        d[i] = INFTY;
        p[i] = -1;
    }
    
    d[s] = 0;
    
    while(1) {
        int u;
        int mincost = INFTY;
        for (int i=0; i<n; i++) {
            if (color[i] != BLACK && d[i] < mincost) {
                mincost = d[i];
                u = i;
            }
        }
        
        if (mincost == INFTY) break;
        
        color[u] = BLACK;
        
        for (int v=0; v<=n; v++) {
            if (color[v] != BLACK && M[u][v] != INFTY) {
                if(d[u] + M[u][v] < d[v]) {
                    d[v] = d[u] + M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
}

int main() {
    scanf("%d", &n);
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            M[i][j] = INFTY;
        }
    }
    
    int u, k;
    for (int i=0; i<n; i++) {
        scanf("%d %d", &u, &k);
        for (int j=0; j<k; j++) {
            int index, tmp;
            scanf("%d %d", &index, &tmp);
            M[u][index] = tmp;
        }
    }
    
    dijkstra(0);
    
    for(int i=0; i<n; i++) {
        printf("%d %d\n", i, d[i]);
    }
    
    return 0;
}


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

using namespace std;

#define int long long

const int mod = 1e9 + 7;
int s(int l, int r) {
  return (l + r) * (r - l + 1) / 2;
}

main() {
  int n, k;
  cin >> n >> k;
  int tot = 0;
  for(int i = k; i <= n; ++i) {
    tot += (s(n - i + 1, n) - s(0, i - 1) + 1 + mod) % mod;
    tot %= mod;
  }
  tot = (tot + 1) % mod;
  cout << tot;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s == "ABC") {
        print("ARC");
    } else {
        print("ABC");
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
#define ALL(V) V.begin(), V.end()


int Main(int N, VI &B)
{
    VI A(N, 0);
    A[0] = B[0];
    REP2(i, 1, N) {
        A[i] = B[i-1];
        if(B[i-1] < A[i-1]) A[i-1] = B[i-1];
    }
    A[N-1] = B[N-2];
    return accumulate(ALL(A), 0);
}

int main(void){
    int N;
    cin >> N;
    VI B(N-1);
    REP(i, N-1) cin >> B[i];
    cout << Main(N, B) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int A, B, X;
    std::cin >> A >> B >> X;

    if (A <= X && (A + B) >= X) {
        std::cout << "YES" << std::endl;
    }
    else {
        std::cout << "NO" << std::endl;
    }

    return 0;
}

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

int main(){
  int A, B;
  cin >> A >> B;
  if(A%3==0 || B%3==0 || (A+B)%3==0){
    cout << "Possible" << endl;
    return 0;
  }
  cout << "Impossible" << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    s_lis = list(map(int, input().split()))
    q = int(input())
    t_lis = list(map(int, input().split()))
    #print(s_lis, t_lis)
    ans = 0

    for t in t_lis:
        low = 0
        high = len(s_lis) - 1
        
        while low <= high:
            mid = (low + high) // 2
            guess = s_lis[mid]
            #print(t, guess)
            if guess == t:
                ans += 1
                break
            elif guess > t:
                high = mid -1
            else:
                low = mid + 1

    print(ans)






if __name__ == "__main__":
    main()



Measured memory_bytes: 16716
#include <iostream>                                             
using namespace std;                                            
                                                                
int gcd(int a,int b) {                                          
  if (a<b) {                                                    
    swap(a,b);                                                  
  }                                                             
  if (b==0) {                                                   
    return a;                                                   
  }                                                             
  return gcd(b,a%b);                                            
}                                                               
                                                                
int main(void) {                                                
  int x, y;                                                     
  cin >> x >> y;                                                
  cout << gcd(x,y) << endl;                                     
  return 0;                                                     
}                                                               
                                                                
                 

Measured memory_bytes: 3076
#include <iostream>

int main ()
{
	int n, m, l;
	std::cin >> n >> m >> l;
	
	long long int** A = new long long int*[n];
	for (int i=0; i<n; i++) {
		A[i] = new long long int[m];
	}
	long long int** B = new long long int*[m];
	for (int i=0; i<m; i++) {
		B[i] = new long long int[l];
	}
	long long int** C = new long long int*[n];
	for (int i=0; i<n; i++) {
		C[i] = new long long int[l];
	}
	
	for (int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			std::cin >> A[i][j];
		}
	}
	for (int i=0; i<m; i++) {
		for (int j=0; j<l; j++) {
			std::cin >> B[i][j];
		}
	}
	
	for (int i=0; i<n; i++) {
		for (int j=0; j<l; j++) {
			long long int sum = 0;
			for (int k=0; k<m; k++) sum += A[i][k] * B[k][j];
			C[i][j] = sum;
		}
	}
	
	for (int i=0; i<n; i++) {
		for (int j=0; j<l; j++) {
			if (j==0) std::cout << C[i][j];
			else std::cout << " " << C[i][j];
		}
		std::cout << std::endl;
	}
	
	for (int i=0; i<n; i++) delete[] A[i];
	delete[] A;
	for (int i=0; i<m; i++) delete[] B[i];
	delete[] B;
	for (int i=0; i<n; i++) delete[] C[i];
	delete[] C;
	
	
	return 0;
}




Measured memory_bytes: 3148
#include<stdio.h>
#include<algorithm>
#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)

using namespace std;

int main(){
	int h[2],m[2],s[2];
	rep(i,3){
		rep(j,2)scanf("%d%d%d",h+j,m+j,s+j);
		int a,b,c,d;
		b=h[0]*3600+m[0]*60+s[0];
		a=h[1]*3600+m[1]*60+s[1]-b;
		c=a%60;
		a/=60;
		d=a%60;
		a/=60;
		printf("%d %d %d\n",a,d,c);
	}
	return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>
#include<bitset>
#include<stack>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll, ll> lltpl;

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



/******************************************************************************************/


const int IINF = 1e9 + 7;
const ll LINF = 1e18 + 7;
const ll MOD = 1e9 + 7;



template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}

// vector
template <typename T>
istream& operator>>(istream & is, vector<T> & vec) { for (T& x : vec) is >> x; return is; }
// pair
template <typename T, typename U>ostream& operator<<(ostream & os, pair<T, U> & pair_var) { os << "(" << pair_var.first << ", " << pair_var.second << ")"; return os; }
// vector
template <typename T>ostream& operator<<(ostream & os, const vector<T> & vec) { os << "{";	for (int i = 0; i < vec.size(); i++) { os << vec[i] << (i + 1 == vec.size() ? "" : ", "); }os << "}"; return os; }
// map
template <typename T, typename U>ostream& operator<<(ostream & os, map<T, U> & map_var) { os << "{";	repi(itr, map_var) { os << *itr; itr++; if (itr != map_var.end()) os << ", "; itr--; }os << "}"; return os; }
// set
template <typename T>ostream& operator<<(ostream & os, set<T> & set_var) { os << "{"; repi(itr, set_var) { os << *itr; itr++; if (itr != set_var.end()) os << ", "; itr--; }os << "}"; return os; }



int dp[1 << 15];
int cost[20][20];

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	string S;
	cin >> N >> S;
	int cnt = 0;
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		if (S[i] == 'x') {
			if (cnt == 1) {
				break;
			}
			cnt++;
		}
		else
		{
			cnt = 0;
		}
		ans++;
	}
	cout << ans << endl;

}



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

using namespace std;

const int N = 100000;

int a[N];

int main () {
	int n, x; cin >> n >> x;
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] > x) {
			ans += a[i] - x;
			a[i] = x;
		}
	}
	for (int i = n - 2; i >= 0; i--) {
		if (a[i] > x - a[i + 1]) {
			ans += a[i] - (x - a[i + 1]);
			a[i] = x - a[i + 1];
		}
	}
	cout << ans;
}

Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<iomanip>
#include<vector>           //????????????????¢??????¨??????????????????

using namespace std;

int main(){

int n=0,i=0;  //????´???°????????¨????????°
cin >> n;     //????´???°??\???
vector<int> V(n);          //???????????????????¢????
long int a=-1000000,b=1000000;   //?????§????°???????????????????a????????§b???????°?
long int sum=0;                  //??\??????????????°???????¨?

for(i=0 ; i<n; i++){

cin >> V[i];                   //???????????£??\??????????´??????\???

}

for(i=0;i<n;i++){

if(V[i] < b)   b=V[i];        //????°??????´??°

if(V[i] > a)   a=V[i];        //?????§?????´??°

sum = sum + V[i];             //????´????????¨?

}


cout << b << " " << a << " " << sum << endl;            //??¨???

return 0;

}

Measured memory_bytes: 1236
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>

using namespace std;

#define ll long long

int main(void){
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    for(int i = 0;i < n;++i)    cin >> a[i];

    int sum = 0;
    for(int i = 0;i < a.size();++i) sum+= a[i];

    if(h > sum){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n;
double p[3030];
double dp[3030][3030];
int main(){
    cin>>n;
    REP(i, 0, n) cin>>p[i];

    dp[0][0]=1.0;
    REP(i, 0, n){
        REP(j, 0, i+1){
            dp[i-j+1][j]+=dp[i-j][j]*p[i];
            dp[i-j][j+1]+=dp[i-j][j]*(1.0-p[i]);
        }
    }

    double ans=0;
    REP(j, 0, n/2+1){
        ans+=dp[n-j][j];
    }
    printf("%.10lf\n", ans);
    return 0;
}

Measured memory_bytes: 71936
#include <iostream>
#include <stdlib.h>
#define llint long long

using namespace std;

llint a, b, c, k;

int main(void)
{
	cin >> a >> b >> c >> k;
	if(abs(a-b) > 1000000000000000000){
		cout << "Unfair" << endl;
		return 0;
	}
	llint ans = a-b;
	if(k % 2) ans *= -1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 

#define NIL -2000000001

int heapsize =0;
void maxHeapify(int A[2000000],int i);

void HeapInsert(int A[2000000],int key);
void HeapIncreaseKey(int A[2000000],int i,int key);
int HeapExtractMax(int A[2000000]);
 
 
int main(){
  int i,x,key,max;
  char c[10];
  int A[2000000];
  while(1){
    scanf("%s",c);
      if(c[0]=='i'){
    scanf("%d",&key);
    HeapInsert(A,key);
      }
      else if(c[1]=='x'){
    max=HeapExtractMax(A);
    printf("%d\n",max);
      }
      else if(c[1]=='n'){
    break;
      }
  }
 
  return 0;
}
  void maxHeapify(int A[],int i){
  int l,r,largest,temp;
  l=i*2;
  r=i*2+1;
  if(l<=heapsize && A[l]>A[i])
    largest = l;
  
  else
    largest = i;
  
  if(r<=heapsize && A[r]>A[largest])
    largest = r;
  
  if(largest!=i){
    temp=A[i];
    A[i]=A[largest];
    A[largest]=temp;
    maxHeapify(A,largest);
  } 
}
void HeapIncreaseKey(int A[],int i,int key){
  int temp;
  if(key<A[i])
    printf("error");
  A[i]=key;
  while(i>1 && A[i/2]<A[i]){
    temp=A[i];
    A[i]=A[i/2];
    A[i/2]=temp;
    i = i/2;
  }
}
 
void HeapInsert(int A[],int key){
  heapsize +=1;
  A[heapsize] = -1000000000;
  HeapIncreaseKey(A, heapsize, key);
}
 
int HeapExtractMax(int A[]){
  int max;
 
  if(heapsize < 1)
    printf("heap under flor\n");
   
  max = A[1];
  A[1] = A[heapsize];
  heapsize -= 1;
  maxHeapify(A, 1);
  return max;
   
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(int a,int b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
int main(){
	ll a,b;
	cin >> a >> b;
	if(a<b)
	swap(a,b);
	ll t=gcd(a,b);
	cout << a*b/t << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define deci fixed<<showpoint<<setprecision //<<deci()<<
#define ll long long
#define mod 1000000007
#define endl "\n"
using namespace std;
double pi = acos(-1);
int a, b;
int main() {
	cin >> a >> b;
	int temp = 1;
	int cnt = 0;
	for (int i = temp; i < b; i += (a - 1),cnt++) {
		
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265358979323846264338327950L
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " = " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
        __f(comma+1, args...);
    }
#else
#define debug(...)
#endif
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	ll n;
 	cin >> n;
 	set <pll> as;
 	ll a, b;	
 	while (n--) {
 		cin >> a >> b;
 		as.insert({a + b, a - b});
 	}
 	ll prev = -1e18;
 	ll ans = 0;
 	while (sz(as) > 0) {
 		pll temp = *as.begin();
 		if (temp.se >= prev) {
 			ans++;
 			prev = temp.fi;
 		}
 		as.erase(as.begin());
 	}
 	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9848
N = int(input())
A = list(map(int, input().split())) # N + 1
B = list(map(int, input().split())) # N

# 重みがないのですべて小さい方から倒せると仮定する
cnt = 0
for i in range(N):
    cnt += min(B[i], A[i])
    diff = B[i] - A[i]
    if diff > 0:
        if A[i+1] < diff:
            cnt += A[i+1]
            A[i+1] = 0
        else:
            cnt += diff
            A[i+1] -= diff
        #A[i] = 0
    #else:
    #    A[i] -= B[i]
#print("A",A)
#print("B",B)
print(cnt)

Measured memory_bytes: 18624
import sys

import numpy as np

input = sys.stdin.readline
P = 10 ** 9 + 7


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A = np.array(A)

    ans = 0
    for b in range(60 + 1):
        cnt_1 = int(np.sum((A >> b) & 1))
        ans += 2 ** b * cnt_1 * (N - cnt_1)
        ans %= P
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 48764
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
namespace Fast_Read {
	inline void read(int &res) {
		res = 0;int tmp = 1;
		char ch = getchar();
		while (ch < '0' || ch > '9') {if (ch == '-')tmp = -1;ch = getchar();}
		while (ch >= '0' && ch <= '9')res = (res<<1)+(res<<3)+(ch^48),ch = getchar();
		res *= tmp;
	}
	inline void read(long long &res) {
		res = 0;long long tmp = 1;
		char ch = getchar();
		while (ch < '0' || ch > '9') {if (ch == '-')tmp = -1;ch = getchar();}
		while (ch >= '0' && ch <= '9')res = (res<<1)+(res<<3)+(ch^48),ch = getchar();
		res *= tmp;
	}
}
using namespace Fast_Read;
int H,n;
int main() {
	read(H);read(n);
	for (register int i = 1,x;i <= n;++i) {
		read(x);
		H -= x;
		if (H <= 0) {printf("Yes\n");return 0;}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define int long long
using namespace std;
int N, A[10000];
int min(){
    int m = A[0];
    for(int i=1; i<N; i++){
        m = (m < A[i])? m: A[i];
    }
    return m;
}
int max(){
    int m = A[0];
    for(int i=1; i<N; i++){
        m = (m > A[i])? m: A[i];
    }
    return m;
}
int sum(){
    int s = 0;
    for(int i=0; i<N; i++){
        s += A[i];
    }
    return s;
}
signed main(){
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    cout << min() << ' ' << max() << ' ' << sum() << endl;
}



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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  string ans;
  if (a + b == 15) ans = "+";
  else if (a * b == 15) ans = "*";
  else ans = "x";

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static int selectSort(int[] data) {
        int ret = 0, n = data.length;
        for (int i = 0; i < n; ++i) {
            int minJ = i;
            for (int j = i; j < n; ++j) {
                if (data[j] < data[minJ]) minJ = j;
            }
            if(minJ != i) {
                ++ret;
                int tmp = data[minJ];
                data[minJ] = data[i];
                data[i] = tmp;
            }
        }
        return ret;
    }

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

        int n = scanner.nextInt();
        int[] data = new int[n];

        for (int i = 0; i < n; ++i) {
            data[i] = scanner.nextInt();
        }

        int cnt = selectSort(data);
        for (int i = 0; i < n; ++i) {
            System.out.print(data[i]);
            if (i != n - 1) System.out.print(" ");
        }
        System.out.println();
        System.out.println(cnt);
    }
}


Measured memory_bytes: 26320