akhauriyash/Code-Regression huggingface dataset:
/*
 * TestWorks1.c
 *
 *
 * input is b and e-1
 * after q operations are done print everything
 * Print: use getchar and put
 * Reverse: 123456 for loop with one counter increasing and one decreasing.
 *  Created on: 2019/09/10
 *      Author: pepe
 */
#include<stdio.h>

int Value[1000];
int z;

struct qeb{
	unsigned int q:10;
	unsigned int b:10;
	unsigned int e:10;
};
struct qeb qeb;

struct cnt
{
	unsigned int a:10;
	unsigned int i:10;
	unsigned int dec:10;
};
struct cnt cnt;

int input();

int Rev(void);

int main(void){
	qeb.q = input();
	for (int i = 0; i < qeb.q; i++){
		Value[i] = input();
	}

	cnt.a = input();
	for (int i = 0; i < cnt.a; i++){
		Rev();
	}
	for (int i = 0; i < qeb.q; i++){//print
		int j = Value[i];
		char buff[20];
		if (j == 0) putchar('0');
		else{
			if (j < 0){
				putchar('-');
				j = -j;
			}
			qeb.b = 0;
			while (j) buff[qeb.b++] = j % 10 +'0', j /= 10;
			while (qeb.b--) putchar(buff[qeb.b]);
		}
		if (i == qeb.q - 1) putchar('\n');
		else putchar(' ');
	}
	return 0;
}

int input(){
	int z = 0, j = getchar();
	if (j == '-'){
		j = getchar();
		do z = z*10 + (j & 0xf), j = getchar(); while (j >= '0');
		z = -z;
	}
	else { do z = z*10 + (j & 0xf), j = getchar(); while (j >= '0'); }
	return z;
}

int Rev(void){
	qeb.b = input();
	//printf("%d", qeb.b);
	qeb.e = input();
	//printf("%d", qeb.e);
	cnt.i = qeb.b;
	cnt.dec = qeb.e-1;
	for (int k = 0; k < (qeb.e - qeb.b) / 2; k++){
		z = Value[cnt.i];
		//printf("%d\n", z);
		Value[cnt.i] = Value[cnt.dec];
		Value[cnt.dec] = z;
		cnt.dec--;
		cnt.i++;
	}
	return 0;
}



Measured memory_bytes: 2092
x, k, d = map(int, input().split())
if x - k * d > 0:
  print(x - k * d)
elif x + k * d < 0:
  print(-x - k * d)
else:
  if x > 0:
    cnt = (x - (x % d)) // d
  elif x < 0:
    cnt = (-x - (-x % d)) // d
  else:
    cnt = 0
  if (k - cnt) % 2 == 0:
    if x > 0:
      print(x % d)
    elif x < 0:
      print(-x % d)
    else:
      print(0)
  else:
    if x > 0:
      print(d - (x % d))
    elif x < 0:
      print(d - (-x % d))
    else:
      print(d)

Measured memory_bytes: 9208
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 10000000000000000;

int main(){
    string S,T,ans;
    ans ="UNRESTORABLE";
    cin >>S>>T;
    int n = S.size();
    int nt =T.size();
    rep(i,n-nt+1){
        bool judge=true;
        rep(j,nt){
            if(S[n-1-i-j] -T[nt-1-j]!=0 && S[n-1-i-j] -T[nt-1-j] > -30) {
                judge = false;
                break;
            }
        }
        if(judge) {
            rep(j,nt)  S[n-1-i-j] = T[nt-1-j];
            rep(i,n) {
                if(S[i]=='?')  {
                    S[i] ='a';
                }
            }
            ans =S;
            break;
        }
    }
    cout << ans<<endl;;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 998244353;
const ll INF = (ll) 1e15;

struct Combination {
    Combination(ll n) {
        mNumTbl.resize(n + 1);
        mInverseNumTbl.resize(n + 1);
        mNumTbl[0] = 1;
        mInverseNumTbl[0] = 1;
        FOR(i, n + 1, 1) {
            mNumTbl[i] = (mNumTbl[i - 1] * i) % MOD;
        }
        FOR(i, n + 1, 1) {
            mInverseNumTbl[i] = modpow(mNumTbl[i]);
        }
    }

    ll get(ll n, ll r) {
        if (n < r || n < 0)
            return 0;
        return (((mNumTbl[n] * mInverseNumTbl[r]) % MOD) * mInverseNumTbl[n - r]) % MOD;
    }

    ll modpow(ll n) {
        ll s = 1, p = n;
        for (ll i = 0; (1LL << i) <= MOD - 2; ++i, p = (p * p) % MOD) {
            if (((MOD - 2) & (1 << i)) == 0)
                continue;
            s *= p;
            s %= MOD;
        }
        return s;
    }

    vector<ll> mInverseNumTbl;
    vector<ll> mNumTbl;
};

ll P[200005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M, K;
    cin >> N >> M >> K;
    Combination cmb(N + 5);
    ll p = M;
    P[N - 1] = p;
    REP(i, N - 1) {
        p = (p * (M - 1)) % MOD;
        P[N - 2 - i] = p;
    }

    ll ans = 0;
    REP(i, K + 1) {
        p = (P[i] * cmb.get(N - 1, i)) % MOD;
        ans += p;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7948
const log = console.log;

const findFirstSet = (bits: number): number | null => {
  for (let i = 0; i < 64; i += 1) {
    if ((bits & 1) === 1) return i;
    bits >>>= 1;
  }

  return null;
};

// ----

function Main(input: string): void {
  const n = parseInt(input);

  let maxDivisionCount = 0;
  let answer = 1;

  for (let i = 1; i <= n; i += 1) {
    const divisionCount = findFirstSet(i);

    if (!divisionCount || maxDivisionCount > divisionCount) continue;

    maxDivisionCount = divisionCount;
    answer = i;
  }

  log(answer);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
  int H,W;
  cin >> H >> W;
  char S[H+2][W+2];
  for(int i = 1; i < H+1; ++i){
    for(int j = 1;j < W+1; ++j){
      cin >> S[i][j];
    }
  }
  for(int i = 0; i < H+2; ++i){
      S[i][0] = '.';
      S[i][W+1] = '.';
  }
  for(int j = 0; j < W+2; ++j){
      S[0][j] = '.';
      S[H+1][j] = '.';
  }
  bool info = true;
  for(int i = 1; i < H+1; ++i){
    for(int j = 1;j < W+1; ++j){
      if(S[i][j] == '#'){
        if(S[i][j+1] == '#') info = true;
        else if(S[i][j-1] == '#') info = true;
        else if(S[i+1][j] == '#') info = true;
        else if(S[i-1][j] == '#') info = true;
        else info = false;
      }
      if(!info) break;
    }
    if(!info) break;
  }
  if(info) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define ll             long long
#define int            long long
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define hell           1000000007
#define elasped_time   1.0 * clock() / CLOCKS_PER_SEC
using namespace std;


template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}


int solve(){
 	int n;cin>>n;
 	vector<int>a(n+1);
 	rep(i,1,101){
 		rep(j,1,101){
 			rep(k,1,101){
 				if(i*i+j*j+k*k+i*j+k*j+k*i<=n)a[i*i+j*j+k*k+i*j+k*j+k*i]++;
 			}
 		}
 	}
 	rep(i,1,n+1)cout<<a[i]<<"\n";cout<<endl;
 return 0;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef SIEVE
    sieve();
    #endif
    #ifdef NCR
    init();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
 

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;


void solve() {
	int n; cin >> n;
	int T; cin >> T;
	int t[100001] = {};
	rep(i, n) {
		int l, r; cin >> l >> r;
		t[l]++; t[r]--;
	}
	rep(i, T) {
		t[i + 1] += t[i];
	}

	int m = 0;
	rep(i, T+1) {
		m = max(m, t[i]);
	}
	cout << m << endl;
}

int main() {

	solve();

	return 0;
}



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


signed main(){
    int N,K;
    cin >> N >> K;
    int Ans=0;
    if(K==0){
        cout << N*N << endl;
        return 0;
    }
    REP(i,N+1){
        if(i<=K)continue;
        
        Ans+=  ((int)((N+1)/i)) * (i-K);
        if((N+1)%i>K){Ans+=((N+1)%i-K);}
        //cout << i << " "  << Ans << endl;
        
    }
    cout <<Ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

const ll MOD = 998244353;

int main(void){
  ll n, i, j, s;
  vector<ll> a;
  vector<vector<ll> > dp;
  cin >> n >> s;
  a.resize(n+1);
  dp.resize(n+1,vector<ll>(s+1,0));

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

  for(i=0;i<n;i++){
    for(j=0;j<=s;j++){
      dp[i+1][j] += dp[i][j]*2;
      dp[i+1][j] %= MOD;
      if(a[i]+j<=s){
        dp[i+1][j+a[i]] += dp[i][j];
        dp[i+1][j+a[i]] %= MOD;
      }
    }
  }

  if(dp[n][s]<0) dp[n][s] += MOD;
  cout << dp[n][s] << endl;

  return 0;
}


Measured memory_bytes: 73764
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

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

	string S;
	cin >> S;

	vector<vector<ll>> encoded_list;
	vector<ll> encoded;
	ll idx = 0;
	while (idx < S.size()) {
		if (S[idx] == 'A') {
			encoded.emplace_back(0);
			++idx;
		}
		else if (idx + 1 < S.size() && S[idx] == 'B' && S[idx + 1] == 'C') {
			encoded.emplace_back(1);
			idx += 2;
		}
		else {
			if (encoded.size() > 0) {
				encoded_list.emplace_back(encoded);
				encoded = vector<ll>();
			}
			++idx;
		}
	}

	if (encoded.size() > 0) {
		encoded_list.emplace_back(encoded);
	}

	ll res = 0;
	ll exchange_count;
	for (ll i = 0; i < encoded_list.size(); ++i) {
		idx = 0;
		exchange_count = 0;
		while (idx < encoded_list[i].size()) {
			if (encoded_list[i][idx] == 1) {
				res += idx - exchange_count;
				++exchange_count;
			}
			++idx;
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 3720
A = [list(map(int,input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]

ans = 'No'
if A[0][0] in B and A[0][1] in B and A[0][2] in B:
    ans = 'Yes'
if A[1][0] in B and A[1][1] in B and A[1][2] in B:
    ans = 'Yes'
if A[2][0] in B and A[2][1] in B and A[2][2] in B:
    ans = 'Yes'
if A[0][0] in B and A[1][0] in B and A[2][0] in B:
    ans = 'Yes'
if A[0][1] in B and A[1][1] in B and A[2][1] in B:
    ans = 'Yes'
if A[0][2] in B and A[1][2] in B and A[2][2] in B:
    ans = 'Yes'
if A[0][0] in B and A[1][1] in B and A[2][2] in B:
    ans = 'Yes'
if A[2][0] in B and A[1][1] in B and A[0][2] in B:
    ans = 'Yes'
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

template<typename T>
struct Graph {
	struct edge {
		int to, rev;
		T cap;
		edge(int to, int rev, T cap) : to(to), rev(rev), cap(cap) {}
	};

	int n;
	vector<vector<edge>> g;
	vector<bool> used;

	Graph(int n) : n(n), g(n) {}

	void add_edge(int from, int to, T cap) {
		g[from].push_back(edge(to, (int)g[to].size(), cap));
		g[to].push_back(edge(from, (int)g[from].size() - 1, (T)0));
	}

	T dfs(int v, int t, T f) {
		if (v == t) return f;
		used[v] = true;
		for (int i = 0; i < g[v].size(); ++i) {
			edge& e = g[v][i];
			if (!used[e.to] && e.cap > 0) {
				T d = dfs(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					g[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return (T)0;
	}

	T max_flow(int s, int t) {
		T res = 0;
		while (1) {
			used = vector<bool>(n, false);
			T tmp = dfs(s, t, numeric_limits<T>::max());
			if (tmp == 0) break;
			res += tmp;
		}
		return res;
	}
};

int main(void) {
	int V, E;
	cin >> V >> E;
	Graph<ll> g(V);
	while (E--) {
		int u, v; ll c;
		cin >> u >> v >> c;
		g.add_edge(u, v, c);
	}
	cout << g.max_flow(0, V - 1) << endl;
	return 0;
}


Measured memory_bytes: 3136
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int N, A, B;
  int count = 0;
  scanf("%d %d %d", &N, &A, &B);
  if(N == 1){
    if(A == B) printf("1");
    else printf("0");
  } else {
    if(A > B){
      printf("0");
    } else {
      printf("%lld", (long long)(B-A)*(N-2)+1);
    }
  }
  return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
typedef long long ll;
using namespace std;

double f(ll x){
  ll sum=0;
  ll cop=x;
  while(x){
    sum+=x%10;
    x/=10;
  }
  return cop*1.0/(sum*1.0);
}

int main()
{
    //printf("%.6f %.6f\n",f(20999),f(21999));
    ll k;scanf("%lld",&k);
    ll tot=0;
    ll now=0,x=1;
    while(tot<k){
        if((now/x)%10!=9){
            now+=x;
            printf("%lld\n",now);tot++;
        }
        else{
            if(f(now+x)>f(now+10*x)){
                x=10*x;
            }
            now+=x;
            printf("%lld\n",now);tot++;
        }
        //printf("tot=%lld \n",tot);
    }
    return 0;
}

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

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

    string s;
    cin >> s;

    if (s[2] == s[3] && s[4] == s[5])
        cout << "Yes\n";
    else
        cout << "No\n";
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int K = int.Parse(input[1]);
            int[] sunuke = new int[N];

            for(int i = 0; i < K ; i++)
            {
                int d = int.Parse(Console.ReadLine());
                int[] A = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
                foreach(int get in A)
                {
                    sunuke[get - 1] += 1;
                }
            }

            Console.WriteLine(N-(Array.FindAll(sunuke, x => x > 0).Length));



        }
    }
}


Measured memory_bytes: 27644
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n%1000==0)
        cout<<0<<endl;
    else
    {
        int n1=ceil(n/1000.0);
        cout<<n1*1000-n<<endl;
    }
    return 0;
}


Measured memory_bytes: 3716
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<iostream>
using namespace std;
int main(void)
{
	int n,y,i,j;
	int b,r,t;
	int once;
	double kin,mx,x,c;
	while(1) {
		mx=-1;
		cin >> n;
		if(n==0) break;
		cin >> y;
		for(i=0;i<n;i++) {
			cin >> b >> r >> t;
			if(t==1) {
				c=(double)r/100;
				kin=(double)10000*(1+y*c);	
			}
			else {
				c=(double)r/100;
				x=1+c;
				for(j=1;j<y;j++) x*=(1+c);
					kin=10000*x;
			}
			if(mx<kin) {mx=kin;once=b;}
		}
		cout << once << endl;
	}
	exit(0);
}
				
				

Measured memory_bytes: 1160
N, M = map(int, input().split())
E = {i: [] for i in range(1, N+1)}
for _ in range(M):
    a, b = map(int, input().split())
    E[a].append(b)
    E[b].append(a)

def res(a, i, E, visit):
    global cnt
    if i == N:
        cnt += 1
        return None
    if E[a]:
        for b in E[a]:
            if b in visit:
                pass
            else:
                res(b, i+1, E, visit + [a])
        return None
    else:
        return None

cnt = 0
res(1, 1, E, [])
print(cnt)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define VAR(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    VAR(i64, N);
    auto cnt = makeV(0LL, 10, 10);
    for (int i = 1; i <= N; ++i) {
        string s = to_string(i);
        cnt[s.front() - '0'][s.back() - '0'] += 1;
    }

    dump(cnt);
    i64 ans = 0;
    for (int head = 1; head <= 9; ++head) {
        for (int tail = 1; tail <= 9; ++tail) {
            ans += cnt[head][tail] * cnt[tail][head];
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define int long long

signed main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  int count = 0;
  while (a[0] != a[1] || a[1] != a[2]) {
    if (a[2] - a[0] >= 2) {
      a[0] += 2;
    } else {
      a[0]++;
      a[1]++;
    }
    sort(a, a + 3);
    count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    bool T=true;
    ll a;
    rep(0,i,n){
        cin>>a;
        if(a%2==0){
        if(!(a%3==0 ||a%5==0))T=false;
        }
    }
    if(T){
        cout<<"APPROVED"<<endl;
    }else{
        cout<<"DENIED"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int E[50][50],F[50][50],mem[31][51][6],used[31][51][6];
int D,c,X,W;

int dfs(int d,int cost,int x){
  if(D==d)return 0;
  if(used[d][cost][x]) return mem[d][cost][x];
  used[d][cost][x]=1;
  
  int res=dfs(d+1,cost,x);  

  for(int i=0;i<c;i++){
    int ncost=cost+F[i][d];
    if(ncost>W)continue;
    if(!E[i][d]||ncost>W)continue;
    res=max(res,dfs(d+1,ncost,x)+E[i][d]);
    
    if(x>=X)continue;
    int ee=E[i][d],cc=ncost;
    for(int j=i+1;j<c;j++){
      ee+=E[j][d],cc+=F[j][d];
      if(!E[j][d]||cc>W)break;
      res=max(res,dfs(d+1,cc,x+1)+ee);
    }
    
    ee=E[i][d],cc=ncost;
    for(int j=i-1;j>=0;j--){
      ee+=E[j][d],cc+=F[j][d];
      if(!E[j][d]||cc>W)break;
      res=max(res,dfs(d+1,cc,x+1)+ee); 
    }
  }
  return mem[d][cost][x]=res;
}

int main(){
  while(1){
    cin>>c>>D>>W>>X;
    if(!c&&!D&&!W&&!X) break;
    memset(used,0,sizeof(used)), memset(mem,0,sizeof(mem));
    for(int i=0;i<c;i++)for(int j=0;j<D;j++) cin>>E[i][j];
    for(int i=0;i<c;i++)for(int j=0;j<D;j++) cin>>F[i][j];
    cout << dfs(0,0,0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1252
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
#mod = 10 ** 9 + 7 
mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

K, T = MAP()
a = LIST()
ma = max(a)
left = K-ma
print(max(0, ma-left-1))


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

int p[1111111], s[1111111];
int main() {
    vector<int> v;
    for(int i = 2; i < 1111111; i++) {
        if(!p[i])
            p[i] = i, v.push_back(i);
        for(int x : v) {
            if(x > p[i] || i * x > 1000000)
                break;
            p[i * x] = x;
        }
    }
    int n, g = 0, f = 0;
    cin >> n;
    for(int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        g = gcd(g, a);
        if(f)
            continue;
        while(a > 1) {
            int x = p[a];
            if(!x)
                swap(a, x);
            a /= x;
            if(s[x] && s[x] <= i) {
                f = 1;
                break;
            }
            s[x] = i + 1;
        }
    }
    cout << (g > 1 ? "not" : f ? "setwise" : "pairwise") << " coprime" << endl;
    return 0;
}


Measured memory_bytes: 12524
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  char s[101];
  scanf("%s", s);
  int n = strlen(s);
  rep(i, 0, n) printf("x");
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include <sstream>
#include <iostream>
#include <cstdlib>
#include <string.h>

using namespace std;

#define BUF_SIZE 1024

int count = 0;

void insertionSort(int array[],int n,int g){
	int v,j;
	for(int i = g;i < n; i++){
		v = array[i];
		j = i - g;
		while(j >= 0 && array[j] > v){
			array[j+g] = array[j];	//??°??????????????§???????????????
			j = j - g;
			count++;
		}
		array[j+g] = v;
	}
}

void shellSort(int array[],int n){
	int m = 0;
	int s = 1;

	while((n/s) > 0){
		s *= 2;
		m++;	//2^(mult-1)?????§?????????????????¨???????¨?
	}

	int G[20];

	for(int k = 0,t = 1; k < m; k++){
		G[k] = n/t;
		t *= 2;
	}

	for(int i = 0; i < m;i++){
		insertionSort(array,n,G[i]);
	}

	printf("%d\n",m);
	for(int i = 0; i < m; i++){
		if(i != m-1){
			printf("%d ",G[i]);
		}else{
			printf("%d\n",G[i]);
		}
	}
	printf("%d\n",count);
	for(int i = 0; i < n; i++){
		printf("%d\n",array[i]);
	}

}

int main(int argc,char* argv[]){
	char buf[BUF_SIZE];
	int n = atoi(fgets(buf,BUF_SIZE,stdin));
	int array[1000000];

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

	shellSort(array,n);

}






  

 



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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=0,a,b,c,cmp,data,m,h,w,x,y,xcmp,ycmp,sum=0;

string s;

vector<int> z;

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

       cin >> s;
       rep(i,s.size()){
           if(s[i]=='p'){
               cnt++;
           }
       }
       Cout(s.size()/2-cnt);
return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define long long ll
#define MAX 100
#define THOU 1000
#define FIVEMAX 100000
#define NINEMAX 1000000000
#define TWEMAX 1000000000000
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define arep(i,a,n) for(int i=a;i<n;i++)

int main(){
 int a,b,n;
 char c;
 string str;
 vector<int>v;
 vector<string>s;
 map<string,int>m;
 pair<int,int>p;
 cin>>n>>a>>b;
 int ans=0;
 if(n%a==0)ans=b*(n/a);
 else ans=b*((n/a)+1);
 
 

cin.tie(0);
ios::sync_with_stdio(false);
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3600
function Main(input) {
  var dataList = input.split("\n");
  var r = dataList[0];
  var m = 3 * r * r;
  console.log(m);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

typedef long long ll;
#define MOD 998244353ll

ll ten[1000000],one[1000000];

struct S{
	int len;
	ll val;
};

using F = int;

S op(S l, S r){
	return S{l.len + r.len, (l.val * ten[r.len] + r.val) % MOD};
}

S e(){
	return S{0, 0};
}

S mapping(F f, S s){
	if(f == 0) return s;
	return S{s.len, one[s.len] * f % MOD};
}

F composition(F l, F r){
	return ((l == 0) ? r : l);
}

F id(){
	return 0;
}

int main(void){
	int N,Q,i;
	
	ten[0] = 1;
	for(i=1;i<1000000;i++) ten[i] = ten[i-1] * 10 % MOD;
	one[0] = 0;
	for(i=1;i<1000000;i++) one[i] = (one[i-1] * 10 + 1) % MOD;
	
	cin >> N >> Q;
	S unit = {1, 1};
	vector <S> v(N, unit);
	lazy_segtree <S, op, e, F, mapping, composition, id> seg(v);
	
	REP(i,Q){
		int L,R,D;
		scanf("%d%d%d", &L, &R, &D);
		seg.apply(L-1, R, D);
		ll ans = seg.prod(0, N).val;
		printf("%d\n", (int)ans);
	}
	
	return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Grouping 2
            int N = int.Parse(Console.ReadLine());

            Console.WriteLine(N / 3);
        }
    }
}

Measured memory_bytes: 13140
s=list(input().split())
a = []
for x in s:
    if x in ['+','-','*']:
        #print(x)
        c,b = str(a.pop()),str(a.pop())
        #print(b,c)
        q = b+x+c
        #print(q)
        a = a + [int(eval(q))]
    #print(a)
    else:
        a = a + [int(x)]
#print(a)
print(a.pop())


Measured memory_bytes: 5608
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
  int a, b, c;
  cin >> a >> b>>c;
  int d=abs(a-b); int e=abs(a-c); int f=abs(c-b);
  int g=min(d+e, e+f);
  cout<<min(g, d+f)<<endl;
  return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
         s: String,
    }

    let reversed_s: String = s.chars().rev().collect();
    let s1 = &s[..(s.len() - 1) / 2];
    let reversed_s1: String = s1.chars().rev().collect();
    let s2 = &s[(s.len() + 3) / 2 - 1..];
    let reversed_s2: String = s2.chars().rev().collect();
    let ans = if s == reversed_s && s1 == reversed_s1 && s2 == reversed_s2 {
        "Yes"
    } else {
        "No"
    };

    println!("{}", ans);
}


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

#define INF 1000000
#define N_MAX 100
#define WH 0
#define GR 1
#define BK 2

int main() {
    int n;
    cin >> n;
    int A[N_MAX][N_MAX] = {};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int a;
            cin >> a;
            if (a == -1) {
                A[i][j] = INF;
            }
            else {
                A[i][j] = a;
            }
        }
    }

    int color[N_MAX] = {};
    int d[N_MAX];
    for (int i = 0; i < n; i++) {
        d[i] = INF;
    }
    int p[N_MAX] = {};

    while (true) {
        int u;
        int min_cost = INF;
        d[0] = 0;
        p[0] = -1;

        for (int i = 0; i < n; i++) {
            if (color[i] != BK && d[i] < min_cost) {
                min_cost = d[i];
                u = i;
            }
        }
        if (min_cost == INF) {
            break;
        }
        color[u] = BK;

        for (int v = 0; v < n; v++) {
            if (color[v] != BK && A[u][v] != INF) {
                if (A[u][v] < d[v]) {
                    d[v] = A[u][v];
                    p[v] = u;
                    color[v] = GR;
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += d[i];
    }
    cout << ans << endl;

    return 0;
}



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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  ll n;
  cin >> n;
  vs a(n, "");

  REP(i, n) {
    string s_in;
    cin >> s_in;
    sort(s_in.begin(), s_in.end());
    a[i] = s_in;
  }
  SORT(a);

  // REP(i, n) {
  //   COUT(a[i]);
  // }

  string check = "";
  ll count=1;
  ll total=0;
  REP(i, n) {
    if (check == a[i]) {
      count++;
    }
    else {
      total += (count * (count - 1) / 2);
      count=1;
    }
    check = a[i];
  }
  total += (count * (count - 1) / 2);

  COUT(total);
}

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

/*
4 3
1 2
2 3
2 4
2 10
1 100
3 1
*/


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

using namespace std;
using ll = long long;
using IP = pair<int, int>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

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

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

bool keta[10] = { false };
int main() {

	int n, k;
	cin >> n >> k;
	int a;

	rep(i, k) {
		cin >> a;
		keta[a] = true;
	}

	for (int i = n; i < 10 * n;i++) {
		int b = i;
		bool flag = true;
		while (b) {
			if (keta[b % 10] == true)flag = false;
			b /= 10;
		}
		if (!flag)continue;
		else {
			pr(i);
			break;
		}
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
ll digit_sum(ll n) {
    if (n < 10) return n;
    return digit_sum(n / 10) + n % 10;
}
#endif


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N; cin >> N;

    ll S = digit_sum(N);

    string ans = N%S==0 ? "Yes" : "No";

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string x;
    int a=-1,b;
    cin>>x;
    for(int i=0;i<x.size();i++){
        if(x[i]=='A'&&a==-1)a=i;
        if(x[i]=='Z')b=i;
    }
    cout<<(b-a)+1;
    return 0;
}


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

int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if(a>=k){
        cout << k << endl;
    }
    else if(a<k && k<=a+b){
        cout << a << endl;
    }
    else if(a+b<k && k<=a+b+c){
        k-=(a+b);
         cout << a-k << endl;
        //else cout << 0 << endl;
    }
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x) {
	return(x + 9) / 10 * 10;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	long long int A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << (B - A + 1) - (B / C - (A - 1) / C) - (B / D - (A - 1) / D) + (B / gcd(C, D) - (A - 1) / gcd(C, D));
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
 
    ll modPow(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%M;
        ll res=1;
        while(b){
            if(b%2==1)
                res=mul(res,a);
            a=mul(a,a);
            b=b/2;
        }
        return res;
    }

    vector<int>adj[100005];
    vector<bool>vis(100005,false);

    void dfs(int i){
        if(!vis[i]){
            vis[i]=true;
            for(auto v : adj[i])
                dfs(v);
        }
    }

    void solve (){
        int total=0;
        int n,m;
        cin>>n>>m;
        for(int i=0;i<m;i++){
            int x,y;
            cin>>x>>y;
            --x;
            --y;
            adj[x].push_back(y);
            adj[y].push_back(x);
        }
        int comp=0;
        for(int i=0;i<n;i++){
            if(!vis[i]){
                // cout<<"in "<<i<<"\n";
                comp++;
                dfs(i);
            }
        }
        cout<<comp-1;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    int n,k;
    string s;
    cin >> n >> s >> k;
    rep(i,s.size())
    {
        if(s[i] != s[k-1]) cout << "*";
        else cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,sum,max,max2;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);
	max=10000;
	max2=0;
	if(max>a){
		max=a;
	}
	if(max>b){
		max=b;
	}
	if(max>c){
		max=c;
	}
	if(e>=d){
		max2=d;
	}
	else{
		max2=e;
	}
	printf("%d\n",max+max2-50);
	return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 998244353;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;

int dp[3030][6010][3];


signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, S;
	cin >> N >> S;
	int A[N];
	rep(i,N) cin >> A[i];
	dp[0][0][0] = 1;
	rep(i,N){
		rep(j,S+1){
			// from 0
			dp[i+1][0][0] = 1;
			dp[i+1][j+A[i]][1] += dp[i][j][0] * (i+1);
			dp[i+1][j+A[i]][2] += dp[i][j][0] * (i+1) * (N-i);

			// from 1
			dp[i+1][j][1] += dp[i][j][1];
			dp[i+1][j+A[i]][1] += dp[i][j][1];
			dp[i+1][j+A[i]][2] += dp[i][j][1] * (N-i);

			// from 2
			dp[i+1][j][2] += dp[i][j][2];

			dp[i+1][j][1] %= MOD;
			dp[i+1][j+A[i]][1] %= MOD;
			dp[i+1][j][2] %= MOD;
			dp[i+1][j+A[i]][2] %= MOD;
		}
	}
	cout << dp[N][S][2] << endl;
 }

Measured memory_bytes: 423552
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
long long c,k,cnt = 0,count=0;
cin >> n >> c >> k;
long long t[n];
for (int i = 0;i < n;i++){
    cin >> t[i];
}
sort(t,t+n);
for (int i = 0;i < n;){
    ++cnt;
    int start = i;
    while (i < n && t[i] - t[start] <= k && i - start < c) ++i;   
}
cout << cnt << endl;
}

Measured memory_bytes: 1024
/*Template by hemnath_d(Enlightened by chamow)*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec vector<ll>
#define pll pair<ll,ll>
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fx first
#define sx second
#define inf 100000000000000
#define minf -100000000000000
#define maxi 100005

int main()
{
    fastread;
    int n;
    string s;
    cin>>n>>s;
    int r,b;
    r=b=0;
    for(int i=0;i<s.size();i++)
    {
    	if(s[i]=='R')r++;
    	else b++;
    }
    if(r>b)
    	cout<<"Yes"<<endl;
    else
    	cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  double L;
  cin>>L;
  cout<<setprecision(20)<<L/3*L/3*L/3<<endl;
}



Measured memory_bytes: 3740
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

map<int, char> ans;


int main(){
    cin.tie(0);

    Int N, M;
    cin >> N >> M;
    Int koubai;
    koubai = lcm(N, M);
    string s;
    string t;
    cin >> s >> t;

    Int i = 0;


    while(i < N){
        ans[koubai/N*i] = s[i];
        i++;
    }
    i = 0;
    while (i < M){
        if (ans[koubai/M*i] == 0 || ans[koubai/M*i] == t[i]){
            ans[koubai/M*i] = t[i];
            i++;
        }else{
            cout << -1 << endl;
            return 0;
        }
    }

    cout << koubai << endl;
    return 0;
    
} 


Measured memory_bytes: 8192
A,B,K = map(int,input().split())
if B - A + 1 >= K:
	for a in range(A-1,A+K-1):
		a += 1
		print(a)
	for b in range(B-K,B):
		b += 1
		if b > A + K - 1:
			print(b)
else:
	for x in range(A-1,B):
		x += 1
		print(x)

Measured memory_bytes: 3060
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( 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 ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
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 : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: usize, a: usize, b: usize,
        mut v: [u64; n]
    }

    v.sort();
    v.reverse();
    let mut mean = 0.0f64;
    for i in 0..a {
        mean += v[i] as f64;
    }
    mean /= a as f64;
    println!("{}", mean);

    let limit = if count(&v[0..a]).len() == 1 {
        let mut k = 0;
        for i in 0..b {
            if v[i] == v[0] {
                k += 1;
            }
        }
        k
    } else {
        a
    };

    let mut ret = 0;
    for i in a..limit+1 {
        let cnt = count(&v[0..i]);
        let cnt_all = count(&v);
        let mut p = 1;
        for (&key, &value) in cnt.iter() {
            p *= comb(*cnt_all.get(&key).unwrap_or(&0) as u64, value as u64);
        }
        ret += p;
    }
    println!("{}", ret);
}

#[allow(dead_code)]
fn count<T: Eq + std::hash::Hash + Clone>(slice: &[T]) -> std::collections::HashMap<T, usize> {
    let mut hmap = std::collections::HashMap::new();
    for item in slice {
        *hmap.entry(item.clone()).or_insert(0) += 1;
    }
    hmap
}

#[allow(dead_code)]
fn comb(n: u64, r: u64) -> u64 {
    let mut ret = 1;
    for i in 0..r {
        ret *= n - i;
        ret /= i + 1;
    }
    ret
}

Measured memory_bytes: 4352
d = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(d)]
t = [int(input()) for i in range(d)]
now = [0]*26
ans = 0
for i in range(d):
    ans += s[i][t[i]-1]
    now[t[i]-1] = i+1
    for j in range(26):
        ans -= (i+1-now[j])*c[j]
    print(ans)
    


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

int main(){
	int a, b;
	cin >> a >> b;
	cout << "a ";
	if(a<b){
		cout << '<';
	}else if(a>b){
		cout << '>';
	}else{
		cout << "==";
	}
	cout << " b\n";
	return 0;
}

Measured memory_bytes: 1124