akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const long long inf = 123456789123456789;
int main() {
	int N, M, L;
	cin >> N >> M >> L;
	vector<int> A(N); vector<long long> B(M + 1);
	for (int i = 0; i < N; ++i) cin >> A[i];
	for (int i = 0; i < M; ++i) cin >> B[i + 1], B[i + 1] += B[i];
	sort(A.begin(), A.end());
	vector<vector<long long> > beauty(N);
	for (int i = 0; i < N; ++i) {
		beauty[i].resize(i);
		for (int j = 0; j < i; ++j) {
			beauty[i][j] = (B[A[i]] - B[A[j] - 1]) / L;
		}
	}
	vector<long long> dp = { beauty[1][0] };
	for (int i = 2; i < N - 1; ++i) {
		vector<long long> ndp(i, inf);
		for (int j = 0; j < i - 1; ++j) {
			ndp[j] = min(ndp[j], dp[j] + beauty[i][i - 1]);
			ndp[i - 1] = min(ndp[i - 1], dp[j] + beauty[i][j]);
		}
		dp = ndp;
	}
	long long ans = inf;
	for (int i = 0; i < N - 2; ++i) {
		ans = min(ans, dp[i] + beauty[N - 1][N - 2] + beauty[N - 1][i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 19564
import java.util.*;
import java.io.PrintWriter;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// N人の社員,配列を0(=まずは上司なし)初期化
		int N = Integer.parseInt(sc.next());
        Integer syain[] = new Integer[N+1];
        Arrays.fill(syain, 0);

        // 社員の上司IDに +1 していく
        for (int i=2; i<=N; i++) {
          int joushi = Integer.parseInt(sc.next());
          syain[joushi] += 1;
        }

        // 直属の部下の人数を出力
        for(int i=1; i<syain.length; i++) {
            System.out.println( syain[i]);
        }
	}
}

Measured memory_bytes: 61092
tmonth = []
lmonth = []

while line = gets
break if line == "\n"
tmonth << line.split(",").map(&:to_i).first
end

while line = gets
lmonth << line.split(",").map(&:to_i).first
end

sum = (tmonth & lmonth).sort
sum.each do |i|
  puts "#{i} #{tmonth.count(i) + lmonth.count(i)}"
end


Measured memory_bytes: 6844
#include<stdio.h>

int main(){
  int h[10000], w[10000], i, j, k = 0;
  while(1){
    scanf("%d %d", &h[k], &w[k]);
    if(h[k] == 0 && w[k] == 0)
      break;
    k++;
  }

  k = 0;
  while(1){
    if(h[k] == 0 && w[k] == 0)
      break;
    for(i = 1; i <= h[k]; i++){
      for(j = 1; j <= w[k]; j++){
        if((i%2 == 0 && j%2 == 0) || (i%2 == 1 && j%2 == 1))
          printf("#");
        else
          printf(".");
      }
      printf("\n");
    }
    printf("\n");
    k++;
  }

  return 0;
}



Measured memory_bytes: 2148
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

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

    std::vector<std::unordered_map<std::string, long long>> dp(n + 1);

    auto IsOk = [](std::string last_four) {
        for (int i = 0; i < 4; i++) {
            std::string t = last_four;
            if (i < 3) {
                std::swap(t[i], t[i + 1]);
            }

            if (t.find("AGC") != std::string::npos) {
                return false;
            }
        }
        return true;
    };
    auto dfs = [&](auto f, int idx, std::string last_three) -> long long {
        if (idx == n) {
            return 1;
        }

        if (dp[idx][last_three] > 0) {
            return dp[idx][last_three];
        }

        long long val = 0;
        for (auto c : { 'A', 'G', 'C', 'T' }) {
            if (IsOk(last_three + c)) {
                val += f(f, idx + 1, last_three.substr(1, 2) + c);
                val %= mod;
            }
        }

        dp[idx][last_three] = val;
        return val;
    };

    std::cout << dfs(dfs, 0, "TTT") << std::endl;
}


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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
const int MOD = 1e9+7;

ll power(ll a, ll b){
    ll r=1;
    while(b>0){
        if(b&1)
            r=r*a %MOD;
        a = a*a %MOD;
        b/=2;
    }
    return r;
}

int main(){
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    double ans = 1.0*w*h/2;
    cout << ans << " ";
    if(x == 1.0*w/2 && y == 1.0*h/2)
        cout << 1;
    else
        cout << 0;
}


Measured memory_bytes: 3784
#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
// #include <unordered_map>
// #include <unordered_set>
#include <utility>
#include <vector>

#define pb push_back
#define mp make_pair

#ifdef ONLINE_JUDGE
#define link renamelink
#define next renamenext
#define prev renameprev
#endif

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef long double ld;

inline void EnableFileIO(const string& fileName, bool local = 0) {
  if (fileName.empty()) return;
  if (local) {
    freopen((fileName + ".in").c_str(), "r", stdin);
    freopen((fileName + ".out").c_str(), "w", stdout);
    return;
  }
#ifdef ONLINE_JUDGE
  freopen((fileName + ".in").c_str(), "r", stdin);
  freopen((fileName + ".out").c_str(), "w", stdout);
#endif
}

const int INF = (1 << 30) - 1;
const LL LINF = (1LL << 61) - 1;
const double EPS = 1e-10, PI = acos(-1);
const int N = 303;

int n, m;
int a[N][N];
int die[N], cnt[N];

bool check(int mid) {
  memset(die, 0, sizeof die);
  for (int t = 0; t < m - 1; t++) {
    memset(cnt, 0, sizeof cnt);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (!die[a[i][j]]) {
          ++cnt[a[i][j]];
          break;
        }
      }
    }
    int mxv = 0;
    for (int i = 1; i < m; i++) {
      if (cnt[i] > cnt[mxv]) mxv = i;
    }
    if (cnt[mxv] <= mid) return 1;
    die[mxv] = 1;
  }
  return 0;
}
int main() {
  // srand((int)time(0));
  // printf("Hello, world!\n");
  // EnableFileIO("");

  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      --a[i][j];
    }
  }
  int l = 0, r = n;
  while (r - l > 1) {
    int mid = (l + r) >> 1;
    if (check(mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		circleInARectangle();

	}
	
	public static void circleInARectangle() {
		
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		
		if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H) {
			System.out.println("Yes");
		} else{
			System.out.println("No");
		}
	}
}


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

int main()
{
	string s;
	cin >> s;
	int i = 0;
	int s1 = 0;
	int s0 = 0;
	while (s[i])
	{
		if (s[i] == '1')
			s1++;
		if (s[i] == '0')
			s0++;
		i++;
	}
	cout << min(s1, s0) * 2 << endl;
	return (0);
}


Measured memory_bytes: 512
#include<iostream>
#include<map>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<vector>
#include<cstring>
#include<sstream>
#include<algorithm>
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;

#define MOD 1000000007

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

    int n;
    cin >> n;

    long long a[n];
    for (int i = 0; i < n; i++) cin >> a[i];

    sort(a, a+n);

    long long res = a[n-1];
    int cur = n-2, i = n-3;
    while (i >= 0) {
        res += a[cur];
        i --;

        if (i >= 0) {
            res += a[cur];
            i --;
        }

        cur --;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 4712
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
int compare_int_small(const void *a, const void *b){
  return *(long int*)a - *(long int*)b; // 小さい順
}
// 公約数
long long int gcd(long long int a, long long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long long int lcm(long long int a, long long int b){
  return a * b / gcd(a, b);
}

#define TRUE 1
#define FALSE 0
#define LEN 100005

typedef struct q{
  int y;
  int x;
}QUEUE;

//int x = 0;
QUEUE *Q;
//P Q[LEN + 1];
int head = 0;
int tail = 0;
int n;

void initialize(int a){
  head = 0;
  tail = 0;
  Q = (QUEUE *)calloc(a, sizeof(QUEUE));
  if(Q == NULL){
    printf("メモリが確保できません\n");
    exit(EXIT_FAILURE);
  }
}

void finalize(){
  if(Q != NULL){
    free(Q);
    Q = NULL;
  }
}

int isEmpty(){
  if(head == tail){
    return TRUE;
  }else{
    return FALSE;
  }
}

int isFull(){
  if(head == (tail + 1) % LEN){
    return TRUE;
  }else{
    return FALSE;
  }
}

void enqueue(QUEUE x){
  fprintf(stderr, "enqueue() point.y:%d point.x:%d\n", x.y, x.x);
  if(isFull() != FALSE){
      printf("Overfllow\n");
  }else{
    Q[tail] = x;
    if((tail + 1) == LEN){
      tail = 0;
    }else{
      tail++;
    }
  }
}

QUEUE dequeue(){
  QUEUE x;
  //  fprintf(stderr, "-> dequeue\n");
  if(isEmpty() != FALSE){
    printf("Undrtfllow\n");
  }else{
    x = Q[head];
    if((head + 1 == LEN)){
      head = 0;
    }else{
      head++;
    }
  }
  return x;
}


// min
int main(void){
  int m1 = 0, d1 = 0, m2 = 0, d2 = 0;
  
  scanf("%d%d %d%d", &m1, &d1, &m2, &d2);

  if(d2 == 1){
    printf("1");
  }else{
    printf("0");
  }
  

  printf("\n");
  return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc166/abc166_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string N;
  cin >> N;
  cout << (N == "ABC" ? "ARC" : "ABC") << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
priority_queue<int> q;
ll ans;
int n,m,x[200000];
int main(){
    cin>>n>>m;
    for(int i=1;i<=m;i++)cin>>x[i];
    sort(x+1,x+1+m);
        for(int i=2;i<=m;i++){
            q.push(x[i]-x[i-1]);
        }
    for(int i=1;i<n;i++){
        if(!q.empty())q.pop();
    }
    while(!q.empty()){
        ans+=q.top();
        q.pop();
    }
    cout<<ans<<endl;
}


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

#define ll long long
#define ar array

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    int n,k;

    cin >> n >> k >> s;

    s[k-1] = tolower(s[k-1]);
    for (int i = 0; i < n; i++){
        cout << s[i];
    }

}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();

		BigInteger big_num = BigInteger.valueOf(1);

		for(int i = 2; i <= num+1; i++){
			big_num = big_num.multiply(BigInteger.valueOf(i));
		}

		System.out.println(big_num.add(BigInteger.valueOf(2)));

		for(int i = 2; i <= num+1; i++){
			System.out.println(i);
		}

	}
}

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

int main() {
    int i;
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2);
    sort(vec.begin(), vec.end());
    for(i = 0; i < 3; i++){
    if(i == 2){
        cout << vec.at(i) << endl;
        break;
    }
    cout << vec.at(i) << " ";
}
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> l(n);
  for(int i=0;i<n;i++){
    cin>>l[i];
  }
  int a=0;
  for(int i=0;i<n;i++){
    int sum=0;
    for(int j=0;j<n;j++){
      if(j!=i){
        sum+=l[j];
      }
    }
    if(sum<=l[i]){
      a++;
    }
  }
  if(a==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::collections::HashSet;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let s : String = get_one();
    let mut hs : HashSet<char> = HashSet::new();
    let mut ans = true;
    for c in s.chars() {
        if hs.contains(&c) {
            ans = false;
            break;
        }
        hs.insert(c);
    }
    println!("{}", if ans { "yes" } else { "no" });
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long num = in.nextLong();
		String s;
		long firstIndexAlpha = (long) 'a'; // アルファベットの最初の文字
		long sizeAlpha = 26; // アルファベットの個数
		if (num <= 0) {
			/* 0以下はブランクで返す */
			

		} else if (num <= sizeAlpha) {
			/* 1～26までの処理 */
			s = String.valueOf((char) (firstIndexAlpha + num - 1));
			System.out.println(s);

		} else {
			/* 27以上の処理 */

			long offset = num - 1; // 0からの連番に補正した値
			long tmp = offset;
			String str = "";
			while (true) {
				long div = tmp / sizeAlpha; // 商
				long mod = tmp % sizeAlpha; // あまり
				/* 1～26までの処理 */
				s = String.valueOf((char) (firstIndexAlpha + mod));
				str = s + str;
				if (div <= 0) {
					break;
				}
				tmp = (div - 1);
			}
			System.out.println(str);

		}
	}
}

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

#define ll 					long long
#define db					double
#define ull 				unsigned long long
#define pii 				pair<int,int>
#define fi 					first
#define se 					second
#define vi 					vector<int>
#define psb 				push_back
#define ppb 				pop_back
#define all(x)			 	(x).begin(),(x).end()
#define sz(x)				(int)(x).size()
#define endln 				printf("\n")
#define gc					getchar_unlocked
#define setmin(x)			memset((x), -1, sizeof((x)))
#define setnul(x)			memset((x), 0, sizeof((x)))
#ifndef getchar_unlocked
#define getchar_unlocked 	getchar
#endif
const int inf = 1e9 + 5;
const ll infll = 1e18+5;
const int mod = 1e9 + 7;

template <typename T>
void gi(T &ret) {
	ret = 0; char inp=gc(); int kl=1;
	while (inp<'0' || inp>'9') {if (inp=='-') kl=-1; inp=gc();}
	while ('0'<=inp && inp<='9') ret=(ret<<3)+(ret<<1)+(inp-'0'), inp=gc();
	if (kl<1) ret=-ret;
}

const int MAXN = 1e5+5;
int n;
bool use[MAXN];
priority_queue <pii> kn;
priority_queue <pii,vector<pii>,greater<pii>> kr;

pii getrm () {
	while (!kn.empty()) {
		pii x = kn.top(); 
		kn.pop();
		if (use[x.se]) continue;
		return x;
	}
	return {-1,-1};
}

pii getlm () {
	while (!kr.empty()) {
		pii x = kr.top();
		kr.pop();
		if (use[x.se]) continue;
		return x;
	}
	return {-1,-1};
}

ll solve () {
	ll ret = 0ll;
	setnul(use);
	bool fi = 1;
	ll tb = 0ll;
	bool yes = 0;

	int ml = -MAXN, mr = MAXN;
	while (1) {
		pii rv = getrm();
		pii lv = getlm();
		if (rv.se==-1) {
			if (mr<=0) ret += (ll)-mr*2;
			else if (ml>=0) ret += (ll)ml*2;
			
			break;
		}
		// printf ("(%d,%d) - (%d,%d)\n", lv.fi,lv.se, rv.fi, rv.se);

		if (rv.fi<lv.fi) {
			// if (tb) break;

			if (rv.fi>=ml && rv.fi>=0) ret += (ll)rv.fi * 2;
			else if (lv.fi <= mr && lv.fi<=0) ret += (ll)(-lv.fi)*2;
			else {
				if (mr<=0) ret += (ll)-mr*2;
				else if (ml>=0) ret += (ll)ml*2;
			}
			break;
		} else {
			if (fi) {
				if (rv.fi<0) {
					yes = 1;
				} else if (lv.fi>0) {
					yes = 1;
				}
				fi = 0;
			}
			ml = max(ml, lv.fi);
			mr = min(mr, rv.fi);
			use[lv.se] = use[rv.se] = 1;
			ret += (ll) (rv.fi-lv.fi) * 2;
		}
	}
	return ret;
}

int solve_spc (int l, int r) {
	assert(0);
	if (r<0) return abs(r)*2;
	if (l>0) return l*2;
	return 0;
}

int main() {
	gi(n);
	int ml = -MAXN, mr = MAXN;
	for (int i=1; i<=n; i++) {
		int l, r; gi(l); gi(r);
		kn.push({l,i});
		kr.push({r,i});

		ml = max(ml, l);
		mr = min(mr, r);
	}
	if (ml<=mr) {
		printf ("%d\n", solve_spc (ml,mr));
	} else {
		printf ("%lld\n", solve());
	}
	return 0;
}

Measured memory_bytes: 2156
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a=0,b=0,c=0;
	int a1,b1,c1;
	for(int i=0;i<n;i++){
		cin>>a1>>b1>>c1;
		a1=a1+max(b,c);
		b1=b1+max(a,c);
		c1=c1+max(a,b);
		a=a1;
		b=b1;
		c=c1;
	}
	cout<<max(max(a,b),c);
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>

#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
#ifdef local
#define dbg(a) cout << #a": " << a << endl;
#else
#define dbg(a)
#endif // loacl


using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const ll inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-6;
const int mod=1e9+7;
const int maxn=20;
const int N=1e6+10;
const int M=N<<1;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll MOD)
{
    ll ans=1;
    while(b)
    {
        if(b&1) ans=(ans*a)%MOD;
        b>>=1;
        a=(a*a)%MOD;
    }
    return ans;
}


int main()
{
#ifdef local
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif // local
    ll a,b;
    cin>>a>>b;
    if(b==1) {cout<<0<<endl;return 0;}
    if(b<=a) {cout<<1<<endl;return 0;}
    b-=a;
    a-=1;
    int cnt=1+b/a;
    if(b%a!=0) cnt++;
    cout<<cnt;

}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
int f1[100001],f2[100001];
int a[100001],used[100001];
int main(){
	int n;
	cin>>n;
	ll s=0; 
	for(int i=0;i<n;i++){
		cin>>f1[i];
	}
	for(int i=0;i<n;i++){
		cin>>f2[i];
		a[i]=f1[i]-f2[i];
		s+=a[i];
	}
	if(s<0){
		cout<<-1;
		return 0;
	}
	sort(a,a+n);
	int cor=0,left=0,right=n-1;
	while(left<right && right>=0 && left<n){
		if(a[right]<0 || a[left]>0){
			break;
		}
		if(a[right]+a[left]>=0){
			if(a[right]==0 || a[left]==0){
				if(a[right]==0){
					right--;
				}
				if(a[left]==0){
					left++;
				}
				continue;
			}
			if(!used[right]){
				cor++;
				used[right]=1;
			}
			if(!used[left]){
				cor++;
				used[left]=1;
			}
			a[right]+=a[left];
			left++;
		}
		else{
			if(!used[right]){
				cor++;
				used[right]=1;
			}
			a[right-1]+=a[right];
			right--;
		}
	}
	cout<<cor;
    return 0;
}

Measured memory_bytes: 1664
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e7+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
int main(void){
	int n,i;cin>>n;
	vector<int> a(n);
	for(i=0;i<n;i++){cin>>a[i];}
	soun(a);
	cout<<a.size()<<endl;
	RE;
}

Measured memory_bytes: 888
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int N, R, T;
    cin >> N >> R >> T;
    vector<int> sp(N);
    for(int i = 0; i < N; ++i) {
        cin >> sp[i];
    }
    vector<int> pos(N);
    for(int i = 0; i < N; ++i) {
        pos[i] = sp[i] % R;
    }
    int ans = 0;
    vector<int> cap(R);
    for(int i = 0; i < T; ++i) {
        for(int j = 0; j < N; ++j) {
            if(cap[pos[j]] == 0) ++ans;
            else --cap[pos[j]];
        }
        for(int j = 0; j < N; ++j) {
            if(i != 0) ++cap[pos[j]];
            pos[j] = (pos[j] + sp[j]) % R;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3084
import numpy as np
import math
import collections
import bisect
from difflib import SequenceMatcher


def main():
    N, M, K = map(int, input().split())

    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    cumsumA = np.cumsum(A)
    p = bisect.bisect_left(cumsumA, K + 0.1)
    time = cumsumA[p - 1]
    tmp = p
    ans = tmp

    cntA = 0
    import numpy as np


import math
import collections
import bisect
from difflib import SequenceMatcher


def main():
    N, M, K = map(int, input().split())

    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    cumsumA = np.cumsum(A)
    a = bisect.bisect_left(cumsumA, K + 0.1) - 1
    time = cumsumA[a]
    tmp = a + 1
    ans = tmp

    b = 0
    while(b < len(B)):
        #print(a, b, ans)
        if time + B[b] <= K:
            time += B[b]
            tmp += 1
            b += 1
            if tmp > ans:
                ans = tmp
        else:
            if a < 0:
                break
            time -= A[a]
            tmp += -1
            a += -1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 57988
import java.util.*;
public class Main  {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int h1 = sc.nextInt();

      int m1 = sc.nextInt();

      int h2 = sc.nextInt();

      int m2 = sc.nextInt();

      int k = sc.nextInt();
      
      int time = ( h2* 60 + m2 ) - (h1 * 60 + m1) - k;
      
      System.out.println(time);
      
      }
      
}


Measured memory_bytes: 35808
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<vector>

using namespace std;

int main(){
  int W,H,N,S;
  int X[100],Y[100],a[100];
  bool B[100][100];
  //入力
  cin >> W >> H >> N;
  for(int i=0; i < N; i++)
    cin >> X[i] >> Y[i] >> a[i];
  //初期化
  for(int i=0; i < W; ++i)
    for(int j=0; j < H; ++j)
        B[i][j] = false;

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

    switch(a[i]){
      case 1:
        for(int k=0; k < X[i]; ++k)
          for(int j=0; j < H; ++j)
              B[k][j] = true;
          break;
      case 2:
        for(int k=X[i]; k < W ; ++k)
          for(int j=0; j < H; ++j)
              B[k][j] = true;
        break;
      case 3:
        for(int k=0; k < W; ++k)
          for(int j=0; j < Y[i]; ++j)
              B[k][j] = true;
        break;
      case 4:
        for(int k=0; k < W; ++k)
          for(int j=Y[i]; j < H; ++j)
              B[k][j] = true;
          break;
    }
  }
  int ans=0;
  for(int i=0; i < W; ++i){
    for(int j=0; j < H; ++j){
      if(B[i][j] == false)  ans++;
        //  cout << B[i][j];
      }
    }

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


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const int MAX = 100001;
 
int main(){
    int N;
    int A[MAX];
    deque<int> color;

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

    for(int i = 0;i < N;i++){
        int index = lower_bound(color.begin(),color.end(),A[i]) - color.begin();

        if(index == 0){
            color.push_front(A[i]);
        }else{
            color[index - 1] = A[i];
        }
    }

    cout << color.size() << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val x = Integer.parseInt(sc.next())
    val y = Integer.parseInt(sc.next())
    val a = Integer.parseInt(sc.next())
    val b = Integer.parseInt(sc.next())
    val c = Integer.parseInt(sc.next())
    val p = LongArray(a)
    val q = LongArray(b)
    val r = LongArray(c)
    repeat(a){p[it] = sc.nextLong()}
    repeat(b){q[it] = sc.nextLong()}
    repeat(c){r[it] = sc.nextLong()}
    val aa = p.sortedDescending().slice(0..x-1).toLongArray()
    val bb = q.sortedDescending().slice(0..y-1).toLongArray()
    val apple = ( aa + bb + r).sortedDescending().slice(0..x+y-1)
    var ans = 0L
    repeat(x+y){ans += apple[it]}
    println(ans)
}


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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<ll> &s, ll a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;


int main() {

    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());

    if (s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Main p = new Main();
	}
	
	HashMap<String, State> map = new HashMap<String, State>();  
	public Main(){
		Scanner sc = new Scanner(System.in);
		createPossiblePattern();
		while(sc.hasNextLine()){
			String puzzle = sc.nextLine();
			puzzle = puzzle.replaceAll(" ", "");
			System.out.println(map.get(puzzle).count);
		}
	}

	
	private void createPossiblePattern(){
		State state = new State(0, 0, "01234567", 0);
		map.put(state.s, state);
		LinkedList<State> queue = new LinkedList<State>(); 
		queue.offer(state);
		
		int[] dx = {-1, 0, 1, 0};
		int[] dy = {0, -1, 0, 1};
		while(!queue.isEmpty()){
			State curState = queue.poll();
			
			for(int i=0;i<4;i++){
				int nx = curState.x + dx[i];
				int ny = curState.y + dy[i];
				
				if(0<=nx && nx<4 && 0<=ny && ny<2){
					StringBuilder next = new StringBuilder(curState.s);
					char w = next.charAt(nx+ny*4);
					next.setCharAt(nx+ny*4, next.charAt(curState.x+curState.y*4));
					next.setCharAt(curState.x+curState.y*4, w);
					
					if(!map.containsKey(next.toString())){
						State nextState = new State(nx, ny, next.toString(), curState.count+1);
						map.put(nextState.s, nextState);
						queue.offer(nextState);
					}
				}
			}
		}
	}
	
	private class State{
		public int x;
		public int y;
		public String s;
		public int count;
		
		public State(int x, int y, String s, int count){
			this.x = x;
			this.y = y;
			this.s = s;
			this.count = count;
		}
	}
	
}

Measured memory_bytes: 38596
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, m, a, b;
  cin >> n >> m >> a >> b;
  cout << (n - a) * (m - b) << endl;
  return 0;
}


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

int main() {
#if LOCAL&01
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll X;
    cin>>X;
    double tmp=1+8*X;
    double dans = (sqrt(tmp)-1.0)/2.0;
    int ans=ceil(dans);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <cctype>
#include <string>

int parse_int(std::string const& s, size_t& i) {
  assert(isdigit(s[i]));
  int res = s[i]-'0';
  while (isdigit(s[++i]))
    res = res*10 + s[i]-'0';
  return res;
}

void skip(std::string const& s, size_t& i) {
  assert(s[i] == '(');
  int opens = 0;
  do {
    if (s[i] == '(') ++opens;
    if (s[i] == ')') --opens;
    ++i;
  } while (opens);
}

void nya(std::string const& s, size_t& i, std::string const& t, size_t& j) {
  assert(s[i] == '(');
  assert(t[j] == '(');
  ++i;
  ++j;

  putchar('(');
  if (s[i] == ')') {
    ++i;
    skip(t, --j);
  } else if (t[j] == ')') {
    ++j;
    skip(s, --i);
  } else {
    nya(s, i, t, j);
  }
  putchar(')');

  assert(s[i] == '[');
  assert(t[j] == '[');
  int x = parse_int(s, ++i);
  int y = parse_int(t, ++j);
  assert(s[i] == ']');
  assert(t[j] == ']');
  ++i;
  ++j;
  printf("[%d]", x+y);

  assert(s[i] == '(');
  assert(t[j] == '(');
  ++i;
  ++j;

  putchar('(');
  if (s[i] == ')') {
    ++i;
    skip(t, --j);
  } else if (t[j] == ')') {
    ++j;
    skip(s, --i);
  } else {
    nya(s, i, t, j);
  }
  putchar(')');

  assert(s[i] == 0 || s[i] == ')');
  assert(t[j] == 0 || t[j] == ')');
  ++i;
  ++j;
}

int main() {
  char buf[1024];
  scanf("%s", buf);
  std::string s = buf;
  scanf("%s", buf);
  std::string t = buf;

  size_t i = 0;
  size_t j = 0;
  nya(s, i, t, j);
  putchar('\n');
}



Measured memory_bytes: 2884
#include <iostream>
using namespace std;
int main()
{
    int x,n,i,j;
    cin>>x>>n;
    if(n==0){
        cout<<x<<endl;
        return 0;
    }
    int arr[n],m[102];
    for(i=1;i<=100;i++)m[i]=0;
    for(i=0;i<n;i++){
        cin>>arr[i];
        m[arr[i]]=1;
    }
    for(j=x;;j++){
        if(j>100)break;
        else if(m[j]==0)break;
    }
    int t1=j;
    for(j=x-1;;j--){
        if(j<=0)break;
        else if(m[j]==0)break;
    }
    int t2=j;
    if(abs(t2-x)<=abs(t1-x)){
        cout<<t2<<endl;
    }
    else cout<<t1<<endl;
    return 0;
}


Measured memory_bytes: 3612
import java.io.*;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Queue;

public class Main {

  public static void main(final String[] args) {

    Scanner sc = new Scanner(System.in);

    int num = sc.nextInt();
    int sum = 0;

    if (num == 1) {
      System.out.println('1');
      return;
    }

    for (int i = 1; i <= num; i++) {
      for (int j = 1; j <= num; j++) {
        for (int k = 1; k <= num; k++) {
          int[] test = {i, j, k};
          sum += gcd(test);
        }
      }
    }

    System.out.println(sum);
  }

  private static int gcd(int[] num) {
    int ans = num[0];

    for (int i = 1; i < num.length; i++) {
      ans = func(ans, num[i]);
    }
    return ans;
  }

  private static int func(int a, int b) {

    if (b != 0) {
      return func(b, a % b);
    } else {
      return a;
    }
  }
}


Measured memory_bytes: 52600
N = int(input())
H = list(map(int, input().split()))
table = [0, abs(H[1]-H[0])]+[0] * (N-2)
for i in range(2, N):
    a = table[i-1] + abs(H[i] - H[i-1])
    b = table[i-2] + abs(H[i] - H[i-2])
    table[i] = min(a,b)
print(table[N-1])


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

int main(){
	int N;
    cin >> N;
    vector<int> X(N);
    rep(i,N) cin >> X[i];
    //sort(X.begin(),X.end());
    int ans(999999999);
    for(int P(1); P<101; P++){
        int tmp(0);
        rep(i,N){
            tmp += pow((X[i]-P),2);
        }
        ans = min(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<vector>
#include<utility>
using namespace std;


int main() {
    int N;
    char S[1000000];
    int fs[1000000];
    int fe[1000000];
    cin >> N;
    for(int i = 0; i < N;i ++) {
        cin >> S[i];
    }

    int n_w = 0, n_e = 0;
    fs[0] = 0;
    fe[N-1] = 0;
    for(int i = 0; i < N; i++) {
         fs[i] = n_w;
        if(S[i] == 'W')  n_w++;

    }
    for(int i = N - 1; i >= 0; i--) {
        fe[i] = n_e + fs[i];
        if(S[i] == 'E') n_e++;
    }
    sort(fe, fe + N);
    cout << fe[0];


    return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N) {
    ll res = 0;
    repn(i, N) {
        if (!(i % 3 == 0 || i % 5 == 0)) res += i;
    }
    cout << res << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


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

int main(){
    string s; cin >> s;
    int a = s.at(0) - '0';
    int b = s.at(1) - '0';
    int c = s.at(2) - '0';
    int d = s.at(3) - '0';
    
    if(a+b+c+d == 7){
        printf("%d+%d+%d+%d=7\n", a, b, c, d);
    }else if(a+b+c-d==7){
        printf("%d+%d+%d-%d=7\n", a, b, c, d);
    }else if(a+b-c+d==7){
        printf("%d+%d-%d+%d=7\n", a, b, c, d);
    }else if(a-b+c+d==7){
        printf("%d-%d+%d+%d=7\n", a, b, c, d);
    }else if(a+b-c-d==7){
        printf("%d+%d-%d-%d=7\n", a, b, c, d);
    }else if(a-b-c+d==7){
        printf("%d-%d-%d+%d=7\n", a, b, c, d);
    }else if(a-b+c-d==7){
        printf("%d-%d+%d-%d=7\n", a, b, c, d);
    }else if(a-b-c-d==7){
        printf("%d-%d-%d-%d=7\n", a, b, c, d);
    }
    return 0;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll p[5009];
ll f[5009];
ll dp[5009][5009];
ll pw[5009];
vector<ll> v[5009];
ll mod = 1e9 + 7;
ll A,B;
void dfs(ll x){
    A++;
    if(p[x] == -1) B++;
    f[x] = 1;
    for(ll y : v[x]){
        if(f[y] == 0) dfs(y);
    }
}
main(){
    ll n;
    cin >> n;
    for(ll i = 1; i <= n; i++){
        cin >> p[i];
        if(p[i] != -1){
            v[i].push_back(p[i]);
            v[p[i]].push_back(i);
        }
    }
    vector<ll > u;
    ll dead = 0, C = 0;
    for(ll i =1; i <= n; i++){
        if(f[i] == 0){
            A = 0;
            B = 0;
            dfs(i);
            if(B == 0) dead += A, C++;
            else u.push_back(A);
        }
    }
    ll ans, cur = 1, X;
    ll S = u.size();
    pw[0] = 1;
    for(ll i = 1; i <= S; i++)
        pw[i] = pw[i-1] * (n-1) % mod;
    X = pw[S-1];
    ans = (n - C) * pw[S] % mod;
    if(!u.size()) {cout<<ans<<endl; return 0;}
    dp[0][0] = n-1;
    dp[0][1] = u[0];
    for(ll i = 1; i < S; i++){
        for(int j = 0; j <= i+1; j++){
            int P = 1;
            if(j > 2) P = j -1;
            dp[i][j] = (n - 1) * dp[i-1][j] % mod;
            if(j >= 1) dp[i][j] = (dp[i][j] + u[i] * dp[i-1][j-1] % mod * P % mod) %mod;
        }
    }
    for(int i = 0; i < S; i++)
    for(int j = 1; j <= S; j++){
            ll P = 1;
            if(j > 2) P = j -1;
            
            if(j == 1 || i > 0)
                ans= (ans + mod - pw[S-i-1] * (i ? dp[i-1][j-1] : 1)%mod * u[i] %mod* P%mod ) % mod;
    }
    cout<<(ans + mod + X * (ll)S%mod)%mod<<endl;
}


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

int main(){
    long long n;
    long long sum = 0;

    cin >> n;
    for(long long i = 1; i <= n; i++){
        if(i%3 == 0 && i%5 == 0) continue;
        else if(i%3 == 0) continue;
        else if(i%5 == 0) continue;
        sum+=i;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3652
package main

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

func main() {
	sc.Split(bufio.ScanWords)

	var x, y, a, b, c int
	fmt.Scan(&x, &y, &a, &b, &c)
	p := make([]int, a)
	q := make([]int, b)
	r := make([]int, c)
	for i := 0; i < a; i++ {
		p[i] = nextInt()
	}
	for i := 0; i < b; i++ {
		q[i] = nextInt()
	}
	for i := 0; i < c; i++ {
		r[i] = nextInt()
	}

	sort.Sort(sort.Reverse(sort.IntSlice(p)))
	sort.Sort(sort.Reverse(sort.IntSlice(q)))
	p = p[:x]
	q = q[:y]

	d := []int{}
	d = append(d, p...)
	d = append(d, q...)
	d = append(d, r...)
	sort.Sort(sort.Reverse(sort.IntSlice(d)))

	ans := 0
	for i := 0; i < x+y; i++ {
		ans += d[i]
	}
	fmt.Println(ans)
}

var sc = bufio.NewScanner(os.Stdin)

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


Measured memory_bytes: 11392
n,k = map(int,input().split())
a_list = list(map(int,input().split()))
a = 0
t = 1
d = 0
hoge_list = []
hoge_set = set()
while a < k:
  hoge_list.append(t)
  hoge_set.add(t)
  t = a_list[t-1]
  a += 1
  if t in hoge_set:
    b = hoge_list.index(t)
    d += 1
    break
if d == 0:
  print(t)
else:
  e = (k-b)%(a-b)
  print(hoge_list[b+e])


Measured memory_bytes: 32380
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define ALL(a) (a).begin(),(a).end()
#define EACH(e,v) for(auto& e:v)
#define SORT(v) sort(ALL(v))
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = 1000'000'007;




vector<int> g2[3*112345];

int dists[3*112345];

int bfs(int from,int to) {
    int dist=0;
    queue<int> que;
    que.push(from);
    dists[from]=0;
    while(!que.empty()){
        int now=que.front();que.pop();
        int nowd=dists[now];
        rep(i,g2[now].size()){
            int nx=g2[now][i];
            if(dists[nx]==-1){
                dists[nx]=nowd+1;
                que.push(nx);
            }
        }
    }
       
    return dists[to];
}

signed main(){
    int n,m;
    cin>>n>>m;
    rep(i,m){
        int u,v;
        cin>>u>>v;
        u--;v--;
       // g2[u].push_back(v);
        g2[u].push_back(v+n);
        g2[u+n].push_back(v+n*2);
        g2[u+n*2].push_back(v);
    }
    rep(i,3*112345){
        dists[i]=-1;
    }
    int s,t;
    cin>>s>>t;
    s--;t--;
    int dist=bfs(s,t);

    int ans=(dist==-1)?-1:dist/3;
    cout<<ans<<endl;

 
}


Measured memory_bytes: 18816
#include<bits/stdc++.h>
#define int long long 
#define LL long long 
#define LD long double
#define PI 3.14159265358979323846
#define MOD ((LL)1e9+7)
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int32_t main()
{
	IOS
	map<char,char>M;
	M['A']='T';M['T']='A';
	M['C']='G';M['G']='C';
	char ch;cin>>ch;cout<<M[ch]<<endl;
	
	

	
}


Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N;
int A[200000], B[200000];

signed main(){
    cin >> N;
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];

    int ans = 0;
    rep(k, 29){
        int cnt = 0;
        vector<pair<int, int>> P0, P1;
        rep(i, N){
            if((B[i]>>k)&1) P1.pb({ B[i]%(1<<k),B[i] });
            else P0.pb({ B[i]%(1<<k),B[i] });
        }
        sort(all(P0)); sort(all(P1));
        rep(i, N){
            if((A[i]>>k)&1){
                cnt += lower_bound(all(P0), mp((1<<k)-A[i]%(1<<k),0)) - P0.begin();
                cnt += P1.end() - lower_bound(all(P1), mp((1<<k)-A[i]%(1<<k),0));
            }
            else{
                cnt += P0.end() - lower_bound(all(P0), mp((1<<k)-A[i]%(1<<k),0));
                cnt += lower_bound(all(P1), mp((1<<k)-A[i]%(1<<k),0)) - P1.begin();
            }
            cnt &= 1;
        }
        ans += cnt<<k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8168
import sys

N, K, Q = map(int, input().split())

if K> Q:
    for i in range(N):
        print('Yes')
    sys.exit()

scores= [0 for n in range(N)]

for i in range(Q):
    scores[int(input()) -1] += 1

# print(scores)

for s in scores:
    if(s > Q-K):
        print('Yes')
    else:
        print('No')


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


int main()
{
  ll n;
  cin >> n;
  
  ll k = n;
  map<ll, int> pr;
  for(ll i = 2; i*i <= k; i++)
  {
    while(k%i == 0)
    {
      k /= i;
      pr[i]++;
    }
  }
  if(k != 1) pr[k]++;
  
  int res = 0;
  for(auto x : pr)
  {
    int sum = 0;
    for(int i = 1; i < 100; i++)
    {
      sum += i;
      if(sum > x.second)
      {
        res += i - 1;
        break;
      }
    }
    //cout << x.second << " " << res << endl;
  }
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void){
	int A, B, C, D, P, tmp;
	scanf("%d%d%d%d%d", &A, &B, &C, &D, &P);
	if (P > C) tmp = B + (P - C) * D;
	else tmp = B;
	if (A * P < tmp)
		printf("%d\n", A * P);
	else printf("%d\n", tmp);
	return 0;
}

Measured memory_bytes: 596
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")

#include <iostream>
#include <string>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <tuple>
#include <queue>
#define PII pair<int, int>
#define T3I tuple<int, int, int>
using namespace std;

typedef long long ll;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;

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

    int n;
    cin >> n;
    vector<pair<int, string>> A;
    map<string, int> cnt;
    for(int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        cnt[s]++;
    }
    for(auto x: cnt) {
        A.push_back(make_pair(x.second, x.first));
    }
    sort(A.begin(), A.end());
    vector<string> B;
    int maxe = A.back().first;
    for(int i = (int)A.size()-1; i >= 0; --i) {
        if(A[i].first == maxe) {
            B.push_back(A[i].second);
        }else {
            break;
        }
    }
    sort(B.begin(), B.end());
    for(auto x: B) {
        cout << x << endl;
    }
}


Measured memory_bytes: 31084
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include <bits/stdc++.h>
using namespace std;

int main(){
	int K;
	int A,B;
	cin>>K>>A>>B;
	for(int i = A; i <= B; i++){
		if(i % K == 0){
			cout<<"OK"<<endl;
			return 0;
		}
		
	}
	cout<<"NG"<<endl;
}

Measured memory_bytes: 3592
def resolve():
    n = int(input())
    monster = [int(i) for i in input().split()]
    damage = [int(i) for i in input().split()]

    before = sum(monster)
    for i, (mst, dmg) in enumerate(zip(monster, damage)):
        if dmg >= monster[i]:
            _dmg = dmg - monster[i]
            monster[i] = 0
            monster[i + 1] = max(monster[i + 1] - _dmg, 0)
        else:
            monster[i] = monster[i] - dmg

    after = sum(monster)
    print(before - after)


resolve()

Measured memory_bytes: 18624