akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;

class Material {

	/** この材料のID */
	int fID;

	/** 材料名 */
	String fName;
	/** 価格 */
	int fBuyCost;

	/** この材料を入手するのに必要な最低価格 */
	int fMinCost;

	/** 変換可能な材料：計算時に破壊する */
	HashSet<Integer> fConvertableItem;

	public Material(int id, String name, int buyCost) {
		fID=id;
		fName=name;
		fBuyCost=buyCost;

		fConvertableItem=new HashSet<Integer>();

		fMinCost=buyCost;
	}

	public int getID() {
		return fID;
	}

	public void addConvertableItem(int item) {
		fConvertableItem.add(item);
	}

	public void removeConvatableItem(int item) {
		fConvertableItem.remove(item);
	}

	public int getMinCost() {
		return fMinCost;
	}

	public void setMinCost(int cost) {
		fMinCost=cost;
	}

	public int[] getConvertableItemByList() {
		Integer[] temp=fConvertableItem.toArray(new Integer[fConvertableItem.size()]);
		int[] ret=new int[temp.length];
		for(int i=0; i<ret.length; i++) ret[i]=temp[i];
		return ret;
	}
}

class MaterialComparator implements Comparator<Material> {

	@Override
	public int compare(Material o1, Material o2) {
		return o1.getMinCost()-o2.getMinCost();
	}

}

public class Main {

	Material[] fMaterials;

	HashMap<String, Integer> fInverse;

	public Main(BufferedReader input) throws IOException {

		fMaterials=new Material[Integer.parseInt(input.readLine())];
		fInverse=new HashMap<String, Integer>((int)(fMaterials.length/0.75));
		for(int i=0; i<fMaterials.length; i++) {
			String[] array=input.readLine().split(" ");
			fMaterials[i]=new Material(i, array[0], Integer.parseInt(array[1]));
			fInverse.put(array[0], i);
		}

		int m=Integer.parseInt(input.readLine());
		for(int i=0; i<m; i++) {
			String[] array=input.readLine().split(" ");
			int itemA=fInverse.get(array[0]);
			int itemB=fInverse.get(array[1]);
			fMaterials[itemA].addConvertableItem(itemB);
			fMaterials[itemB].addConvertableItem(itemA);
		}

	}

	public void calculateAllCheapest() {

		LinkedList<Material> tempMaterials=new LinkedList<Material>();
		for(int i=0; i<fMaterials.length; i++)
			tempMaterials.add(fMaterials[i]);

		while(!tempMaterials.isEmpty()) {

			Collections.sort(tempMaterials, new MaterialComparator());

			Material target=tempMaterials.pollFirst();
			for(int i: target.getConvertableItemByList()) {
				fMaterials[i].removeConvatableItem(target.getID());
				if(fMaterials[i].getMinCost()<target.getMinCost()) {
					System.out.println("error! algorithm or program is incorrect.");
				}
				fMaterials[i].setMinCost(target.getMinCost());
			}

		}
	}

	public int getResult() {
		int sum=0;
		for(int i=0; i<fMaterials.length; i++)
			sum+=fMaterials[i].getMinCost();
		return sum;
	}

	public static void main(String[] args) throws IOException {

		BufferedReader br=new BufferedReader(new InputStreamReader(System.in), 1);

		Main main=new Main(br);
		main.calculateAllCheapest();
		System.out.println(main.getResult());
	}
}

Measured memory_bytes: 86528
n, m = map(int, input().split())
lst = [int(i) for i in input().split()]

s = 0
for i in range(n):
  s += lst[i]
count = 0
for i in range(n):
  if lst[i] * 4 * m >= s:
    count += 1
if count >= m:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;

void pr(bool f){
	if(f)cout<<"Yay!"<<endl;
	else cout<<":("<<endl;
}



signed main(){
	int N;
	cin>>N;
	string s;
	cin>>s;
	vector<int>v[10];
	REP(i,N){
		v[s[i]-'0'].push_back(i);
	}
	int ans = 0;
	REP(i,10){
		REP(j,10){
			if(v[i].size()==0)continue;
			int ni = v[i][0];
			auto itr = upper_bound(ALL(v[j]),ni);
			if(itr==v[j].end())continue;
			int nj = *itr;
			vector<int>cnt(10,0);
			FOR(k,nj+1,N){
				cnt[s[k]-'0']=1;
			}
			REP(k,10)ans+=cnt[k];
		}
	}
	cout<<ans<<endl;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, k;
  cin >> n >> k;
  long long ans = n % k;
  cout << min(ans, abs(k - ans)) << '\n';
  return 0;
}


Measured memory_bytes: 3568
x = int(input())

lb = -1
ub = 1145141919
ans = 0

while ub - lb > 1:
    mid = (lb + ub) // 2
    s = mid * (mid + 1) // 2
    if s >= x:
        ub = mid
        ans = mid
    else:
        lb = mid

print(ub)


Measured memory_bytes: 2940
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int K;
    cin >> K;
    int evenNum = K / 2;
    int oddNum = K / 2 + K % 2;
    cout << evenNum * oddNum << endl;
}

Measured memory_bytes: 256
let map2 f a b =
  let l = Array.length a in
  let r = Array.make l (f a.(0) b.(0)) in
  for i = 1 to l - 1 do
    r.(i) <- f a.(i) b.(i)
  done;
  r

let () = Scanf.scanf "%d\n" @@ fun n ->
    let v = Array.init n (fun _ -> Scanf.scanf "%d " (fun v -> v)) in
    let c = Array.init n (fun _ -> Scanf.scanf "%d " (fun v -> v)) in
    Printf.printf "%d" (map2 (fun v c -> max (v - c) 0) v c |> Array.fold_left (+) 0)


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
vector<int> memo(100010, -1);
int rec(int N) {
    if(N==0) return 0;
    if(memo.at(N) != -1) return memo.at(N);
    
    int ans = N;
    for(int i = 1; i <= N; i *= 6) ans = min(ans, rec(N-i)+1);
    for(int i = 1; i <= N; i *= 9) ans = min(ans, rec(N-i)+1);
    memo.at(N) = ans;
    return ans;
}
int main() {
    int N;
    cin >> N;
    cout << rec(N) << endl;
}


Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

#define pi 3.141592653589793
#define mod 1000000007


int main() {
	int n;
	cin >> n;
	vector<int>l(n), r(n);
	for (int i = 0; i < n; i++)cin >> l[i] >> r[i];
	int res = 0;
	for (int i = 0; i < n; i++) {
		res += r[i] - l[i] + 1;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int K, S, counter=0;
    cin >> K >> S;
    for(int i = 0; i <= K; i++)
    {
        for(int j = 0; j <= K; j++)
        {
            int k = S - i - j;
            if(k <= K && k >= 0) counter++;
        }
    }
    cout << counter << endl;
}


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

using namespace std;

typedef long long ll;
typedef long long int lli;
typedef unsigned long long int ulli;

void fast_io(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

int main(){

	fast_io();
	//code starts here
	
	ulli answer = 0;
	lli n;
	cin >> n;
	
	for(int i = 1; i <= n; i++){
		if(i*i >= n)break;
		lli lo = i, hi = n;
		lli ans = i;
		while(lo <= hi){
			lli mid = (lo+hi)/2;
			if(i*mid<n){
				ans = mid;
				lo = mid + 1;
			} else {
				hi = mid - 1;
			}
		}
		answer += (2*(ans-i));
		answer++;
	}
	
	cout << answer << endl;
	
	return 0;

}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  int n, k;
  cin >> n >> k;

  int num = 0;
  if (n % 2 == 0) {
    num = n / 2;
  } else {
    num = (n + 1) / 2;
  }

  string ans = "YES";
  if (k > num) {
    ans = "NO";
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl

li shine[4040];
li submit[4040];

int main(){
	li n;
	while(1){
		cin>>n;
		if(n==0)break;
		rep(i,4040)shine[i]=0;
		rep(i,4040)submit[i]=0;
		vector<li> jun;
		rin{
			li a1,a2,a3;
			cin>>a1>>a2>>a3;
			shine[a1]+=a2*a3;
			jun.pb(a1);
		}
		bool ita=false;
		rep(i,sz(jun)){
			if(shine[jun[i]]>=1000000 && submit[jun[i]]==0){
				submit[jun[i]]=1;
				cout<<jun[i]<<endl;
				ita=true;
			}
		}

		if(!ita)puts("NA");
	}

	return 0;
}

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

mt19937_64 llrand((int) chrono::steady_clock::now().time_since_epoch().count());

#define st first
#define nd second
#define pb push_back

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;

const int INF = 0x3f3f3f3f;
const ll MOD = 1e9+7;
const int N = 1e6+5;

ll n, k, sum_mn[N], sum_mx[N];

ll add(ll a, ll b) {
  a %= MOD, b %= MOD;
  if(a + b > MOD) return a + b - MOD;
  return a + b;
}

ll sub(ll a, ll b) {
  a %= MOD, b %= MOD;
  if(a - b < 0) return a - b + MOD;
  return a - b;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> k;

  for(ll i = 1; i <= n+1; i++) sum_mn[i] = sum_mn[i-1] + (i-1ll);
  for(ll i = 1; i <= n+1; i++) sum_mx[i] = sum_mx[i-1] + (n-i+1ll);

  //for(int i = 0; i <= n+1; i++) {
  //  db(i _ sum_mn[i] _ sum_mx[i]);
  //}
  
  ll ans = 0;
  for(ll i = k; i <= n+1; i++) ans = add(ans, add(sub(sum_mx[i], sum_mn[i]), 1ll));
  cout << ans << "\n";
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N; cin >> N;
    ll A[3*N]; rep(i, 3*N) cin >> A[i];
    priority_queue<ll, vector<ll>, greater<ll>> pq_front;
    priority_queue<ll> pq_back;
    for(int i = 0; i < N; i++) pq_front.push(A[i]);
    for(int i = 3*N-1; i >= 2*N; i--) pq_back.push(A[i]);

    ll sum_front = 0, sum_back = 0;
    rep(i, N){
        sum_front += A[i];
        sum_back += A[3*N -1 - i];
    }
    ll zenhan[N+1], kouhan[N+1];
    zenhan[0] = sum_front; kouhan[N] = sum_back;
    for(int i = N; i < 2*N; i++){
        ll dif = A[i] - pq_front.top();
        if(dif > 0){
            sum_front += dif;
            pq_front.pop();
            pq_front.push(A[i]);
        }
        zenhan[i - (N-1)] = sum_front;
    }
    for(int i = 2*N-1; i >= N; i--){
        ll dif = A[i] - pq_back.top();
        if(dif < 0){
            sum_back += dif;
            pq_back.pop();
            pq_back.push(A[i]);
        }
        kouhan[i - N] = sum_back;
    }
    ll ans = zenhan[N]-kouhan[N];
    rep(i, N) ans = max(ans, zenhan[i]-kouhan[i]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5876
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main (String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Baggage[] w = new Baggage[n];
        boolean[] checked = new boolean[n];
        for (int i = 0; i < n; i ++) {
            w[i] = new Baggage(sc.nextInt(), i);
        }
        Arrays.sort(w);

        int i, j, swap;
        int cost = 0;
        int min = w[0].weight;
        for (i = 0; i < n; i++) {
            if (checked[i]) continue;
            checked[i] = true;
            swap = 0;
            j = w[i].index;

            while (j != i) {
                checked[j] = true;
                cost += w[j].weight;
                swap++;
                j = w[j].index;
            }
            cost += Math.min(w[i].weight * swap, min * swap + (min + w[i].weight) * 2);
        }

        System.out.println(cost);
    }
}

class Baggage implements Comparable<Baggage> {
    public int weight;
    public int index;

    public Baggage(int weight, int index) {
        this.weight = weight;
        this.index = index;
    }

    @Override
    public int compareTo(Baggage b) {
        if (weight < b.weight) return -1;
        else if (weight > b.weight) return 1;
        else return 0;
    }
}

Measured memory_bytes: 30348
import datetime
while 1:
    y1,m1,d1,y2,m2,d2 = (int(x) for x  in input().split())
    if y1 < 0:break
    start = datetime.date(y1,m1,d1)
    end = datetime.date(y2,m2,d2)
    print((end - start).days)


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

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

    return 0;
}


Measured memory_bytes: 256
N,W=map(int,input().split())
w=[0]*N
v=[0]*N
for i in range(N):
    w[i],v[i]=map(int,input().split())
dp=[[0 for i in range(W+1)] for j in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if j<w[i]:
            dp[i+1][j]=dp[i][j]
        else:
            dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i])
print(dp[N][W])


Measured memory_bytes: 171784
#include <stdio.h>
#include <algorithm>
using namespace std;
int a[5005];
int main()
{
	int n,m,i,j,k,t;
	while(~scanf("%d",&n))
	{
		for(i=1;i<=n;i++) scanf("%d",&a[i]);
		sort(a+1,a+1+n);
		long long s=0;
		for(i=1;i<=n;i++)
		for(j=i+1;j<=n;j++)
		 {
		 	s+=(lower_bound(a+1,a+1+n,a[i]+a[j])-(a+1))-j;
		 }
		 printf("%lld\n",s);
	}
	return 0;
} 

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言
#define MAX 100000

//問題をよく読もう！
//論理的に考えよう！
//サンプルを確認しよう!
//絶対に諦めるな！
//工夫をしろ！
int main() {
  int A, B, C;
  cin >> A >> B >> C;

  if(A == B) cout << C << endl;
  if(B == C) cout << A << endl;
  if(C == A) cout << B << endl;

  return 0;
}


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

bool visited[1000];
vector<int> path, adj[1000];

bool dfs(int i) {
    path.push_back(i);
    if (visited[i]) return true;
    visited[i] = true;
    for (int j : adj[i]) {
        if (dfs(j)) return true;
    }
    visited[i] = false;
    path.pop_back();
    return false;
}

int main() {
    int n, m; cin >> n >> m;
    bool edges[n][n] = {};
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        adj[a-1].push_back(b-1);
        edges[a-1][b-1] = true;
    }
    for (int i = 0; i < n; i++) {
        memset(visited, 0, sizeof visited);
        if (dfs(i)) break;
    }
    if (path.empty()) { cout << "-1\n"; return 0; }
    int start = 0;
    for (int i = 0; i < path.size()-1; i++) if (path[i] == path.back()) start = i;
    path.erase(path.begin(), path.begin()+start+1);
    for (;;) {
        bool upd = false;
        for (int a = 0; !upd && a < path.size(); a++)
            for (int b = 0; !upd && b < path.size(); b++) {
                if (a != b && a+1 != b && !(b == 0 && a == path.size()-1) && edges[path[a]][path[b]]) {
                    if (a > b) {
                        path.erase(path.begin()+a+1, path.end());
                        path.erase(path.begin(), path.begin()+b);
                    } else {
                        path.erase(path.begin()+a+1, path.begin()+b);
                    }
                    upd = true;
                }
            }
        if (!upd) {
            cout << path.size() << endl;
            for (int k : path) cout << k+1 << endl;
            break;
        }
    }
}


Measured memory_bytes: 1280
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)

if len(s) >= len(t):
    for i in range(len(t)):
        if ord(s[i]) - ord('a') < ord(t[i]) - ord('a'):
            print('Yes')
            quit()
        elif ord(s[i]) - ord('a') > ord(t[i]) - ord('a'):
            print('No')
            quit()
    else:
        print('No')
        quit()
else:
    for i in range(len(s)):
        if ord(s[i]) - ord('a') < ord(t[i]) - ord('a'):
            print('Yes')
            quit()
        elif ord(s[i]) - ord('a') > ord(t[i]) - ord('a'):
            print('No')
            quit()
    else:
        print('Yes')
        quit()

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

int solve(int n, int q, vector<vector<int>> members, int mxm) {
  vector<int> atnd(mxm + 1, 0);
  for (auto member : members) {
    for (int date : member) {
      atnd[date]++;
    }
  }
  int attendable = q - 1, date = 0;
  for (int i = 0; i <= mxm; i++) {
    if (atnd[i] > attendable) {
      attendable = atnd[i];
      date = i;
    }
  } 
  return date;
}


int main() {
  int N, Q;
  while (cin >> N >> Q and N) {
    vector<vector<int>> members(N);
    int mxm = 0;
    REP(i, N) {
      int M;
      cin >> M;
      REP(j, M) {
        int date;
        cin >> date;
        members[i].push_back(date);
        mxm = max(mxm, date);
      }
    }
    cout << solve(N, Q, members, mxm) << endl;
  }
}

Measured memory_bytes: 1240
using System;
class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);
        int c = int.Parse(s[2]);
        int sum = 0;
        for(int i=a;i<=b;i++)
        {
            if (c % i == 0)
                sum += 1;
        }
        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 9220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

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

  if (x < a) {
    cout << 0 << endl;
  } else {
    cout << 10 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
n = int(input())
lst = [list(map(int,input().split())) for i in range(2)]

ans = 0
for i in range(n):
    l = sum(lst[0][:i+1])
    r = sum(lst[1][i:])
    if (l+r > ans):
        ans = l+r
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

int main(){
    int N;
    int a[15];
    cin>>N;
    for(int i=0;i<N;++i)cin>>a[i];
    int max=0;
    int max_num=0;
    for(int i=0;i<N;++i){
        if(max<a[i]){
            max=a[i];
            max_num=i;
        }
    }
    long long value=0;
    for(int i=0;i<N;++i){
        value+=a[i];
    }
    cout<<value-a[max_num]/2<<endl;
    
}


Measured memory_bytes: 256
def two(n):
  n = str(n)
  top = int(n[0])
  b = len(n) - 1
  ans = b * (b-1) // 2 * 81 + (top-1) * b * 9 
  if b == 0:
    return 0
  for k,i in enumerate(n[1:],1):
    i = int(i)
    if i:
      ans += i + (b - k) * 9
      break
  return ans

n = int(input())
k = int(input())
if k == 1:
  n = str(n)
  top = int(n[0])
  ans = (len(n)-1) * 9 + top
  print(ans)
elif k == 2:
  n = str(n)
  top = int(n[0])
  b = len(n) - 1
  ans = b * (b-1) // 2 * 81 + (top-1) * b * 9 
  if b == 0:
    print(0)
    exit()
  for k,i in enumerate(n[1:],1):
    i = int(i)
    if i:
      ans += i + (b - k) * 9
      break
  print(ans)
elif k == 3:
  n = str(n)
  top = int(n[0])
  b = len(n) - 1
  if b <= 1:
    print(0)
    exit()
  ans = b * (b-1) * (b-2) // 6 * 729 + (top-1) * b * (b-1) // 2 *81
  n = int(n)
  t = n % (top * (10 ** b))
  mini_ans = two(t)
  ans += mini_ans
  print(ans)


Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

L, R, d = MAP()

print(R//d - (L-1)//d)

Measured memory_bytes: 10500
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

//00:53

int ch,cv;
int dat[5][5];

map<lli,int> dp;

lli toi(){
	lli res=0;
	rep(i,9){
		res*=10;
		res+=dat[i%3][i/3];
	}
	return res;
}

void tod(lli x){
	irep(i,9){
		dat[i%3][i/3]=x%10;
		x/=10;
	}
}

typedef pair<int,lli> ilp;

int dd[5]={1,0,-1,0,1};

int main(void){
	for(;;){
		scanf("%d%d",&ch,&cv);
		if(ch==0 && cv==0)break;
		dp.clear();
		rep(y,3)rep(x,3)scanf("%d",&dat[y][x]);
		
		priority_queue<ilp,vector<ilp>,greater<ilp> > que;
		que.push(ilp(0,toi()));
		
		rep(y,3)rep(x,3)scanf("%d",&dat[y][x]);
		lli gl=toi();
		while(!que.empty()){
			ilp pa=que.top();
			que.pop();
			lli no=pa.sec;
			int co=pa.fir;
			//printf("%lld %d\n",no,co);
			//if(co>10)break;
			if(dp.count(no)!=0 && dp[no]<=co)continue;
			if(no==gl){
				printf("%d\n",co);
				break;
			}
			dp[no]=co;
			
			tod(no);
			int sx,sy;
			rep(y,3)rep(x,3)if(dat[y][x]==0){
				sx=x; sy=y;
			}
		
			rep(i,4){
				int ty=sy+dd[i+1],tx=sx+dd[i];
				
				if(ty<0 || 2<ty)ty=(ty+3)%3;
				else{
					if(tx<0)ty=(ty+2)%3;
					else if(2<tx)ty=(ty+1)%3;
					tx=(tx+3)%3;
				}
				
				swap(dat[ty][tx],dat[sy][sx]);
				int nc=co;
				if(dd[i]==0)nc+=cv;
				else nc+=ch;
				
				//printf("%lld %d\n",toi(),nc);
				que.push(ilp(nc,toi()));
				swap(dat[ty][tx],dat[sy][sx]);
			}
		}
	}
	
	return 0;
}

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

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin>>n>>m;
    vector<int> indegree(n+1), dis(n+1, 0);
    vector<vector<int>> g(n+1);
    
    for(int i = 0;i<m;i++)
    {
        int x, y;
        cin>>x>>y;
        indegree[y] += 1;
        g[x].push_back(y);
    }
    
    queue<int> q;
    for(int i = 1;i<=n;i++)
    {
        if(indegree[i] == 0)
        {
            q.push(i);
        }
    }
    int ans = 0;
    while(!q.empty())
    {
        int x = q.front();
        q.pop();
        
        for(int i = 0;i<g[x].size();i++)
        {
            dis[g[x][i]] = max(dis[g[x][i]], 1 + dis[x]);
            ans = max(dis[g[x][i]], ans);
            indegree[g[x][i]] -= 1;
            if(indegree[g[x][i]] == 0)
            {
                q.push(g[x][i]);
            }
        }
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 9332
#include <iostream>
#include <string>
#include <set>

int main()
{
    char a[4010];
    int n;
    std::cin >> n;

    int r = 0, g = 0, b = 0;

    for (int i = 1; i <= n; ++i)
    {
        std::cin >> a[i];
        if (a[i] == 'R') ++r;
        else if (a[i] == 'G') ++g;
        else if (a[i] == 'B') ++b;
    }

    long long int ans = r*1LL*g*b;
    for (int j = 2; j <= n; ++j)
    {
        for (int k = j + 1; k <= n; ++k)
        {
            int i = j * 2 - k;
            if (i >= 1 && a[i] != a[j] && a[j] != a[k] && a[i] != a[k])
                --ans;
        }
    }

    std::cout << ans;
}


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

int main() {
	int n, t[110000], m, p[110], x[110];
	int tsum = 0;

	cin >> n;
	for (int i = 0; i < n; i++)cin >> t[i];
	cin >> m;
	for (int i = 0; i < m; i++)cin >> p[i] >> x[i];

	for (int i = 0; i < n; i++)tsum += t[i];
	for (int i = 0; i < m; i++)cout << tsum - t[p[i] - 1] + x[i] << endl;
	return 0;
}

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

int main(){
int n,l;
int ans=0;
int mi=1000;
cin >> n >> l;
vector<int> a(n);
for(int i=0;i < n;++i){
a[i] = l;
l++; 
}
for(int i=0;i < n;++i){
if(abs(mi) > abs(a[i]))
mi = a[i];
ans +=a[i];
}

cout << ans - mi << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
const int N=100010;
int v[N];
vector <int> q[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline bool cmp(const int &x,const int &y) {return v[x]<v[y];}
inline void dfs(int x) {
    for(int i=0;i<q[x].size();i++) dfs(q[x][i]);
    sort(q[x].begin(),q[x].end(),cmp);
    for(int i=0;i<q[x].size();i++)
	v[x]=max(v[x],int(v[q[x][i]]+q[x].size()-i));
}
int main() {
    int n;
    cin>>n;
    for(int i=2;i<=n;i++) q[gi()].push_back(i);
    dfs(1);
    cout<<v[1];
    return 0;
}

Measured memory_bytes: 11392
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while (x->right != NIL){
    x = x->right;
  }
  return x;
}

Node treeSearch(Node u, int k){
  while (u != NIL && k !=  u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;

}

/*Node treeSuccessor(Node x){
  

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}*/

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else{
    if(z->key < y->key){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}

void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 25132
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int{
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil{
		panic(e)
	}
	return i
}

func main(){
	sc.Split(bufio.ScanWords)
	n, d := nextInt(), nextInt()
	count := 0


	for i:=0; i<n; i++{
		p,q := nextInt(), nextInt()
		direction := math.Sqrt(float64(p*p+q*q))
		if direction <= float64(d){
			count++
		}
	}
	fmt.Println(count)
}

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

#pragma GCC optimize("Ofast")

using namespace std;

typedef long long ll;
typedef long double ld;
mt19937 rnd(time(0));
#define ioss ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("avia.in", "r", stdin); freopen("avia.out", "w", stdout);
#define _GLIBCXX_DEBUG
#define s second
#define f first
#define pb push_back
#define add insert
#define del erase
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pii pair<int,int>
#define res resize
#define PI acos(-1)
const ll INF = 1e9;//9223372036854775807L; //LONG_MAX;
constexpr ll mod = 1e9 + 7;


void solve() {
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    for (int i = 0; i < n; i++) {
        cout << a[i] << b[i];
    }
}

signed main() {
    ioss
    //file
    //id.resize(3e5);
    int t = 1;                                                                                                                                                                        //ll
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
	string x;
	cin >> x;
	int n = x.size();
	int num = 0;
	int numt = 0;
	RFOR(i, n - 1, 0) {
		if (x[i] == 'T') {
			numt++;
		}
		else if (numt > 0) {
			numt--;
			num++;
		}
	}
	cout << n - num*2 << endl;
	return 0;
}

Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1240>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

void C(string& str){
    str = str.substr(1) + *str.begin();
}
void J(string& str){
    str = *str.rbegin() + str.substr(0,str.length()-1);
}
void E(string& str){
    if(str.length()&1) str = str.substr(str.length()/2+1) + str[str.length()/2] + str.substr(0,str.length()/2);
    else str = str.substr(str.length()/2) + str.substr(0,str.length()/2);
}
void A(string& str){
    reverse(str.begin(),str.end());
}
void M(string& str){
    for(char& c:str){
        if(isdigit(c)){
            c = (c-'0'+1)%10 + '0';
        }
    }
}
void P(string& str){
    for(char& c:str){
        if(isdigit(c)){
            c = (c-'0'+9)%10 + '0';
        }
    }
}
map<char,int> char2idx;
void (*Func[])(string& str) = {J,C,E,A,P,M};
void init(){
    string FuncName = "JCEAPM";
    for(int i = 0; i < FuncName.length();i++) char2idx[FuncName[i]] = i;
}
string solve(){
    string order,res;
    cin >> order >> res;
    reverse(order.begin(),order.end());
    for(char& c:order){
        Func[char2idx[c]](res);
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    init();
    int n; cin >> n;
    while(n--){
        cout << solve() << endl;
    }
    return 0;
}



Measured memory_bytes: 3080
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << ((b-a)==(c-b) ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>

using namespace std;


#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;


/*vectorの要素を全部確認するやつだよ。普通に拡張for文したほうがいいよ。

for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}

*/


/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}

*/


/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/




/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/


int main() {
	int n, d; cin >> n >> d;
	int x[30][30];

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < d; ++j) {
			cin >> x[i][j];
		}
	}
	int ans = 0;

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

			int f = 0;
			for (int j = 0; j < d; ++j) {
				f += pow(abs(x[i][j] - x[r][j]), 2);
			}
			for (int g = 1; g <= 300; g++) {
				if (f == g * g) { ans++; }
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <time.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <math.h>
using namespace std;
typedef long long  ll;
static const ll INF = (ll)1 << 62;
static const ll MOD = 1e9 + 7;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

map <string, ll> m;
int main() {
	ll n; cin >> n;
	string str[101];
	ll point[101];
	repe(i, 1, n) {
		string s; cin >> str[i];
		ll p; cin >> point[i];
		m[str[i]]++;
	}

	for (map<string, ll>::iterator it = m.begin(); it != m.end(); it++) {
		string s1 = it->first;
		vector<pair<ll, ll>> v;
		repe(i, 1, n) {
			if (s1 == str[i]) {
				v.push_back(make_pair(point[i], i));
			}
		}
		sort(v.begin(), v.end());
		reverse(v.begin(), v.end());
		for (vector<pair<ll, ll>>::iterator it = v.begin(); it != v.end(); it++) {
			cout << it->second << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

void solve(long long N, std::vector<long long> A, long long Q, std::vector<long long> B, std::vector<long long> C){
    map<ll,ll> mp;
    ll sum =0;
    for(int i=0;i<N;i++){
        mp[A[i]]++;
        sum += A[i];
    }
    // cerr <<"sum=" << sum << endl;
    for(int i=0;i<Q;i++){
        sum -= B[i] * mp[B[i]];
        sum += C[i] * mp[B[i]];
       
        mp[C[i]] += mp[B[i]];
         mp[B[i]] =0;
        cout <<sum<<"\n";
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> B(Q);
    std::vector<long long> C(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&B[i]);
        scanf("%lld",&C[i]);
    }
    solve(N, std::move(A), Q, std::move(B), std::move(C));
    return 0;
}


Measured memory_bytes: 11320
from sys import stdin
def input():
    return stdin.readline().strip()
 
n = int(input())
m, a, r, c, h = 0, 0, 0, 0, 0
for _ in range(n):
    i = input()
    i = i[0]
    if i == 'M':
        m += 1
    elif i == 'A':
        a += 1
    elif i == 'R':
        r += 1
    elif i == 'C':
        c += 1
    elif i == 'H':
        h += 1
 
ans = 0
from itertools import combinations
for i in combinations([m, a, r, c, h], 3):
    i, j, k = i
    ans += i * j * k
print(ans)

Measured memory_bytes: 9120
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans = min(a, b) + min(c, d);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read

def main():
    N, *X = map(int, read().split())
    A = sorted(X)
    #if N%2 == 0:
    j = N//2 - 1
    Aj = A[j]; Aj1 = A[j+1]
    for i in range(N):
        if X[i] <= Aj:
            print(Aj1)
        else:
            print(Aj)
    #else:
    #    j = N//2 + 1
    #    A1j = A[j-1]; Aj = A[j]; Aj1 = A[j+1]
    #    for i in range(N):
    #        if X[i] <= A1j:
    #            print((Aj+Aj1)/2)
    #        elif X[i] == Aj:
    #            print((A1j+Aj1)/2)
    #        elif X[i] >= Aj1:
    #            print((A1j+Aj)/2)
    #        else:
    #            return
    #    

if __name__ == "__main__":
    main()


Measured memory_bytes: 21912
import java.util.Scanner;

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

		Scanner scan = new Scanner(System.in);
		// １番目に入力される文字列
		String charStr = scan.nextLine();

		// 2番目に入力される命令数
		int command = scan.nextInt();

		// 配列を宣言
		char[] charArray = new char[charStr.length()];
		for (int i = 0; i < charStr.length(); i++) {
			// 文字列を配列(char型)に格納
			charArray[i] = charStr.charAt(i);
		}

		for (int i = 0; i < command; i++) {
			// 命令の種類を入力
			String firstCommand = scan.next();
			// 範囲:A番目からB番目
			int setNumA = scan.nextInt();
			int setNumB = scan.nextInt();
			// 出力の命令の時
			if (firstCommand.equals("print")) {
				for (; setNumA <= setNumB; setNumA++) {
					System.out.print(charArray[setNumA]);
				}
				System.out.println("");

				// 逆順の命令の時
			} else if (firstCommand.equals("reverse")) {
				for (int j = 0; j < (setNumB - setNumA + 1) / 2; j++) {
					char change = charArray[setNumA + j];
					charArray[setNumA + j] = charArray[setNumB - j];
					charArray[setNumB - j] = change;
				}

				// 置き換えの命令の時
			} else if (firstCommand.equals("replace")) {

				// 置き換える文字を入力
				String replace = scan.next();
				for (int j = 0; setNumA <= setNumB; setNumA++, j++) {

					// 入力した文字を指定した範囲と置き換える
					charArray[setNumA] = replace.charAt(j);
				}

			}
		}
		scan.close();
	}
}



Measured memory_bytes: 31500
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;
const lli INF = 1e18L+5;
/*
lli power(lli x,lli y)
{
    lli res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}
*/
int main()
{
//cout.precision(10);
//cout.setf(ios::fixed,ios::floatfield);
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
	lli T=1;
    //cin>>T;
	while(T--)
	{
		lli i,a,b,n,z;
		cin>>a>>b;
		lli cunt=1,j=0;
		while(cunt<b)
		{
			cunt--;
			cunt+=a;
			j++;
		}
		cout<<j<<endl;
	}
}
/*
contest
tt
*/


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template<typename Monoid>
struct SegmentTree{
    using F = function<Monoid(Monoid, Monoid)>;

    int sz;
    vector<Monoid> seg;

    const F f;      // モノイドに対して二項演算を行う関数オブジェクト
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1){
        sz = 1;
        while(sz < n)   sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x){
        seg[k + sz] = x;
    }

    void build(){
        for(int k = sz - 1; k > 0; --k){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    void update(int k, const Monoid &x){
        k += sz;
        seg[k] = x;
        while(k >>= 1){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    Monoid query(int a, int b){
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1){
            if(a & 1)   L = f(L, seg[a++]);
            if(b & 1)   R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const{
        return seg[k + sz];
    }
};

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

    int H, W, M;
    cin >> H >> W >> M;
    vector<vector<int>> table(H);
    vector<int> row_sum(H, 0), column_sum(W, 0);
    SegmentTree<int> seg(W, [](int a, int b){return max(a, b);}, 0);
    for(int i = 0; i < M; ++i){
        int X, Y;
        cin >> X >> Y;
        --X, --Y;
        table[X].emplace_back(Y);
        ++row_sum[X];
        ++column_sum[Y];
    }
    for(int i = 0; i < W; ++i)  seg.set(i, column_sum[i]);
    seg.build();
    int ans = 0;
    for(int x = 0; x < H; ++x){
        for(int y : table[x]){
            seg.update(y, seg[y] - 1);
        }
        chmax(ans, row_sum[x] + seg.query(0, W));
        for(int y : table[x]){
            seg.update(y, seg[y] + 1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 26120
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let r: f64 = sc.read();
    println!("{}", r * 2. * std::f64::consts::PI);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 2208
import java.util.*;
/**
 * AtCoder Beginner Contest 044
 * 
 * 
 * @author stmasa2016
 *
 */
public class Main {
	
	
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String in = sc.nextLine();
		String[] inArray = in.split(" ");
		List <String> strList = new ArrayList<String>();
		
		for (int i = 0; i < inArray.length; i++) {

			if (strList.contains(inArray[i])) {
				continue;
			} else {
				strList.add(inArray[i]);
			}
		}


		System.out.println(strList.size());
	}
	

	
}

Measured memory_bytes: 8916
#include <iostream>

using namespace std;

int K,S;
long long int ans = 0;
int main(){
    cin >> K >> S;
    
    for(int x = K; x >= 0; x--){
        for(int y = K; y >= 0; y--){
            if(S - x - y >= 0 && S - x - y < K+1){
                ans++;
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

//A: koukyoukoukokukikou
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String r = "yuiophjklnm";
		while(true){
			String s = sc.next();
			if(s.equals("#"))break;
			int c = 0;
			int m = -1;
			for(char t : s.toCharArray()){
				boolean right = false;
				for(int i=0;i<r.length();i++)if(t==r.charAt(i))right=true;
				if(right){
					if(m==-1)m=0;
					else if(m==1){
						m=0;
						c++;
					}
				}
				else{
					if(m==-1)m=1;
					else if(m==0){
						m=1;
						c++;
					}
				}
			}
			System.out.println(c);
		}
	}
}

Measured memory_bytes: 12000