akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <list>
#include <string>
using namespace std;
const long INF = 1e9;
const long MOD = 1e9 + 7;
#define repi(i, n, init) for (int i = init; i < int(n); i++)

int main()
{
    list<int> l;
    int n;
    cin >> n;
    string op;
    repi(i, n, 0)
    {
        cin >> op;
        if (op == "insert")
        {
            int x;
            cin >> x;
            l.insert(l.begin(), x);
        }
        else if (op == "delete")
        {
            int x;
            cin >> x;
            for (list<int>::iterator itr = l.begin(); itr != l.end(); itr++)
            {
                if (*itr == x)
                {
                    l.erase(itr);
                    break;
                }
            }
        }
        else if (op == "deleteFirst")
        {
            l.erase(l.begin());
        }
        else if (op == "deleteLast")
        {
            l.erase(--l.end());
        }
    }
    string out = "";
    for (auto itr = l.begin(); itr != l.end(); itr++)
    {
        out += to_string(*itr);
        out += " ";
        // cout << *itr << ((++itr) != --l.end() ? " " : "\n");
        // itr--;
    }
    out.erase(--out.end());
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 34548
n = int(input())
d = list(map(int,input().split()))

chofuku = 0
for x in d:
    for y in d:
        chofuku += x*y
chofuku //= 2

nochofuku = 0
for x in d:
    nochofuku += x*x
nochofuku //= 2

print(chofuku-nochofuku)


Measured memory_bytes: 9128
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define repd(i,a,b) for (ll i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;

int main(void)
{
	int K;
	cin >> K;
	ll ans = 0;
	ll temp;
	repd(i,1,K+1)
	{
		repd(j,1,K+1)
		{
			repd(k,1,K+1)
			{
				temp = gcd(i,j);
				ans += gcd(temp,k);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

bool fn_is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

bool isOK(int index, int key, vector<ll>& a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main()
{
    int n, T; cin >> n >> T;
    int ans = INF;
    rep(i,n) {
        int c, t; cin >> c >> t;
        if (t > T) continue;
        ans = min(ans, c);
    }
    if (ans == INF)
        cout << "TLE" << endl;
    else
        cout << ans << endl;
}


Measured memory_bytes: 3564
[A,B,C,D] = list(map(int,input().split()))
#print(C,D)
#both
import fractions
f=fractions.gcd(C,D)
f2=C*D//f
#print(f2)

both=B//f2 - (A-1)//f2
#print('both', both)

#C
Ccount=B//C - (A-1)//C
#print('C', Ccount)

#D
Dcount=B//D - (A-1)//D
#print('D', Dcount)

print(B-A+1 -(Ccount+Dcount-both))

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

int main() {
    int n, x, a[10005], k = 0, suma = 0;
    cin >> n >> x;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        k += a[i];
        if(k<=x) {
            suma++;
        }
    }
    cout << suma+1;
    return 0;
}


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

public class Main{

    public static void main(String[] args) throws IOException {
        Reader.init();
        int N=Reader.nextInt();
      	String S=Reader.next();
      	String T=Reader.next();
      	StringBuilder sb=new StringBuilder();
      	for(int i=0;i<N;i++){
        	sb.append(S.charAt(i));
          	sb.append(T.charAt(i));
        }
      	println(sb.toString());
    }

    static int mod=1000000007;
    public static void read(int arr[], int N) throws IOException{ for(int i=0;i<N;i++){ arr[i]=Reader.nextInt(); } }
    public static void read(long arr[], int N) throws IOException{ for(int i=0;i<N;i++){ arr[i]=Reader.nextLong(); } }
    public static void read(String arr[], int N) throws IOException{ for(int i=0;i<N;i++){ arr[i]=Reader.next(); } }
    public static void print(Object O){ System.out.print(O); }
    public static void println(Object O){ System.out.println(O); }
    public static void display(int arr[]){ System.out.println(Arrays.toString(arr)); }
    public static void display(int arr[][], int N){ for(int i=0;i<N;i++){ System.out.println(Arrays.toString(arr[i])); } }
}


class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    static void init() {
        reader=new BufferedReader(new InputStreamReader(System.in));
        tokenizer=new StringTokenizer("");
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) {
            tokenizer=new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException { return Integer.parseInt(next()); }
    static double nextDouble() throws IOException { return Double.parseDouble(next()); }
    static long nextLong() throws IOException { return Long.parseLong(next()); }
    static String nextLine() throws IOException { return reader.readLine(); }
}

Measured memory_bytes: 23252
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#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 <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}

vector<ll> fact, factinv, inv;
ll mod = 998244353;
void prenCkModp(ll n) {
	fact.resize(n + 5);
	factinv.resize(n + 5);
	inv.resize(n + 5);
	fact.at(0) = fact.at(1) = 1;
	factinv.at(0) = factinv.at(1) = 1;
	inv.at(1) = 1;
	for (ll i = 2; i < n + 5; i++) {
		fact.at(i) = (fact.at(i - 1) * i) % mod;
		inv.at(i) = mod - (inv.at(mod % i) * (mod / i)) % mod;
		factinv.at(i) = (factinv.at(i - 1) * inv.at(i)) % mod;
	}

}
ll nCk(ll n, ll k) {
	return (fact.at(n) * ((factinv.at(k) * factinv.at(n - k)) % mod)) % mod;
}
int modPow(long long a, long long n, long long p) {
	if (n == 0) return 1; // 0乗にも対応する場合
	if (n == 1) return a % p;
	if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
	long long t = modPow(a, n / 2, p);
	return (t * t) % p;
}

int main() {
	ll N, A, B, K;
	cin >> N >> A >> B >> K;
	prenCkModp(N+N);
	ll an = 0;
	rep (i, N+1) {
		if ((K - A * i) % B == 0 && K - A * i >= 0&&N>=(K-A*i)/B) {
			an += nCk(N, i) * nCk(N, (K - A * i) /B);
			an %= mod;
		}
	}
	cout << an<< endl;

}

Measured memory_bytes: 14336
#include <cstdio>
#include <algorithm>
using namespace std;
#define LL unsigned long long
LL a,b,n;
int main()
{
	scanf("%llu%llu%llu",&a,&b,&n);
	LL ans;
	if(b-1<=n)
		ans=max((a*n)/b-a*(n/b),(a*(b-1))/b);
	else
		ans=(a*n)/b-a*(n/b);
	printf("%llu\n",ans);
	return 0;
}

Measured memory_bytes: 1724
# B - Bingo
import itertools
A = list()
for o in range(3):
    a = list(map(int, input().split()))
    A.append(a)
N = int(input())
b = list(int(input()) for p in range(N))#mapオブジェクトにlistをつける

bingo = [A[0],A[1],A[2],[A[0][0],A[1][0],A[2][0]],[A[0][1],A[1][1],A[2][1]],[A[0][0],A[1][1],A[2][2]],[A[0][2],A[1][2],A[2][2]],[A[0][2],A[1][1],A[2][0]]]

B_perm = []    
B = itertools.permutations(b,3)
for i in B:
    B_perm.append(list(i))#タプルをリストに直す

result = 'No'
for j in range(len(B_perm)):
    if B_perm[j] in bingo: 
        result = 'Yes'

print(result)

Measured memory_bytes: 9268
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int t;double a;
	cin >> t >> a;
	double h[n+5];
	for(int i=1;i<=n;i++){
		cin >> h[i];
	}
	int ans;double min=0x3f3f3f;
	for(int i=1;i<=n;i++){
		if(abs(a-(t-h[i]*0.006))<min){
			ans=i;
			min=abs(a-(t-h[i]*0.006));
		}
	}
	cout << ans;
	return 0;
} 

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

using namespace std;

int main()
{
    long long n;
    long double ft;
    cin>>n;
    n+=1;
    while(n--){
        ft=sqrt(n);
        if(ft-floor(ft)==0){
            cout<<n;
            break;
        }
    }
    return 0;
}


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

int main(){
  int x,y;
  cin>>x>>y;
  vector<int>z(x);
  int sum=0;
  for(int i=0;i<x;i++){
    cin>>z.at(i);
    sum+=z.at(i);
  }
  sort(z.begin(),z.end());
  reverse(z.begin(),z.end());
  for(int j=0;j<y;j++){
  if(4*y*z.at(j)<sum){
  cout<<"No"<<endl;
  return 0;
  }
  }
  cout<<"Yes"<<endl;
}

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

using namespace std;

int main() {
  int n; cin >> n;
  vector<int> d(n);
  vector<int> cnt(n + 5, 0);
  int maxd = 0;
  for (int i = 0; i < n; ++i) {
    cin >> d[i];
    maxd = max(maxd, d[i]);
    cnt[d[i]] += 1;
  }

  if (d[0] != 0) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i < n; ++i) {
    if (d[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  int ans = 1;
  for (int i = 1; i <= maxd; ++i) {
    int a = cnt[i - 1];
    int b = cnt[i];
    for (int i = 0; i < b; ++i)
      ans = 1LL * ans * a % 998244353;
  }
  cout << ans << endl;
  
  return 0;
}


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


void solve(){
  int n,m,x;
  scanf("%d %d",&n,&x);
  if(500*n>=x)printf("Yes\n");
  else printf("No\n");
}
int main(){
  /*
  int q;
  scanf("%d",&q);
  while(--q)solve();
  */
  solve();

  return 0;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String line;
      while(true) {

        if( (line = br.readLine()) == null || line.isEmpty() ) break;

        Dice dice1 = new Dice(line.split(" "));
        System.out.println(dice1.doRotate(br.readLine()));
      }
    }
  }
}

class Dice {
  private int[] side;

  public Dice( int[] ia ) {
    side = Arrays.copyOf(ia, ia.length);
  }
  public Dice( String[] s ) {
    side = new int[s.length];
    for ( int i=0; i < 6; i++)
      side[i] = Integer.parseInt(s[i]);
  }

  public int doRotate(String s) {
    for ( int i=0; i < s.length(); i++ ) {
      rotate(s.substring(i, i+1));
    }
    return side[0];
  }

  private void rotate(String o) {
    switch(o) {
      case "N" :
        rotateN();
        break;
      case "S" :
        rotateS();
        break;
      case "W" :
        rotateW();
        break;
      case "E":
        rotateE();
        break;
      default :
    }
  }

  private void rotateN() {
    int tmp = side[0];
    side[0] = side[1]; side[1] = side[5]; side[5] = side[4];
    side[4] = tmp;
  }
  private void rotateS() {
    int tmp = side[0];
    side[0] = side[4]; side[4] = side[5]; side[5] = side[1];
    side[1] = tmp;
  }
  private void rotateW() {
    int tmp = side[0];
    side[0] = side[2]; side[2] = side[5]; side[5] = side[3];
    side[3] = tmp;
  }
  private void rotateE() {
    int tmp = side[0];
    side[0] = side[3]; side[3] = side[5]; side[5] = side[2];
    side[2] = tmp;
  }
}


Measured memory_bytes: 24396
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[Integer.parseInt(sa[i]) - 1] = i;
		}
		br.close();

		TreeSet<Integer> set = new TreeSet<Integer>();
		set.add(-1);
		set.add(n);
		long ans = 0;
		for (int i = 0; i < n; i++) {
			long x = a[i] - set.lower(a[i]);
			long y = set.higher(a[i]) - a[i];
			ans += x * y * (i + 1);
			set.add(a[i]);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 51888
#include<stdio.h>
int main()
{
    int n,m,i,j,count=0;
    scanf("%d",&n);
    int t[n];
    for(i=1;i<=n;i++)
    {
        scanf("%d",&t[i]);
    }
    scanf("%d",&m);
    int p,x;
    for(i=1;i<=m;i++)
    {
        count=0;
        scanf("%d%d",&p,&x);
        for(j=1;j<=n;j++)
        {
            if(j==p)
            {
                count=count+x;
            }
            else
            {
                count=count+t[j];
            }
        }
        printf("%d\n",count);
    }
    return 0;
}


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

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

    int h[N];
    for(int i=0; i<N; i++){
        cin >> h[i];
    }

    int c[N];
    c[0] = 0;
    c[1] = abs(h[1]-h[0]);
    for(int i=2; i<N; i++){
        c[i] = min(c[i-2] + abs(h[i]-h[i-2]), c[i-1] + abs(h[i]-h[i-1]));
    }
    cout << c[N-1];
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int A, B;
  while (cin >> A >> B) {
    int res = 0;
    if (A >= 13) {
      res = B;
    } else if (A >= 6) {
      res = B / 2;
    }
    cout << res << endl;
  }
  return 0;
}


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

#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define M 1000000007

void solve()
{
	ll a,b;
	cin>>a>>b;
	if(b>=a) cout<<"unsafe";
	else cout<<"safe";
}

int main() 
{
	FAST
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++) solve();
	return 0;
}

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.solv();
	}

	private void solv() {
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();

		int[] A = new int[n + 1];
		int[] B = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			A[i] = input.nextInt();
		}
		
		// C[i]???i???????????°????¨????
		int[] C = new int[10000];
		for (int i = 1; i <= n; i++) {
			C[A[i]]++;
		}
		
		// C[i]???i??\????????°???????????°????¨??????????
		for (int i = 1; i < C.length; i++) {
			C[i] += C[i - 1];
		}
		
		for(int i = 1; i <= n; i++){
			B[C[A[i]]] = A[i];
			C[A[i]]--;
		}
		
		print(B);
	}

	private void print(Object[] xs) {
		StringBuilder sb = new StringBuilder();
		for (Object x : xs)
			sb.append(x.toString()).append(' ');
		System.out.println(sb.toString().trim());
	}

	private void print(int[] xs) {
		StringBuilder sb = new StringBuilder();
		for(int i = 1; i < xs.length; i++){
			sb.append(xs[i]).append(' ');
		}
		System.out.println(sb.toString().trim());
	}

	private static class Scanner {
		BufferedReader r;
		StreamTokenizer st;

		public Scanner(InputStream in) {
			r = new BufferedReader(new InputStreamReader(in));
			st = new StreamTokenizer(r);
		}

		public String next() {
			nextToken();
			return st.sval;
		}

		public Integer nextInt() {
			nextToken();
			return (int) st.nval;
		}

		private int nextToken() {
			int token = st.TT_EOF;
			try {
				token = st.nextToken();
			} catch (IOException e) {
			}
			return token;
		}
	}
}

Measured memory_bytes: 156056
#include <bits/stdc++.h>
using namespace std;
#define NIL -1
#define MAX 10000
typedef struct Node { int parent, left, right; } Node;
Node T[MAX];
int n;
void preParse(int u)
{
    if (u == NIL) return;
    cout << " " << u;
    preParse(T[u].left);
    preParse(T[u].right);
}
void inParse(int u)
{
    if (u == NIL) return;
    inParse(T[u].left);
    cout << " " << u;
    inParse(T[u].right);
}
void postParse(int u)
{
    if (u == NIL) return;
    postParse(T[u].left);
    postParse(T[u].right);
    cout << " " << u;
}
int main(void)
{
    int n, u, left, right, root = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) T[i].parent = NIL;

    for (int i = 0; i < n; ++i) {
        cin >> u >> left >> right;
        T[u].left = left;
        T[u].right =right;
        if (left != NIL) T[left].parent = u;
        if (right != NIL) T[right].parent = u;
    }

    for (int i = 0; i < n; ++i) if (T[i].parent == NIL) root = i;

    cout << "Preorder" << endl;
    preParse(root);
    cout << endl << "Inorder" << endl;
    inParse(root);
    cout << endl << "Postorder" << endl;
    postParse(root);
    cout << endl;
}




Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;

int main() {
        int n, t, a;
        ull tt = 1, aa = 1;
        cin >> n;
        while (n-->0) {
                cin >> t >> a;
                ull gg = max((tt-1) / t + 1, (aa-1) / a + 1);
                tt = gg * t;
                aa = gg * a;
        }
        cout << tt + aa << endl;

        return 0;
}

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

int main() {
	// your code goes here
	int n,sum=0,temp;
	cin>>n;
	temp = n;
	while(n)
	{
		int r = n%10;
		n /=10;
		sum+=r;
	}
	if(temp%sum==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


/*
--------------------------------------------

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;

/*
--------------------------------------------

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())

/*
--------------------------------------------

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

/*
--------------------------------------------

	constant

--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

/*

	Optimizer

*/
//#pragma GCC optimize("Ofast")


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

  int N,A;
  cin >> N >> A;

  cout << (N*N-A) << endl;
  return 0;
}


Measured memory_bytes: 256
/*
题意是求一个序列中"所有子序列的中位数"所组成的序列的中位数 
看题解了，完全不会。https://www.cnblogs.com/quzhizhou/p/9535597.html  

首先我们先二分最后序列的中位数。设tot为中位数 >= mid的区间个数，若中位数序列的中位数 >= mid，
则有tot >= n(n+1)/4。
我们另外构造一个序列b[i], 当a[i]>=mid时b[i]=1, 否则bi=-1. 
那么若区间[l, r]的中位数 >= mid, 则b[l]+...+b[r] >= 0. 
于是我们求出序列b[i]的前缀和序列sum[i]，那么问题就变成了求满足l <= r且sum[r]-sum[l-1]>=0的数对(l,r)数量(0<=l,r<=n)，
这个问题可以用与求逆序对数量相似的方法解决. 树状数组即可. 
*/ 
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;

const int NN = 110000;
int a[NN], l, r, n, mid, ans;
int s[NN * 2];  
//树状数组，注意，[-n-1, n], 为了让每一个存的值都是>0, 都加上n即可（因为树状数组不能从0开始）
//所以开双倍空间给数组 

int lowbit(int x){
	return x & (-x);
} 

void add1(int x, int k){
	while (x <= n * 2){
		s[x] += k;
		x += lowbit(x);
	}
}

int getsum(int x){
	int sum = 0;
	while (x > 0){
		sum += s[x];
		x -= lowbit(x);
	}
	return sum;
}

int check(int mid){
	memset(s, 0, sizeof(s));  //树状数组清0 
	//for(int i=1;i<=2*n;i++)s[i]=0;
	//与求逆序对的方法相同 
	add1(n, 1);  //因为在每个数的基础上都加了n，所以这句话相当于在和等于0的点+1
	int sum = 0;
	ll tmp = 0;
	for (int i=1; i<=n; i++){
		if (a[i] >= mid) sum++;
		else sum--;
		tmp += getsum(sum + n);
		add1(sum + n, 1);
	} 
	//return tmp>=1ll*n*(n+1)/4;
	long long nn = ((long long) n) * (n + 1) / 4; //注意！nn必须给long long
	if (tmp >= nn) return true;
	else return false; 
}

int main(){
	//freopen("atcoderarc101d.in", "r", stdin);
	
	scanf("%d", &n);
	l = 0x7fffffff; r = 0;
	for (int i=1; i<=n; i++){
		scanf("%d", &a[i]);
		if (a[i] >= r) r = a[i];
		if (a[i] <= l) l = a[i];
	}
	//printf("%d %d\n", l, r);
	while (l <= r){
		mid = (l + r) / 2;
		if (check(mid)){
			ans = mid; 
			l = mid + 1;
		} else r = mid-1;
	}
	printf("%d", ans);
	
	return 0;
} 

Measured memory_bytes: 1536
import sys
m=500000;a=[1]*m
for i in range(3,999,2):
 if a[i//2]:a[i*i//2::i]=[0]*((m-1-i*i//2)//i+1)
for e in map(int,sys.stdin):print([e-1,sum(a[:(e+1)//2])][e>3])


Measured memory_bytes: 14892
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in =new Scanner(System.in);
		int P[]={6000,4000,3000,2000};
		for(int i=0;i<4;i++){
			int j=in.nextInt(),k=in.nextInt();
			System.out.println(P[j-1]*k);
		}
	}

}



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

// a^n mod を計算する
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
 
// a^{-1} mod を計算する
ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}
 
const int MAX = 510000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    COMinit();
    ll f_max = 0;
    ll f_min = 0;
    for (int i = 0; i < N; i++) {
        f_min += A[i] * COM(N - i - 1, K - 1);
        f_min %= MOD;
    }
    for (int i = N - 1; i >= 0; i--) {
        f_max += A[i] * COM(i, K - 1);
        f_max %= MOD;
    }
    cout << (f_max - f_min + 5 * MOD) % MOD << "\n";
    
    return 0;
}

Measured memory_bytes: 12928
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC103_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = NM[0];
            var M = NM[1];

            var ab = new List<Tuple<int, int>>();
            for (int i = 0; i < M; i++)
            {
                var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
                ab.Add(new Tuple<int, int>(line[0], line[1]));
            }

            ab = ab.OrderBy(x => x.Item2).ToList();
            var ans = new List<int>();
            foreach (var item in ab)
            {
                if (ans.Count == 0)
                {
                    ans.Add(item.Item2 - 1);
                }
                else if (item.Item1 > ans.Max())
                {
                    ans.Add(item.Item2 - 1);
                }
            }

            Console.WriteLine(ans.Count());
        }
    }
}


Measured memory_bytes: 27188
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, X[8], Y[8];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> X[i] >> Y[i];

	vector<int> ord;
	rep(i, 0, N) ord.push_back(i);

	long double sm = 0;
	do {
		rep(i, 0, N - 1) {
			int a = ord[i];
			int b = ord[i + 1];

			long double dx = X[a] - X[b];
			long double dy = Y[a] - Y[b];

			sm += sqrt(dx * dx + dy * dy);
		}
	} while (next_permutation(all(ord)));

	rep(i, 0, N) sm /= (i + 1);
	printf("%.10Lf\n", sm);
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(k,nu)    for(int i=k; i<nu;  i++)
#define rep2(k,n)   for(int j=k; j<n;  j++)
#define size_a(array) sizeof(array) / sizeof(array[0])
#define INF 1000000000000 //1e+12
#define MOD 10000007 //1e9+7
#define ll long long
#define pb pop_back
template<typename T> inline void chMin(T* a, T* b) {if(*a>*b) *a=*b;}
template<typename T> inline void chMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  divUp(T a, T b)   {return ((a+b-1)/b);}
const double PI = acos(-1);


int main(){
    int k; cin >> k;
    ll ans=0;

    rep(1,k+1){
        rep2(1,k+1){
            for(int l=1; l<k+1; l++){
                ans += gcd(i,gcd(j,l));
            }
        }
    }
    cout << ans << endl;
    return 0;
}
/*

*/


Measured memory_bytes: 3616
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

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

int N, Q;
int S[212345], T[212345], X[212345], D[212345];

int main() {

	scanf("%d%d", &N, &Q);
	rep(i, N) scanf("%d%d%d", &S[i], &T[i], &X[i]);
	rep(i, Q) scanf("%d", &D[i]);

	vector<vector<int>> d(Q+1);

	vector<pair<int, pair<int, int>>> sorter;
	rep(i, N) sorter.push_back({ X[i],{S[i],T[i]} });

	sort(sorter.begin(), sorter.end());
	rep(i, N) {
		X[i] = sorter[i].first;
		S[i] = sorter[i].second.first;
		T[i] = sorter[i].second.second;
	}

	rep(i, N) {
		d[distance(D, lower_bound(D, D + Q, S[i] - X[i]))].push_back(X[i]);
		d[distance(D, lower_bound(D, D + Q, T[i] - X[i]))].push_back(-X[i]);
	}

	set<int> s;
	rep(q, Q) {
		for (auto dd : d[q]) {
			if (dd > 0) s.insert(dd);
			if (dd < 0) {
				if (s.find(-dd) != s.end()) s.erase(s.find(-dd));
			}
		}
		if (s.size()) printf("%d\n", *s.begin());
		else printf("-1\n");
	}

	return 0;
}


Measured memory_bytes: 28528
#include<stdio.h>

int main()
{
	int N;
	scanf("%d", &N);
	int V[N], C[N];
	int i;
	for(i=0;i<N;i++)
	{
		scanf("%d", &V[i]);
	}
	for(i=0;i<N;i++)
	{
		scanf("%d", &C[i]);
	}
	int sum = 0;
	for(i=0;i<N;i++)
	{	
		if(V[i]>C[i])
			sum = sum + V[i]-C[i];
	}
	printf("%d", sum);
}


Measured memory_bytes: 128
#include<stdio.h>
#define N 100000

typedef struct{
  int count;
  char pict;
  int number;
}a;

int partition(a *,int,int);
void quicksort(a *,int,int);

main(){

  int n,r,p,i,flag=0;
  a A[N];
  char m;

  scanf("%d%c",&n,&m);

  for( i=0 ; i<n ; i++){
    scanf("%c%d%c",&A[i].pict,&A[i].number,&m);
    A[i].count = i;
  }

  r=n-1;
  p=0;

  quicksort(A,p,r);
   
  for( i=0 ; i<n-1 ; i++){
    if( A[i].number == A[i+1].number && A[i].count > A[i+1].count && flag==0){
      printf("Not stable\n");
      flag=1;
    }
    if(flag == 0 && i == n-2) printf("Stable\n");
  }

  for( i=0 ; i<n ; i++){
    printf("%c %d\n",A[i].pict,A[i].number);
  }
  
  return 0;
}

int partition(a *A,int p,int r){

  int x,i,j;
  a n;

    x = A[r].number;
    i = p-1;

    for( j=p ; j<r; j++){
      if(A[j].number <= x){
	i = i+1;
	n=A[i];
	A[i]=A[j];
	A[j]=n;
	
      }
    }
    n=A[i+1];
    A[i+1]=A[r];
    A[r]=n;
   
    return i+1;
}


void quicksort(a *A,int p,int r){

  int q;

  if( p < r ){
    q=partition(A,p,r);
    quicksort(A,p,q-1);
    quicksort(A,q+1,r);
  }
  return ;
}

Measured memory_bytes: 1776
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

struct Circle {
	int x, y, r, c;
	bool has_intersection(const Circle& that) const {
		return (x - that.x) * (x - that.x) + (y - that.y) * (y - that.y) < (r + that.r) * (r + that.r);
	}
};
bool is_overwrapped(const std::vector<Circle>& circles, const int i, const int state) {
	bool has_overwrap = false;
	for (auto j = 0; j < i && !has_overwrap; ++j) if ((state & (1 << j)) == 0) {
		has_overwrap = circles[i].has_intersection(circles[j]);
	}
	return has_overwrap;
}
int max_removable(const std::vector<Circle>& circles, const int state, std::unordered_map<int, int>& memo) {
	if (memo.find(state) != memo.end()) return memo[state];
	int res = 0;
	for (auto i = 0; i < circles.size(); ++i) if ((state & (1 << i)) == 0) {
		if (!is_overwrapped(circles, i, state)) {
			for (auto j = 0; j < i; ++j) if ((state & (1 << j)) == 0 && circles[i].c == circles[j].c && !is_overwrapped(circles, j, state)) {
				res = std::max(res, max_removable(circles, state | (1 << i) | (1 << j), memo) + 2);
			}
		}
	}
	return memo[state] = res;
}
int main() {
	while (true) {
		int n; std::cin >> n; if (n == 0) break;
		std::vector<Circle> circles(n);
		for (auto& c : circles) std::cin >> c.x >> c.y >> c.r >> c.c;
		std::unordered_map<int, int> memo;
		std::cout << max_removable(circles, 0, memo) << '\n';
	}
}



Measured memory_bytes: 43812
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 1;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregion

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

  int n;
  cin >> n;
  int x = n * 800, y = n / 15 * 200;
  cout << x - y << endl;
  return 0;
}


Measured memory_bytes: 256
def coins(probabilities):
    n = len(probabilities)
    res = [0] * (n + 1)
    res[0] = 1

    for i, p in enumerate(probabilities, start=1):
        q = 1 - p
        carry = 0
        for j in range(i + 1):
            res[j], carry = res[j] * q + carry, res[j] * p

    return sum(res[(n + 1) // 2:])


def main():
    input()  # n
    probabilities = [float(x) for x in input().split()]
    return coins(probabilities)


print(main())


Measured memory_bytes: 42908
N = int(input())
A = sorted(list(map(int,input().split())))
B = [0 for _ in range(N+1)]
for i in range(1,N+1):
    B[i] = B[i-1]+A[i-1]
cnt = 1
for i in range(N-2,-1,-1):
    if A[i+1]<=2*B[i+1]:
        cnt += 1
    else:
        break
print(cnt)

Measured memory_bytes: 92364
//32
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    char o[10];
    sprintf(o,"%o",n);
    for(int i=0;o[i];i++){
      cout<<char(o[i]+(o[i]>='4')+(o[i]>='5'));
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	vi a(4,0);
	rep(i,4)a[i]=s[i]-'0';
	rep(i,8){
		int ans=a[0];
		rep(j,3){
			if(i&(1<<j))ans+=a[j+1];
			else ans-=a[j+1];
		}
		if(ans!=7)continue;
		cout<<a[0];
		rep(j,3){
			if(i&(1<<j))cout<<"+"<<a[j+1];
			else cout<<"-"<<a[j+1];
		}
		puta("=7");
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	
 	
 	int n,m;
 	
 	scanf("%d %d",&n,&m);

 	string a,b;

 	for(int i=0;i<n;i++)a.pb('0'+m);
 	for(int i=0;i<m;i++)b.pb('0'+n);
 	printf("%s\n",min(a,b).c_str() );
}		


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

int main(void) {
	int N;
	string S, T;
	cin >> N >> S >> T;
	for (int i = 0; i < N; i++) {
		cout << S[i] << T[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long gcd(long long a, long long b);
int main(){
    long long a,b;
    cin>>a>>b;
    long long n = gcd(a,b);
    int ans=1;
    for(long long i=2;i*i<=n;i++){
        if(n%i==0){
            while(n%i==0){
                 n/=i;
            }
            ans++;
        }
    }
    if(n!=1)ans++;
    cout<<ans<<endl;
    return 0;
}
long long gcd(long long a, long long b){
    if(b==0)return a;
    else return gcd(b,a%b);
}


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

#define ALL(v) v.begin(), v.end()
typedef long long ll;



using namespace std;
int main() {
	ll a,b,x;
	cin >> a >> b >> x;
	
	if (a == 0)cout << b / x + 1 << endl;
	else cout << b / x - (a - 1) / x << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int H, W;
char a[9][9];

int main()
{
    cin >> H >> W;
    int cnt = 0;
    rep(i, H)
    {
        rep(j, W)
        {
            cin >> a[i][j];
            if (a[i][j] == '#')
            {
                cnt++;
            }
        }
    }
    if (cnt == (H + W - 1))
    {
        cout << "Possible" << endl;
    }
    else
    {
        cout << "Impossible" << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
//----------------------Shanu Garg here---------------------
//-------------Search on youtube : Shanu Garg---------------
//-Studying at National Institute of Technology Delhi(NITD)-
//---------------------From Delhi, India--------------------

#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define f(i,n) for(auto i=0;i<n;i++)
#define fr(i,n) for(auto i=n-1;i>=0;i--)
#define fs(i,a,b,c) for(auto i=a;i!=b;i+=c)
#define fl(i,x) for(auto i : x)
#define nl cout<<"\n";
#define chk(x) cout<<#x<<" : "<<x, nl
#define ll long long int
#define u unsigned
#define vi vector<int>
#define vvi vector<vi>
#define pr pair<ll, ll>
#define vii vector<pair<int, int>>
#define vll vector<pr>
#define vl vector<ll>
#define m(a,b) map<a, b>
#define ci m(char, ll)
#define ii m(ll, ll)
#define mid(a,b) ((a+b)/2)
#define pb push_back
#define LCM(a,b) ((a*b)/__gcd(x,y))
const int INF = 0x3f3f3f3f, mod = 1e9 + 7;

class triplet{
    ll f, s, t;};

vl in(ll n){vl v;ll x;
    f(i,n)
    cin>>x, v.pb(x);
    return v;}
void out(vl v){
    fl(i,v)cout<<i;
}
void out(vl v, char ch){
    fl(i,v)
    cout<<i<<ch;
}

void solve(){
   ll A,B;
   cin>>A>>B;
   A--, B--;
   ll c=0;
   while(c*A < B){
       c++;
   }
   cout<<c;
}

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

Measured memory_bytes: 3592
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
memo = [0] * N

def score(c):
    if c == "r":
        return P
    if c == "s":
        return R
    if c == "p":
        return S

ans = 0

for i in range(N):
    if i < K:
        ans += score(T[i])
        memo[i] = 1
        continue
    if T[i] == T[i - K]:
        if memo[i - K] == 0:
            ans += score(T[i])
            memo[i] = 1
    else:
        ans += score(T[i])
        memo[i] = 1

print(ans)       

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<vector<bool>> linked_list;

int dfs(int v, int n, vector<bool> visited){
   bool all_visited = true;
   for(int i=0; i<n; ++i){
       if (visited[i] == false){
           all_visited = false;
       }
   } 
   if(all_visited) return 1;
   int res = 0;
   for(int i=0; i<n; ++i){
       if(linked_list[v][i]){
           if(visited[i]) continue;
           visited[i] = true;
           res += dfs(i, n, visited);
           visited[i] = false;
       }
   }
   return res;
}
signed main(){
    int n, m;
    cin >> n >> m;
    linked_list.resize(n);
    for(int i=0; i<n; ++i) linked_list[i].resize(n, false);
    for(int i=0; i<m; ++i){
        int start, end;
        cin >> start >> end;
        linked_list[start-1][end-1] = true;
        linked_list[end-1][start-1] = true;
    }
    vector<bool> visited(n, false);
    visited[0] = true;
    cout << dfs(0, n, visited) << endl;

    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

int main(){
  long double a,b,x; cin >> a >> b >> x;

  long double squar = x/a;
  long double waterline = x/(a*a);

  long double pi = 2.0 * asin(1.0);
  long double unit_r = 180.0 / pi;

  long double ans;
  if(waterline*2 <= b){
    ans = 90 - atan((squar/b)*2 / b) * unit_r;
  }
  else{
    ans = 90 - atan(a / ((b-waterline)*2)) * unit_r;
  }
  
  cout << setprecision(10);
  cout << ans << endl;
}


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

const int INF = 1e9 + 9;

int main() {
  int i, j, n, t, a, min = INF;
  int h[1010];
  int b[1010];
  cin >> n >> t >> a;

  for (i = 0; i < n; i++) {
    cin >> h[i];
    b[i] = t * 1000 - h[i] * 6 - a * 1000;
    if (b[i] < 0) {
      b[i] = b[i] * (-1);
    }
    if (min > b[i]) {
      min = b[i];
      j = i;
    }
  }
  j++;
  cout << j << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int dp[2020];
int main()
{
	int n;
	cin>>n;
	dp[0]=1;
	for(int i=0;i<=n;++i)
		for(int j=3;i+j<=n;++j)
			dp[i+j]=(dp[i+j]+dp[i])%mod;
	printf("%d\n",dp[n]);
}

Measured memory_bytes: 3732
n = int(input())
L = list(map(int,input().split()))
flag = True
for i in range(n-1):
  if L[i] < L[i+1]:
    L[i+1] -= 1
  elif L[i] == L[i+1]:
    None
  else:
    flag = False
    break
if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 14396
#include <stdio.h>
#include <stdlib.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

int main(void)
{
    int n, a[200001];

    scanf("%d", &n);
    rep(i, n)
        scanf("%d", &a[i]);

    qsort(a, n, sizeof(int), compare_int);

    rep(i, n - 1) if (a[i] == a[i + 1])
    {
        puts("NO");
        return 0;
    }

    puts("YES");
    return 0;
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll mod=1000000007;
ll modpow(ll x,ll y){
if(y==0)
  return 1;
  else if(y%2==0){
  ll z=modpow(x,y/2);
    return (z*z)%mod;
  }else{
  ll z=modpow(x,y/2);
    return (x*((z*z)%mod))%mod;
  }
    
}
ll S;
ll fac[10000];
int main(){
  cin>>S;
  fac[0]=1;
  for(ll i=1;i<10000;i++)
    fac[i]=(fac[i-1]*i)%mod;
  ll ans=0;
  for(ll i=1;3*i<=S;i++){
  ll a=fac[S-2*i-1];
    ll b=modpow(fac[i-1],mod-2);
    ll c=modpow(fac[S-3*i],mod-2);
    a=(a*b)%mod;a=(a*c)%mod;
    ans=(ans+a)%mod;
  }cout<<ans<<endl;
    
  return 0;
}


Measured memory_bytes: 3708
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

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

	Vec b(n+1), c(n+1);
	priority_queue<ll, Vec, greater<ll> > que1;
	rep(i, n){
		b[0] += a[i];
		que1.push(a[i]);
	}
	rep(i, n){
		b[i+1] = b[i];
		ll q = que1.top();
		if(a[n+i] > q){
			b[i+1] += a[n+i]-q;
			que1.pop();
			que1.push(a[n+i]);
		}
	}
	priority_queue<ll> que2;
	rep(i, n){
		c[n] += a[3*n-1-i];
		que2.push(a[3*n-1-i]);
	}
	repr(i, n){
		c[i] = c[i+1];
		ll q = que2.top();
		if(a[n+i] < q){
			c[i] += a[n+i]-q;
			que2.pop();
			que2.push(a[n+i]);
		}
	}

	ll ans = -LINF;
	rep(i, n+1) chmax(ans, b[i]-c[i]);
	co(ans);

	return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	string s;
	while(true){
		s=to_string(n);
		if(s.at(0)==s.at(1)&&s.at(1)==s.at(2))break;
		++n;
	}
	cout<<s<<"\n"s;
}

Measured memory_bytes: 256