akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,m,n;
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        ll t=0;
        while(1)
        {
            if(t==0)
            {
                c=c-b;
                if(c<=0)
                {
                    cout<<"Yes";
                    return 0;
                }
                t=1;
            }
            else
            {
                a=a-d;
                if(a<=0)
                {
                    cout<<"No";
                    return 0;
                }
                t=0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3652
n = int(input())
d = list(map(int,input().split()))
cnt = {}
for i in d:
  if i not in cnt:
    cnt[i] = 1
  else:
    cnt[i] += 1
m = int(input())
t = list(map(int,input().split()))
flag = True
for i in t:
  if i in cnt:
    if cnt[i]>0:
      cnt[i] -= 1
    else:
      flag = False
      break
  else:
    flag = False
    break
if flag:
  print("YES")
else:
  print("NO")


Measured memory_bytes: 52048
#include<iostream>
#include<queue>
using namespace std;
int main(){
    int n,k,sum,minus,ans=0;
    cin>>n>>k;
    int v[n];
    for(int i=0;i<n;i++)cin>>v[i];
    for(int l=0;l<=min(n,k);l++){
        for(int r=0;r<=min(n-l,k-l);r++){
            priority_queue<int>q;
            sum=minus=0;
            for(int a=1;a<=l;a++){
                if(v[a-1]>=0)sum+=v[a-1];
                else minus+=-v[a-1],q.push(-v[a-1]);
            }
            for(int a=1;a<=r;a++){
                if(v[n-a]>=0)sum+=v[n-a];
                else minus+=-v[n-a],q.push(-v[n-a]);
            }
            for(int a=0;!q.empty()&&a<k-(l+r);a++)minus-=q.top(),q.pop();
            ans=max(ans,sum-minus);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()




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

	int n;
	string c;
	cin >> n >> c;

	int a = 0, b = n - 1;
	int ans = 0;
	while (a < b) {
		while (a < b && c[a] != 'W')a++;
		while (a < b && c[b] != 'R')b--;
		if (a >= b)break;
		ans++;
		a++;
		b--;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3776
#include<iostream>

using namespace std;

const int maxn = 1e5;
long long a[maxn],b[maxn];
int main(){
	int n;
	cin >> n;
	
	for(int i = 0;i < n;i++){
		cin >> a[i] >> b[i];
	}
	
	long long ans = 0;
	for(int i = n-1;i >= 0;i--){
		int amari = (a[i] + ans) % b[i];
		if(amari != 0){
			ans += b[i] - amari;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
s = str(input())
t = str(input())
l = []
for i in range(len(s)-len(t)+1):
    num = 0
    for h in range(len(t)):
        if s[i+h] == t[h] or s[i+h] == '?':
            num += 1
        elif s[i+h] != t[h]:
            break
    if num == len(t):
        w2 = s[:i] + t + s[i + len(t):]
        w = ""
        for j in range(len(w2)):
            if w2[j] == "?":
                w += "a"
            else:
                w += w2[j]
        l.append(w)
l.sort()
if 0 < len(l):
    print(l[0])
else:
    print("UNRESTORABLE")

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

vector<pair<int , int> > prime_factorize(int N) {
    vector<pair<int ,int > > res;
    for (int a = 3; a * a <= N; ++a) {
        if (N % a != 0) continue;
        int  ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    int N,counter=0;
    cin >> N;
    for(int i=105;i<=N;i=i+2){
    const auto &pf = prime_factorize(i);
    long long res = 1;
    for (auto p : pf) res *= p.second + 1;
    if(res==8)counter++;}
    cout<<counter<<endl;
}

Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())
path="R"*(tx-sx) + "U"*(ty-sy) + "L"*(tx-sx) + "D"*(ty-sy) + "D" + "R"*(tx-sx+1) + "U"*(ty-sy+1) + "L" + "U" + "L"*(tx-sx+1) + "D"*(ty-sy+1) + "R"
print(path)

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

int main(void){
    int a,b;
    string s;
    cin >> a >> b;
    cin >> s;
    for (size_t i = 0; i < a+b+1; i++)
    {
        if (i==a)
        {
            if (s[i]!='-')
            {
                cout << "No";
                return 0;
            }
        }else
        {
            if (s[i]=='-')
            {
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
#import random


def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()

def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)

YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True

def main():
    N = I()
    T, A = MI()
    H = LI()
    TMP = []

    for i in range(N):
        TMP.append(T - H[i] * 0.006)

    mn = 10**19
    ans = 0
    for i in range(N):
        if mn > abs(TMP[i] - A):
            mn = abs(TMP[i] - A)
            ans = i

    print(ans + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
A = int(input())
B = int(input())
C = int(input())
X = int(input())
result = 0

def sum(a, b, c):
    return (a*500 + b*100 + c*50)

for l in range(A + 1):
    for m in range(B + 1):
        for n in range(C + 1):
            if sum(l,m,n) == X:
                result += 1

print(result)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
    long long n, k, ans=0;
    cin>>n>>k;
    ans=(n/k)*(n/k)*(n/k);
    if (k%2==0)
    {
        if (n%k>=k/2) ans+=(n/k+1)*(n/k+1)*(n/k+1);
        else ans+=(n/k)*(n/k)*(n/k);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
    int n,d;
    int x[10][10];
    double dis[10];
    cin>>n>>d;
    for(int i=0;i<n;i++)
    {
        double sum = 0;
        for(int j=0;j<d;j++)
        {
            cin>>x[i][j];
        }
    }
    int ans = 0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i==j)continue;
            double s = 0;
            for(int k=0;k<d;k++)
            {
                s += abs(x[i][k] - x[j][k]) * abs(x[i][k] - x[j][k]);
            }
            s = sqrt(s);

            if((int)s == s)ans++;
        }
    }
    cout<<ans/2;
}

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

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

    int all_e=0, all_w=0;
    for(int i=0; i<n; i++){
        if(s[i]=='E') all_e++;
        if(s[i]=='W') all_w++;
    }
    int ans = n;
    int cum_e=0, cum_w=0;
    for(int i=0; i<n; i++){
        int e=0;
        if(s[i]=='E') e = all_e - cum_e-1; // 西向きにしなければならない人数
        else          e = all_e - cum_e;
        int w = cum_w;         // 東向きにしなければならない人数
        int tmp = e + w;
        ans = min(ans, tmp);
        if(s[i]=='E') cum_e++;
        if(s[i]=='W') cum_w++;
    }

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

Measured memory_bytes: 3916
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] lst = new int[n];
		for (int i=0;i<n;i++) {
			lst[i] = sc.nextInt();
		}
		HashMap<Integer, Integer> dict = new HashMap<Integer, Integer>();
		ArrayList<Integer> ans = new ArrayList<Integer>();
		for (int k=0;k<n;k++) {
			if (dict.get(lst[k]) == null) {
				dict.put(lst[k], 1);
			} else {
				dict.put(lst[k], dict.get(lst[k]) + 1);
				if (dict.get(lst[k]) == 0) dict.remove(lst[k]);
			}
			if (dict.get(lst[n - 1 - k]) == null) {
				dict.put(lst[n - 1 - k], -1);
			} else {
				dict.put(lst[n - 1 - k], dict.get(lst[n - 1 - k]) - 1);
				if (dict.get(lst[n - 1 - k]) == 0) dict.remove(lst[n - 1 - k]);
			}
			if (dict.isEmpty()) ans.add(k + 1);	
		}
		for (int i=0;i<ans.size();i++) {
			if (i > 0) System.out.print(" ");
			System.out.print(ans.get(i));
		}
		System.out.println();
	}
}



Measured memory_bytes: 71460
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int n;
	
	cin >> n;

	ll a[n], b[n], c[n];
	
	rep(i, n)
	{
		cin >> a[i];
	}
	rep(i, n)
	{
		cin >> b[i];
	}
	rep(i, n)
	{
		cin >> c[i];
	}

	sort(a, a+n);
	sort(c, c+n);

	ll count = 0;
	for(int i = 0; i < n; i++)
	{

		ll ai = lower_bound(a, a+n, b[i]) - a;

		ll ci = upper_bound(c, c+n, b[i]) - c;

		//cout << i << " " << ai << " " << ci << endl; 

		count = count + ai * (n-ci);
	}

	cout << count << endl;

	
	return 0;
}


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

int main()
{
  int n;
  cin >> n;
  set<char> st;
  char c;
  for (int i = 0; i < n; i++) {
    cin >> c;
    st.insert(c);
  }
  if (st.size() == 4) cout << "Four" << endl;
  else cout << "Three" << endl;
}


Measured memory_bytes: 256
K,N = map(int,input().split())
A = list(map(int, input().split()))

result = [K - abs(A[-1] - A[0])]
for i in range(N-1):
    diff = abs(A[i] - A[i+1])
    result.append(diff)

result.sort()
print(sum(result[:-1]))


Measured memory_bytes: 25800
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
using namespace std;
int main() {
    int n; scanf("%d", &n);
    vector<int> a(n); repeat (i,n) scanf("%d", &a[i]);
    array<bool, 10001> dp = {};
    dp[0] = true;
    repeat (i, n) {
        repeat_reverse (j, 10001) {
            if (dp[j] and j + a[i] < 10001) {
                dp[j + a[i]] = true;
            }
        }
    }
    int result = 0;
    repeat (i, 10001) {
        if (dp[i] and i % 10 != 0) {
            result = i;
        }
    }
    printf("%d\n", result);
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <fstream>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <assert.h>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL 
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
 
 
#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
 
//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)
 
struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}
 
};
typedef vector<vector<Edge>> Graph;
typedef unsigned long long ull;

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

ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
ll mod_pow(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = (res * x) % MODU;
		x = (x*x)%MODU;
		n >>= 1;
	}
	return res;
}
ll divmod(ll a, ll b) { // a/b(mod m)
								  // a/b (mod m)
								  // a*b^-1
								  // b^-1 * b = 1
								  // b^(m-1) = 1 
								  // b^(m-2) * b = 1
								  // b^-1 = b^(m-2)

								  // a/b = a * b^(m-2)

	return (a * mod_pow(b, MODU - 2)) % MODU;
}
struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) { //ｘの入ってる集合と yの入ってる集合を併合
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) { //xとyが同じ集合に入っているかどうかを判定
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	bool isroot(int x) {
		return data[x] < 0;
	}
	int size(int x) {
		return -data[root(x)];
	}
};


int main(){
	string s;
	cin >> s;
	reverse(ALL(s));
	int count[2020] = {}, cur = 0, base = 1;	
	ll ans = 0;
	REP(i, s.length()){
		count[cur]++;
		
		cur += base * (s[i] - '0');
		cur %= 2019;
		base = (base * 10) % 2019;

		ans += count[cur];
	}

	cout << ans << endl;

	return 0;
}   

Measured memory_bytes: 3496
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    if(n==a&&n==b&&a==b)
    {
        cout<<"No";
    }
    else if(n==a)
    {
        cout<<"Yes";
    }
    else if(a==b)
    {
        cout<<"Yes";
    }
    else if(n==b)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

long long fac[51000], finv[51000], inv[51000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 51000; 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;
    }
}

// 二項係数計算
long long 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() {
    // 前処理
    COMinit();

    // 計算例
    cout << COM(100000, 50000) << endl;
}*/

//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/

int main(){
    string S,T;
    cin >> S >> T;
    ll s = S.size();
    bool ans = false;
    if(S == T)ans = true;
    rep(i,s){
        string U = S[s - 1] + S.substr(0,s - 1);
        if(U == T)ans = true;
        S = U;
        //cout << U << endl;
    }
    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;
    //cout << S[s - 1] + S.substr(0,s - 1) << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod= 1000000007;
int main()
{
    ll n,k;

    cin>>n>>k;

    ll ans=0;

    for (ll i=k; i<=n+1; ++i)
    {
        ans+=-i*i+i*(n+1)+1;
        ans%=mod;
    }
    cout<<ans;

    
    
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int a, b, k;
    cin >> a >> b >> k;
    int area = b - a+1;
    if(area <= k*2){
        for(int i = a; i <=b; i++){
            cout << i << endl;
        }
        return 0;
    }
    for(int i = a; i < a+k; i++){
        cout << i << endl;
    }
    for(int i = b-k+1; i <= b; i++){
        cout << i << endl;
    }
    
}


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

template <typename T>
struct BIT {
	int n;
	vector<T> value;
	BIT(int n): n(n), value(n + 1){}
	
	T add(int k, T x){
		while (k <= n){
			value[k] += x;
			k += k & -k;
		}
	}
	
	T sum(int k){
		T s = 0;
		while (k){
			s += value[k];
			k -= k & -k;
		}
		return s;
	}
};

typedef long long lint;
const lint MOD = 1e9 + 7;
lint fact[100001];

int main()
{
	fact[0] = 1;
	for (int i = 1; i <= 100000; i++){
		fact[i] = (fact[i - 1] * i) % MOD;
	}
	
	int n, r;
	while (scanf("%d", &n), n){
		vector<int> v(n);
		BIT<lint> bit(n);
		for (int i = 0; i < n; i++){
			v[i] = i + 1;
			bit.add(i + 1, 1);
		}
		
		scanf("%d", &r);
		for (int i = 0; i < r; i++){
			int s, t;
			scanf("%d %d", &s, &t);
			swap(v[--s], v[--t]);
		}
		
		lint res = 0;
		for (int i = 0; i < n; i++){
			bit.add(v[i], -1);
			res += (bit.sum(v[i]) * fact[n - i - 1]);
			res %= MOD;
		}
		
		printf("%lld\n", res);
	}
	
	return 0;
}

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

public class Main {
	private final static String NEGATIVE = "NO\n";
	private final static String AFFIRMATIVE = "YES\n";

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 512);
		int number = Integer.parseInt(br.readLine());
		int sides[] = new int[3];
		StringTokenizer tknz;
		StringBuilder builder = new StringBuilder();

		for (; 0 < number; number--) {
			tknz = new StringTokenizer(br.readLine());
			for (int i = 0; i < 3; i++) {
				sides[i] = Integer.parseInt(tknz.nextToken());
			}
			Arrays.sort(sides);
			if (sides[0] * sides[1] * sides[2] % 60 != 0) {
				builder.append(NEGATIVE);
			} else if (Math.pow(sides[0], 2) + Math.pow(sides[1], 2) != Math.pow(sides[2], 2)) {
				builder.append(NEGATIVE);
			} else {
				builder.append(AFFIRMATIVE);
			}
		}
		System.out.print(builder);
	}
}

Measured memory_bytes: 18556
def solve():
    S = input()

    s = [0 for _ in range(len(S))]
    for i, si in enumerate(S):
        if si == 'R':
            t = S[i:].index('L')
            if t % 2 == 0:
                s[i+t] += 1
            else:
                s[i+t-1] += 1
        else:
            t = S[:i].rfind('R')
            if (i - t) % 2 == 0:
                s[t] += 1
            else:
                s[t+1] += 1
                
    return s

print(*solve())

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

typedef long long int ll;
#define pb push_back
#define mod 1000000007
ll a[2000005]={0};
ll dp[20000005]={0};
int main()
{
   ll n,i,j,k,m,x;

   cin>>n>>m;

   for(i=0;i<m;i++)
   {
        cin>>x;
        a[x]=1;
   }

   dp[0]=1;

   if(a[1]==0)
    dp[1]=1;

    for(i=2;i<=n;i++)
    {
        if(a[i]==0)
        {
            dp[i]=dp[i-1]+dp[i-2];
            dp[i]=dp[i]%mod;
        }
    }

    cout<<dp[n];
}

Measured memory_bytes: 3072
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

s = ins()
hasa = (s[0]=='A') or (s[1]=='A') or (s[2]=='A')
hasb = (s[0]=='B') or (s[1]=='B') or (s[2]=='B')
if hasa and hasb:
    print('Yes')
else:
    print('No')


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

int main()
{
 map<int,int > m;
 int n;
 cin >>n;
 for(int i=1;i<=n;i++)
 {
     int a;
     cin>>a;
     m[a]++;
 }
 cout <<m.size()<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;int a[25],p[10],i,j,n,q;
int main(){p[0]=1;for(i=1;i<10;i++){p[i]=p[i-1]*10;}
    while(true){memset(a,0,sizeof(a));
        cin>>a[0]>>q;if(a[0]==0){break;}
        for(i=1;i<25;i++){
            n=0;
            for(j=9;j>=0;j--){
                for(int k=0;k<q;k++){
                    if((a[i-1]/p[k])%10==j){
                        a[i]+=j*p[q-1-n];
                        a[i]-=j*p[n];n++;
                    }
                }
            }
            for(j=0;j<i;j++){
                if(a[i]==a[j]){cout<<j<<' '<<a[i]<<' '<<i-j<<endl;goto E;}
            }
        }
        E:;
    }
}

Measured memory_bytes: 1160
nm = gets.chomp.split(" ").map(&:to_i)

if nm[0] >= 0 && nm[1] > 0
  if nm[0] <= nm[1]
    p nm[1] - nm[0]
  else
    p nm[0] - nm[1] + 2
  end
elsif nm[0] >= 0 && nm[1] < 0
  if nm[0] + nm[1] > 0
    p nm[0] + nm[1] + 1 
  else
    p -nm[1] - nm[0] + 1 
  end
elsif nm[0] < 0 && nm[1] > 0
  #p nm[1] - nm[0]
  if nm[0] + nm[1] > 0
    p nm[1] + nm[0] + 1 
  else
    p -nm[0] - nm[1]  + 1 
  end
elsif nm[0]>=0 && nm[1] == 0
  p nm[0]+1
else
  if nm[0] <= nm[1]
    p nm[1] - nm[0]
  else
    p nm[0] - nm[1] + 2
  end

end


Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<complex>
using namespace std;
typedef long long LL;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
int ff,ans[105][105][3],a,b,dist[105][105],tong[105][105];
int main(){
	a=read(); b=read();
	for(int i=1;i<=a;i++)for(int j=1;j<=b;j++)dist[i][j]=read();
	for(int i=0;i<=100;i++)for(int j=0;j<=100;j++)for(int o=0;o<=100;o++){
		int f=1;
		for(int k=1;k<=a&&f;k++){
			for(int l=1;l<=b&&f;l++)if(i*k+j*l+o<dist[k][l])f=0;
		}
		if(!f)continue;
		for(int k=1;k<=a;k++){
			for(int l=1;l<=b;l++){
				if(i*k+j*l+o==dist[k][l]){
					ans[k][l][0]=i+1; ans[k][l][1]=j+1; ans[k][l][2]=o;
				}
			}
		} break;
	}
	ff=1;
	for(int i=1;i<=a;i++)for(int j=1;j<=b;j++)if(!ans[i][j][0])ff=0;
	if(!ff){
		puts("Impossible"); return 0;
	}
	puts("Possible");
	int m=200; for(int i=1;i<=a;i++)for(int j=1;j<=b;j++){
		if(!tong[ans[i][j][0]][ans[i][j][1]])m++; tong[ans[i][j][0]][ans[i][j][1]]=1;
	}
	cout<<202<<" "<<m<<endl; memset(tong,0,sizeof(tong));
	for(int i=1;i<=100;i++)cout<<i<<" "<<i+1<<" X\n";
	for(int i=102;i<=201;i++)cout<<i<<' '<<i+1<<" Y\n";
	for(int i=1;i<=a;i++)for(int j=1;j<=b;j++)if(ans[i][j][0]){
		if(!tong[ans[i][j][0]][ans[i][j][1]]){
			cout<<ans[i][j][0]<<" "<<203-ans[i][j][1]<<" "<<ans[i][j][2]<<endl;
		}
		tong[ans[i][j][0]][ans[i][j][1]]=1;
	}
	puts("1 202");
}


Measured memory_bytes: 384
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =10;
const int N = 1e6+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

  
int main() 
{ 
  int n,k,x,y;
  scf(n),scf(k),scf(x),scf(y);

  if(n<=k)
    prin(x*n);
  else
  {
    int a=x*k+y*(n-k);

    prin(a);
  }



  
  
    
} 
  


Measured memory_bytes: 3816
#include<bits/stdc++.h>
//#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
using namespace std;
int n,k;
const int mod = 1e9+7;
ll dp[405][405];
int a[405];
ll pr[405];
main() {
    ios::sync_with_stdio(0);
    cin >> n ;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        pr[i] = a[i];
    }
    for (int i = 1; i <= n;i++)
        pr[i] += pr[i-1];
    for (int r = 1; r <= n; r++)
    for (int l = r-1; l > 0; l--) {
        dp[l][r] = 10000000000000000;
        for (int i = l; i < r; i++)
            dp[l][r] = min(dp[l][r],dp[l][i] + dp[i+1][r] + pr[r] - pr[l-1]);
    }
    cout << dp[1][n];

}


Measured memory_bytes: 4896
#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define fi first
#define se second
#define forn(i, n)for(int i=0;i<int__(n);i++) 
#define sz(a)int__(a.size())
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a){return out << "(" << a.first << ", " << a.second << ")";}
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int Mod(int x){const int mm=998244353;x%=mm;if(x<0)x+=mm;return x;}
int Pow(int x,int n){if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}
#define watch(x) cout << #x << " : " << x << endl;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
#define all(x) x.begin(), x.end()

const int mod = 998244353;
vi fact;

int comb(int n,int r) {
	if(n==r or r==0) return 1;

	int num=fact[n];
	int denom = Mod(fact[r] * fact[n-r]);

	denom = Pow(denom,mod-2);

	return Mod(num*denom);
}

int__ main() {
	fast;

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

	fact = vi(n+1,1);
	for(int i=1;i<=n;i++) {
		fact[i] = Mod(i*fact[i-1]);
	}
	int ans = 0;
	for(int i=0;i<=k;i++) {
		int c = comb(n-1,n-1-i);
		int w = Mod(m * Pow(m-1,n-1-i));

		ans += Mod(c*w);
		ans = Mod(ans);
	}

	cout << ans << endl;
}

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

using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main()
{
    string s;
    cin>>s;
    if(s=="ABC")
        cout<<"ARC";
    else
        cout<<"ABC";
    return 0;
}


Measured memory_bytes: 3548
# 2019/04/13
# AtCoder Beginner Contest 124 - A

# Input
a, b = map(int,input().split())
sum = 0

# Calc
if a > b:
    sum = a
    a -= 1
else:
    sum = b
    b -= 1

if a > b:
    sum += a
else:
    sum += b

# Output
print(sum)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(int i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(int i=(a);i<(n);i++)cout<<(arr)[i]<<' ';

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}

int main(){
	fast;
	ll x, y, a, b;
	cin>>x>>y>>a>>b;
	string ans = "";
	forn(i, 0, b-y){
		ans+="U";
	}
	forn(i, 0, a-x){
		ans+='R';
	}
	forn(i, 0, b-y){
		ans+="D";
	}
	forn(i, 0, a-x){
		ans+='L';
	}
	ans+="L";
	forn(i, 0, b-y){
		ans+="U";
	}
	ans+="U";
	ans+="R";
	forn(i, 0, a-x){
		ans+='R';
	}
	ans+="D";
	ans+='R';
	forn(i, 0, b-y){
		ans+="D";
	}
	ans+="D";
	ans+="L";
	forn(i, 0, a-x){
		ans+='L';
	}
	ans+="U";
	cout<<ans<<endl;
	// cout<<ans.size()<<endl;

}

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

namespace AtCoder.DP
{
    class EDPC_N
    {
        static long[,] dp;
        static long[] acc;

        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
            dp = new long[n, n + 1];
            acc = new long[n + 1];

            for (int i = 0; i < n; i++)
                acc[i + 1] = acc[i] + a[i];

            Union(0, n);
            Console.WriteLine(dp[0, n]);
        }

        public static long Union(int left, int right)
        {
            if (right - left == 1 || dp[left, right] != 0)
                return dp[left, right];

            long min = long.MaxValue;
            for (int i = left + 1; i < right; i++)
            {
                var temp = Union(left, i) + Union(i, right);
                if (min > temp)
                    min = temp;
            }
            dp[left, right] = min + acc[right] - acc[left];
            return dp[left, right];
        }
    }
}


Measured memory_bytes: 14652
#include <iostream>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned ll
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define all(x) x.begin() , x.end()
#define mp make_pair
#define x first
#define y second
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod = 1e9 + 7;
using namespace std;
void add(int& a , int b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
    if(b == 0) return 1 ;
    ull c = Pow(a , b / 2) ;
    if(b % 2) return c * c * a ;
    return c * c ;
}

int main(){
	IOS;
    cout.precision(30) ;
    int n ; cin >> n ;
    vector<vi> x(n , vi(n , -1)) ;
    for(int i = 0 ; i < n ; i++){
        int a ; cin >> a ;
        int X , Y;
        for(int j = 0 ; j < a ; j++){
            cin >> X >> Y ;
            X-- ;
            x[i][X] = Y ;
        }
    }
    int ans = 0 ;
    for(int i = 0 ; i < (1 << n) ; i++){
        bool b = true ;
        for (int j = 0 ; j < n ;j++){
            if(i & (1 << j)){
              for(int k = 0 ; k < n ;k++){
                if(x[j][k] != -1){
                    if(((x[j][k] != 0)  && ((i & (1 << k)) == 0)) || ((x[j][k] == 0)  && ((i & (1 << k)) != 0)))  {
                        b = false ;
                    }
                }
              }
            }
            /*else{
                for(int k = 0 ; k < n ;k++){
                    if(x[j][k] != -1){
                        if(((x[j][k] ==0) && ((i & (1 << k)) == 0)) || ((x[j][k] !=0 ) && ((i & (1 << k)) != 0))){

                            b = false ;
                        }
                    }
                }
            }*/
        }
        if(b) {
            //cout << i << endl ;
            ans = max(ans , __builtin_popcount(i)) ;
        }
    }
    cout << ans << endl ;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main()
{
	int n = 0;
	std::cin >> n;

	std::vector<int> diff(n);
	int inputNum = 0;
	int preNum = 0;

	std::cin >> preNum;
	for (int count = 1; count < n; ++count)
	{
		std::cin >> inputNum;
		if (inputNum - preNum == 1)
		{
			diff.at(preNum - 1) = 1;
		}
		preNum = inputNum;
	}

	unsigned long long satisfaction = 0;

	for (int count = 0; count < n; ++count)
	{
		std::cin >> inputNum;
		satisfaction += inputNum;
	}

	for (int index = 0; index < n - 1; ++index)
	{
		std::cin >> inputNum;
		satisfaction += diff.at(index) * inputNum;
	}

	std::cout << satisfaction << std::endl;
}

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

#define INF 10000000000000000

LL zab[11000];

int main(){
    LL n;
    cin >> n;
    vector<pair<LL,LL> > g;
    for(LL i = 0; i < n; i++){
        LL a, b;
        cin >> a >> b;
        a += b;
        g.push_back(make_pair(a,b));
    }
    sort(g.begin(), g.end());

    for(LL i = 0; i <= n; i++){
        zab[i] = INF;
    }
    zab[0] = 0;

    for(LL i = 0; i < n; i++){
        g[i].first -= g[i].second;
        for(LL j = n-1; j >= 0; j--){
            if(zab[j] <= g[i].first){
                zab[j+1] = min(zab[j+1], zab[j] + g[i].second);
            }
        }
    }

    LL best = 0;
    for(LL i = 0; i <= n; i++){
        if(zab[i] < INF){
            best = i;
        }
    }
    cout << best << endl;
}


Measured memory_bytes: 512
#include<cstdio>
#include<string>

using namespace std;

int main(void){
	int n;
	while(scanf("%d", &n) && n != 0){
		int dice[6] = {1,2,3,4,5,6};
		int ans = 1;
		int c = 0;
		
		char str[16];
		
		for(int i = 0; i < n; i++){
			int temp;
			
			scanf("%s", str);
			
			if(str[0] == 'N'){
				temp = dice[0];
				dice[0] = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[4];
				dice[4] = temp;
			}else if(str[0] == 'E'){
				temp = dice[0];
				dice[0] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[2];
				dice[2] = temp;
			}else if(str[0] == 'W'){
				temp = dice[0];
				dice[0] = dice[2];
				dice[2] = dice[5];
				dice[5] = dice[3];
				dice[3] = temp;
			}else if(str[0] == 'S'){
				temp = dice[0];
				dice[0] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[1];
				dice[1] = temp;
			}else if(str[0] == 'R'){
				temp = dice[1];
				dice[1] = dice[2];
				dice[2] = dice[4];
				dice[4] = dice[3];
				dice[3] = temp;
			}else if(str[0] == 'L'){
				temp = dice[1];
				dice[1] = dice[3];
				dice[3] = dice[4];
				dice[4] = dice[2];
				dice[2] = temp;
			}
			ans += dice[0];
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
///╔══╗
///╚╗╔╝
///╔╝╚(¯`v´¯)
///╚══╝`.¸.´farzin


#include <bits/stdc++.h>

#define int int64_t
#define pb push_back
#define ibsws ios_base::sync_with_stdio
#define gcd __gcd
#define s second
#define f first
#define mp make_pair
typedef std::pair<int,int> pii ;

using namespace std;

const int N=410,inf=1e15;
int n,a[N],dp[N][N],ps[N];

int32_t main(){
	ibsws(true==false);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        ps[i]=ps[i-1]+a[i];
    }
    for(int j=1;j<=n;j++){
        for(int i=1;i+j<=n;i++){
            if(i==i+j){
                dp[i][i+j]=a[i];
                continue;
            }
            if(j==1){
                dp[i][i+j]=a[i]+a[i+j];
                continue;
            }
            dp[i][i+j]=inf;
            for(int k=0;k<=j;k++){
                dp[i][i+j]=min(dp[i][i+j],dp[i][i+k]+dp[i+k+1][i+j]-ps[i-1]+ps[i+j]);
            }
        }
    }
    cout<<dp[1][n];
}


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

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

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const int MAX_VAL = 1e5;

int uniq = -1;
vector<array<int, 2>> find(vi vals) {
    vi ct(MAX_VAL + 1);
    for (int v : vals) ct[v]++;

    vector<array<int, 2>> app;
    for (int i = 1; i <= MAX_VAL; i++) {
        if (ct[i])
            app.push_back({ vals.size() - ct[i], i });
    }

    sort(all(app));

    vector<array<int, 2>> res;
    for (int i = 0; i < 2; i++) {
        if (i < app.size()) {
            res.push_back({ app[i][1], app[i][0] });
        } else {
            res.push_back({ uniq--, vals.size() });
        }
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);

    int N;
    cin >> N;

    vi odd(N/2), even(N/2);
    for (int i = 0; i < N; i++) {
        if (i&1) cin >> odd[i/2];
        else cin >> even[i/2];
    }

    int ans = INT_MAX;
    for (auto a : find(even)) {
        for (auto b : find(odd)) {
            if (a[0] != b[0])
                ans = min(ans, a[1] + b[1]);
        }
    }

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



Measured memory_bytes: 2204
import java.util.*;
import java.lang.*;

class Main {

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

	public void surprise() {
		Scanner scanner = new Scanner(System.in);
		int numOps = scanner.nextInt();
		int key, pri;
		Node root = null;

		for(int i = 0; i < numOps; i++) {
			String op = scanner.next();

			if(op.equals("insert")) {
				key = scanner.nextInt();
				pri = scanner.nextInt();
				root = insert(root, key, pri);
			} else if(op.equals("find")) {
				key = scanner.nextInt();
				System.out.println(find(root, key) ? "yes" : "no");
			} else if(op.equals("delete")) {
				key = scanner.nextInt();
				root = erase(root, key);
			} else if(op.equals("print")) {
				printTreap(root);
			}
		}
	}

	public Node rightRotate(Node t) {
		Node s = t.left;
		t.left = s.right;
		s.right = t;
		return s;
	}

	public Node leftRotate(Node t) {
		Node s = t.right;
		t.right = s.left;
		s.left = t;
		return s;
	}

	public Node insert(Node t, int key, int pri) {
		if(t == null)
			return new Node(key, pri);

		if(key == t.key)
			return t;

		if(key < t.key) {
			t.left = insert(t.left, key, pri);
			if(t.pri < t.left.pri)
				t = rightRotate(t);
		} else {
			t.right = insert(t.right, key, pri);
			if(t.pri < t.right.pri)
				t = leftRotate(t);
		}

		return t;
	}

	public Node erase(Node t, int key) {
		if(t == null)
			return null;

		if(key == t.key) {
			if(t.left == null && t.right == null)
				return null;
			else if(t.left == null)
				t = leftRotate(t);
			else if(t.right == null)
				t = rightRotate(t);
			else {
				if(t.left.pri > t.right.pri)
					t = rightRotate(t);
				else 
					t = leftRotate(t);
			}

			return erase(t, key);
		}

		if(key < t.key)
			t.left = erase(t.left, key);
		else
			t.right = erase(t.right, key);

		return t;
	}

	public boolean find(Node root, int target) {
		if(root == null)
			return false;

		if(root.key == target)
			return true;
		else if(root.key < target)
			return find(root.right, target);
		else
			return find(root.left, target);
	}

	public void printTreap(Node root) {
		inorderTraverse(root);
		System.out.println();
		preorderTraverse(root);
		System.out.println();
	}

	private void inorderTraverse(Node root) {
		if(root != null) {
			inorderTraverse(root.left);
			System.out.print(" " + root.key);
			inorderTraverse(root.right);
		}
	}

	private void preorderTraverse(Node root) {
		if(root != null) {
			System.out.print(" " + root.key);
			preorderTraverse(root.left);
			preorderTraverse(root.right);
		}
	}

	class Node {
		int key;
		int pri;
		Node left;
		Node right;

		public Node(int k, int p) {
			key = k;
			pri = p;
			left = null;
			right = null;
		}
	}
}


Measured memory_bytes: 183560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair


int main()
{
  ll a,b,c;
  cin>>a>>b>>c;
  ll d[a][b+1];
  for(ll i=0;i<a;i++)
  {
    for(ll j=0;j<b+1;j++)
    cin>>d[i][j];
  }
  vector<ll> v;
  for(ll i=0;i<(1<<a);i++)
  {
    ll count=0,sum[b]={0},sum1=0,k=i;
    while(k)
    {
      if(k%2!=0)
      {
        for(ll j=0;j<b+1;j++)
        {
          if(j==0)
          sum1+=d[count][j];
          else
          {
            sum[j-1]+=d[count][j];
          }
        }
      }
      k/=2;
      count++;
    }
    ll z=0;
    for(ll j=0;j<b;j++)
    {
      if(sum[j]>=c)
      z++;
    }
    if(z==b)
    v.pb(sum1);
  }
  if(v.empty())
  cout<<-1<<endl;
  else
  {
    sort(v.begin(),v.end());
    cout<<v[0]<<endl;
  }
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fo(i,n) for(ll i=0;i<n;i++)
#define fok(i,k,n) for(ll i=k;i<n;i++)
#define ci(x) cin>>x
#define ci2(x,y) cin>>x>>y
#define co(x) cout<<x<<"\n"
#define co2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define deb1(x) cout<<#x<<" "<<x<<endl
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n"
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;	
constexpr ll INF = static_cast<ll>(1e18);


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, a ,b;
	cin>>n>>a>>b;
	cout<<n/(a+b)*a+min(n%(a+b),a)<<"\n";
	return 0;
}


Measured memory_bytes: 256
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let values: Vec<i32> = sc.vec(3);
    let mut x = values.iter().cloned().max().unwrap();
    let mut result: i32 = values.iter().cloned().fold(0, |sum, a| sum + a) - x;
    let k: usize = sc.read();
    for _ in 0..k {
        x *= 2;
    }
    result += x;
    println!("{}", result);
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .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: 4352
#include"bits/stdc++.h"
using namespace std;

#define MAX 100002

int n;
int m;

vector<int> v;

long long int lef(int a,int b){
	if(a>b)return 0;
	int ans=0;
	while(a<=b){
		if(v[a]+v[b]>=m)return LLONG_MAX/3LL;
		ans=max(ans,v[a]+v[b]);
		a++;
		b--;
	}
	return ans;
}
long long int rig(int a,int b){
	if(a>b)return 0;
	int ans=0;
	while(a<=b){
		if(v[a]+v[b]<m)return LLONG_MAX/3LL;
		ans=max(ans,(v[a]+v[b])%m);
		a++;
		b--;
	}
	return ans;
}

int main(){
	cin>>n>>m;
	for(int i=0;i<2*n;i++){
		int a;
		scanf("%d",&a);
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	int mint=0;
	int maxt=n;
	long long int ans=LLONG_MAX;
	while(mint+1<maxt){
		int mid=(mint+maxt)/2LL;
		if(lef(0,mid*2-1)==LLONG_MAX/3LL){
			maxt=mid;
			continue;
		}
		if(rig(mid*2,2*n-1)==LLONG_MAX/3LL){
			mint=mid;
			continue;
		}
		ans=min(ans,max(lef(0,mid*2-1),rig(mid*2,2*n-1)));
		maxt=mid;
	}
	while(mint<=maxt){
		ans=min(ans,max(lef(0,mint*2-1),rig(mint*2,2*n-1)));
		mint++;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1400