akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#define rep(i, n) for(i=0; i<n; i++)
#define pb push_back
#define ll long long
using namespace std;
int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, i;
    cin >> n;
    ll sum = 0, S=0;
    vector<ll> notch;
    for(i=0; i<n; i++){
        ll x;
        cin >> x;
        notch.pb(x);
        S += x;
    }
    ll mi = S;
    for(i=0; i<n; i++){
        sum += notch[i];
        mi = min(mi, abs(sum - (S-sum)));
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 5276
import java.util.*;public class Main{public static void main(String[]a){Scanner s=new Scanner(System.in);for(int t=s.nextInt();t-->0;){int[]l=new int[3];for(int i=0;i<3;i++)l[i]=s.nextInt();Arrays.sort(l);System.out.println(l[0]*l[0]+l[1]*l[1]==l[2]*l[2]?"YES":"NO");}}}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
int h,w;
vector<vector<int>> fielda,fieldb;
bool memo[80][80][13000];
int MIN= 1000000000;

int search(int i,int j,int k){
  memo[i][j][k] = false;
  //cout << i << ' ' << j << ' ' << k << endl;
  int tmpk = abs(fielda.at(i).at(j)-fieldb.at(i).at(j));
  int ret;
  if(i==(h-1)&&j==(w-1)){ret = min(abs(k-tmpk),abs(k+tmpk));return ret;} 
  int ni = i+1;
  int nj = j+1;
  //cout << memo[ni][j][k-tmpk] << endl;
  int ret1,ret2,ret3,ret4;
  ret1=ret2=ret3=ret4=1e9;
  if(ni<h){
    if(memo[ni][j][abs(k-tmpk)])ret1=search(ni,j,abs(k-tmpk));
    if(memo[ni][j][k+tmpk])ret2=search(ni,j,k+tmpk);
  }
  if(nj<w){
    if(memo[i][nj][abs(k-tmpk)])ret3=search(i,nj,abs(k-tmpk));
    if(memo[i][nj][k+tmpk])ret4=search(i,nj,k+tmpk);
  }
  return min(ret1,min(ret2,min(ret3,ret4)));
}
    

int main(){
  cin >> h >> w;
  int tmp;
  for(int i=0;i<h;i++){
    vector<int> vectmp;
    for(int j=0; j<w; j++){
      cin >> tmp;
      vectmp.push_back(tmp);
    }
    fielda.push_back(vectmp);
  }
  for(int i=0;i<h;i++){
    vector<int> vectmp;
    for(int j=0; j<w; j++){
      cin >> tmp;
      vectmp.push_back(tmp);
    }
    fieldb.push_back(vectmp);
  }
  //cout << "hoge" << endl;
  //int k=abs(fielda.at(0).at(0) - fieldb.at(0).at(0));
  memset(memo,true,sizeof(memo));
  MIN = search(0,0,0);
  cout << MIN << endl;
}
  


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

using namespace std;

#define ll long long
#define M 1005000
#define ii pair<ll, ll>
#define fi first
#define se second
#define pb push_back



int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    ll n;
    cin >> n;    
    cout << pow(n, 3);
    
    return 0;
}


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

int main() {
  int n; cin >> n;
  vector<int> a(n+1);
  for(int i=0; i<n+1; ++i){
    cin >> a[i];
  }
  vector<int> b(n);
   for(int i=0; i<n; ++i){
    cin >> b[i];
  }
  
  long long ans=0;
  for(int i=0; i<n; ++i){
    if(a[i]<=b[i]){
      ans+=a[i];
      b[i]-=a[i]; 
      if(a[i+1] >= b[i]){
        ans += b[i];
        a[i+1]-=b[i];
        b[i]=0;
      }else{
        ans += a[i+1];
        a[i+1]=0;
        b[i]-=a[i+1];
      }      
    }else{
      ans+=b[i];
      b[i]=0;
    }
   
  
  }
  if(a[n]>b[n-1]){
    ans+=b[n-1];
     
  
  }else{
    ans+=a[n];
      
  
  }
    
  cout << ans << endl;
  
}


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

ans = 0
left, right = 0, 0
total = 0
while left < N:
    if right < N and total + A[right] == total ^ A[right]:
        total += A[right]
        right += 1
    else:
        ans += right - left
        total -= A[left]
        left += 1
print(ans)


Measured memory_bytes: 24584
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n; cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    int sum = 0;
    rep(i,n) rep(j,i) {
        sum += d[i] * d[j];
    }
    cout << sum << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
    int value;
    int pos;
} result;

result equation(char *s, int pos);
result factor(char *s, int pos);
result term(char *s, int pos);

result equation(char *s, int pos)
{
    result temp, next;
    temp = factor(s, pos);
    while (s[temp.pos] == '+' || s[temp.pos] == '-'){
        next = factor(s, temp.pos + 1);
        if (s[temp.pos] == '+'){
            temp.value += next.value;
        }
        else {
            temp.value -= next.value;
        }
        temp.pos = next.pos;
    }
    
    return (temp);
}

result factor(char *s, int pos)
{
    result temp, next;
    temp = term(s, pos);
    while (s[temp.pos] == '*' || s[temp.pos] == '/'){
        next = term(s, temp.pos + 1);
        if (s[temp.pos] == '*'){
            temp.value *= next.value;
        }
        else {
            temp.value /= next.value;
        }
        temp.pos = next.pos;
    }
    
    return (temp);
}

result term(char *s, int pos)
{
    int i;
    int value;
    result temp;
    
    if (s[pos] == '('){
        temp = equation(s, pos + 1);
        temp.pos += 1;
        return (temp);
    }
    else {
        value = 0;
        while ('0' <= s[pos] && s[pos] <= '9'){
            value = value * 10 + (s[pos++] - '0');
        }
        temp.value = value;
        temp.pos = pos;
        return (temp);
    }
}

int main(void)
{
    result res;
    char expr[256];
    int i, n;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++){
        res.pos = 0;
        scanf("%s", expr);
        res = equation(expr, 0);
        printf("%d\n", res.value);
    }
    
    return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll unsigned long long

using namespace std;
const long long  MAX = 1000000000000000000;
ll n,m;
ll a[100100];
ll ans=1;

int main()
{
	cin  >> n; 
	for(ll i=1;i<=n;i++)
		cin >> a[i];
	sort(a+1,a+n+1);
	if(a[1]==0)
	{	
		cout << "0" << endl; 
		return 0; 
	}
	bool flag=true;
	for(ll i=n;i>=1;i--)
	{
		if(ans > MAX/a[i])
		{
			flag=false;
			break;
		}
		ans=ans*a[i];
	}
	if(flag)
		cout << ans <<endl; 
	else cout << "-1" <<endl;
	return 0;
}

Measured memory_bytes: 4436
#include "bits/stdc++.h"

//region Template
#include "ext/pb_ds/assoc_container.hpp"
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int MOD = 1000000007;

using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;

#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
void print() {}
template<typename T, typename... Args>
void print(T firstArg, Args... args) {
	#ifdef LOCAL
	cout << firstArg << "\t";
	print(args...);
	#endif
}
//endregion

/* Notes:
 * Farah </3
 */

const int MAXN = 1e5 + 6;
const int INF = 2e9;

long long modPow(long long pow){
	long long ans = 1;
	long long p = 2;
	while(pow){
		if(pow & 1)
			ans = (ans * p) % 1000000007;
		p = (p * p) % 1000000007;
		pow >>= 1;
	}
	return ans;
}

int freq[MAXN];
int main() {
	#ifdef LOCAL
	setIn("in.txt");
	setOut("out.txt");
	#endif

	int n;
	cin >> n;

	set<int> s;
	for(int i = 0; i < n; i++){
		int x;
		 cin >> x;

		 freq[x]++;
		 s.insert(-x);
	}

	int one = 0;
	for(auto x: s){
		if(freq[-x] > 2){
			finish(0);
		}
		if(freq[-x] == 1){
			one++;
		}

		if(one > 1){
			finish(0);
		}
	}

	int idx = 0;
	for(auto x : s){
		if(freq[-x] < 2 && idx != n / 2){
			finish(0);
		}
		idx++;
	}
	cout << modPow(n / 2);
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<int> d(n);
	for(int i = 0; i < n; ++i) {
		cin >> d[i];
	}
	
	ll ans = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = i + 1; j < n; ++j) {
			ans += (d[i] * d[j]);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;

//typedef modint998244353 mint;

const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const ll MAX = 1e9 + 5;

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

	ll diff = b - a;
	for (int i = 0; i < n; i++) {
		ll l = c * (n - 1 - i) - d * i;
		ll r = d * (n - 1 - i) - c * i;

		if (l <= diff && diff <= r) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}

Measured memory_bytes: 3624
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N = int(input())
    a = list(map(int,input().split()))
    cnt = [0] * (max(a) + 2)

    for i in a:
        if i != 0:
            cnt[i-1] += 1
        cnt[i] += 1
        cnt[i+1] += 1
    print(max(cnt))

if __name__ == "__main__":
    main()

Measured memory_bytes: 13964
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    ll left=4*a*b;
    ll right=(c-a-b)*(c-a-b);
    if(c-a-b>0){
        if(left<right) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
}

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

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

ll g1(ll n, int p) {
  if (n == 0) return 0;
  return n / p + g1(n / p, p);
}

ll g2(ll n, int p) {
  if (n % 2 == 1) return 0;
  ll res = g1(n / 2, p);
//  if (p == 2) res += n / 2;
  return res;
}

int main() {
  ll n, ans;
  cin >> n;

  ans = min(g2(n, 2), g2(n, 5));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int selectionSort(int A[], int N) {
	int i, j, t, sw = 0, minj;
	for (i = 0; i < N - 1; i++) {
		minj = i;
		for (j = i; j < N; j++) {
			if (A[j] < A[minj]) {
				minj = j;
			}
		}
		t = A[i]; A[i] = A[minj]; A[minj] = t;
		if (i != minj) {
			sw++;
		}
	}
	return sw;
}

int main() {
	int A[100], N, i, sw;

	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	sw = selectionSort(A, N);

	for (i = 0; i < N; i++){
		if (i > 0) {
			printf(" ");
		}
		printf("%d", A[i]);
	}
	printf("\n");
	printf("%d\n", sw);

	return 0;
}


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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1000000007;

int main() {
	int s;
	cin >> s;
	ll a[3000005];
	bool b[3000005];
	for (int i = 0;i < 3000005;i++) {b[i] = false;}
	int las = s;
	a[0] = las;
	b[las] = true;
	for (int i = 1;i < 1000005;i++) {
		if (a[i-1]%2==0) {a[i] = a[i-1]/2;}
		else {a[i] = a[i-1]*3+1;}
		if (b[a[i]]) {cout << i + 1 << endl;return 0;}
		else {b[a[i]] = true;}
	}
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    string s;
    cin >> s;
    int n = s.size();
    char c = s[0];
    int cnt = 1;
    VI cnts;
    for(int i = 1; i < n; i++){
        if (s[i] != c){
            cnts.push_back(cnt);
            cnt = 0;
            c = s[i];
        }
        cnt++;
    }
    cnts.push_back(cnt);
    cout << (cnts.size() - 1) << endl;
    return 0;
}

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

const int MAX = 1000000;
bool A[MAX];

int main() {
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= 3; ++i) {
        if (i!=a && i!=b) cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

    string s, new_s;

    while (true) {
        cin >> s;
        if (s == "-") {
            break;
        }

        int n;
        cin >> n;

        for (int i = 0; i < n; i++) {
            int num;
            cin >> num;

            for (int i = num; i < s.length(); i++) {
                new_s += s[i];
            }

            for (int i = 0; i < num; i++) {
                new_s += s[i];
            }
            s = new_s;
            new_s = "";
        }

        cout << s << endl;
    }


}

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

#define ll long long
#define el cout << '\n';
#define lcm(a, b) a / __gcd(a, b)*b
#define IOS   ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define mod 1000000007
#define pr pair<int, int>

//debug
template <class... Args>
auto &see(const Args &... args) { return ((cerr << " " << args), ...) << '\n'; }
#define bug(...)  cerr << "[ " #__VA_ARGS__ " ] = "; see(__VA_ARGS__) << '\n';

int egcd(int a, int b, int &x, int &y)
{
    if (b == 0)
    {
        x = 1;
        y = 0;
        return a;
    }
    int x1, y1;
    int d = egcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

int main()
{
    IOS
    ll x , y , a, b ; cin >> a >> b >> x >> y ;
    
    set<ll> s ;

    s.insert(a*x) ;
    s.insert(a*y) ;
    s.insert(b*x) ;
    s.insert(b*y) ;

    cout << *(s.rbegin()) ;
    el

}

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

int main(){
    
    int n,k;
    cin >> n >> k;
    int total=0;
    int x;
    
    
    for(int i=0;i<n;i++){
        cin >> x;
        if(x<k-x)total+=2*x;
        else total+=2*(k-x);
    }
    
    
    
    cout << total << endl;

    
    return 0;
}


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

using namespace std;

const int MOD = 1000000007;

int main() {
	int n; cin >> n;
	vector<long long> a(n);
	for (auto& e : a) cin >> e;
	long long cnt[60] = {};
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < 60; ++j)
			if (a[i] & (1LL << j)) cnt[j]++;
	long long mul = 1, ans = 0;
	for (int i = 0; i < 60; ++i) {
		(ans += (((n - cnt[i]) * cnt[i]) % MOD * mul) % MOD) %= MOD;
		(mul *= 2) %= MOD;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2560
/********************************************************************
 * Ejercicio: Grid 1                                                *
 * Url: https://atcoder.jp/contests/dp/tasks/dp_h                   *
 * Lenguaje: c++                                                    *
 * Autor: Sebastian Vega                                            *
 * Fecha: 28-08-2020                                                *
 *******************************************************************/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define forn(i, a, b) for (int i = a; i < b; ++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}

const int MAX = 3 * 1e3 + 1;
int n, m, dp[MAX][MAX];
string s, t, ans;

int f(int i, int j) {
  if (i == n || j == m) return 0;
  int &r = dp[i][j];
  if (r != -1) return r;
  if (s[i] == t[j]) return r = f(i + 1, j + 1) + 1;
  return r = max(f(i, j + 1), f(i + 1, j));
}

void build(int i, int j) {
  if (i == n || j == m) return;
  if (s[i] == t[j]) {
    ans += s[i];
    build(i + 1, j + 1);
  } else if (f(i, j) == f(i, j + 1))
    build(i, j + 1);
  else
    build(i + 1, j);
}

int main() {
#ifdef LOCAL
  freopen("in.txt", "r", stdin);
// freopen("main.txt", "w", stdout);
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
  ios::sync_with_stdio(0);
  cin.tie(0);
#define endl '\n'
#define dbg(...) 18
#endif
  cin >> s >> t;
  n = SZ(s), m = SZ(t);
  memset(dp, -1, sizeof(dp));
  f(0, 0);
  ans = "";
  build(0, 0);
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;

int main(){
	ll H,W;
	cin>>H>>W;
	ll ret=min(H,W);
	if(H%3==0||W%3==0)ret=0;
	for(ll i=1;i<=H-1;i++){
		ret=min(ret,max(i*W,(H-i)*((W+1)/2))-min(i*W,(H-i)*(W/2)));
	}
	swap(H,W);
	for(ll i=1;i<=H-1;i++){
		ret=min(ret,max(i*W,(H-i)*((W+1)/2))-min(i*W,(H-i)*(W/2)));
	}
	cout<<ret<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    long long int n,k,d,x,cnt=0;
    cin>>n>>k;
    long long int b[105]={0};
    for(int i=1;i<=k;i++)
    {
        cin>>d;
        for(int j=1;j<=d;j++)
        {
        cin>>x;
        b[x]++;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(b[i]==0)
        cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3616
#include<stdio.h>

int main(){
	int n,pm,pe,pj;
	int i;
	char grade;

	while(scanf("%d",&n),n){

		for(i = 0; i < n; i++){
			scanf("%d %d %d",&pm,&pe,&pj);
			int ave = (pm + pe + pj) / 3;
			if(pm == 100 || pe == 100 || pj == 100){
				grade = 'A';
			}else if((pm + pe) / 2  >= 90){
				grade = 'A';
			}else if(ave >= 80){
				grade = 'A';
			}else if(ave >= 70){
				grade = 'B';
			}else if(ave >= 50 && (pm >= 80 || pe >= 80)){
				grade = 'B';
			}else{
				grade = 'C';
			}
			printf("%c\n",grade);
		}
	}

	return 0;
}

Measured memory_bytes: 1028
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: usize, p: i64,
        wb: [(i64, i64); n],
    }
    let mut base = 0;
    let mut ws = vec![];
    for &(w, b) in &wb {
        let w = w * (100 - p);
        let b = b * p;
        base -= b;
        ws.push(w + b);
    }
    ws.sort();
    ws.reverse();
    let mut cur = 0;
    for i in 0..n {
        cur += 1;
        base += ws[i];
        if base >= 0 {
            break;
        }
    }
    puts!("{}\n", cur);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 10492
#include<stdio.h>
#include<string.h>

#define M 1000000
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch) {
	if (ch == 'A') return 1;
	else if (ch == 'C') return 2;
	else if (ch == 'G') return 3;
	else if (ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]) {
	long long sum = 0, p = 1, i;
	for (i = 0; i < strlen(str); i++) {
		sum += p*(getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return (key % M - 1) + 1; }
// Hash function
int hash(int key, int i)
{
	return (h1(key) + i * h2(key)) % M;
}

int find(char str[]) {
	long long i = 0;
	long long key = getKey(str);
	while (true)
	{
		long long j = hash(key, i);
		if (strcmp(H[j], str) == 0)
			return 1;
		else if (strlen(H[j]) == 0)
			return 0;
		i++;
	}
}

int insert(char str[]) {
	long long i = 0;
	long long key = getKey(str);
	while (true)
	{
		long long j = hash(key, i);
		if (H[j][0] == '\0') {
			strcpy(H[j], str);
			return 1;
		}
		else {
			i++;
		}
		
	}
}

int main() {
	int i, n, h;
	char str[L], com[9];
	for (i = 0; i < M; i++) H[i][0] = '\0';

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%s %s", com, str);

		if (com[0] == 'i') {
			insert(str);
		}
		else {
			if (find(str)) {
				printf("yes\n");
			}
			else {
				printf("no\n");
			}
		}
	}

	return 0;
}

Measured memory_bytes: 16336
import sys 
import numpy as np
import bisect as bs 

def binarySearch_canread(data, target):
    if len(data) == 0:
        return None
    if len(data) == 1:
        return data[0]

    # 追加　全部読める場合と何も読めない場合
    if target > max(data):
        return len(data)
    elif target < min(data):
        return 0

    min_diff = float('inf')
    imin = 0
    imax = len(data) - 1
    closest_num = None

    while imin <= imax:
        imid = imin + (imax - imin) // 2

        if imid + 1 < len(data):
            min_diff_right = abs(data[imid + 1] - target)
        if imid > 0:
            min_diff_left = abs(data[imid - 1] - target)

        if min_diff_left < min_diff:
            min_diff = min_diff_left 
            closest_num = data[imid - 1]
        if min_diff_right < min_diff:
            min_diff = min_diff_right
            closest_num = data[imid + 1]

        if data[imid] < target:
            imin = imid + 1
        elif data[imid] > target:
            imax = imid - 1
        else:
            return list(data).index(data[imid]) + 1 # data[imid]

    # 何冊読めるかを返したい
    differ = target - closest_num
    can_read = None
    if differ > 0: # 読める時間（target）の方が大きい
        can_read = max([i for i, x in enumerate(data) if x == closest_num]) + 1
    elif differ < 0: # 読める時間の方が少ない
        can_read = min([i for i, x in enumerate(data) if x == closest_num])



    return can_read

if __name__ == '__main__':
    read = sys.stdin.buffer.read 
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines 

    N, M, K = map(int, readline().split())
    A = np.array(readline().split(), np.int64)
    B = np.array(readline().split(), np.int64)

    Acum = np.zeros(N+1, np.int64)
    Acum[1:] = np.cumsum(A)
    Bcum = np.zeros(M+1, np.int64)
    Bcum[1:] = np.cumsum(B)

    # Aから1冊ずつ取っていく
    max_read = 0
    # O(N * logN)
    for i, cumNum in enumerate(Acum): # Aを1つも撮らない場合もあるので0から
        if cumNum <= K:
            limit = K - cumNum
            # O(logN)
            can_reading = i + bs.bisect_right(Bcum[1:], limit)
            if (max_read < can_reading):
                max_read = can_reading

    print(max_read)

Measured memory_bytes: 42872
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

void op(int x, int y){cout << x+1 << " " << y+1 << "\n";}

bool solve(){
  string s;
  cin>>s;
  int n = s.size();

  if(n==2){
    if(s == "10") {
      cout << "1 2" << endl;
      return true;
    } else {
      return false;
    }
  }

  if(s[n-1]=='1') return false;

  if(s[0]=='0' || s[n-2]=='0') return false;

  rep(i,n/2){
    if(s[i] != s[n-i-2]) return false;
  }

  int last = 0;
  rep(i,n-1){
    if(s[i]=='0'){
      op(last, i+1);

    } else {
      op(last, i+1);
      last = i+1;
    }
  }
  return true;
}

int main(){
  if(!solve()) cout << "-1" << endl;

  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int dx[4]={-1,0,0,1};
int dy[4]={0,-1,1,0};
 
int main(){
  char a[55][55];
  int H,W;
  cin>>H>>W;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>a[i][j];
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(a[i][j]=='#'){
        bool flag=false;
        for(int t=0;t<4;t++){
          int nx,ny;
          nx=j+dx[t],ny=i+dy[t];
          if(0<=nx&&nx<W&&0<=ny&&ny<H){
            if(a[ny][nx]=='#'){
              flag=true;
            }
          }
        }
        if(flag==false){
          cout<<"No"<<endl;
          return 0;
        }
      }
    }
  }
  cout<<"Yes"<<endl;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
 priority_queue<ll,vector<ll>,greater<ll>>que;
 U_MAP mp;

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>n;
    rep(i,n)cin>>a[i];
    multiset<ll> st;
    st.insert(a[n-1]);
    rrrep(i,n-2,0){
            auto it = st.upper_bound(a[i]);
            if(it==st.end()){
                ans++;
                st.insert(a[i]);
            }
            else{
                st.erase(it);
                st.insert(a[i]);
            }
    }
    Cout(ans+1);
    return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  ll a, b, x; scanf("%lld %lld %lld", &a, &b, &x);
  ll ans = b / x - max(0LL, a - 1) / x;
  if (a == 0) { ++ans; }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        int x = ( a+d-1 ) / d;
        int y = ( c+b-1 ) / b;

        if( x>=y ){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }
}

Measured memory_bytes: 26944
from bisect import*
from collections import*
n,k,*a=map(int,open(0).read().split())
b=defaultdict(list)
for i,v in enumerate(a):b[v]+=i,
s=a[0]
i=c=0
while 1:
  t=b[s]
  m=len(t)
  j=bisect(t,i)
  c+=j==m
  i=t[j%m]+1
  if i==n:break
  s=a[i]
k%=c+1
s=a[0]
i=c=0
while c<k-1:
  t=b[s]
  m=len(t)
  j=bisect(t,i)
  c+=j==m
  i=t[j%m]+1
  s=a[i]
r=[]
while 1:
  t=b[s]
  m=len(t)
  j=bisect(t,i)
  if j==m:
    r+=s,
    i+=1
  else:
    i=t[j]+1
  if i==n:
    break
  s=a[i]
print(*r)

Measured memory_bytes: 118972
n, k = map(int, input().split())
array = list(map(int, input().split()))
if k == 1:
  print(0)
  quit()
  
import itertools
cost = float('inf')
for cand in itertools.combinations(range(1, n), k-1):
  dp = array[:]
  curr_cost = 0
  for index in cand:
    max_val = max(dp[:index])
    if array[index] > max_val:
      continue
    curr_cost += max_val - array[index] + 1
    dp[index] = max_val + 1
  cost = min(cost, curr_cost)
  
print(cost)

Measured memory_bytes: 40540
#include<bits/stdc++.h>
using namespace std;
int k,i= -1;
vector<long long> vec = {};
void dfs(long long x,int a){
    vec.push_back(x);
    if(x > 1000000000000) return;
    if(x == 0){
        for (int j = 1; j < 10; j++)
        {
            dfs(j,j);
        }
    }
    else{
        if(a != 0 && a!= 9){
            dfs(10*x + a-1,a-1);
            dfs(10*x + a,a);
            dfs(10*x + a+1,a+1);
        }
        if(a == 0) {
            dfs(10*x + 0,0);
            dfs(10*x + 1,1);
        }
        if(a == 9) {
            dfs(10*x + 8,8);
            dfs(10*x + 9,9);
        }
    }
}

int main(){
    cin >> k;
    dfs(0,0);
    sort(vec.begin(),vec.end());
    cout << vec[k] << endl;
}


Measured memory_bytes: 69000
object Main {
    def main(args:Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        while(sc.hasNextInt) {
            val a = sc.nextInt
            val b = sc.nextInt
            println(gcd(a, b) + " " + lcm(a, b))
        }
    }
    def gcd(a: Long, b: Long): Long = {
        if (b == 0) a else gcd(b, a % b)
    }
    def lcm(a: Long, b: Long): Long = a * b / gcd(a, b)
}

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

class Cmondai
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var S = Console.ReadLine();
        var white = S.Count(x => x == '.');
        var black = 0;
        var min = white;
        for (int i=0;i<N;++i)
        {
            var count = 0;
            //i番目までを白にしたとき
            if (S[i] == '#') black += 1;
            else white -= 1;
            count = black + white;
            if (count < min) min = count;
        }
        Console.WriteLine(min);
    }
}

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

#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define fi first
#define se second
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef long double ld;
typedef string st;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e14;
ll mpow(ll a,ll b,ll p=MOD){a=a%p;ll res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const ll N=800005;
ll dp[N][2];
vi a[N];
void dfs(ll u=1,ll p=1)
{
  ll aw=1,bw=1;
  for(auto x:a[u]){
    if(x!=p)
    {
      dfs(x,u);
      aw=(aw*((dp[x][0]+dp[x][1])%MOD))%MOD;
      bw=(bw*(dp[x][0]))%MOD;
    }
  }
  dp[u][0]=aw;
  dp[u][1]=bw;
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin>>n;
  forn(i,n-1)
  {
    ll x,y;
    cin>>x>>y;
    a[x].pb(y);
    a[y].pb(x);
  }
  dfs();
  cout<<(dp[1][0]+dp[1][1])%MOD;
}
//nothing is impossible

Measured memory_bytes: 30848
h, w = gets.split(" ").map(&:to_i)
data = h.times.map do 
    gets.chomp.split("")
end

dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]

data.each_with_index do |i, idx|
    i.each_with_index do |j, jdx|
        if(j == "#" || j == "*")
            for k in 0..3 do
                height = idx + dy[k]
                width = jdx + dx[k]
                if(height < h && width < w && 0 <= height && 0 <= width)
                    if(data[height][width] == "#")
                        data[height][width] = "*"
                    end
                end
            end
        end
    end
end

data.each do |i|
    i.each do |j|
        if(j == "#")
            print("No")
            exit 0
        end
    end
end
print("Yes")

Measured memory_bytes: 2172
(defvar N (read))
(defvar M (read))
 
(defparameter left 0)
(defparameter right (1+ N))
 
(loop repeat M do
      (defparameter tmp-left (read))
      (defparameter tmp-right (read))
      
      (if (< left tmp-left)
          (setf left tmp-left))
      (if (< tmp-right right)
          (setf right tmp-right)))
 
(if (>= right left)
    (print (1+ (- right left)))
    (print 0))

Measured memory_bytes: 57828
package main

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

func main() {
	N := nextInt()
	A := []int{
		nextInt(),
		nextInt(),
		nextInt(),
	}
	sum := A[0] + A[1] + A[2]
	if sum == 0 {
		fmt.Println("No")
		return
	}

	S := make([]int, N)
	ans := make([]int, N)

	for i := 0; i < N; i++ {
		s := nextString()

		if s == "AB" {
			S[i] = 1
		} else if s == "AC" {
			S[i] = 2
		} else {
			S[i] = 3
		}
	}

	for i := 0; i < N; i++ {
		var a, b, c int
		s := S[i]
		if s == 1 {
			a = 0
			b = 1
			c = 2
		} else if s == 2 {
			a = 0
			b = 2
			c = 1
		} else {
			a = 1
			b = 2
			c = 0
		}
		if A[a] == 0 && A[b] == 0 {
			fmt.Println("No")
			return
		}
		if sum == 2 && (A[a] == 1 && A[b] == 1) && (i != N-1 && S[i] != S[i+1]) {
			if S[i+1] == a+c {
				ans[i] = a
				A[a]++
				A[b]--
			} else {
				ans[i] = b
				A[a]--
				A[b]++
			}
		} else if A[a] < A[b] {
			ans[i] = a
			A[a]++
			A[b]--
		} else {
			ans[i] = b
			A[b]++
			A[a]--
		}
		// fmt.Println(S[i], ans[i], A[0], A[1], A[2])
	}

	fmt.Println("Yes")
	a := []string{"A", "B", "C"}

	for i := 0; i < N; i++ {
		fmt.Println(a[ans[i]])
	}
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 5436
//#pragma GCC target ("avx2,sse2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>

using namespace std;

const int N = 2e6 + 14;
const int INF = 1e9;
const int mod = 1e9;
const int SZ = (1 << 17) - 1;
const int K = 320;

#define eb emplace_back
#define sz(s) (int)(s.size())
#define ppb pop_back

#define ll long long

#define int ll

map <string, int > mp;

string s[N];

set <string> st;

void solve() {
	int n;
	cin >> n;
	int mx = 0;
	for (int i = 1; i <= n; ++ i) {
		cin >> s[i];
		mp[s[i]]++;
		mx = max(mx, mp[s[i]]);
	}
	for (int i = 1; i <= n; ++ i) {
		if (mp[s[i]] == mx)
			st.insert(s[i]);
	}
	for (auto to : st)
		cout << to << '\n';
}

main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cerr << "Ready\n";
	solve();
	return 0;
}

Measured memory_bytes: 48896
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int r, g, b;
    cin >> r >> g >> b;
    int val = 100 * r + 10 * g + b;
    if (val % 4 == 0) {
        cout << "YES" << endl;
    }
    else 
    {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222






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


  ll a, b, c;
  cin >> a >> b >> c >> n;
  rep(i, 3001) rep(j, 3001) {
    if (a*i + b * j > n) continue;
    tmp = n - a * i - b * j;
    if (tmp%c == 0) ans++;
  }
  cout << ans << endl;
  



  return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
#define enl "\n";
using namespace std;
using ll=long long;
using ld=long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class CMinimization {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n, k;
	    in >> n >> k;
	    vector<int> a(n);
	    for(int i=0; i<n; i++){
	        in >> a[i];
	    }

	    out << ceil((double)(n-k) / (k-1))+1 << endl;
	}
};


int main() {
	CMinimization solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main(int argc, char const *argv[]) {
int A,B,C;
cin>>A>>B>>C;
bool ok=false;
for(int i=0;i<=B;i++){
  if(A*i%B==C) ok=true;
}
if(ok){
  cout<<"YES"<<endl;
}else{
  cout<<"NO"<<endl;
}



  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int S=0;
    int h=0,m=0,s=0;
    scanf("%d",&S);
    h=S/3600;
    m=S/60-h*60;
    s=S-h*3600-m*60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

Measured memory_bytes: 1852
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
    speed_up;
    ll n, i;
    cin>>n;
    ll gcd = 0;
    while(n--)
    {
        cin>>i;
        gcd = __gcd(gcd, i);
    }
    cout<<gcd<<endl;

//peace

  return 0;
}

Measured memory_bytes: 3640
def ABC_97_A():
    a,b,c,d = map(int, input().split())
    
    if (abs(b-a) <= d and abs(c-b) <= d) or abs(c-a) <= d:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':

    ABC_97_A()

Measured memory_bytes: 3060
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;
int deco[1000];

void Sequence() {
	ll a, b;
	char op;
	cin >> a >> op >> b;

	cout << (op == '+' ? a + b : a - b) << endl;
}
int main() {
	Sequence();
	return 0;
}



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

#define en "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fs first
#define sc second
#define size(a) (int) a.size()
#define deb(x) cerr << #x << " => " << x << en
#define debp(a) cerr << #a << " => " <<"("<<a.fs<<", "<<a.sc<<") " << en;
#define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en;
#define debpa(x) cerr << #x << en; for (auto a : x)cerr<<"("<<a.fs<<", "<<a.sc<<") "; cerr << en;
#define debm(x) cerr << #x << en; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << en;}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m;
while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2)
#define mul(a, b) ((a % HELL) * (b % HELL)) % HELL

int32_t main() { fastio;
	int n, k;
	cin >> n >> k;
	int arr[n];
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	sort(arr, arr + n);
	int sum = 0;
	for (int i = 0; i < k; i++) {
		sum += arr[i];
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3624
import java.util.*

fun main(args: Array<String>) {
    Scanner(System.`in`).use { sc ->
        var r = 0
        val n = sc.nextInt()
        val list = sc.asSequence().take(n).map{it.toInt()}.toMutableList()
        while (true) {
            for (i in list.indices) {
                if (list[i] % 2 == 0) {
                    list[i] = list[i] / 2
                } else {
                    println(r)
                    return
                }
            }
            r++
        }
    }
}


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

using namespace std;

int n, a[1234567], b[1234567], c[1234567];
long long res = 0;

void init()
{
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		{
			scanf("%d", &a[i]);
		}
	//sort(a, a + n);
	for (int i = 0; i < n; ++i)
	{
		b[i] = i;
		while(b[i] >= 0 && a[b[i] - 1] >= a[i]) 
		{
			b[i] = b[b[i] - 1];
		}
	}
	for (int i = n - 1; i >= 0; --i)
	{
		c[i] = i;
		while(c[i] <= n - 1 && a[c[i] + 1] >= a[i]) 
		{
			c[i] = c[c[i] + 1];
		}
	}
	for (int i = 0; i < n; ++i)
	{
		res += (long long) a[i] * (c[i] - i + 1) * (i - b[i] + 1);
	}
	printf("%lld\n", res);
	//printf("%lld\n", res - 1);
}

int main()
{


	init();

	return 0;
}

Measured memory_bytes: 2560