akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if (a > b) {
			System.out.println("a > b");
		} else if (a < b) {
			System.out.println("a < b");
		} else {
			System.out.println("a == b");
		}
	}

}

Measured memory_bytes: 26268
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define long int64_t
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef priority_queue<pii, vector<pii>, greater<pii>> min_pq;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OST;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#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...); }

int main()
{
	fio;
	string s;
	cin >> s;
	int idx = 0, wc = 0;
	long ans = 0;
	bool f = false;
	for(char &c : s)
	{
		if(c == 'W')
		{
			if(f)
				ans += idx - wc;
			wc++;
		}
		if(c == 'B')
			f = true;
		idx++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 720
N = str(int(input()))
total = 0
digits = [i for i in range(len(N)) if i != 0 and i % 2 != 0]

if len(N) % 2 != 0:
    total += int(N) - int(str(1) + (len(N) - 1) * "0") + 1

for digit in digits:
    total += int("9" * digit) - int("1" + "0" * (digit - 1)) + 1

print(total)


Measured memory_bytes: 3060
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

    cout << s.substr(0, s.size() - 8) << endl;

}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
	int N;
	cin >> N;
	ll T;
	cin >> T;
	ll t[Nmax]={},sa=0;
	REP(i,N) cin >> t[i];
	REP(i,N-1) sa+=max((ll)0,t[i+1]-t[i]-T);
	ll ans=t[N-1]-t[0]+T-sa;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {
	int n;
	scanf("%d", &n);
	int ans = 0;
	while (n--) {
		int x;
		scanf("%d", &x);
		while (!(x & 1)) {
			x >>= 1;
			++ans;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int H, W;
char a[110][110];

bool judgeH(int i){
	for (int j = 0; j < W; j++)
		if (a[i][j] == '#') return false;
	return true;
}

bool judgeW(int j){
	for (int i = 0; i < H; i++)
		if (a[i][j] == '#') return false;
	return true;
}

int main()
{
	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++){
		if (judgeH(i)) continue;
		for (int j = 0; j < W; j++){
			if (judgeW(j)) continue;
			cout << a[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
const int N=100005;
using namespace std;
string s;
ll a[2100],ans,num,t=1;
int main(){
    cin>>s;
    for(int i=s.size()-1;i>=0;i--)
	{
        a[num]++;
        num=(num+(s[i]-'0')*t)%2019;
        ans+=a[num];
        t=t*10%2019;
    }
    cout<<ans;
    return 0;
}

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

int main(){

int N;
cin >> N;

vector<int>W(N);

for(int i = 0; i < N; i++){ 
       cin >> W.at(i);
}

vector<int>sum(N + 1, 0);
for(int i = 1; i < N + 1; i++){ 
       sum.at(i) = sum.at(i - 1) + W.at(i - 1) ;
}


int ans = 10000;

for(int i = 0; i < N + 1; i++){ 
       ans = min(ans, abs(sum.at(i) - (sum.at(N)- sum.at(i))));
}

cout << ans << endl; 
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int h,w;
	int i,j,k,p,q;
	int flg=0,step=0;
	int max=0;
    char dammy;

	scanf("%d%d%c",&h,&w,&dammy);

	char maze[h+2][w+2];
	int head=0,tail=0;

	for(i=1;i<=h;i++){
		for(j=1;j<=w+1;j++)
			scanf("%c",&maze[i][j]);
    }


	for(i=0;i<=h+1;i++){
		maze[i][0]='#';
		maze[i][w+1]='#';
	}
	for(i=0;i<=w+1;i++){
		maze[0][i]='#';
		maze[h+1][i]='#';
	}


/*	for(i=0;i<=h+1;i++){
		for(j=0;j<=w+1;j++)
			printf("%c",maze[i][j]);
        printf("\n");
	}
*/
	int v[h+2][w+2],queue[h*w][2];

	for(p=1;p<=h;p++){
		for(q=1;q<=w;q++){
				if(maze[p][q]=='.'){

				for(i=0;i<=h+1;i++){
					for(j=0;j<=w+1;j++)
						v[i][j]=0;
				}

				for(i=0;i<h*w;i++){
					queue[i][0]=0;
					queue[i][1]=0;
				}

				head=tail=0;
				queue[tail++][0]=p;
				queue[tail][1]=q;
				v[p][q]=1;
				do{
					j=queue[head++][0];
					k=queue[head][1];
					if(maze[j-1][k]=='.'&&v[j-1][k]==0){
						queue[tail++][0]=j-1;
						queue[tail][1]=k;
						v[j-1][k]=v[j][k]+1;
						step=v[j][k]+1;
						}
					if(maze[j+1][k]=='.'&&v[j+1][k]==0){
						queue[tail++][0]=j+1;
						queue[tail][1]=k;
						v[j+1][k]=v[j][k]+1;
						step=v[j][k]+1;
						}
					if(maze[j][k-1]=='.'&&v[j][k-1]==0){
						queue[tail++][0]=j;
						queue[tail][1]=k-1;
						v[j][k-1]=v[j][k]+1;
						step=v[j][k]+1;
						}
					if(maze[j][k+1]=='.'&&v[j][k+1]==0){
						queue[tail++][0]=j;
						queue[tail][1]=k+1;
						v[j][k+1]=v[j][k]+1;
						step=v[j][k]+1;
						}
					}
					while(head!=tail);
				}
				if(max<=step)
					max=step;
				step=0;
			}
		}
		printf("%d",max-1);
		return 0;
	}


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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> mii;
typedef map<ll,int> mli;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;  ///1e9+7

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    ll n,m,q,x,c;
    cin>>n>>m;
    ll a[m+1]={0};
    c=n;
    while(c--){
        cin>>q;
        while(q--){
            cin>>x;
            a[x]++;
        }
    }
    ll ans=0;
    for(ll i=1;i<=m;i++) if(a[i]==n) ans++;
    cout<<ans el;
}

main()
{
//    fastio();
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 3648
#include <stdio.h>

int main(){
    int i, j, H, W;
    while(1){
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0)break;
        for(j=1; j<=H; j++){
            for(i=1; i<=W; i++){
                printf("#");
            }
        printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2492
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		int k = Integer.parseInt(sa[2]);
		br.close();

		int mod = 998244353;
		NCR ncr = new NCR(n, mod);
		long ans = 0;
		for (int i = 0; i <= k; i++) {
			long v1 = ncr.calc(n - 1, i);
			long v2 = power(m - 1, n - 1 - i, mod);
			long val = m * v1 % mod * v2 % mod;
			ans += val;
			ans %= mod;
		}
		System.out.println(ans);
	}

	static long power(long x, long n, int m) {
		if (n == 0) {
			return 1;
		}
		long val = power(x, n / 2, m);
		val = val * val % m;
		if (n % 2 == 1) {
			val = val * x % m;
		}
		return val;
	}

	static class NCR {
		long[] p, pi;
		int m;

		public NCR(int n, int mod) {
			n++;
			m = mod;
			p = new long[n];
			pi = new long[n];
			p[0] = 1;
			pi[0] = 1;
			for (int i = 1; i < n; i++) {
				p[i] = p[i - 1] * i % m;
			}
			pi[n - 1] = BigInteger.valueOf(p[n - 1])
					.modInverse(BigInteger.valueOf(m)).longValue();
			for (int i = n - 1; i > 1; i--) {
				pi[i - 1] = pi[i] * i % m;
			}
		}

		public long calc(int n, int r) {
			if (n < r) return 0;
			return p[n] * pi[r] % m * pi[n - r] % m;
		}
	}
}


Measured memory_bytes: 36348
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#define poi 500000
#define inf 0x3f3f3f3f
using namespace std;
inline int re()
{
	char c=(char)getchar();
	int x=0,k=1;
	while(c<'0'||c>'9')
	{if(c=='-')k=-1;c=(char)getchar();}
	while(c>='0'&&c<='9')
	{x=(x<<1)+(x<<3)+c-'0';c=(char)getchar();}
	return k<0?-x:x;
}
void wr(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) wr(x/10);
	putchar(x%10+'0');
}
int main()
{
	int n=re(),ans=0;
	int tx=re(),ty=re();
	for(int i=1;i<=n;i++)
	{
		int x=re(),y=re();
		if(x>=tx&&y>=ty) ans++;
	}
	wr(ans);
	return 0;
}
/*

*/

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

typedef long long ll;
typedef pair<ll, ll> P;

int Q, l[100001], r[100001];

int main(){
    cin >> Q;
    for(int i=0;i<Q;i++)    cin >> l[i] >> r[i];

    vector<int> nums(100001);
    for(int i=1;i<100001;i++){
        nums[i] = i;
    }

    vector<int> ans;
    for(int i=2;i<=100000;i++){
        if(nums[i] == 0) continue;
        for(int j=2;i*j<=100000;j++){
            nums[i*j] = 0;
        }
        int x = (i + 1) / 2;
        if(nums[x] != 0 && i != 2){
            ans.push_back(i);
        }
    }

    for(int i=0;i<Q;i++){
        auto li = lower_bound(ans.begin(), ans.end(), l[i]);
        auto ri = upper_bound(ans.begin(), ans.end(), r[i]);
        int cnt = ri - li;
        cout << cnt << endl;
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  int a, b;
  cin >> a >> b;
  vi x(999);
  for (int i = 0; i < 999; i++) x.at(i) = (i + 1) * (i + 2) / 2;
    //1, 3, 6, 10, 15, ...
  for (int i = 1; i < 999; i++) {
    if (x.at(i) - x.at(i - 1) == b - a) {
      cout << x.at(i) - b << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int D = B - A;
		if (D % 2 == 0) {
			System.out.println("Alice");
		} else {
			System.out.println("Borys");
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}




int main() {
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(n*a,b) << endl;
}

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

int main(){
  int n,nm=0;
  string s;
  cin>>n>>s;
  for(int i=0;i<n;i++){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
      nm++;
    }
  }
  cout<<nm<<endl;
}

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

#define pb push_back
#define mk make_pair
#define sc second
#define fr first

using namespace std;

typedef long long ll;

const int N = (int) 1e6 + 5;
const int mod = (int) 1e9 + 7;

int a,b;
deque<int> v;
string c,st;

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

        if(a <= b) {
                cout << "Impossible" << endl;
                return 0;
        }
        int n = a + b;
        v.pb(1);

        for (int i = 2; i <= n; i ++) {
                if(v.empty()) {
                        v.pb(i);
                        continue;
                }
                cout << "? " << v.back() - 1 << " " << i - 1 << endl;
                fflush(stdout);
                cin >> c;
                if (c == "N")
                        v.pop_back();
                else
                        v.pb(i);
        }
        int u = v.back();

        for (int i = 1; i <= n; i ++) {
                cout << "? " << u - 1 << " " << i - 1 << endl;
                fflush(stdout);
                cin >> c;
                if(c == "Y")
                        st += '1';
                else
                        st += '0';
        }
        cout << "! " << st << endl;
        fflush(stdout);
        return 0;
}


Measured memory_bytes: 724
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n, k;
	scanf("%d%d", &n, &k);

	vector<int> res;

	int t;
	while (n)
	{
		t = n % k;
		n /= k;
		res.push_back(t);
	}

	printf("%d\n", res.size());

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <queue>
#include <set>

using namespace std;

long long N, A, B, C, D;

int main()
{
    string ans = "NO";
    cin >> N >> A >> B >> C >> D;
    for (int i = 0; i < N - 1; i++)
    {
        if(C * (N - 1 - i) - D * i <= B - A && B - A <= -C * i + (N - 1 - i) * D)
        {
            ans = "YES";
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n, c[510], s[510], f[510], res;
int main(void){
    // Your code here!
    cin >> n;
    for (ll i = 1; i < n; i++) {
        cin >> c[i] >> s[i] >> f[i];
    }
    for (ll i = 1; i < n; i++) {
        res = c[i] + s[i];
        for (ll j = i + 1; j < n; j++) {
            res = max(s[j], ((res - 1) / f[j] + 1) * f[j]) + c[j];
        }
        cout << res << endl;
    }
    cout << 0 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000000
#define mod 1000000007

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	if(a>8 || b>8){
		cout<<":("<<endl;
	}
	else
		cout<<"Yay!"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    while(true){
        int H = sc.nextInt();
        int W = sc.nextInt();

        if(H == 0 && W == 0)
           break;

        for(int i = 0;i<H;i++){
            for(int j = 0;j<W;j++){
                if((i+j)%2==0){
                    System.out.printf("#");
                }else{
                    System.out.printf(".");
                }
            }
                System.out.printf("\n");
        }
                System.out.printf("\n");
    }
  }
}



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

int main() {
  ll n, ans = 1e18;
  cin >> n;
  int len = sqrt(n);
  for(int i = 1; i <= len; ++i) {
    if(n % i == 0)
      ans = min(ans, i + n / i - 2);
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 256
import java.io.{BufferedReader, InputStream, InputStreamReader, PrintWriter}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.reflect.ClassTag

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val S = sc.next()
    val K = sc.nextInt()
    val N = S.length

    def cost(c: Char): Int = ('z' + 1 - c) % 26
    def forward(c: Char, num: Int) = ((c - 'a' + num) % 26 + 'a').toChar

    def step(i: Int, k: Int): Int = {
      if (i == N - 1) k
      else if (cost(S(i)) <= k) {
        out.print('a')
        step(i + 1, k - cost(S(i)))
      } else {
        out.print(S(i))
        step(i + 1, k)
      }
    }

    val k = step(0, K)
    out.print(forward(S(N - 1), k))

    out.println()
  }


  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }

  private def rep(n: Int)(f: Int => Unit): Unit = (0 until n) foreach f

  private def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    (0 until n) foreach (i => res(i) = f(i))
    res
  }

  private implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }

    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
      rep(a => map.getOrElseUpdate(f(a), ArrayBuffer()) += a)
      map
    }

    def rep(f: A => Unit): Unit = {
      as.indices foreach (i => f(as(i)))
    }

    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      var sum = num.zero
      rep(a => sum = num.plus(sum, f(a)))
      sum
    }
  }

  private implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))
    }
  }

  class UnionFind(n: Int) {
    private val par = Array.ofDim[Int](n)
    par.indices foreach (i => par(i) = i)
    private val rank = Array.ofDim[Int](n)

    def find(x: Int): Int = {
      if (par(x) == x) x
      else {
        par(x) = find(par(x))
        par(x)
      }
    }

    def unite(x: Int, y: Int): Unit = {
      val x1 = find(x)
      val y1 = find(y)
      if (x1 != y1) {
        if (rank(x1) < rank(y)) {
          par(x1) = y1
        } else {
          par(y1) = x1
          if (rank(x1) == rank(y1)) rank(x1) += 1
        }
      }
    }
  }
}


Measured memory_bytes: 29304
#include <iostream>
#define rep(S, L) for (int i = S; i < L; ++i)
using namespace std;

int main() {
  int n, a, b;
  cin >> n;
  if (n == 1) {
    cout << "Hello World" << endl;
  } else {
    cin >> a >> b;
    cout << a + b << endl;
  }
  return 0;
}


Measured memory_bytes: 3156
#include<stdio.h>
int main(){
    int a,b,c;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);

    if(a==(b+c))printf("Yes");
    else if(b==(a+c))printf("Yes");
    else if(c==(a+b))printf("Yes");
    else printf("No");
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>

typedef long long int ll;

using namespace std;

int main(){
    vector<int> l;
    while(true){
        int a;
        cin >> a;
        if(a==0){
            break;
        }
        l.push_back(a);
    }
    for (int i=1;i<l.size()+1;++i){
        cout << "Case " << i << ": " << l[i-1] << endl;
    }
    return 0;
}



Measured memory_bytes: 3256
import sys
sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()

class modfact(object):
    def __init__(self, n):
        fact, invfact = [1] * (n + 1), [1] * (n + 1)
        for i in range(1, n + 1): fact[i] = i * fact[i - 1] % MOD
        invfact[n] = pow(fact[n], MOD - 2, MOD)
        for i in range(n - 1, -1, -1): invfact[i] = invfact[i + 1] * (i + 1) % MOD
        self._fact, self._invfact = fact, invfact

    def inv(self, n):
        return self._fact[n - 1] * self._invfact[n] % MOD

    def fact(self, n):
        return self._fact[n]

    def invfact(self, n):
        return self._invfact[n]

    def comb(self, n, k):
        if k < 0 or n < k: return 0
        return self._fact[n] * self._invfact[k] % MOD * self._invfact[n - k] % MOD

    def perm(self, n, k):
        if k < 0 or n < k: return 0
        return self._fact[n] * self._invfact[n - k] % MOD

def resolve():
    n, k = map(int, input().split())
    mf = modfact(n)
    res = 0
    for i in range(min(k + 1, n)):
        res += mf.comb(n, i) * mf.comb(n - 1, i) % MOD
        res %= MOD
    print(res)
resolve()

Measured memory_bytes: 42608
#include <iostream>
#include <algorithm>
#include<vector>
#include <utility>
#include <string>

using namespace std;

int main(){
  int n,a,b,c,i,j,k,m,x;
  string s;
  cin >> n >> m >> x;
  b = c = 0;
  for(i=0;i<m;i++){
    cin >> a;
    if(a>x)b++;
    else c++;
  }
  cout << min(b,c) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
int dp[242321],a[242321],ans = 0;


int main() {
	int x1, x2, y1, y2,a,b;
	cin >> x1 >> y1 >> x2 >> y2;
	a = x2 - x1;
	b = y2 - y1;
	REP(i, b) cout << "U";
	REP(i, a) cout << "R";
	REP(i, b) cout << "D";
	REP(i, a) cout << "L";
	cout << "L";
	REP(i, b + 1) cout << "U";
	REP(i, a + 1) cout << "R";
	cout << "DR";
	REP(i, b + 1) cout << "D";
	REP(i, a + 1) cout << "L";
	cout << "U" << endl;
	
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a = 0;
        int b = 0;
        int c = 0;
        for(int i = 0;i < N;i++){
            long ai = sc.nextLong();
            if(ai%4 == 0)   a++;
            else if(ai%2 == 0)  c++;
            else    b++;
        }
        if(a >= b || (c == 0 && a+1 == b))  System.out.println("Yes");
        else    System.out.println("No");
    }
}

Measured memory_bytes: 48216
lista = []
for i in range(3):
  a,b = map(int,input().split())
  lista.append(a)
  lista.append(b)
l1 = 0
l2 = 0
l3 = 0
l4 = 0
for j in lista:
  if j == 1:
    l1 += 1
  if j == 2:
    l2 += 1
  if j == 3:
    l3 += 1
  if j == 4:
    l4 += 1
c = (l1)%2 + (l2)%2 + (l3)%2 + (l4)%2
if c <= 2:
  print('YES')
else:
  print('NO')
  


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cctype>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#include<fstream>
#define ld double
#define ull unsigned long long 
#define ll long long 
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair 
#define INF 2000000000
#define MOD 1000000007 

using namespace std;

const int MAXN=2e5+5;


int n,m,pos[MAXN];
vector<pii >G[MAXN];



int main()
{
	scanf("%d%d",&n,&m);
	
	for(int i=0;i<m;i++)
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);x--;y--;
		G[x].push_back(mp(z,y));
		G[y].push_back(mp(-z,x));
	}
	
	for(int i=0;i<n;i++)pos[i]=INF;
	
	for(int i=0;i<n;i++)
	{
		if(pos[i]==INF)
		{
			queue<int>qu;
			pos[i]=0;
			qu.push(i);
			
			while (!qu.empty())
			{
				int u=qu.front();
				qu.pop();
				for(int j=0;j<G[u].size();j++)
				{
					int len=G[u][j].first,to=G[u][j].second;
					if(pos[to]==INF)
					{
						pos[to]=len+pos[u];
						qu.push(to);
					}
					else if(pos[to]-pos[u]!=len)
					{
						printf("No\n");
						return 0;	
					}
				
				}
			}
			
		}
	}
	
	printf("Yes\n");
	
	

	return 0;	
} 

Measured memory_bytes: 11720
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    int w[10], k[10];
    int ws, ks;

    ws = ks = 0;
    for (int i = 0; i < 20; i++) {
        if (i < 10)
            cin >> w[i];
        else
            cin >> k[i % 10];
    }
    sort(w, w + 10, greater<int>());
    sort(k, k + 10, greater<int>());
        
    for (int i = 0; i < 3; i++) {
        ws += w[i];
        ks += k[i];
    }

    cout << ws << " " << ks << endl;

    return 0;
}

Measured memory_bytes: 1180
import sys
fin = sys.stdin.readline


N = int(fin())
happiness_list = tuple(tuple(int(elem) for elem in fin().split()) for _ in range(N))

dp = [0] * 3
for i in range(N):
    next_dp = [0] * 3
    for j in range(3):
        next_dp[j] = max(dp[k] + happiness_list[i][k] for k in range(3) if k != j)
    dp = next_dp
print(max(dp))


Measured memory_bytes: 65116
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String str = sc.next();
			if (str.endsWith("s")) {
				System.out.println(str + "es");
			} else {
				System.out.println(str + "s");
			}
		}
	}
}

Measured memory_bytes: 38456
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <string>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

#define ALL(C)                      (C).begin(), (C).end() 
#define ARRAY_SIZE(A)               (sizeof(A) / sizeof(A[0]))
#define SIZE_ARRAY(A)               (sizeof(A) / sizeof(A[0]))
#define ALL_ARRAY(A)                (A), (A) + SIZE_ARRAY(A)

#define FOR(i, N)                   for (int i = 0; i < (int)(N); ++i)
#define FORC(i, C)                  for (int i = 0; i < (int)(C).size(); ++i)
#define FORN(i, x, n)               for (int i = x; i <= (int)(n); ++i)

#define FORI(N)						FOR(i, N)
#define FORJ(N)						FOR(j, N)
#define FORK(N)						FOR(k, N)

#define PRINT(x)                    std::cout << #x << " = [" << (x) << "]" << std::endl

int main() {
#if defined(_DEBUG)
	freopen_s((FILE**)stdin, "ReadMe.txt", "r", stdin);
#endif

	long long a, b, x;
	cin >> a >> b >> x;
	a = (a + x - 1) / x * x;
	b = b / x * x;
	//PRINT(a); PRINT(b);
	long long ret = b / x - a / x + 1;
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  contest
//
//  Created by TmpGuest on 2020/4/18.
//  Copyright © 2020 TmpGuest. All rights reserved.
//

#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
int main() {
ios_base::sync_with_stdio(false);
    cin.tie(0);
    int s,w;
    cin>>s>>w;
    if(s>w)
        cout<<"safe\n";
    else
        cout<<"unsafe\n";
        
    
    return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define allof(a) a.begin(),a.end()

typedef pair< int, int > pii;

int n;
vector< pii > vp;

int solve() {
	sort(allof(vp));
	int ans = 0;
	
	for_(i,0,n) for_(j,i+1,n) {
		pii pi = vp[i], pj = vp[j];
		int dx = pj.first - pi.first, dy = pj.second - pi.second;
		
		pii npi(pi.first + dy, pi.second - dx), npj(pj.first + dy, pj.second - dx);		
		if (binary_search(allof(vp), npi) && binary_search(allof(vp), npj)) {
			ans = max(ans, dx * dx + dy * dy);
		}
		
		npi = pii(pi.first - dy, pi.second + dx); npj = pii(pj.first - dy, pj.second + dx);
		if (binary_search(allof(vp), npi) && binary_search(allof(vp), npj)) {
			ans = max(ans, dx * dx + dy * dy);
		}
	}
	
	return ans;
}

int main() {
	while (cin >> n, n) {
		vp.clear();
		
		for_(i,0,n) {
			int x, y; cin >> x >> y;
			vp.push_back(pii(x,y));
		}
		
		cout << solve() << endl;
	}
	
	return 0;
}

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

int main() {
	ios :: sync_with_stdio(false);
	int sum = 0;
	for(int i = 0; i < 5; i ++) {
		int x; cin >> x;
		if(x <= 40)
			x = 40;
		sum += x;
	}
	cout << sum / 5 << '\n';
	return 0;
}

Measured memory_bytes: 3128
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1)(r(2).readFileSync("/dev/stdin","UTF-8"))},function(e,t){e.exports=function(e){for(var t=e.split("\n"),r=t[0].split(" "),n=Number(r[0]),o=Number(r[1]),i=[],u=0,s=0;s<n;s++){var f=t[s+1].split("");for(j=0;j<o;j++)"."==f[j]&&(u+=1);i.push(f)}for(var l=[{x:0,y:0,dist:0}];l.length>0;){var d=l.shift();if(!(d.x<0||d.x>=o||d.y<0||d.y>=n||"#"==i[d.y][d.x]||"+"==i[d.y][d.x])){if(d.x==o-1&&d.y==n-1)return void console.log(u-d.dist-1);i[d.y][d.x]="+",l.push({x:d.x+1,y:d.y,dist:d.dist+1}),l.push({x:d.x-1,y:d.y,dist:d.dist+1}),l.push({x:d.x,y:d.y+1,dist:d.dist+1}),l.push({x:d.x,y:d.y-1,dist:d.dist+1})}}console.log(-1)}},function(e,t){e.exports=require("fs")}]);

Measured memory_bytes: 7884
// abc067_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int A, B;
    cin >> A >> B;

    if (A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0){
        print("Possible");
    } else {
        print("Impossible");
    }

    return 0;
}


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int cnt[5];
vector<int> v;
string target = "MARCH";
ll ans = 0;

void Combination (vector<int> comb, int n, int r, int step, int init) {
  // r桁すべてが生成された
  if (step == r) {
    ll tmp = 1;
    for (int i = 0; i < r; i++) {
      tmp *= v[comb[i]];
    }
    ans += tmp;
    return;
  }

  // 全桁生成されていない
  for (int i = init; i <= n - r + step; i++) {
    comb.push_back(i);
    Combination(comb, n, r, step + 1, i + 1);
    comb.pop_back();
  }
}

int main() {
  // 入力
  int N;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) cin >> s[i];

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 5; j++) {
      if (s[i][0] == target[j]) {
        cnt[j]++;
      }
    }
  }

  for (int i = 0; i < 5; i++) if (cnt[i] > 0) {
    v.push_back(cnt[i]);
  }

  if (v.size() >= 3) {
    vector<int> comb;
    Combination(comb, v.size(), 3, 0, 0);
  }


  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6144
#include <iostream>
using namespace std;
int main(){
  int n, a[100000] = {0}, b[100000] = {0};
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = 0; i < n; i++){
    b[a[i] - 1] = i + 1;
  }
  for(int i = 0; i < n; i++){
    cout << b[i];
    if(i == n - 1){
      cout << endl;
    }else{
      cout << " ";
    }
  }
  return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0); }
 
int main() {
  ull a, b, t;
  cin >> a >> b >> t;

  ull o = (t + 0.5) / a;
  cout << o * b << endl;
 
 
  return 0;
}


Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
        ($line:expr, $name:ident, $t:tt) => {
            let $name = value!($line, $t);
        };
    }

    macro_rules! values_def {
        ($lines:expr, $n:expr, $name:ident, $t:tt) => {
            let $name = {
                let mut vec = Vec::new();
                for i in 0..$n {
                    let mut next = $lines.next().unwrap().split_whitespace();
                    vec.push(value!(next, $t));
                }
                vec
            };
        };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:i64 k:i64)(list:[i64]));
    let &min = list.iter().min().unwrap();
    let find = list
        .into_iter()
        .enumerate()
        .filter(|&(i, x)| x == min)
        .map(|(i, _)| i as i64)
        .collect::<Vec<_>>();

    let mut count = div(find[0] + 1, k);
    let mut cer = count * (k - 1);
    for x in find.into_iter().skip(1) {
        if cer + 1 == x {
            cer = x;
        } else if cer >= x {

        } else {
            let a = div(x - cer + 1, k);
            count += a;
            cer += a * (k - 1);
        }
    }
    //last
    count += div(n - cer - 1, k - 1);
    count.to_string()
}

fn div(a: i64, b: i64) -> i64 {
    (a + (b - 1)) / b
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "4 3\n2 3 1 4" => "2",
    test2: "3 3\n1 2 3" => "1",
    test3: "8 3\n7 3 1 8 4 6 2 5" => "4",
    add1: "8 3\n2 1 2 2 2 1" => "4",
}

pub fn diff_seq(v: Vec<usize>) -> Vec<usize> {
    v.clone()
        .into_iter()
        .skip(1)
        .zip(v.into_iter())
        .map(|(a, b)| a - b)
        .collect()
}


Measured memory_bytes: 6396
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

template<class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

template<class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }




int main() {
    int n;
    vector<int> v[100001];

    int psum;
    cin>>n;
    vector<pair<int,int>> qq;
rep(i,n-1){
    int a,b;
    cin>>a>>b;
    qq.push_back({a,b});
    v[a].push_back(b);
    v[b].push_back(a);
}

int p=0;
 psum = 0;
for(int i=1;i<=n;i++){
    if(psum<v[i].size()){
        p=i;
        psum=v[i].size();
    }
}


queue<pair<int,int>> q;
q.push({p,-1});

//int a[100001][100001];
map<pair<int,int>,int> a;



while(!q.empty()){
    auto pp = q.front();q.pop();
    int pf =pp.first;
    int ps = pp.second;
    int color = 1;
    int nc = 0;
    if(ps!=-1){
       // nc=a[ps][pf];
        nc=a[{ps,pf}];
    }
    for(int i=0;i<v[pf].size();i++){
        int t = v[pf][i];
        if(t!=ps){
            while(nc==color)color++;
           // a[pf][t]=color;
           // a[t][pf]=color;
           a[{pf,t}]=color;
           a[{t,pf}]=color;
            q.push({t,pf});
            color++;
        }
    }
}
 // dfs(p,-1);
cout<<psum<<endl;
  rep(i,n-1){
    cout<<a[{qq[i].first,qq[i].second}]<<endl;
  }
    return 0;
}


Measured memory_bytes: 19316
# D
N = int(input())

al = [chr(ord('a') + i) for i in range(26)]

def dfs(S, i):
    if len(S) == N:
        yield ''.join(S)
        return
    for j in range(i):
        for w in dfs(S + [al[j]], i):
            yield w
    for w in dfs(S + [al[i]], i + 1):
        yield w

for w in dfs([], 0):
    print(w)

Measured memory_bytes: 4412
from operator import itemgetter
N = int(input())
ls = sorted(sorted([list(map(int,input().split())) for _ in range(N)]),key=itemgetter(1))



flag = 1
t = 0
for i in range(N):
  t += ls[i][0]
  if ls[i][1] < t:
    flag = 0
    print("No")
    break

if flag == 1:
  print("Yes")

Measured memory_bytes: 54596
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; scanf("%lld", &x); return x;}
ld fin(){double x; scanf("%lf", &x); return x;}
char yuyushiki[1000010]; string stin(){scanf( "%s", yuyushiki ); return yuyushiki;}

// head

int main(){

  ll n = in();
  ll k = in();
  vector<ll> a(n);
  REP(i, n){
    a[i] = in();
  }
  vector<ll> v(0);
  REP(i, n){
    ll cur = 0;
    FOR(j, i, n){
      cur += a[j];
      v.pb(cur);
    }
  }

  ll ans = 0;
  vector<bool> can(SZ(v), true);
  for(ll i = 50; i >= 0; i--){
    ll cnt = 0;
    REP(j, SZ(v)){
      if(can[j] && (v[j] & PW(i))){
        cnt++;
      }
    }
    if(cnt >= k){
      REP(j, SZ(v)){
        if(!(v[j] & PW(i))){
          can[j] = false;
        }
      }
      ans += PW(i);
    }
  }

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


Measured memory_bytes: 6132
n = int(input())
jobL = []
index=0
while index < n:
    a, b = map(int, input().split())
    jobL.append([b, a])
    index+=1
jobL.sort()
timeCounter=0
index2=0
while index2 < len(jobL):
    timeCounter+=jobL[index2][1]
    if timeCounter <= jobL[index2][0]:
        index2+=1
    else:
        break
if index2 == len(jobL):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 35600
using System;

namespace _2904
{
	class Program
	{
		static void Main(string[] args)
		{
			string s = Console.ReadLine();
			int count = 0;int ret = 0;
			for (int i = 0; i < s.Length; i++)
			{
				count += s[i] == 'R' ? 1 : -1;
				if (count == 4) { count = 0; ret++; }
				if (count == -4) count = 0;
			}
			Console.WriteLine(ret);
		}
	}
}



Measured memory_bytes: 17928
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ll long long
const int MX=200000;
int N, M, k, x;
int arr[MX];
ll calc(ll n, ll m)
{
    if(n == 1)
    {
        if(m > 2)
            return m-2;
        if(m == 2) return 0;
        return 1;
    }
    if(n == 2) return 0;
    return m*n-2*n-2*m+4;
}
int main()
{
   ll n, m;
   cin>>n>>m;
   ll an=0;
   if(n < 3) an=calc(n, m);
   else an=calc(m, n);
   cout<<an;
}


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

int main() {
  int W,H,x,y,d=0;
  cin >> W >> H >> x >> y;
  
  if(x==W/2.0 && y==H/2.0)
    d=1;
  
  cout << (double)W*(double)H/2.0 << " " << d << endl;
}

Measured memory_bytes: 384