akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

vector<pair<long long, long long> > prime_factorize(long long n) {
  vector<pair<long long, long long> > res;
  for (long long p = 2; p * p <= n; ++p) {
    if (n % p != 0) continue;
    int num = 0;
    while (n % p == 0) { ++num; n /= p; }
    res.push_back(make_pair(p, num));
  }
  if (n != 1) res.push_back(make_pair(n, 1));
  return res;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, 0, n) cin >> a[i];
  if(count(all(a), 0) != 0){
    cout << 0 << endl;
    return 0;
  }

  ll ans = 1;
  rep(i, 0, n){
    if(a[i] <= 1000000000000000000/ans){
      ans *= a[i];
    }else{
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3992
def main():
    inp=list(map(lambda x:int(x),input().split()))
    r=inp[0]
    D=inp[1]
    x=inp[2]

    res_array=[]
    for i in range(10):
        x=r*x-D
        res_array.append(x)

    for i in res_array:
        print(i)


if __name__=="__main__":
    main()
    

    


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
long long v[1000];
long long w[1000];
long long dp[110][100010];
long long f(int i,long long W){
    if(W < 0) return -1e9;
    if(i == 0) return 0;
    if(dp[i][W]!=-1LL) return dp[i][W];
    dp[i][W] = max( f(i-1, W- w[i])+v[i] , f(i-1,W) );
    return dp[i][W];
}
int main(){
    memset(dp,-1,sizeof dp);
    memset(v,0,sizeof v);
    memset(w,0,sizeof w);
    int n;
    long long k;
    cin>>n>>k;
    for(int i = 1 ; i <= n ; i++){
        cin>>w[i]>>v[i];
    }
    cout<<f(n,k)<<"\n";
    return 0;
}


Measured memory_bytes: 86272
#include<bits/stdc++.h>
#include<string>
#define pii pair<int,int>
#define fr(j,n) for(int j=0;j<n;j++)
#define f(n) for(int i=0;i<n;i++)
#define rt return 0;
#define sc second
#define fi first
#define i(n) int n;cin>>n;
#define pb(i) push_back(i);
#define rt return 0;
#define sz(v) v.size()
#define allv v.begin(),v.end()
#define ff(i,in,fi) for(int i=in;i<fi;i++)
//#define df int n;cin>>n;int a[n];fr(n){cin>>a[i];}5 8 7 14 55 19 9 2
using namespace std;
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define invect(data,n,commands) for(int xxx = 0;xxx<n;xxx++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define ll long long int
#define p(s) cout<<#s<<":"<<s<<'\n';
#define here(n) cout<<"here"<<n<<endl;
#define ios         ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

int main()
{
	ios;
	string s,t;
	cin>>s>>t;
	int sum=0;
	f(3)
	{
		if(s[i]==t[i])
			sum++;

	}
	cout<<sum;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int N;
int table[105];

int main(){

	scanf("%d",&N);

	int maximum = -BIG_NUM,minimum = BIG_NUM;

	for(int i = 0; i < N; i++){

		scanf("%d",&table[i]);
		maximum = max(maximum,table[i]);
		minimum = min(minimum,table[i]);
	}

	int ans = BIG_NUM;

	for(int num = minimum; num <= maximum; num++){

		int sum = 0;
		for(int i = 0; i < N; i++){

			sum += (num-table[i])*(num-table[i]);
		}

		ans = min(ans,sum);
	}

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
def resolve():
	import numpy as np
	from collections import deque

	h, w = map(int, input().split())
	s = [input() for i in range(h)] # [[input()] for ...] は誤答 （文字列も配列であることを考えると3重配列になっちゃう） 
	directions = [[0, 1], [0, -1], [1, 0], [-1, 0]] # [y軸, x軸]
	ans = 0

	for sh in range(h): # start hight
		for sw in range(w):
			if s[sh][sw] == "#":
				continue
			distance = [[-1 for j in range(w)] for i in range(h)]
			distance[sh][sw] = 0
			q = deque([[sh, sw]]) # 1段目の[]はdequeの引数がイテラブルであるため、2段目の[]はy軸x軸のペアを表現するため

			while q:
				y, x = q.popleft() # アンパックしてくれる
				for i, j in directions:
					ny, nx = y+i, x+j

					# エリア内判定
					if not ((0 <= ny < h) and (0 <= nx < w)):
						continue
					# 壁判定
					elif s[ny][nx] == "#":
						continue
					# 訪問済み判定
					elif distance[ny][nx] != -1:
						continue

					distance[ny][nx] = distance[y][x] + 1
					q.append([ny, nx]) # q.append([[ny, nx]]) は誤答
			#ans = max(ans, max(max(distance)))
			ans = max(ans, np.max(distance))
	print(ans)
resolve()

Measured memory_bytes: 12504
#include <stdio.h>
#include <stdlib.h>

/* ケーキのピースリスト */
typedef struct piece * link;
struct piece { int w; int d; int a; link prev; link next; };
link head, foot;
int size;

/* リストの末尾に要素を1つ追加する */
link add() {
	link l = (link)malloc(sizeof(struct piece));
	l->prev = foot->prev;
	l->next = foot;
	l->prev->next = l;
	l->next->prev = l;
	size++;
	return l;
}

/* 指定された識別番号の要素をリストから取り除く */
link pop(int i) {
	link l;
	int j;
	for (j = 1, l = head->next; j < i; j++) l = l->next; /* ポインタを取得する */
	l->prev->next = l->next;
	l->next->prev = l->prev;
	size--;
	return l;
}

/* ピースの大きさを変更する */
void setSize(link l, int w, int d) {
	l->w = w;
	l->d = d;
	l->a = w * d;
}

/* ピースを入れ換える */
void swap(link a, link b) {
	int c;
	c = a->w; a->w = b->w; b->w = c;
	c = a->d; a->d = b->d; b->d = c;
	c = a->a; a->a = b->a; b->a = c;
}

/* ケーキを初期化する */
void init(int w, int d) {
	link l;
	while (size > 0) {
		l = pop(1);
		free(l);
	}
	l = add();
	setSize(l, w, d);
}

/*
	指定された識別番号のケーキをカットする
	カットすべきピースの周囲を、北西の角から時計回りに s 進んだ地点がカットの起点になる
*/
void cut(int p, int s) {
	link l, m;
	int w, d;

	/* カットするピースを取り出す */
	l = pop(p);
	w = l->w;
	d = l->d;
	free(l);

	/* カットする位置と方向を求める (sが正なら南北、負なら東西にカットする) */
	s %= (w * 2 + d * 2);
	if (s < w);
	else if (s < w + d) s = w - s;
	else if (s < w * 2 + d) s = (w * 2 + d) - s;
	else s = s - (w * 2 + d * 2);

	/* カットする */
	l = add();
	m = add();
	if (s < 0) {
		/* 南北 */
		s = -s;
		setSize(l, w, s);
		setSize(m, w, d - s);
	} else {
		/* 東西 */
		setSize(l, s, d);
		setSize(m, w - s, d);
	}

	/* 識別番号を付け替える */
	if (l->a > m->a) swap(l, m); /* 面積の小さいほうが先 */
}

/* ピースを小さい順に並び替える */
void sort() {
	link l;
	int i, j;
	/* バブルソート */
	for (i = 1; i < size; i++) {
		for (j = 0, l = head->next; j < size - i; j++, l = l->next) {
			if (l->a > l->next->a) swap(l, l->next);
		}
	}
}

int main(void) {
	int n; /* カットの回数 */
	int w, d; /* ケーキの大きさ */
	int i;
	/* 初期化 */
	head = (link)malloc(sizeof(struct piece));
	foot = (link)malloc(sizeof(struct piece));
	setSize(head, 0, 0);
	setSize(foot, 0, 0);
	head->prev = NULL;
	head->next = foot;
	foot->prev = head;
	foot->next = NULL;
	size = 0;

	/* データセット毎の処理 */
	while (scanf("%d%d%d", &n, &w, &d) == 3 && n >= 0 && n <= 100 && w > 0 && d > 0) {
		int p; /* カットするピースの識別番号 */
		int s; /* カットの起点 */
		init(w, d);

		/* カット */
		for (i = 0; i < n; i++) {
			scanf("%d%d", &p, &s);
			cut(p, s);
		}

		/* ピースの面積を昇順で出力する */
		link l;
		sort();
		for (i = 0, l = head->next; i < size; i++, l = l->next) {
			if (i > 0) printf(" ");
			printf("%d", l->a);
		}
		printf("\n");
	}

    return 0;
}

Measured memory_bytes: 608
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        ArrayList<Goods> list = new ArrayList<Goods>();
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        for (int i = 0; i < N; i++) {
            list.add(new Goods(sc.nextInt(), sc.nextInt()));
        }
        new knapsackSolver(list, W);
    }
}

class knapsackSolver {
    ArrayList<Goods> list = new ArrayList<Goods>();
    int W;

    knapsackSolver(ArrayList<Goods> list, int W) {
        this.list = list;
        this.W = W;
        list.sort(Comparator.comparing(Goods::getCostperformance).reversed());
        System.out.println(solve(new int[list.size()], 0L));
    }

    long solve(int[] fix, long tempAns) {
        long z = 0;
        long sumWeight = 0;

        for (int i = 0; i < list.size(); i++) {
            if (fix[i] == 1) {
                Goods goods = list.get(i);
                z += goods.value;
                sumWeight += goods.weight;
            }
        }
        if (sumWeight > W)// 実行不可能
            return tempAns;

        for (int i = 0; i < list.size(); i++) {
            if (fix[i] != 0)
                continue;
            Goods goods = list.get(i);
            if (sumWeight + goods.weight < W) {
                z += goods.value;
                sumWeight += goods.weight;
            } else if (sumWeight + goods.weight == W) {
                z += goods.value;
                sumWeight += goods.weight;
                if (z > tempAns) {
                    tempAns = z;
                    return tempAns;// 更新
                }
                return tempAns;// 終端
            } else {
                double check = z + (double) (W - sumWeight) / goods.weight * goods.value;
                sumWeight = W;
                if (check < tempAns) {
                    return tempAns;// 終端
                }
                int[] nex = fix.clone();
                nex[i] = -1;
                tempAns = solve(nex, tempAns);
                nex[i] = 1;
                tempAns = solve(nex, tempAns);
                return tempAns;// 分岐
            }
        }
        if (z > tempAns) {
            tempAns = z;
            return tempAns;// 更新
        }
        return tempAns;// 終端
    }
}

class Goods {
    final int weight;
    final int value;
    final double costperformance;

    Goods(int weight, int value) {
        this.weight = weight;
        this.value = value;
        this.costperformance = (double) value / weight;
    }

    public double getCostperformance() {
        return costperformance;
    }

    @Override
    public String toString() {
        return weight + ":" + value + ":" + costperformance;
    }
}

Measured memory_bytes: 41084
#include<iostream>
#include<string>

using namespace std;

int main()
{
  int a, b;
  string op;
  
  while(true)
    {
      cin >> a >> op >> b;
      
      if (op == "+")
        cout << a + b << endl;
      else if (op == "-")
        cout << a - b << endl;
      else if (op == "*")
        cout << a * b << endl;
      else if (op == "/")
        cout << a / b << endl;
      else if (op == "?")
        break;
    }
  return 0;
}

Measured memory_bytes: 1204
s = list(str(input()))
t = list(str(input()))
ans = []
an = 0
if len(s) < len(t):
    print("UNRESTORABLE")
    exit()
for i in range(len(s)-len(t)+1):
    cou = s[i:i+len(t)]
    for k in range(len(t)):
        if s[i+k] != t[k] and s[i+k] != "?" and t[k] != "?":
            break
        if k == len(t)-1:
            ans.append(s[:i]+t+s[i+len(t):])
for h in range(len(ans)):
    for f in range(len(s)):
        if ans[h][f] == "?":ans[h][f] = "a"
    ans[h] = "".join(ans[h])
if ans == []:
    print("UNRESTORABLE")
    exit()
ans.sort()
print(ans[0])

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

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int T;
    cin >> T;
    while(T--){
        int n,ans=0;
        cin >> n;
        vector <pair <int,int> > l,r;
        for(int i=0;i<n;i++){
            int k,a,b;
            cin >> k >> a >> b;
            if(a>b){
                ans+=b,a-=b;
                l.push_back({a,k});
            }
            else{
                ans+=a,b-=a;
                r.push_back({b,k+1});
            }
        }
        sort(l.rbegin(),l.rend());
        sort(r.rbegin(),r.rend());
        set <int> sl,sr;
        for(int i=1;i<=(int)l.size();i++)
            sl.insert(i);
        for(int i=0;i<(int)r.size();i++)
            sr.insert(n-i);
        for(auto [k,i]:l){
            auto it=sl.upper_bound(i);
            if(it==sl.begin())continue;
            it--;
            ans+=k;
            sl.erase(it);
        }
        for(auto [k,i]:r){
            auto it=sr.lower_bound(i);
            if(it==sr.end())continue;
            ans+=k;
            sr.erase(it);
        }
        cout << ans << '\n';
    }
}

Measured memory_bytes: 15640
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
rieki = []
#print(x,y)
for i in range(n):
  rieki.append(x[i]-y[i])

count = 0  
for i in rieki:
  if i >0:
    count+=i

print(count)    

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

const int MOD = 1000000007;
class ModInt
{
public:
    int64_t x;
    ModInt(int64_t x = 0) : x((x % MOD + MOD) % MOD) {}
    ModInt operator-() const { return ModInt(-x); }
    ModInt &operator+=(const ModInt a)
    {
        if ((x += a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    ModInt &operator-=(const ModInt a)
    {
        if ((x += MOD - a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    ModInt &operator*=(const ModInt a)
    {
        (x *= a.x) %= MOD;
        return *this;
    }
    ModInt operator+(const ModInt a) const { return ModInt(*this) += a; }
    ModInt operator-(const ModInt a) const { return ModInt(*this) -= a; }
    ModInt operator*(const ModInt a) const { return ModInt(*this) *= a; }
    ModInt pow(int64_t n) const
    {
        if (n == 0)
            return 1;
        ModInt t = pow(n >> 1);
        t *= t;
        if (n & 1)
            t *= *this;
        return t;
    }
    ModInt inv() const { return pow(MOD - 2); }
    ModInt &operator/=(const ModInt a) { return *this *= a.inv(); }
    ModInt operator/(const ModInt a) const { return ModInt(*this) /= a; }
};
istream &operator>>(istream &is, const ModInt &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const ModInt &a) { return os << a.x; }

vector<ModInt> fac;
vector<ModInt> fac_inv;
vector<ModInt> inv;
void init_comb(int mx)
{
    fac = vector<ModInt>(mx + 1), fac_inv = vector<ModInt>(mx + 1), inv = vector<ModInt>(mx + 1);
    fac.at(0) = fac.at(1) = 1;
    fac_inv.at(0) = fac_inv.at(1) = 1;
    inv.at(1) = 1;
    for (int i = 2; i <= mx; i++)
    {
        fac.at(i) = fac.at(i - 1) * i;
        inv.at(i) = -inv.at(MOD % i) * (MOD / i);
        fac_inv.at(i) = fac_inv.at(i - 1) * inv.at(i);
    }
}
ModInt comb(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac.at(n) * fac_inv.at(k) * fac_inv.at(n - k);
}
ModInt perm(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac.at(n) * fac_inv.at(n - k);
}

void solve(int N, int M)
{
    init_comb(5e5);
    ModInt res;
    for (int s = 0; s <= N; s++)
    {
        ModInt x = comb(N, s) * perm(M, s) * perm(M - s, N - s) * perm(M - s, N - s);
        if (s % 2 == 0)
            res += x;
        else
            res -= x;
    }
    cout << res << endl;
}

int main()
{
    int N;
    cin >> N;
    int M;
    cin >> M;
    solve(N, M);
    return 0;
}


Measured memory_bytes: 14888
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())
    X = []
    L = []
    LX = []
    for i in range(N):
        temp = list(map(int,input().split()))
        LX.append([temp[0]+temp[1],temp[0]-temp[1]])

    LX.sort()

    res = 0
    end = - 10 ** 9

    for i in range(N):
        if end <= LX[i][1]:
            res += 1
            end = LX[i][0]

    print(res)



main()


Measured memory_bytes: 20528
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    ll n;
    cin >> n;
    bool ok = true;
    for(ll i = 1; i <= 3500; i++){
        for(ll j = 1; j <= 3500; j++){
            ll a = n*i*j;
            ll b = 4*i*j-n*j-n*i;
        //   cout << a << " " << b << endl;
            if(b >0 && a%b==0){
                cout << i << " " << j << " " << a/b << endl;
                ok = false;
                break;
            }
        }
        if(ok==false) break;
    }
    return 0;
}


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

#define INT_MIN -2147483648
#define MAX_N 100010
int N, K;
int S[MAX_N];

int main() {
  while (true) {
  cin >> N >> K;
  if (N == 0 && K == 0) break;
  for (int i=0; i<N; i++) cin >> S[i];

  int pre = 0;
  for (int i=0; i<K; i++) pre += S[i];
  int ans = pre;

  for (int i=1; i<=N-K; i++) {
    pre = pre - S[i-1] + S[i+K-1];
    ans = max(ans, pre);
  }
  cout << ans << "\n";
  }
  return 0;
}

Measured memory_bytes: 3464
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define infy 2e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
const int N = 404;
ll dp[N][N];
ll a[N];
ll pr[N];
ll pre(ll i){
       if(pr[i] != -1){return pr[i];}
       return pr[i] = a[i]+pre(i-1);
}
ll get(ll i,ll j)
{
       if(i==0){return pre(j);}
       return pre(j)-pre(i-1);
}
ll f(int i,int j)
{
       if(i>j){return infy;}
       if(j-i==1){return a[i]+a[j];}
       if(i==j){return 0;}
       if(dp[i][j] != -1){return dp[i][j];}
       dp[i][j] = infy;
       for(int k = i ; k < j ; k++)
       {
              dp[i][j] = min(dp[i][j],get(i,k)+f(i,k)+f(k+1,j)+get(k+1,j));
       }
       return dp[i][j];
}
int main()
{
       memset(pr,-1,sizeof pr);
       memset(dp,-1,sizeof dp);
       int n;
       cin>>n;
       arrin(a,n);
       cout<<f(0,n-1)<<endl;

}


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e7;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from,to,w;
    edge(int uu,int vv,int ww):from(uu),to(vv),w(ww){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }
};

const int N = 205;

int main(){
   /* string s1,s2;
    cin >> s1 >> s2;
    int ans = 0;
    for(int i = 0;i<s1.length();i++){
        ans += s1[i] == s2[i];
    }
    cout <<ans;*/
    int a,b;
    cin >> a >> b;
    if(b == 1)
        return cout << 0,0;
    int ans = 1,sockets = a;
    while(sockets < b){
        ans++;
        sockets += a-1;
    }
    cout << ans;
}











Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int digit(ll x)
{
    int d = 0;
    while (x) {
        x /= 10;
        ++d;
    }

    return d;
}

int f(ll a, ll b)
{
    return max(digit(a), digit(b));
}

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

    int ans = 100;
    for (ll i = 1; i*i <= N; ++i) {
        if (N % i == 0) {
            ll j = N / i;

            ans = min(ans, f(i, j));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3108
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define f(i,n) for(int i=0;i<int(n);i++)
#define V (100000)
#define LLM (1000000000000000000)
struct edge{
	int to;
	long long dis;
	long long cap;
	int rev;
};
struct resu{
	long long di;
	long long ca;
};
vector<edge> g[V];
bool used[V];
bool fin;
int a[V];
int b[V];
int n, m, s, t;

//辺追加(1回)
void add_edge(void){
	int x, y;
	long long z;
	scanf("%d %d %lld", &x, &y, &z);
	x--;
	y--;
	g[x].push_back({ y, z, g[y].size() });
	g[y].push_back({ x, 0, g[x].size() - 1 });
}

resu bellmanford(void){
	long long c[V];
	long long d[V];
	resu ret;
	int x;
	long long y;
	f(i, V){
		c[i] = LLM;
		d[i] = LLM;
	}
	d[s] = 0;
	f(ii, n - 1){
		f(i, n){
			f(j, g[i].size()){
				if (g[i][j].cap > 0){
					if (d[g[i][j].to] > d[i] + g[i][j].dis){
						d[g[i][j].to] = d[i] + g[i][j].dis;
						a[g[i][j].to] = i;
						b[g[i][j].to] = j;
						c[g[i][j].to] = g[i][j].cap;
					}
				}

			}
		}
	}
	if (d[t] == LLM){
		ret = { 0, 0 };
	}
	else{
		x = t;
		y = LLM;
		while (x != s){
			y = min(y, c[x]);
			x = a[x];
		}
		ret = { d[t], y };
	}
	return ret;
}

//最大流探索
long long max_flow(long long q){

	long long ret = 0;
	fin = true;
	resu res;
	int x;
	bool z = true;
	while (z){
		res = bellmanford();
		if (res.ca == 0){
			z = false;
			fin = false;
		}
		else if (res.ca >= q){
			x = t;
			while (x != s){
				g[a[x]][b[x]].cap -= q;
				g[x][g[a[x]][b[x]].rev].cap += q;
				x = a[x];
			}
			ret += (res.di*q);
			q = 0;
		}
		else{
			x = t;
			while (x != s){
				g[a[x]][b[x]].cap -= res.ca;
				g[x][g[a[x]][b[x]].rev].cap += res.ca;
				x = a[x];
			}
			q -= res.ca;
			ret += (res.di*res.ca);
		}
		if (q <= 0)z = false;
	}
	if (fin)return ret;
	else return -1;
}


int main(void){
	long long su;
	int x, y;
	long long v, z, ans;
	scanf("%d %d %lld", &n, &m, &su);
	for (int i = 0; i < m; i++){
		scanf("%d %d %lld %lld", &x, &y, &z, &v);
		g[x].push_back({ y, v, z, g[y].size() });
		g[y].push_back({ x, -v, 0, g[x].size() - 1 });
	}
	s = 0;
	t = n - 1;
	ans = max_flow(su);
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 6784
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int  x=scan.nextInt();
		int  y=scan.nextInt();
		int  Z=0;
		if (x>=y) {
			while(true) {
				Z=x % y;
				if (Z==0) break;
				else {
					x = y;
				    y = Z;
					
				}
			}
			System.out.println(y);
		}
		else {
			while(true) {
				Z=y % x ;
				if (Z==0) break;
				else {
					y = x;
				    x = Z;
					
				}
			}
			System.out.println(x);
		}
	}
}



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

int main(){
    int N, C, K;
    cin >> N >> C >> K;
    int passengers[N];
    for(int i = 0; i < N; i++){
        cin >> passengers[i];
    }
    sort(passengers, passengers + N);
    int ans = 1, bus_member = 1, bus_time = passengers[0];
    for(int i = 1; i < N; i++){
        if(bus_member == C || bus_time + K < passengers[i]){
            ans++;
            bus_member = 1;
            bus_time = passengers[i];
        }else{
            bus_member++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
def examE():
    N, T = LI()
    A, B = [0] * N, [0] * N
    for i in range(N):
        A[i], B[i] = LI()
    dp = [[0 for _ in range(T+ 1)] for _ in range(N + 1)]
    dp2 = [[0 for _ in range(T+ 1)] for _ in range(N + 1)]
    for i in range(N):
        for j in range(A[i],T+1):
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - A[i]] + B[i])
            dp2[i + 1][j] = max(dp2[i + 1][j], dp2[i][j - A[i]] + B[i])
        for j in range(1,T+1):
            dp2[i+1][j] = max(dp2[i+1][j], dp[i][j-1] + B[i], dp2[i][j])
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
#    print(dp[N][T])
    ans = dp2[N][T]
    print(ans)

import sys,copy,bisect,itertools
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examE()


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

using namespace std;
int main()
{

    int N;
    cin >> N;
    int ans =0;
    for(int i = 3; i <= N; i+=2){
        int y = 1;
        int i_ = i;
        for(int j = 3; j <= N; j+=2){
            int a = 1;
            while((i_%j)==0){
                i_/=j;
                a++;
            }
            y*=a;

        }
        if(y==8)ans++;
        
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
status = [input() for _ in range(N)]
C = Counter(status)
print("AC x {}".format(C["AC"]))
print("WA x {}".format(C["WA"]))
print("TLE x {}".format(C["TLE"]))
print("RE x {}".format(C["RE"]))

Measured memory_bytes: 16616
#include<cstdio>
#include<algorithm>

using namespace std;

int N,M;
int s[100100];
int t[100100];
int p[100100];

int sum[100100];

long long get(int s,int t){
	bool swapped=(s>t);
	if(s>t) swap(s,t);
	int le=lower_bound(p,p+M,s)-p;
	int ri=lower_bound(p,p+M,t)-p;
	if(le==ri) return t-s;
	else if((ri-le)%2==0){
		int res=sum[ri-2]-sum[le];
		res+=p[le]-s;
		res+=t-p[ri-1];
		return res;
	}else{
		int res=sum[ri-1]-sum[le];
		res+=p[le]-s;
		if(swapped) res=(t-s)-res;
		return res;
	}
}

int main(){
	scanf("%d%d",&N,&M);
	for(int i=0;i<N;i++) scanf("%d%d",s+i,t+i);
	for(int i=0;i<M;i++) scanf("%d",p+i);
	sort(p,p+M);
	for(int i=0;i<M;i++){
		if(i==0) sum[i]=0;
		else if(i<=2) sum[i]=p[i]-p[i-1];
		else sum[i]=sum[i-2]+(p[i]-p[i-1]);
	}
	long long ans=0;
	for(int i=0;i<N;i++) ans+=get(s[i],t[i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2604
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]



def main():
    A,B,M=map(int,input().split())
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    wari=[]
    for i in range(M):
        x,y,c=map(int,input().split())
        wari.append([x,y,c])
    ans=min(a)+min(b)
    for i in range(M):
        temp=a[wari[i][0]-1]+b[wari[i][1]-1]-wari[i][2]
        ans=min(ans,temp)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 84784
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    ll r, g, b, n;
    cin >> r >> g >> b >> n;

    ll ans = 0;
    for (ll i = 0; i <= n; i++) {
        for (ll j = 0; j <= n; j++) {
            ll cur = n - r * i - g * j;
            if (cur >= 0) {
                if (cur % b == 0) {
                    ans++;
                }
            }
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int seen[3][3];
int main()
{

   int n,i,j,c=0,p,f=0;
   int a[3][3];
   for(i=0;i<3;i++)
   {
       for(j=0;j<3;j++)
        {
            cin>>a[i][j];

        }
   }
   cin>>n;

   int v[n],k;
   for(i=0;i<n;i++)
   {
       cin>>v[i];
   }
    for(i=0;i<3;i++)
    {
        for(j=0;j<n;j++)
        {
           for(k=0;k<n;k++){
            if(a[i][j]==v[k]) seen[i][j]=1;

           }
        }
    }
    for(i=0;i<3;i++)
    {
        if(seen[i][0] && seen[i][1] && seen[i][2])
        {
            cout<<"Yes\n";
            return 0;
        }
    }
    for(i=0;i<3;i++)
    {
        if(seen[0][i] && seen[1][i] && seen[2][i])
        {
            cout<<"Yes\n";
            return 0;
        }
    }

        if(seen[0][0] && seen[1][1] && seen[2][2])
        {
            cout<<"Yes\n";
            return 0;
        }

        if(seen[2][0] && seen[1][1] && seen[0][2])
        {
            cout<<"Yes\n";
            return 0;
        }
        cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int ans[] = new int[w];
        for(int i = 0; i<w; i++){
            ans[i] = i+1;
        }
        int n = sc.nextInt();
        for(int i = 0; i<n; i++){
            String t = sc.next();
            String p[] = t.split(",");
            int a = Integer.parseInt(p[0]);
            int b = Integer.parseInt(p[1]);
            int tmp = ans[a-1];
            ans[a-1] = ans[b-1];
            ans[b-1] = tmp;
        }
        for(int i = 0; i<w; i++){
            System.out.println(ans[i]);
        }
        sc.close();
    }
}


Measured memory_bytes: 26120
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
using namespace std;
int n,k,a[100010],s;
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=k;i++)
	{
		s+=a[i];
	}
	cout<<s<<endl;
	return 0;
}

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

ans = 0
for a in range(N):
    La = Ls[a]
    for b in range(a+1, N):
        Lb = Ls[b]
        for c in range(b+1, N):
            Lc = Ls[c]
            if La != Lb and Lb != Lc and Lc != La:
                if La+Lb > Lc and Lb+Lc > La and Lc+La > Lb:
                    ans += 1
print(ans)


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

int main() {
  int group[] = {0, 1, 0, 2, 0, 2, 0, 0, 2, 0, 2, 0};
  int a, b;
  cin >> a >> b;
  cout << (group[a-1] == group[b-1] ? "Yes" : "No") << endl;
}

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

typedef long long ll;


int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  if (b - a >= 2 * k) {
    for (int i = a; i <= a+k-1; i++) {
      cout << i << endl;
    }
    for (int i = b-k+1; i <= b; i++) {
      cout << i << endl;
    }
  } else {
    for (int i = a; i <= b; i++) {
      cout << i << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
int prime[55555];         // i番目の素数
bool is_prime[55555 + 1]; // is_prime[i]がtrueならiは素数

int sieve(int n) {
    int p = 0;
    for(int i = 0; i <= n; i++) {
        is_prime[i] = true;
    }
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i < n + 1; i++) {
        if(is_prime[i]) {
            prime[p++] = i;
            for(int j = 2 * i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }
    return p;
}

int main() {
    int N;
    cin >> N;
    long long sum = 0;
    sieve(10000);
    int i = 0;
    REP(cnt, N) {
        while(prime[i] % 5 != 1) {
            i++;
        }
        cout << prime[i] << " ";
        i++;
    }
    cout << endl;
    return 0;
}

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

int main(){
  int s ;
  cin >> s ;
  vector<int>vec(1000000);
  vec.at(0) = s;
  for (int i = 1; i <1000000; i++){
    if (vec.at(i-1) % 2 ==  0)
    vec.at(i) = vec.at(i-1)/2;
    else 
      vec.at(i) = 3*vec.at(i-1)+1;
  }
 int m = 0;
  for (int i = 1; i < 1000000; i++){
    if (m ==1){
      break;
    }
    for (int j = 0; j < i;j++){
      if (vec.at(j) == vec.at(i)){
        cout << i+1 << endl;
        m++;
        break;
      }
      
      else
        continue;
    }
  }
}


Measured memory_bytes: 4096
fun main(args: Array<String>) {
    abc149b()
}

fun abc149b() {
    val (a, b, k) = readLine()!!.split(' ').map { it.toLong() }

    val afterA = Math.max(0, a - k)
    val remain = Math.max(0, k - a)

    val afterB = Math.max(0, b - remain)

    println("$afterA $afterB")
}


Measured memory_bytes: 36344
#include<iostream>
#include<set>
#include<algorithm>
using namespace std;

int main(){
    set<int> a, b, c;
    int n, m, x;
    
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x;
        a.insert(x);
    }
    cin >> m;
    for(int i = 0; i < m; i++){
        cin >> x;
        b.insert(x);
    }

    set_difference(a.begin(), a.end(), b.begin(), b.end(), inserter(c, c.end()));

    for(int x : c)  printf("%d\n", x);

    return 0;
}


Measured memory_bytes: 31248
s = int(input())
a = [s]
i = 1

while a[-1] not in a[:-1]:
  if a[i-1]%2 == 0:
    a.append(a[i-1]/2)
  else:
    a.append(3*a[i-1]+1)
  
  i += 1

print(i)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
ll gcd(ll a,ll b){
    if(min(a,b)==0)return max(a,b);
    if(max(a,b)%min(a,b)==0)return min(a,b);
    return gcd(min(a,b),max(a,b)%min(a,b));
}
int main(){
    ll n;cin>>n;
    vector<ll>a(n);
    rep(i,n){
        cin>>a[i];
    }
    vector<ll>b(n),c(n);
    b[0]=a[0];
    REP(i,1,n){
        b[i]=gcd(b[i-1],a[i]);
    }
    c[n-1]=a[n-1];
    for(int i=n-2;i>=0;i--){
        c[i]=gcd(c[i+1],a[i]);
    }
    ll ans=1;
    ans=max(c[1],ans);
    ans=max(ans,b[n-2]);
    REP(i,1,n-1){
        ans=max(gcd(b[i-1],c[i+1]),ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
 int n,y;
 cin >> n >> y;
 for (int i=0;i <= n;i++){
   for (int j=0; j <= n;j++){
     if (n-i-j >= 0){
       if (10000*i+5000*j+1000*(n-i-j)==y){
         printf("%d %d %d\n",i,j,n-i-j);
         return 0;
       }
     }
   }
 }
 printf("-1 -1 -1\n");
}

Measured memory_bytes: 256
N = int(input())
a_list = list(map(int, input().split()))
cnt = 0
ref_num = 1
for i in range(N):
  if a_list[i] == ref_num:
    ref_num += 1
  else:
    cnt += 1

if ref_num == 1:
  print(-1)
else:
  print(cnt)

Measured memory_bytes: 24744
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		if (test.charAt(2) == test.charAt(3) && test.charAt(4) == test.charAt(5)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int n,k;
vector<int> G[2010];
int a[2010], b[2010];
bool used[2010];
int dfs(int nd, int d) {
    int ans = (d > k / 2);
    for (int i = 0; i < G[nd].size(); i++) {
        if (used[G[nd][i]]) continue;
        used[G[nd][i]] = 1;
        ans += dfs(G[nd][i], d+1);
    }
    return ans;
}
 
int main() {
    cin >> n >> k;
    for (int i = 0; i < n - 1; i++) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    int ans = n;
    if (k&1) {
        for (int i = 0; i < n - 1; i++) {
            memset(used,0,sizeof(used));
            used[a[i]] = 1;
            used[b[i]] = 1;
            ans = min(ans, dfs(a[i], 0) + dfs(b[i], 0));
        }
    } else {
        for (int i = 0; i < n; i++) {
            memset(used,0,sizeof(used));
            used[i] = 1;
            ans = min(ans, dfs(i,0));
        }
    }
    cout << ans << endl;
    return 0;
}

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

int a, b, c, d;
const int MOD = 998244353;
int dp[3055][3055];

int main() {
    cin >> a >> b >> c >> d;

    dp[a][b] = 1;

    for (int i = a; i <= c; i++) {
        for (int j = b; j <= d; j++) {
            if (i == a && j == b) continue;

            dp[i][j] = (1ll * dp[i - 1][j] * j % MOD + 1ll * dp[i][j - 1] * i) % MOD;
         //   dp[i][j] = (1ll * dp[i][j] - dp[i - 1][j - 1] + MOD) % MOD;
            dp[i][j] = (1ll * dp[i][j] - 1ll * (i - 1) * (j - 1) % MOD * dp[i - 1][j - 1] % MOD + MOD) % MOD;

        }
    }

    cout << dp[c][d] << endl;

    return 0;
}

Measured memory_bytes: 39368
#include <bits/stdc++.h>
using namespace std;
int main(){
vector<int>moji(3);
  for(int i=0;i<3;i++){
  cin>>moji.at(i);
  }
  sort(moji.begin(),moji.end());
  int count=1;
   for(int i=1;i<3;i++){
   		if(moji.at(i-1) != moji.at(i)){
        count++;
        }
  }
  cout<<count<<endl;
}

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	// debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, left, right)  (a).begin()+(left),(a).begin()+(right)	// left to (right-1)

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	vector<ll> b(n);
	vector<ll> c(n);
	vector<ll> sa(n);
	int res = 0;
	FOR(i, 0, n - 1) {
		cin >> a[i];
	}
	FOR(i, 0, n - 1) {
		cin >> b[i];
	}
	FOR(i, 0, n-1) {
		if (a[i] < b[i]) {
			c[i] = b[i];
			res++;
		}
		else {
			c[i] = a[i];
			sa[i] = a[i] - b[i];
		}
	}
	ll suma = accumulate(ALL(a), 0LL);
	ll sumc = accumulate(ALL(c), 0LL);
	if (suma == sumc) {
		pv(res);
		return 0;
	}
	else {
		sort(ALL(sa));
		ll remini = sumc - suma;
		RFOR(i, n - 1, 0) {
			remini -= sa[i];
			res++;
			if (remini <= 0) {
				pv(res);
				return 0;
			}
		}
		ps(-1);
		return 0;
	}
	return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define FASTIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define inf 1e18
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mod 1000000007
#define pb push_back
#define all(s) s.begin(),s.end()
#define pie 3.14159265358979323846
#define fr(i,a,b)  for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=b-1;i>=a;i--)
#define gcd __gcd
#define con continue
#define pii pair<ll,ll>
const ll N=100;
signed main(){
    FASTIO;
    ll tt=1;
    //cin>>tt;
    while(tt--){
       ll n,a,b,d,ans=0;cin>>n>>d;
       for(ll i=0;i<n;i++){
          cin>>a>>b;
          double dd=sqrt(1.0*(a*a+b*b));
          if(dd<=d)ans++;
       }
       cout<<ans;
    }
}


Measured memory_bytes: 3636
#include<iostream>
#include<cctype>
#include<string>

class Dice{
  public:
	int face[6];
	Dice(){}
	
	void move_s(){
		int t;
		t = face[0]; face[0] = face[4]; face[4] = face[5]; face[5] = face[1]; face[1] = t;
	}
	void move_e(){
		int t;
		t = face[0]; face[0] = face[3]; face[3] = face[5]; face[5] = face[2]; face[2] = t;
	}
};

int main(){
	Dice d;
	std::string ord;
	
	for(int i=0; i <=5; i++){
		std::cin >> d.face[i];
	}
	
	std::cin >> ord;
	
	for(int i=0; i<ord.size() ; i++){
		if(ord[i] == 'S'){d.move_s();}
		else if(ord[i] == 'E'){d.move_e();}
		else if(ord[i] == 'N'){for (int j = 0; j < 3; j++){d.move_s();}}
		else{for (int j = 0; j < 3; j++){d.move_e();}}
	}
	std::cout << d.face[0] << std::endl;
	
	return 0;
}

Measured memory_bytes: 1208
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>

using namespace std;

int main(){
    int x;
    cin>>x;
    if(x<1200) cout<<"ABC"<<endl;
    else cout<<"ARC"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
const int N=220002,M=10010,mod=998244353;
ll n,m,T,k,h,w,cnt,x,y,z,indx,t,ans,a[N],r[N],c[N],b[N];
string s;
int main()
{
	scanf("%lld",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+n+1,greater<int>());
	if (n==1)
	{
		printf("0");
		return 0;
	}
	ans+=a[1];
	int m=n-2;
	for (int i=2;i<=n;i++)
	{
		if (m>1) m-=2,ans+=a[i]*2;
			else if (m) m--,ans+=a[i];
	}
	printf("%lld",ans);
}

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

int main()
{
	string S;
	cin >> S;


	int ans = 0;
	for (int i = 0; i < S.size(); i++) {
	
		if (S[i] == '1') {
			ans++;
	}
	}
	cout << ans << endl;
		}

Measured memory_bytes: 3612
def main(argv)
  s = gets.chomp
  
  x = ['RUD'.split(''), 'LUD'.split('')]
  
  flag = true
  s.split('').each_with_index do |c, i|
    if x[i % 2].find_index(c) === nil then
      flag = false
    end
  end
  
  puts (flag ? 'Yes' : 'No')
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#include "stdio.h"

int main(){
  //代入
  int n,a[21],b[21],c[21],ans=0;
  scanf("%d ",&n);
  for(int i=0;i<n;i++){scanf("%d ",&a[i]);}
  for(int i=0;i<n;i++)scanf("%d ",&b[i]);
  for(int i=0;i<n-1;i++)scanf("%d ",&c[i]);
  c[n-1]=0;
 
  for(int i=0;i<n;i++){
    ans+=b[a[i]-1];
    if(i!=0&&a[i]==a[i-1]+1)ans+=c[a[i-1]-1];
  }

  
  printf("%d",ans);
  return 0;
}

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

int main(){
  int N;
  cin >> N ;
  if ((N / 10) % 111 == 0 || (N % 1000) % 111 == 0 ){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math


H,W = map(int, input().split())
N = int(input())
a = [int(i) for i in input().split()]

color_count = {}
for i in range(N):
    color_count[i+1] = a[i]

color_count = dict(sorted(color_count.items(),key=lambda x:-x[1]))


mas = [[0 for i in range(W)] for j in range(H)]
colors = list(color_count.keys())

color = colors[0]
color_i = 0
color_cnt = color_count[color]
cnt = 0

for h_i in range(H):
    if h_i%2==0:
        for w_i in range(W):
            mas[h_i][w_i] = color
            cnt += 1
            if h_i == H - 1 and w_i == W-1:
                break
            if cnt == color_cnt:
                color_i += 1
                color = colors[color_i]
                cnt = 0
                color_cnt = color_count[color]
    else:
        for w_i in reversed(range(W)):
            mas[h_i][w_i] = color
            cnt += 1
            if h_i == H - 1 and w_i == 0:
                break
            if cnt == color_cnt:
                color_i += 1
                color = colors[color_i]
                cnt = 0
                color_cnt = color_count[color]

# print(mas)
for h_i in range(H):
    for w_i in range(W):
        print(mas[h_i][w_i],end=" ")
    print()


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

int main() {
  int n;
  cin >> n;
  cin.ignore();
  for (int i = 0; i < n; i++) {
    string sentence;
    getline(cin, sentence);
    int j = 0;
    while(1) {
      j = sentence.find("Hoshino", j);
      if (j == string::npos) break;
      sentence.replace(j, 7, "Hoshina");
    }
    cout << sentence << endl;
  }
  return 0;
}


Measured memory_bytes: 3156