akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstring>
#include<vector>
#include<list>
#include<set>
#include<map>
using namespace std;
#define LL long long
#define pi (4*atan(1.0))
#define eps 1e-14
#define bug(x)  cout<<"bug"<<x<<endl;
const int N=1e5+10,M=1e6+10,inf=1e9+10;
const LL INF=1e18+10,mod=2147493647;


int main()
{
    LL n,a,b,c,d;
    scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
    n--;
    LL fuck=d-c;
    if(n%2)
    {
        for(int i=1;i<=n;i+=2)
        {
            LL l,r;
            int cc=(n-i)/2;
            if(a>b)
            {
                l=a-1LL*i*c;
                r=a-1LL*i*d;
                if(b<=l&&b>=r)return 0*printf("YES\n");
                if(abs(b-l)<=1LL*fuck*cc||abs(b-r)<=1LL*fuck*cc)return 0*printf("YES\n");
            }
            else
            {
                l=a+1LL*i*c;
                r=a+1LL*i*d;
                if(b>=l&&b<=r)return 0*printf("YES\n");
                if(abs(b-l)<=1LL*fuck*cc||abs(b-r)<=1LL*fuck*cc)return 0*printf("YES\n");
            }
        }
        printf("NO\n");
    }
    else
    {
        for(int i=0;i<n;i+=2)
        {
            LL l,r;
            int cc=(n-i)/2;
            if(a>b)
            {
                l=a-1LL*i*c;
                r=a-1LL*i*d;
                if(b<=l&&b>=r)return 0*printf("YES\n");
                if(abs(b-l)<=1LL*fuck*cc||abs(b-r)<=1LL*fuck*cc)return 0*printf("YES\n");
            }
            else
            {
                l=a+1LL*i*c;
                r=a+1LL*i*d;
                if(b>=l&&b<=r)return 0*printf("YES\n");
                if(abs(b-l)<=1LL*fuck*cc||abs(b-r)<=1LL*fuck*cc)return 0*printf("YES\n");
            }
        }
        printf("NO\n");
    }
    return 0;
}


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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

#define POS(latte,malta) ((latte>>malta)&1)
int main() {
	int N;
	int ret = 0;
	cin >> N;
	vector<int> a(N);
	vector<int> b(N);
	cin >> a;
	cin >> b;
	vector<int> c(N);
	for (int i : range(29)) {
		const int M = (1 << (i + 1)) - 1;
		const int K = 1 << i;
		for (int j : range(N))c[j] = b[j] & M;
		sort(ALL(c));
		for (int j : range(N)) {
			const int C = a[j] & M;
			int A, B;
			{
				int lb = 0;
				int ub = K;
				while (ub - lb > 1) {
					const int mid = (lb + ub) / 2;
					((POS(C + mid, i) == POS(C, i)) ? lb : ub) = mid;
				}
				A = ub;
			}
			{
				int lb = A;
				int ub = K<<1;
				while (ub - lb > 1) {
					const int mid = (lb + ub) / 2;
					((POS(C + mid, i) != POS(C, i)) ? lb : ub) = mid;
				}
				B = ub;
			}
			int cnt = distance(lower_bound(ALL(c), A), lower_bound(ALL(c), B));
			if (POS(C, i))cnt = N - cnt;
			if (cnt % 2)ret ^= K;
		}
	}
	cout << ret << endl;
	return 0;

}


Measured memory_bytes: 2560
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>
#include <functional>
#include <iterator>

#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end())
#define ll long long
#define INF 2000000000
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define PI 3.14159265358979
int dx[4] = { -1,0,1,0 }, dy[4] = { 0,1,0,-1 };
using namespace std;

int main(){	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d)cout << "Left" << endl;
	else if (a + b < c + d)cout << "Right" << endl;
	else cout << "Balanced" << endl;
	
	return 0;
}



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

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

int main(void) {
    string s;
    int cnt[26] = {0};
    bool flg = true;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    REP(i, s.length()) {
        cnt[s[i] - 'a']++;
    }

    REP(i, 26) {
        if (cnt[i] % 2) {
            flg = false;
        }
    }

    cout << (flg? "Yes" : "No") << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>

 struct Node{
  int key;
  Node *next;
  Node *prev;
};

Node *nil;

void init(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

Node* listSearch(int key){
  Node *cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void deleteNode(Node *t){
  if(t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void printList(){
  Node *cur = nil->next;
  int isf = 0;
  while(1){
    if(cur == nil) break;
    if(isf++ >0) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");

}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}


void deleteKey(int key){
  deleteNode(listSearch(key));
}


/*void print(Node *t){
  int i=0;
  while(t != nil){
    if(i) printf(" ");
    printf("%d", t->key);
    i++;
    t = t->next;
  }
}

int main(){
  int n, i, b;
  char a[20];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",a);
    if(a == "deleteFirst") deleteNode(nil->next);
    else if(a == "deleteLast") deleteLast(nil->prev);
    else if(a == "delete") {
      scanf("%d",&b);
      deleteNode(listSearch(b));
    }
    else if(a == "insert"){
      scanf("%d", &b);
      insert(b);
    }
  }

  print(nil->next);
      

 

  return 0;
}
*/

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();

  for(i=0;i<n;i++){
    scanf("%s%d", com, &key);
    if(com[0] == 'i'){
      insert(key);
      np++;
      size++;
    }
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
	if(com[6] == 'F') deleteFirst();
	else if(com[6] == 'L')deleteLast();
      }else{
	deleteKey(key);
	nd++;
      }
      size--;
    }
  }
  printList();

  return 0;
}



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

int main() {
    string S;
    cin >> S;
    for (int i = 0; i < S.length(); ++i){
    	S[i] = (S[i] == '1' ? '9' : '1');
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<ll,ll>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e5+10;

	int n;
	#define lc x<<1
	#define rc x<<1|1
	#define mid (l+r)/2
	queue<int> one[N*4];
	void insert(int fl,int fr,int num,int x=1,int l=1,int r=n)
	{
		if(fl==l and fr==r) {one[x].push(num);return;}
		if(fr<=mid) insert(fl,fr,num,lc,l,mid);
		else if(fl>mid) insert(fl,fr,num,rc,mid+1,r);
		else insert(fl,mid,num,lc,l,mid),insert(mid+1,fr,num,rc,mid+1,r);
	}
	int ret;
	bool fukit(int pos,int x=1,int l=1,int r=n)
	{
		if(sz(one[x])) {ret=one[x].front(),one[x].pop();return 1;}
		if(l==r) return 0;
		if(pos<=mid) return fukit(pos,lc,l,mid);
		return fukit(pos,rc,mid+1,r);
	}
    
	bool use[N];int tl[N],tr[N],cc[N];
	ll f[N];priority_queue< pr,vc<pr>,greater<pr> > q;set<int> no;
    void main()
	{
		n=qread();int m=qread();
		fo(i,1,m){int l=qread(),r=qread(),c=qread();insert(l,r,i);tl[i]=l,tr[i]=r,cc[i]=c;}
		memset(f,0x3f,sizeof f);f[1]=0;q.push(MP(f[1],1));fo(i,2,n) no.insert(i);
		while(sz(q))
		{
			pr now=q.top();q.pop();int id=now.SE;
			//printf("id=%d now=%d\n",id,now.FR);
			if(id<=n)
			{
				f[id]=now.FR;
				while(fukit(id)) if(!use[ret]) use[ret]=1,q.push(MP(now.FR+cc[ret],n+ret));
			}
			else
			{
				id-=n;int l=tl[id],r=tr[id];
				while(1)
				{
					set<int>::iterator IT=no.lower_bound(l);
					if(IT!=no.end() and (*IT)<=r) q.push(MP(now.FR,*IT)),no.erase(IT);
					else break;
				}
			}
		}write(f[n]==f[n+1]?-1:f[n]);
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 279932
// Author: Sayantanu
#include <bits/stdc++.h>

using namespace std;

#define ll long long int
const int mod = 1e9 + 7;

int main() {
    int n,m;
    cin>>n>>m;
    int dp[n][m];
    memset(dp,-1,sizeof(dp));
    dp[n-1][m-1] = 1;
    for(int i = 0 ; i < n ; i ++)
        for(int j = 0  ; j < m; j++){
            char c;
            cin>>c;
            if(c=='#')dp[i][j] = 0;
        }

    for(int i=n-1;i>=0;i--){
        for(int j=m-1;j>=0;j--){
            if(dp[i][j]==-1){
                if((i+1)<n)dp[i][j] = dp[i+1][j];
                if((j+1)<m)dp[i][j] = (max(dp[i][j],0) + dp[i][j+1])%mod;
                if(dp[i][j]==-1)
                    dp[i][j] = 0;
            }
        }
    }


    cout<<dp[0][0]<<endl;
    return 0;
}

Measured memory_bytes: 7464
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;

const ll M = 1000000007;

vector<ll> fac(300001);
vector<ll> ifac(300001);


ll mpow(ll x, ll n){
    
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){
    
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main()
{
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % M;
        
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M;
        
    }
    
    ll N,K;
    cin >> N >> K;
    vl A(N,0);
    for(ll i = 0; i < N; i++) cin >> A[i];
    sort(all(A));
    
    ll ans = 0;
    for (ll i = 1; i <= N; i++) {
        
        if(i >= K){
            ans += (A[i-1]*comb(i-1,K-1)%M)%M;
            ans %= M;
        }
        if(N-i+1 >= K){
            ans += M;
            ans -= (A[i-1]*comb(N-i,K-1)%M)%M;
            ans %= M;
        }
        
    }
    
    out(ans%M);
    
    
    
    
    
    return 0;
}


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

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ans = 3;
	if (a == b || b == c || c == a) {
		ans--;
	}
	if (a == b && b == c && c == a) {
		ans--;
	}
	cout << ans << endl;
	return 0;

}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

int shortest(vector<vector<int>> g, int s, int t) {
  const int n = g.size();
  queue<int> q;
  q.push(s);
  vector<int> dist(n, -1);
  dist[s] = 0;
  while (!q.empty()) {
    int u = q.front(); q.pop();
    for (int v : g[u]) {
      if (dist[v] == -1) {
        dist[v] = dist[u] + 1;
        q.push(v);
      }
    }
  }
  return dist[t];
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n*3);
  rep(i, m) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    rep(j, 3) {
      g[u*3+j].push_back(v*3+(j+1)%3);
    }
  }
  int s, t;
  cin >> s >> t;
  s--; t--;
  int ans = shortest(g, 3*s, 3*t);
  if (ans == -1) {
    cout << -1 << endl;
  } else {
    cout << ans/3 << endl;
  }
}


Measured memory_bytes: 34304
from math import gcd
from functools import reduce

def make_prime_table(n):
    sieve = list(range(n + 1))
    sieve[0] = -1
    sieve[1] = -1
    for i in range(4, n + 1, 2):
        sieve[i] = 2
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i] != i:
            continue
        for j in range(i * i, n + 1, i * 2):
            if sieve[j] == j:
                sieve[j] = i
    return sieve


def prime_factorize(n):
    result = []
    while n != 1:
        p = prime_table[n]
        e = 0
        while n % p == 0:
            n //= p
            e += 1
        result.append((p, e))
    return result


def f():
    s = set()
    for i in range(N - 1, -1, -1):
        t = prime_factorize(A[i])
        for p, _ in t:
            if p in s:
                return False
            s.add(p)
    return True


N, *A = map(int, open(0).read().split())

prime_table = make_prime_table(10 ** 6)
if f():
    print('pairwise coprime')
elif reduce(gcd, A) == 1:
    print('setwise coprime')
else:
    print('not coprime')


Measured memory_bytes: 121944
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e18;

  


int main(){
 ll T;
 cin>>T;
 for(int t=0;t<T;t++){
  ll n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  priority_queue<mp,vector<mp>,greater<mp> > q;
  set<ll> s;
  q.push( mp(0,n) );
  ll ans = inf;
  ll size = 1e5*5;
  vector<ll> dp(size);
  for(ll i=0;i<=1e5;i++){
   dp[i] = i*d;
   if( i%2 == 0 ){
    dp[i] = min( dp[i/2] + a , dp[i]);
   }
   if( i%3 == 0 ){
    dp[i] = min( dp[i/3] + b , dp[i]);
   }
   if( i%5 == 0 ){
    dp[i] = min( dp[i/5] + c , dp[i] );
   }
  }
  
  while(!q.empty() ){
   mp now = q.top();
   q.pop();
   ll coin = now.first;
   ll num = now.second;
 
   if( log(d) + log(num) <= log( 1e17 ) ){
    ans = min( ans , coin + d*num );
   }
   if( num <= 1e5 )ans = min( ans , coin+dp[num] );

 //  cout<<coin<<' '<<num<<' '<<ans<<endl;
   if( ans <= coin ) continue;
   if( s.find(num) != s.end() ) continue;
   //s[num] = coin;
   s.insert( num );
   /*if( num == 0 ){
    cout<<coin<<endl;
    break;
   }*/

   ll nc = coin + d;
   ll nn = num + 1;
   /*if( s.find(nn) == s.end() ){
    q.push( mp( nc , nn ) );
   }
   nn = num -1;
   if( s.find(nn) == s.end() ){
    q.push( mp( nc , nn ) );
   }*/

   if( num%2 == 0 ){
    nc = coin + a;
    nn = num/2;
    if( s.find(nn) == s.end() ) q.push( mp(nc,nn) );
   }else{
    nc = coin + a + d;
    nn = num/2;
    if( s.find(nn) == s.end() ) q.push( mp(nc,nn) );
    nn = (num+1)/2;
    if( s.find(nn) == s.end() ) q.push( mp(nc,nn) );
   }
   if( num%3 == 0 ){
    nc = coin + b;
    nn = num/3;
    if( s.find(nn) == s.end() ) q.push( mp(nc,nn) );
   }else{
    nc = coin + b + d*(num%3);
    nn = num/3;
    if( s.find(nn) == s.end() ) q.push( mp(nc,nn) );
    nc = coin + b + d* ( 3 - (num%3) );
    nn = (num+2)/3;
    if( s.find(nn) == s.end() ) q.push( mp(nc,nn) );

   }

   if( num%5 == 0 ){
     nc = coin + c;
     nn = num/5;
     if( s.find(nn) == s.end() ) q.push( mp(nc,nn) );
   }else{
     nc = coin + c + d*(num%5);
     nn = num/5;
     if( s.find(nn) == s.end() ) q.push( mp(nc,nn) );
     nc = coin + c + d*( 5 - (num%5) );
     nn = (num+4)/5;
     if( s.find(nn) == s.end() ) q.push( mp(nc,nn) );
   }
  }

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


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


void solve(long long A, long long B, long long C){
  cout << (A^B^C) << endl;
}

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


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

int main(void){
    long long int K;
    long long int N;
    cin >> K >> N;

    vector<long int> A(N, 0);
    REP(i, N) cin >> A[i];

    vector<int> dist(N, 0);
    REP(i, N-1){
        dist[i] = A[i+1] - A[i];
    }
    dist[N-1] = K - A[N-1] + A[0];
    sort(dist.begin(), dist.end());
    cout << K - dist[N-1] << endl;

    return 0;
}

Measured memory_bytes: 2560
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;


int main() {
    int n; cin >> n;
    vector<ll> da(n);
    rip(i,n,0) cin >> da[i];
    ll ans = 0, now = da[0];
    rip(i,n,1) {
        if(now < da[i]) {
            now = da[i];
        }
        else {
            ans += now-da[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4832
using System;
using System.Linq;

namespace B___NarrowRectanglesEasy
{
    class Program
    {
        static void Main(string[] args)
        {
            var Wab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int W = Wab[0], a = Wab[1], b = Wab[2];

            Console.WriteLine(Math.Abs(b - a) >= W ? Math.Max(a, b) - Math.Min(a, b) - W : 0);
        }
    }
}


Measured memory_bytes: 11348
#include <iostream>
#include <map>
#include <cmath>

using namespace std;

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int N;
int main() {
  int i;
  int ans = pow(10, 9);
  cin >> N;
  int A[N];
  for(i=0; i<N; i++){
		cin >> A[i];
    ans = min(ans, prime_factor(A[i])[2]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<numeric>
#include<utility>
#define ul unsigned long long int
#define ll long long int
#define MAX 1000000+1
using namespace std;
#define F first
#define S second
#define pi 2*acos(0.0)
#define PB push_back
#define CL clear()



int main()
{

    int n, m;
    cin >> n >> m;
    vector<int> arr[n+1];
    for(int i= 1; i <=n; i++)
        arr[i].clear();
    int a, b;
    for(int i = 0; i < m; i++)
    {
        cin >> a >> b;
        arr[a].PB(b);
        arr[b].PB(a);
    }
    for(int i= 1; i <=n; i++)
        cout << arr[i].size()<<"\n";


}




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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N;
string T;
int S[202020];

struct SuffixArray {
	int N; vector<int> rank,lcp,sa; string S;
	
	SuffixArray(string S) : S(S){
		int i,h=0; vector<int> tmp,tr;
		N=S.size(); rank.resize(N+1); sa.resize(N+1); tmp.resize(N+1);
		FOR(i,N+1) sa[i]=i, rank[i]=i==N?-1:S[i];
		
		for(int k=1; k<=N; k<<=1) {
			auto pred2 = [k,this](int& a,int &b)->bool{ return (((a+k<=N)?rank[a+k]:-1)<((b+k<=N)?rank[b+k]:-1));};
			auto pred = [pred2,k,this](int& a,int &b)->bool{ return (rank[a]!=rank[b])?(rank[a]<rank[b]):pred2(a,b);};
			int x=0;
			if(k!=1) for(i=1;i<N+1;i++) if(rank[sa[i]]!=rank[sa[x]]) sort(sa.begin()+x,sa.begin()+i,pred2), x=i;
			sort(sa.begin()+x,sa.end(),pred);
			FOR(i,N+1) tmp[sa[i]]=(i==0)?0:tmp[sa[i-1]]+pred(sa[i-1],sa[i]);
			swap(rank,tmp);
		}
		lcp.resize(N+1); tr.resize(N+1);
		FOR(i,N+1) tr[sa[i]]=i;
		FOR(i,N) {
			int j=sa[tr[i]-1];
			for(h=max(h-1,0);i+h<N && j+h<N; h++) if(S[j+h]!=S[i+h]) break;
			lcp[tr[i]-1]=h;
		}
	}
};


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>T;
	N=T.size();
	
	SuffixArray sa(T);
	FOR(i,N) {
		S[sa.lcp[sa.rank[i]-1]+1]++;
		S[N-i+1]--;
	}
	
	int ma=0;
	for(i=1;i<=N;i++) {
		S[i]+=S[i-1];
		ma=max(ma,S[i]);
	}
	cout<<ma<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

int main(){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    if(s.at(0) == s.at(1) && s.at(1) != s.at(2) && s.at(2) == s.at(3)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		double x1 = sc.nextDouble();
		double y1 = sc.nextDouble();
		double x2 = sc.nextDouble();
		double y2 = sc.nextDouble();
		System.out.println(Math.hypot(Math.abs(x2-x1),Math.abs(y2-y1)));
	}
}

Measured memory_bytes: 18396
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1)
int main(){
 
ll x ,y,sum=0;
cin>>x>>y;
//x-=1;y-=1;
while(x--)sum+=x;
while(y--)sum+=y;
cout<<sum<<endl;
 
return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

const ll INF = 1e16;

int n;
vector<ll> v;
ll a[222222];
ll b[222222];

void solve() {
   rep (i, n) {
      ll t = a[i];
      a[i] = INF;
      sort(a, a + n);
      cout << a[n/2] << endl;
      a[i] = t;

      rep (j, n) {
         cout << a[i] << " ";
      }
      cout << endl;
   }
}

int main() {
   cin >> n;
   rep (i,n) {
      cin >> a[i];
      b[i] = a[i];
   }

   // solve();
   // exit(0);

   sort(b, b+n);
   int x = (n/2)-1, y = (n/2);
   int small = b[x], big = b[y];

   rep (i, n) {
      if (a[i] <= small) {
         cout << big << endl;
      } else {
         cout << small << endl;
      }
   }

   return 0;
}

Measured memory_bytes: 5376
import numpy as np
h,w=map(int,input().split())
s=[]
for _ in range(h):
    si=input()
    si=si.replace('.', '1')
    si=si.replace('#', '0')
    s.append(list(map(int,si)))
s=np.array(s)

left=np.zeros((h,w))
right=np.zeros((h,w))
up=np.zeros((h,w))
down=np.zeros((h,w))

for i in range(w):
    if(i==0):
        left[:,i]=s[:,i]
        right[:,w-i-1]=s[:,w-i-1]
    else:
        left[:,i]=(left[:,i-1]+1)*s[:,i]
        right[:,w-i-1]=(right[:,w-i]+1)*s[:,w-i-1]

for i in range(h):
    if(i==0):
        down[i,:]=s[i,:]
        up[h-i-1,:]=s[h-i-1,:]
    else:
        down[i,:]=(down[i-1,:]+1)*s[i,:]
        up[h-i-1,:]=(up[h-i,:]+1)*s[h-i-1,:]

ans=left+right+up+down-3
print(int(np.max(ans)))


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,m;cin>>n>>m;
    int arr[n]={0};
    int a,b;
    for (int i=0;i<m;i++){
        cin>>a>>b;
        arr[a-1]++;
        arr[b-1]++;
    }for (int i=0;i<n;i++){
        cout<<arr[i]<<endl;
    }
    return 0;
}

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

int main(){
  size_t n;
  cin >> n;
  string s;
  cin >> s;
  char bef;
  set<string> st;
  bef = s.back();
  st.insert(s);
  for(int i = 1; i < n; ++i){
    cin >> s;
    if(bef != s.front())return 0 & puts("No");
    if(st.count(s))return 0 & puts("No");
    bef = s.back();
    st.insert(s);
  }
  puts("Yes");
}

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

int main() {
  int n,ans=100,a,sum;
  cin>>n;
  for(int i; i<n ; i++){
  cin>>a;
    while(a%2!=1){
     a/=2;
       sum++;
    }
   
    
    if(sum<ans){
      ans=sum;
      
           }
    sum=0;
  }
  
  
  
  cout<<ans<<endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N; ll x;
  cin >> N >> x;
  ll a[N];
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < N-1; i++) {
    if (a[i] > x) {
      ans += a[i] - x;
      ans += a[i+1];
      a[i] = x;
      a[i+1] = 0;
    } else if (a[i] + a[i+1] > x) {
      ans += a[i+1] - (x - a[i]);
      a[i+1] = x - a[i]; 
    } else {
      
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4384
from heapq import heappush, heappop

x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ab = [ea + eb for ea in a for eb in b]
ab.sort()

hp = []
for e in c:
    heappush(hp, (-(e + ab[-1]), x * y - 1))

ans = []
for _ in range(k):
    yum, i = heappop(hp)
    yum = -yum
    ans.append(yum)
    if i != 0:
        yum += ab[i-1] - ab[i]
        yum = -yum
        heappush(hp, (yum, i - 1))

print(*ans, sep="\n")


Measured memory_bytes: 55400
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
ls=[a,b,c,d,e]
for i in range(len(ls)):
    for j in range(len(ls)-i):
        if ls[i] - ls[j] > k:
            print(':(')
            break
    else:
        continue
    break
else:
    print('Yay!')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N;
ll five;
ll two;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    if(N % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    ll val = 1;
    ll num = 0;
    while(true) {
        val *= 5;
        num++;
        if(val > N) break;
        five += N / (val * 2);
    }
    cout << five << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int n100 = n / 100;
        int n10 = (n / 10) % 10;
        int n1 = n % 10;
        System.out.print(10 - n100);
        System.out.print(10 - n10);
        System.out.println(10 - n1);
    }
}


Measured memory_bytes: 21332
package main

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

func main()  {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	H, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	scanner.Scan()
	A, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	if i := H % A; i != 0 {
		fmt.Println(H / A + 1)
	} else {
		fmt.Println(H / A)
	}
}

Measured memory_bytes: 1832
num, okashi = map(int, input().split(" "))
snk = [1 for i in range(num)]
for i in range(okashi):
    ninnzuu = (int)(input())
    temp = list(map(int, input().split(" ")))
    for j in temp:
        snk[j - 1] = 0
print(sum(snk))

Measured memory_bytes: 9188
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <unistd.h>
#include <map>
#include <set> 

#define pii pair<int,int>
#define REP(i, n) for (long long i = 0; i < (n); i++) 
using namespace std;


typedef long long ll;
static const ll INF = 1000000000000000000LL;
static const ll MOD = 1000000007;


//各範囲の文字の数をセグ木で保存
//各文字の部分累積和をとっておけば、
//

int main()
{
    int N;
    cin >> N;
    string s;
    cin >> s;
    
    set <int> st[26];
    REP(i,N)
    {
        st[s[i] - 'a'].insert(i);
    }
    //終端を設定しておく
    REP(d,26)
    {
        st[d].insert(N);
    }
    int Q;
    cin >> Q;

    REP(i,Q)
    {
        int q;
        cin >> q;
        if(q == 1)
        {
            int l;
            char c;
            cin >> l >> c;
            --l;
            if(s[l] != c)
            {
                st[s[l] - 'a'].erase(l);
                st[c - 'a'].insert(l);
                s[l] = c;
            }
        }
        else
        {
            int l,r;
            cin >> l >> r;
            --l;--r;
            int res = 0;
            REP(d,26)
            {
                int off = *st[d].lower_bound(l);
                if(off <= r)++res;
            }
            cout << res << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 24196
#pragma GCC optimze("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
// inbuilt function in c++
// abs(-2)=2 , __gcd(2,3)=1 , swap(a,b) , 
//string/array s = "aba"; sort(s.begin(), s.end());  do {  cout << s << '\n';  } while(next_permutation(s.begin(), s.end()));  
//for all permutation of s.
#include <bits/stdc++.h>
#define int                 long long int
#define double              long double
#define get(a,n)            for(int i=0;i<n;i++){cin>>a[i];}
#define out(a,n)            for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<endl;
#define maxm(a)             int maxi=LLONG_MIN;int index;for(int i=0;i<n;i++){if(maxi<a[i]){maxi=a[i];index=i;}}
#define minm(a)             int mini=LLONG_MAX;int index;for(int i=0;i<n;i++){if(mini>a[i]){mini=a[i];index=i;}}
#define db(x)               cout<<x<<" "<<endl;
#define endl                "\n"
#define PI                  acos(-1)
#define half(a)             a%2?cout<<(a/2+1)<<endl:cout<<a/2<<endl;
#define array               int a[n];for(int i=0;i<n;i++){cin>>a[i];}
#define pb(a)                push_back(a)
#define all(a)              a.begin(),a.end()
using namespace std;
void show(int *a)
{
    int size = (*(&a + 1) - a)-1;
    for(int i=0;i<size;i++)
    {
            cout<<a[i]<<" ";
    }   
    cout<<endl;
}
int binary_search(int *a,int n,int e)
{
    int f,l,m;f=0;l=n-1;
    while(f<=l)
    {//returns index of that value.
        m=(f+l)/2;
        if(e==a[m])
            return(m);
        else if(e>a[m])
                f=m+1;
            else
                l=m-1;
    }
    return -1;
}
vector<int> pf;
void primefactors(int n)  
{  
    while (n % 2 == 0)  
    pf.push_back(2),n = n/2;  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        while (n % i == 0)  
        {  
            pf.push_back(i); 
            n = n/i;  
        }  
    }  
    if (n > 2)  
        pf.push_back(n);
        //dont forgot to clear pf vector. 
}  
vector<int> fac;
//vector<int,greater<int>>fac;
void factors(int n) 
{ 
    for (int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            if (n/i == i) 
            fac.push_back(i);
            else
            fac.push_back(i),fac.push_back(n/i); 
        } 
    } 
    //dont forgot to clear fac vector.
} 
// priority_queue stores the values in descending order q.front() returns maximum element. ".size() works for priority_queue."
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(15);
    int t=1;
//    cin>>t;
    while(t--)
    {
     int x,n;
      cin>>x>>n;
      int p[n];map<int,int>mp;
      for(int i=0;i<n;i++)
      {
          cin>>p[i];mp[p[i]]=1;
      }int a,b;
      for(int i=x;i<=200;i++)
      {
          if(mp[i]==0){
          a=i;break;}
      }
      for(int i=x;i>=-100;i--)
      {
          if(mp[i]==0){
          b=i;break;}
      }
        if(abs(a-x)==abs(b-x))
        cout<<b<<endl;
        else if(abs(a-x)>abs(b-x))
        cout<<b<<endl;
        else
        cout<<a<<endl;
        
    }
   

  
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if (u == s) a--;
    else b--;
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F0(i,n) for (int i = 0; i < n; i++)
#define F1(i,n) for (int i = 1; i <= n; i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define SZ(x) ((int)x.size())
const double eps = 1e-10;
const int inf = 1000000009;
int i, j, k, m, n, l;
int ans = -1;
string s[505];
int have[505];

int main() {
	//freopen("x.in", "r", stdin);
	cin >> n;
	F0(i, n) {
		cin >> s[i];
		F0(j, n) if (s[i][j] == '#') {
			have[j] = 1;
			ans = 0;
		}
	}
	if (ans < 0) {
		cout << -1 << endl;
	}
	else {
		int best_row = -1;
		F0(i, n) {
			int cnt = 0;
			F0(j, n) cnt += (s[i][j] == '#');
			best_row = max(best_row, cnt + have[i]);
		}
		ans = n + 1 - best_row;
		F0(j, n) {
			int is_empty = 0;
			F0(i, n) if (s[i][j] == '.') is_empty = 1;
			ans += is_empty;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 512
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        var t = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var a = Console.ReadLine().Split().Select(x => int.Parse(x)).OrderByDescending(x => x).ToArray();
        Console.WriteLine(Math.Max(a[0] - 1 - (t[0] - a[0]), 0));
    }
}

Measured memory_bytes: 11348
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
class Main{
  public static void main(String args[]) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
   String[] original =  br.readLine().split("");//????????°????????????
   String[] serch =  br.readLine().split("");//??¢????????????
 
   int flag = 0;
   for(int i = 0; i < original.length; i++){
      if(serch[0].equals(original[i])){
         int j ;
         int k = i;
         int count = 0;
         for(j = 0;j<serch.length;j++,k++){

             if(k == original.length){
                 k = 0;//????????°????????§???????????????
             }//if
  
             if( serch[j].equals( original[k]) ){
                 count++;//???????????????????????????????????????
             }//if
 
        }//for
 
         if(count == serch.length){
            flag = 1;//????????????????????¢???????????????????????°??¨????????????????????°?????????
         }
      }//if
   }//for
 
   if(flag == 1){
 
       System.out.println("Yes");
 
   }else{
       System.out.println("No");
   }
 
  }
}

Measured memory_bytes: 24504
#include <stdio.h>
int main(){
    int a;
    int b;
    int c;
    int d;
    int e;
    scanf("%d%d%d",&a,&b,&c);
    if(b>a){
        d=b-a;
    }else{
        d=a-b;
    }
    if(c>a){
        e=c-a;
    }else{
        e=a-c;
    }
    if(d>e){
        printf("B");
    }else{
        printf("A");
    }
    return 0;
}

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

using namespace std;

void fastio() {
	cin.tie(nullptr);
	cin.sync_with_stdio(false);
}

using LL = long long;
using LD = long double;

const LL MOD = 1e9+7;
const LL INF = LLONG_MAX;
const LL N = 1e6+1;

#define F first
#define S second

int main() {
	fastio();
	
	LL d, s, t;
	cin >> d >> t >> s;

	if (t*s >= d) cout << "Yes\n";
	else cout << "No\n";




}

Measured memory_bytes: 3644
N, M, K = map(int, input().split())

mod = 998244353

fac = [1]
inv = [1]
for i in range(1, N + 10) :
  fac.append(fac[-1] * i % mod)
  inv.append(pow(fac[-1], mod - 2, mod))

def comb(n, r) :
  return fac[n] * inv[n-r] * inv[r] % mod

ret = 0
for k in range(K + 1) :
  ret += comb(N - 1, k) * M * pow(M - 1, N - k - 1, mod) % mod
  ret %= mod
print(ret)

Measured memory_bytes: 98412
#!/usr/bin/env python
# coding: utf-8

# In[9]:


N, M = map(int, input().split())
S = input()


# In[10]:


last = S[0]
if last == '0':
    A = [0]
else:
    A = []
renzoku = 1
for i in range(1, N):
    if S[i] == last:
        renzoku += 1
    else:
        A.append(renzoku)
        renzoku = 1
        last = S[i]
A.append(renzoku)
if S[-1] == '0':
    A.append(0)


# In[11]:


A


# In[14]:


l = 0
r = l + 2 * M + 1
if r > len(A):
    t = sum(A)
else:
    t = sum(A[l:r])
ret = t
l = 2
while True:
    r = l + 2 * M + 1
    if r > len(A):
        break
    t = t + A[r - 2] + A[r - 1] - A[l - 2] - A[l - 1]
    ret = max(t, ret)
    l += 2
print(ret)


# In[ ]:





# In[ ]:





# In[ ]:






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

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

  if(x>=a && x <= a+b) cout << "YES";
  else cout << "NO";

  return 0;
}

Measured memory_bytes: 256
////////////////////////    W H I T E C L O U D    ////////////////////////
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<ll>adj[100003];
ll vis[100003];
void dfs(ll s)
{
    ll i,x;
    vis[s]=1;
    for(i=0; i<adj[s].size(); i++)
    {
        x=adj[s][i];
        if(vis[x]==-1)dfs(x);
    }
}
int main()
{
    FAST();
    ll n,m,i,a,b,cnt=0;
    cin>>n>>m;
    for(i=1; i<=m; i++)
    {
        cin>>a>>b;
        adj[a].push_back(b);
         adj[b].push_back(a);
    }
    memset(vis,-1,sizeof(vis));
    for(i=1; i<=n; i++)
    {
        if(vis[i]==-1)
        {
            cnt++;dfs(i);
        }
    }
    cout<<cnt-1<<endl;


    return 0;
}








Measured memory_bytes: 11068
#include <iostream> 
#include <vector>
#include <string>
#include <math.h>
#include <stack>
#include <set>
#include <algorithm>
using namespace std;
#define ll long long int

int main( ) {
  int n;
  cin >> n;
  vector <int> a(n),b(n),c(n);
  for ( int i = 0; i < n; i++ ) cin >> a[i];
  for ( int i = 0; i < n; i++ ) cin >> b[i];
  for ( int i = 0; i < n; i++ ) cin >> c[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  
  ll ans = 0;
  for ( int j = 0; j < n; j++ ) {
    int i = lower_bound(a.begin(),a.end(),b[j]) - a.begin();
    int k = upper_bound(c.begin(),c.end(),b[j]) - c.begin();
    ans += (ll)i * (n - k);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


int n, m, a[102]; float sum=0;

void solve()
{
    cin >> n >> m;
    for (int i=0; i<n; i++){
       cin >> a[i];
       sum+=a[i];
    }
    sort(a,a+n);
    float k=sum/(4*m);
    for (int i=n-1; i>n-1-m;i--) {
        if (a[i]<k) {
            nout("No"); return;
        }
    }nout("Yes");
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3508
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x,y;
  x=c-a; y=d-b;
  cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x<<endl;
}

Measured memory_bytes: 256
#include <iostream>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define SORT_DOWN(v, n) sort(v, v+n, greater<int>());
#define VSORT_DOWN(v) sort(v.begin(),v.end(), greater<int>());
#define INF 999999999
using namespace std;

int main() {
  int sosu[1000] = {2};
  int koho[55] = {};
  int index = 0;
  int num  = 3;
  while (koho[54] == 0 && sosu[999] == 0) {
    for (size_t i = 0; i < 1000; i++) {
      if (sosu[i] == 0 && num % 10 == 1) {
        sosu[i] = num;
        koho[index] = num;
        index++;
        break;
      } else if (sosu[i] == 0) {
        sosu[i] = num;
        break;
      } else if (num % sosu[i] == 0) {
        break;
      }
    }
    num++;
  }
  int n;
  cin >> n;
  for (size_t i = 0; i < n-1; i++) {
    cout << koho[i] << " ";
  }
  cout << koho[n-1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;

	vector<int>a(n);
	vector<int>b(n);
	rep(i, n) {
		cin >> a[i] >> b[i];
	}

	vector<pair<int, int>>c(n);
	rep(i, n) {
		c[i].first = a[i];
		c[i].second = b[i];
	}

	sort(c.begin(), c.end());

	ll ans = 0;
	ll pur = 0;

	rep(i,n){
		while (c[i].second > 0 && pur < m) {
			int x = c[i].second;
			pur++;
			c[i].second = x - 1;
			ans += c[i].first;
		}
		/*if (pur == m) {
			break;
		}*/
	}
	cout << ans << endl;
}

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

typedef long long  LL;
int n,q;
LL p[100010],X,Y,ans[100010];
map <LL,LL> M;

void work()
{
	scanf("%d %d",&n,&q),p[0]=n;
	for (int i=1; i<=q; i++)  scanf("%lld",&p[i]);
	M[-p[q]]=1;
	for (int i=q-1,last=q; i>=0; i--)
		if (p[i]<p[last])
			{
				for (map <LL,LL> ::iterator x=M.begin(); x!=M.end(); x=M.begin())
					if ((X=-(*x).first)>p[i])
						{
							M[-p[i]]+=(Y=(*x).second)*(X/p[i]);
							if (X%p[i])  M[-X%p[i]]+=Y;
							M.erase(x);
						}else  break;
				last=i;
			}
	for (map <LL,LL> ::iterator x=M.begin(); x!=M.end(); x++)
		ans[-(*x).first]=(*x).second;
	for (int i=n; i; i--)  ans[i]+=ans[i+1];
	for (int i=1; i<=n; i++)  printf("%lld\n",ans[i]);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 9344
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define PI 3.14159265358979323846
#define INF 2000000007
#define LINF 2000000000000000007
#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;
string s;
int cnt[3];
signed main(){
	cin>>s;
	
	rep(i,s.size()){
		cnt[s[i]-'a']++;
	}
	int res=max({abs(cnt[1]-cnt[2]),abs(cnt[0]-cnt[2]),abs(cnt[0]-cnt[1])});
	if(res>1)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
}


Measured memory_bytes: 512