akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,k,i;
    cin>>n>>k;
    int p[n];

    for(i = 0; i < n; i++)cin>>p[i];
    double mx=0,pnum;
    for(i = 0; i < k; i++)
        mx+=(p[i]+1)/2.0;
    pnum = mx;
    for(i = k; i < n; i++)
    {
        pnum = pnum-(p[i-k])/2.0+p[i]/2.0;
        if(pnum>mx)
            mx = pnum;
    }
    cout<<fixed<<setprecision(12)<<mx<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#define INF 2000000000
using namespace std;

struct Card{
	char s;
	int n;
};

Card L[50002],R[50002];

void merge(Card a[],int l,int m,int r){
	int n1=m-l;
	int n2=r-m;
	for(int i=0;i<n1;i++)
		L[i]=a[l+i];
	for(int i=0;i<n2;i++)
		R[i]=a[m+i];
	L[n1].n=INF;
	R[n2].n=INF;
	int i=0,j=0;
	for(int k=l;k<r;k++){
		if(L[i].n<=R[j].n)
			a[k]=L[i++];
		else
			a[k]=R[j++];
	}
}

void mergesort(Card a[],int l,int r){
	if(l+1<r){
		int m=(l+r)/2;
		mergesort(a,l,m);
		mergesort(a,m,r);
		merge(a,l,m,r);
	}
}

int partition(Card a[],int p,int r){
	Card x=a[r],tmp;
	int i=p-1;
	for(int j=p;j<r;j++){
		if(a[j].n<=x.n){
			i++;
			swap(a[i],a[j]);
		}
	}
	i++;
	swap(a[i],a[r]);
	return i;
}

void quicksort(Card a[],int l,int r){
	if(l>=r)
		return ;
	int m=partition(a,l,r);
	quicksort(a,l,m-1);
	quicksort(a,m+1,r);
}

int main(){
	int n;
	Card a[100000],b[100000];
	cin>>n;
	for(int i=0;i<n;i++){
		char s[3];
		int x;
		cin>>s>>x;
		a[i].s=b[i].s=s[0];
		a[i].n=b[i].n=x;
	}
	mergesort(a,0,n);
	quicksort(b,0,n-1);
	bool f=true;
	for(int i=0;i<n;i++)
		if(a[i].s!=b[i].s){
			f=false;
			break;
		}
	cout<<(f?"Stable":"Not stable")<<endl;
	for(int i=0;i<n;i++)
		cout<<b[i].s<<' '<<b[i].n<<endl;
	return 0;
}

Measured memory_bytes: 5384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <ctime>

#define inf 0x3f3f3f3f
#define Inf 0x3FFFFFFFFFFFFFFFLL
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, n) for (int i = 1; i <= (n); ++i)
#define clr(x, a) memset(x, (a), sizeof x)
using namespace std;
typedef long long ll;

int main() {
	ll n, x; cin >> n >> x;
	ll ans = n;
	ll p = n - x;
	if (p <= x) swap(p, x);
	
	while (p % x != 0) {
		ll t = p / x;
		ans += t * 2 * x;
		p %= x;
		swap(x, p);
	}
	ll d = p / x;
	ans += (d * 2 - 1) * x;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

	
int main(void){
    int X,Y;
    cin >> X >> Y;
    if(Y%2==0 && 2*X<=Y && Y<=4*X){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}



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

int main() {

  int N;
  cin >> N;

  int ans;
  for(int i=1; i < 11 ; i++){
    if(1000 * i - N >= 0){
      ans = 1000 * i - N;
      break;
    }
  }

  cout << ans << endl;

return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
    int a;
    cin >> a;
    for (int i = 1; i <= 9; i++)
    {
        for (int j = 1; j <= 9; j++)
        {
            if (i * j == a)
            {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
template <typename T>
inline T  read()
{
    char c=getchar();
    T x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
template <typename T>
inline void write(T x) 
{
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) write(x / 10);
    putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
int main()
{
    int a = read<int>(), b = read<int>();
    int c = min(a/0.08,b/0.1);
    for(int i = c; ;i++)
    {
        if((int)(i*0.08) == a && (int)(i*0.1) == b)
        {
            cout<<i<<endl;
            break;
        }
        if((int)(i*0.08) > a && (int)(i *0.1) >b)
        {
            cout<<-1<<endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    int res = 0;
    rep(i, 4) {
        if(s[i] == '+')
            res++;
        else
            res--;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########
a,b,c = mi()
maxval = max(a,b,c)
x = min(a,b,c)
y = sum([a,b,c]) - (x + maxval)
print(int(x*y/2))

Measured memory_bytes: 3064
use proconio::input;

fn main() {
    input! {
        n: usize,
        s: String,
    }
    let mut num = 0;
    let mut color = 'Z';
    for c in s.chars() {
        if color != c {
            num += 1;
            color = c;
        }
    }
    println!("{}", num);
}


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

int main() {
  ll a,b,c,d; cin >> a >> b >> c >> d;
  if(a%d==0 && c%b==0){
    if(a/d>=c/b) cout << "Yes" << endl;
    else if(a/d<c/b) cout << "No" << endl;
  }
  else if(a%d==0 && c%b!=0){
    if(a/d>=(c/b+1)) cout << "Yes" << endl;
    else if(a/d<(c/b+1)) cout << "No" << endl;
  }
  else if(a%d!=0 && c%b==0){
    if((a/d+1)>=c/b) cout << "Yes" << endl;
    else if((a/d+1)<c/b) cout << "No" << endl;
  }
  else if(a%d!=0 && c%b!=0){
    if((a/d+1)>=(c/b+1)) cout << "Yes" << endl;
    else if((a/d+1)<(c/b+1)) cout << "No" << endl;
  }
  
  return 0;
}

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

using namespace std;

int main(){
    int people,money,ave,count;
    vector<int> syotoku;
    vector<int> res;

    while(1){
        cin>>people;
        if(people == 0) break;

        ave = 0;
        syotoku.clear();
        count = 0;
        for(int i=0;i<people;i++){
            cin>>money;
            ave+=money;
            syotoku.push_back(money);
        }

        ave/=people;
        for(int i=0;i<people;i++){
            if(syotoku[i]<=ave) count++;
        }

        res.push_back(count);
    }

    for(int i=0;i!=res.size();i++){
        cout<<res[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3248
H,W=gets.split.map &:to_i;p [[H,W],[W,H]].map{|h,w|(1..h/2).map{|i|x,y=[w*i,w/2*(h-i),(w-w/2)*(h-i)].minmax;z,q=[i,(h-i)/2,h-i-(h-i)/2].minmax;[y-x,(q-z)*w].min}.min}.min

Measured memory_bytes: 4348
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
    SPEED;        
    int w,s;
    cin>>s>>w;
    if(s<=w)
        cout<<"unsafe";
    else
        cout<<"safe";
}

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

int main(void)
{
    vector<int> inp(5), vec(5);
    rep(i, 5) cin >> inp[i];
    rep(i, 5) vec.at(i) = i+1;
    int ans = 10000;
    do{
        int sum = 0;
        rep(i, 5)
        {
            sum += inp[vec.at(i)-1];
            if(i == 4) continue;
            while(!(sum%10) == 0)
            {
                sum++;
            }
        }
        ans = min(ans, sum);
    }while(next_permutation(vec.begin(), vec.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
int n,r;
ll suma,sumb,rest;
struct ta{
	ll a,b;
}s[100005];
bool cmp(ta A,ta B){return A.a-A.b<B.a-B.b;}
bool ch[100005];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&s[i].a),suma+=s[i].a;
	for(int i=1;i<=n;i++)scanf("%lld",&s[i].b),sumb+=s[i].b;
	sort(s+1,s+1+n,cmp);
	if(suma<sumb){
		printf("-1");
		return 0;
	}
	r=n;
	for(int i=1;i<=n;i++)
	if(s[i].a<s[i].b){
		ch[i]=1;
		if(s[i].a+rest<s[i].b){
			ch[r]=1;
			rest+=s[r].a-s[r].b;
			s[r].a=s[r].b;
			r--;
		}
		rest-=s[i].b-s[i].a;
		s[i].a=s[i].b;
	}
	int tot=0;
	for(int i=1;i<=n;i++)if(ch[i])tot++;
	printf("%d",tot);
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int count = scanner.nextInt();
			scanner.nextLine();
			System.out.println(IntStream.range(0, count).map(i -> devide2Count(scanner.nextInt())).min().getAsInt());
		}
	}

	/**
	 * numberが何回2で割れるかを取得する
	 * 
	 * @param number
	 * @return
	 */
	private static int devide2Count(int number) {
		int result = 0;
		while (number % 2 == 0) {
			number = number / 2;
			result++;
		}
		return result;
	}
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;

  for(int i=0;i<(1<<3);i++) {
    int sum = s[0]-'0';
    for(int j=0;j<3;j++) {
      if((i >> j) & 1) {
        sum += (s[j+1]-'0');
      } else {
        sum -= (s[j+1]-'0');
      }
    }
    if(sum == 7) {
      cout << s[0];
      for(int k=0;k<3;k++) {
        if((i >> k) & 1) {
          cout << '+';
        } else {
          cout << '-';
        }
        cout << s[k+1];
      }
      cout <<"=7" << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
    long long int a, b;
    char op;
    cin >> a >> op >> b;
    if(op == '+') cout << a + b << endl;
    else cout << a - b << endl;
    return 0;
}

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

int top = 0, S[1000];
void push(int x) {
  S[++top]=x;
}
int pop() {
  top--;
  return S[top+1];
}
int main() {
  int a, b;
  char s[100];
  while(cin >> s) {
    if(s[0] == '+') {
      a = pop();
      b = pop();
      push(a+b);
    }else if(s[0] == '-') {
      b = pop();
      a = pop();
      push(a-b);
    }else if(s[0] == '*') {
      a = pop();
      b = pop();
      push(a*b);
    }else {
      push(atoi(s));
    }
  }
  cout<<pop()<<endl;
  return 0;
}



Measured memory_bytes: 3092
//#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;

const int N = 1e5 + 5;

/***************************************************************************/

string C;
set<int> adj[N];
int deg[N];
int dep[N];

void dfs(int v, int p) {
	dep[v] += (((C[v] == 'W') + deg[v]) % 2) * 2;
	//assert(((C[v] == 'W') + deg[v]) % 2 == 0);
	for(auto it : adj[v]) {
		if(it == p) continue;
		dep[it] = dep[v]; //+ 1;
		dfs(it, v);
	}
}

bool find_path(int v, int p, int t, vector<int> &path) {
	path.pb(v);
	if(v == t) return true;
	for(auto it : adj[v]) {
		if(it == p) continue;
		if(find_path(it, v, t, path)) return true;
	}
	path.pop_back();
	return false;
}

int na = -1;
int find_dia_point(int n) {
	int ans = -1, mx = -1;
	for(int i=1; i<=n; i++) {
		if(deg[i] != 1 or i == na) continue;
		if(dep[i] > mx) {
			ans = i;
			mx = dep[i];
		}
	}
	assert(ans != -1);
	return ans;
}

inline void flip(char &c) {
	if(c == 'B') c = 'W';
	else c = 'B';
}

int ans = 0;

void dfs_order(int v, int p) {
	flip(C[v]);
	for(auto it : adj[v]) {
		if(it == p) continue;
		ans += 2;
		dfs_order(it, v);
		flip(C[v]);
	}
	if(C[v] == 'W') {
		flip(C[v]);
		ans++;
	}
}

set<pair<pii, int> > S;

int main() {

	boost;
	int n; cin>>n;
	for(int i=1; i<n; i++) {
		int a, b; cin>>a>>b;
		adj[a].insert(b);
		adj[b].insert(a);
		deg[a]++, deg[b]++;
	}
	cin>>C; C = '_' + C;
	
	for(int i=1; i<=n; i++) {
		S.insert(mp(mp(deg[i], (C[i]=='W')), i));
	}

	while(!S.empty()) {
		int d = S.begin()->fi.fi;
		int c = S.begin()->fi.se;
		int v = S.begin()->se;

		if(d > 1 or c != 0) break;

		S.erase(S.begin());

		for(auto it : adj[v]) {
			auto val = mp(mp(deg[it], (C[it]=='W')), it);
			deg[it]--;
			adj[it].erase(v);

			S.erase(val);
			val.fi.fi--;
			S.insert(val);
		}

		adj[v].clear();
		deg[v] = 0;
	}
	if(S.empty()) {
		cout<<"0\n";
		return 0;
	}
	if(S.size() == 1) {
		cout<<"1\n";
		return 0;
	}

	int root = S.begin()->se;
	dfs(root, 0);
	int a = find_dia_point(n);
	memset(dep, 0, sizeof dep);
	dfs(a, 0);
	na = a;
	int b = find_dia_point(n);

	vector<int> path;
	find_path(a, 0, b, path);

	int last = -1;
	for(auto it : path) {
		if(last != -1) {
			adj[last].erase(it);
			adj[it].erase(last);
		}
		last = it;
	}

	for(auto it : path) {
		ans++;
		dfs_order(it, 0);
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 28388
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;


const int MOD = (int)1e9 + 7;

int add(int x, int y){
    return (x + y) % MOD;
}

const int N = 43, M = (1 << 17) + 10;
int n, x, y, z;
int dp[N][M];

int main(){
    cin >> n >> x >> y >> z;
    int ansMask = (1 << (z-1)) + (1 << (y+z-1)) + (1 << (x+y+z-1));
    int m = 1 << (x+y+z);
    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int mask = 0; mask <= m; mask++){
            if(dp[i][mask] == 0)continue;
            for(int p = 1; p <= 10; p++){
                if(mask == m){
                    dp[i+1][m] = add(dp[i+1][m], dp[i][m]);
                    continue;
                }
                int nmask = ((mask << p) | (1 << (p-1))) & (m-1);
                if((nmask & ansMask) == ansMask) nmask = m;
                dp[i+1][nmask] = add(dp[i+1][nmask], dp[i][mask]);
            }
        }
    }
    cout << dp[n][m] << endl;
}

Measured memory_bytes: 19456
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n;
        cin>>n;
        vvl G(n,vl(0));
        vector<pll> P(n-1);
        map<pll,ll> Ans;
        rep(i,n-1){
            ll a,b;
            cin>>a>>b;
            a--;b--;
            P[i]=mp(a,b);
            G[a].pb(b);
            G[b].pb(a);
        }
        queue<ll> Q;
        Q.push(0);
        ll k=0;
        map<ll,ll> used;
        while(!Q.empty()){
            ll x=Q.front();
            Q.pop();
            ll res=1;
            for(ll a:G[x]){
                pll c=mp(min(x,a),max(x,a));
                if(Ans[c]!=0)continue;
                if(used[x]==res)res++;
                Ans[c]=res;
                if(used[x]<res)used[x]=res;
                used[a]=res;
                chmax(k,res);
                Q.push(a);
                res++;
            }
        }
        cout<<k<<endl;
        rep(i,n-1)cout<<Ans[P[i]]<<endl;
    }

Measured memory_bytes: 20608
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

int main(){
    int n, min = 100000, sum = 0;
    scanf("%d", &n);

    for(int i = 1; i <= (n / 2); i++){

        for(int j = i; j > 0; j = j / 10) sum += j % 10;
        for(int j = n - i; j > 0; j = j / 10) sum += j % 10;

        if(sum < min) min = sum;

        sum = 0;
    }

    printf("%d\n", min);

    return 0;
}


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

#define rep_(v, f, l) for (int v = (f); v < (l); ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

int main()
{
    int n;
    while (n = in()){
        rep(i, n){
            int pm, pe, pj;
            pm = in();
            pe = in();
            pj = in();
            int all_ave = (pm + pe + pj) / 3.;
            int me_ave = (pm + pe) / 2.;
            int is_perfect = pm == 100 || pe == 100 || pj == 100;
            if (is_perfect || me_ave >= 90 || all_ave >= 80){
                puts("A");
            }
            else if (all_ave >= 70 || (all_ave >= 50 && max(pm, pe) >= 80)){
                puts("B");
            }
            else {
                puts("C");
            }
        }
    }

    return (0);
}

Measured memory_bytes: 1168
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception addd) {
					addd.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception addd) {
				addd.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	
	public static FastReader sc = new FastReader();
 
	//static int MOD = (int) (1e9+7),MAX=(int) (2e5);
    static List<Integer>[] edges;
  
	public static void main(String[] args) {
		precompute((int)3e5);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		long ans = 0;
	//	out.println(solve(n,m,n-1));
		for(int K=n-1;K>=n-k-1;--K) {
			ans = (ans + solve(n,m,K)%MOD)%MOD;
			//out.println(solve(n,m,K));
		}
	  out.print(ans);
		out.close();
   }
	static long solve(int n,int m,int k) {
		return mul(mul(mul(fac[n - 1], inv(mul(fac[k], fac[n - k - 1]))), m), pow(m - 1, k));
	}
	static final int MOD = 998244353;
	 
	static int add(int a, int b) {
		int res = a + b;
		return res >= MOD ? res - MOD : res;
	}
 
	static int sub(int a, int b) {
		int res = a - b;
		return res < 0 ? res + MOD : res;
	}
 
	static int mul(long r, long fac2) {
		int res = (int) ((long) r * fac2 % MOD);
		return res < 0 ? res + MOD : res;
	}
 
	static long pow(long fac2, int e) {
		if (e == 0) {
			return 1;
		}
		long r = fac2;
		for (int i = 30 - Integer.numberOfLeadingZeros(e); i >= 0; i--) {
			r = mul(r, r);
			if ((e & (1 << i)) != 0) {
				r = mul(r, fac2);
			}
		}
		return r;
	}
 
	static long inv(int a) {
		return pow(a, MOD - 2);
	}
 
	static long[] fac,inv;
	static void precompute(int n)
	{

		 fac = new long[n+1];
	     inv = new long[n+1];
		fac[0]=fac[1]=1;
		for(int i=2;i<fac.length;i++)
		{
			fac[i]=fac[i-1]*i;
			fac[i]%=MOD;
		}
		
		inv[n]=pow(fac[n],(int) (MOD-2));
		for(int i=n-1;i>=0;i--)
		{
			inv[i]=inv[i+1]*(i+1);
			inv[i]%=MOD;
		}
	}
 
	
	
}



Measured memory_bytes: 38020
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	int d;cin>>d;
	cout<<"Christmas";
	rep(i,25-d)cout<<" Eve";
	cout<<endl;
}

Measured memory_bytes: 256
from sys import stdin


def readline_from_stdin() -> str:
    return stdin.readline().rstrip


if __name__ == '__main__':
    N = int(input())
    S = [input() for i in range(0, N)]

    print("AC x", S.count("AC"))
    print("WA x", S.count("WA"))
    print("TLE x", S.count("TLE"))
    print("RE x", S.count("RE"))


Measured memory_bytes: 79192
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int num[3];
	int ans = 0;
	
	cin >> num[0] >> num[1] >> num[2];
	
	sort(num, num + 3);
	
	while (num[2] - num[1] > 1) {
		num[1] += 2;
		ans++;
	}
	
	while (num[1] - num[0] > 1) {
		num[0] += 2;
		ans++;
	}
	

	
	while (num[0] != num[1] || num[1] != num[2] || num[0] != num[2]) {
		num[0]++;
		num[1]++;
		ans++;
		sort(num, num + 3);
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
    
    
    


void solve() 
{
    int h,w;
    cin>>h>>w;
    char s[h][w];
    REP(i,h)REP(j,w)cin>>s[i][j];
    vector<vector<int> >d(h*w,vector<int>(h*w,INF));
    REP(i,h)REP(j,w){
        if(s[i][j]=='.'){
            int now=i*w+j;
            //cout<<i<<" "<<j<<" "<<now<<endl;
            d[now][now]=0;
            REP(k,4){
                int nx=i+dx[k],ny=j+dy[k];
                if(nx>=0&&ny>=0&&nx<h&&ny<w)if(s[nx][ny]=='.'){d[now][nx*w+ny]=1;d[nx*w+ny][now]=1;}
            }
        }
    }

    //REP(i,h*w){REP(j,h*w)cout<<(d[i][j]==INF?-1:d[i][j])<<" ";cout<<endl;}
    REP(k,h*w)REP(i,h*w)REP(j,h*w)if(d[i][k]!=INF&&d[k][j]!=INF&&s[k/w][k%w]!='#')d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    //REP(i,h*w){REP(j,h*w)cout<<(d[i][j]==INF?-1:d[i][j])<<" ";cout<<endl;}
    int ans=0;
    REP(i,h*w)REP(j,h*w)if(d[i][j]!=INF)ans=max(ans,d[i][j]);
    cout<<ans<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int A,B;

signed main(){
  cin >> A >> B;

  (A+B)%2==0 ? cout << (A+B)/2 << endl : cout << "IMPOSSIBLE" << endl;
  return 0;
}


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

#define pb push_back
#define rep(i, a, n) for(int (i)=a; (i)<(n); (i)++)
#define FOR(i, n) rep(i, 0, n)
#define F(n) FOR(i, n)
#define FF(n) FOR(j, n)
#define repi(i, a, n) for(int (i)=a; (i)<=(n); (i)++)
#define FORI(i, n) repi(i, 1, n)
#define FI(n) FORI(i, n)
#define FFI(n) FORI(j, n)
#define IN(x) int x; cin>>(x);
#define SIN(x) string x; cin>>x;
#define INN(x, y) int x, y; cin>>(x)>>(y);
#define INFO(a) cout<<"info "<<a<<endl
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define vpii vector<pair<int, int> >
#define sortv(x) sort((x).begin(), (x).end())
#define sortvd(x) sort((x).begin(), (x).end(), greater<int>())
#define lboundv(x,v) lower_bound((x).begin(),(x).end(),(v))-(x).begin();
#define uboundv(x,v) upper_bound((x).begin(),(x).end(),(v))-(x).begin();
#define ite iterator
#define fi first
#define se second
#define mems(a, v) memset((a), (v), sizeof((a)))
#define lmid(l, r) ((l)+(r)-1)/2
#define rmid(l, r) ((l)+(r))/2+1
#define mp make_pair

typedef long long ll;
typedef long double LD;

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	IN(n);
	cout<<(int) pow(((int) sqrt(n)), 2)<<endl;
	return 0;
}

Measured memory_bytes: 256
const main = stdin => {
  const input = stdin.trim().split('\n')
  const [D, N] = input[0].split(' ').map(x => parseInt(x))

  let num = N
  if (N === 100) {
    num = 101
  }

  if (D === 0) {
    console.log(num)
  } else if (D === 1) {
    console.log(num * 100)
  } else {
    console.log(num * 10000)
  }
}


// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 30584
#include <stdio.h>

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

void insertionSort(int A[], int N){
  int j, i, v;
  for (i = 1; i < N; i++){
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    trace(A, N);
   }
}

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

  scanf("%d", &N);
  for (i = 0; i < N; i++) scanf("%d", &A[i]);
  
  trace(A, N);
  insertionSort(A, N);

  return 0;
}
       

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n;
    cin>>n;
    vi a(n);
    vi b(n);
    FOR(i,0,n){
        cin>>a[i];
        b[a[i]-1]=i;
    }
    set<int> st;
    LL ans=0;
    st.insert(-1);
    st.insert(-2);
    st.insert(n);
    st.insert(n+1);
    st.insert(b[n-1]);

    FORD(i,n-1,0){
        st.insert(b[i]);
        auto itr=st.lower_bound(b[i]);
        auto r1=next(itr);
        auto r2=next(r1);
        auto l1=--itr;
        auto l2=--itr;
        auto r1v=*r1;
        auto r2v=*r2;
        auto l1v=*l1;
        auto l2v=*l2;
        if(r2v==n+1)r2v=n;
        if(l2v==-2)l2v=-1;
        ans+=1LL*(r2v-r1v)*(b[i]-l1v)*(i+1)+1LL*(l1v-l2v)*(r1v-b[i])*(i+1);
        //cerr<<ans<<endl;
    }
    cout<<ans;

}


Measured memory_bytes: 5760
import java.io.*;

public class Main {

  public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] in;
    in = br.readLine().split(" ");
    int n = Integer.parseInt(in[0]);
    int m = Integer.parseInt(in[1]);

    br.close();

    System.out.println((n * (n-1) + m * (m-1)) / 2);
    
  }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

int main(){
  ll n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  ll x=abs(a-b);
  for(int i=0;i<=n-1;i++){
    ll ma=d*(n-1-i*2)+(d-c)*i;
    ll mi=c*(n-1-i*2)-(d-c)*i;
    if(x>=mi&&x<=ma){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
struct SS{
    int a;//第几位
    int b;//位置上数字
}SS[10];
int main(){
    int i,j,n,m,sun;//sun用来判断-1的情况
    char x[10];
    scanf("%d%d",&n,&m);
    sun=0;
    for(i=0;i<m;i++){
        scanf("%d%d",&SS[i].a,&SS[i].b);
        if(n>1&&SS[i].a==1&&SS[i].b==0) sun++;//前导零情况
        if(SS[i].a>n) sun++;//位置数大于总共位置数
    }
    if(sun!=0) {
        printf("-1\n");
        return 0;
    }
    x[0]='1';
    if(n==1&&m==0) x[0]='0';//注意：当一位数不输入时结果为0
    for(i=1;i<n;i++)
        x[i]='0';//字符串值初始化
    for(i=0;i<m;i++){
        for(j=0;j<m;j++){
            if(SS[i].a==SS[j].a&&SS[i].b!=SS[j].b) sun++;//判断是否有位置相同数不同的情况
        }
    }
    if(sun!=0) {
        printf("-1\n");
        return 0;
    }
    for(i=0;i<n;i++){
        x[SS[i].a-1]=(SS[i].b+'0');//把相应位置数给字符串
    }
    for(i=0;i<n;i++)
        printf("%c",x[i]);
        printf("\n");
    return 0;
}


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

typedef long long lint;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const lint inv = MOD - 2;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

typedef pair<int, int> P;

int main(){
    int n;
    cin >> n;
    vector<P> x(n);
    rep(i, n){
        cin >> x[i].first;
        x[i].second = i;
    }
    SORT(x);
    vector<int> ans(n);
    rep(i, n){
        if(i < n/2){
            ans[x[i].second] = x[n/2].first;
        }else{
            ans[x[i].second] = x[n/2-1].first;
        }
    }
    rep(i, n){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4480
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		int K = sc.nextInt();
		boolean[] add = new boolean[N];
		long[][] a = new long[N][];
		for (int i = 0; i < N; ++i) {
			int t = sc.nextInt() - 1;
			long d = sc.nextLong();
			a[i] = new long[] { d, t };
		}

		PriorityQueue<Long> ind = new PriorityQueue<>();
		PriorityQueue<Long> not = new PriorityQueue<>();
		Arrays.sort(a, new Comparator<long[]>() {
			@Override
			public int compare(long[] o1, long[] o2) {
				return Long.compare(-o1[0], -o2[0]);
			}
		});

		long tot = 0;
		int independent = 0;
		for (int i = 0; i < N; ++i) {
			if (independent == K || add[(int) a[i][1]]) {
				not.add(-a[i][0]);
				continue;
			}
			if (independent < K) {
				ind.add(a[i][0]);
				tot += a[i][0];
				add[(int) a[i][1]] = true;
				++independent;
			}
		}
		int sz = 0;
		long ans = 0;
		for (int i = independent; i >= 0; --i) {
			while (sz + i < K) {
				tot += -not.poll();
				++sz;
			}
			ans = Math.max(ans, tot + (long) i * i);
			if (i > 0) {
				long rm = ind.poll();
				tot -= rm;
				not.add(-rm);
			}
		}
		System.out.println(ans);
	}

	void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

}

class Scanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}
}


Measured memory_bytes: 34128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
using namespace std;
using ll=long long;
using R=double;

int W,H;

int t[50][50];

void visit(int h,int w){
  t[h][w]=0;
  for(int nh=h-1;nh<h+2;nh++){
    for(int nw=w-1;nw<w+2;nw++){
      if(t[nh][nw]==1&&0<=nh&&0<=nw&&nh<H&&nw<W)visit(nh,nw);
    }
  }
}

int main(void){
  int a,b,c,n;
  while(1){
    cin>>W>>H;
    c=0;
    if(W==0&&H==0)break;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
    cin>>t[i][j];
      }
    }
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
    if(t[i][j]==1){
      c++;
      visit(i,j);
    }
      }
    }
    cout<<c<<endl;
  }
}



Measured memory_bytes: 3172
use proconio::{fastout, input};
use std::io::*;
use std::str::FromStr;

use std::cmp::{max, min};
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};

fn main() {
    input! {
        x: i64,
        y: i64,
    }
    if (x - y).abs() <= 1 {
        println!("Brown");
    } else {
        println!("Alice");
    }
}


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

using namespace std;

int main () {
	long long i, o, t, j, l, s, z;
	cin >> i >> o >> t >> j >> l >> s >> z;
	long long ans = o * 2;
	long long ans1 = 0, ans2 = 0;
	ans2 += ((j / 2) * 4 + (l / 2) * 4 + (i / 2) * 4);
	long long mn = min (1ll, min (min (j, l), i));
	ans1 += 6 * mn;
	j -= mn;
	i -= mn;
	l -= mn;
//	cout << ans << endl;
	ans1 += ((j / 2) * 4 + (l / 2) * 4 + (i / 2) * 4);
	cout << ans / 2 + max (ans1, ans2) / 2;
	return 0;
}                                                                        

Measured memory_bytes: 256
use std::io::*;

fn read_str() -> String {
  let mut buf = String::new();
  stdin().read_line(&mut buf).ok();
  buf.trim().to_string()
}

fn main() {
  let s = read_str();
  let ans = if s.chars().any(|c| c=='9') {"Yes"} else {"No"};
  println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
const int INF = 1e9;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int solve() {
    int H, W;
    cin >> H >> W;
    vector<string> G(H);
    vector<vector<int>> dist(H, vector<int>(W, INF));
    rep(i, 0, H) cin >> G[i];
    int white = 0;
    rep(i, 0, H) rep(j, 0, W) {
        if(G[i][j] == '.') white++;
    }
    using P = pair<int, int>;
    queue<P> Q;
    Q.push(P(0, 0));
    dist[0][0] = 1;
    while(!Q.empty()) {
        P p = Q.front(); Q.pop();
        int y = p.first, x = p.second;
        rep(i, 0, 4) {
            int ny = y + dy[i], nx = x + dx[i];
            if(ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
            if(G[ny][nx] == '.') {
                Q.push(P(ny, nx));
                dist[ny][nx] = dist[y][x] + 1;
                G[ny][nx] = '#';
                if(ny == H - 1 && nx == W - 1) return white - dist[ny][nx];
            }
        }
    }
    return -1;
}

int main() {
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdlib>
#define ll long long
using namespace std;
int main()
{
	ll a;
	double b;
	scanf("%lld %lf",&a,&b);
	b=b+1e-7;
	ll c=b*100;
	ll d=c*a/100;
	printf("%lld",d);
}

Measured memory_bytes: 3760
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static boolean solve() {
		int n = in.nextInt();
		if (n == 0) return false;
		int sa = 0, sb = 0;
		for (int i=0; i<n; i++) {
			int a = in.nextInt();
			int b = in.nextInt();
			if (a == b) {
				sa += a;
				sb += b;
			} else if (a > b) {
				sa += a + b;
			} else {
				sb += a + b;
			}
		}
		out.println(sa+" "+sb);
		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.currentTimeMillis();

		while(solve());
		out.flush();

		long end = System.currentTimeMillis();
		dump((end-start) + "ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 57936
/*input
2 3 1
3 3
3 3 3
1 2 1
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = unsigned long long;
using ld = long double;
using pii = pair<ll,ll>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=1e18;
const int INF=1e6+1;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
int arr[maxn],arr2[maxn],sarr[maxn],sarr2[maxn];
int main(){
    int a,b,m;
    cin>>a>>b>>m;
    REP(i,a) cin>>arr[i],sarr[i]=arr[i];
    REP(i,b) cin>>arr2[i],sarr2[i]=arr2[i];
    sort(sarr,sarr+a);
    sort(sarr2,sarr2+b);
    int ans=sarr[0]+sarr2[0];
    REP(i,m){
        int x,y,z;
        cin>>x>>y>>z;
        --x;
        --y;
        MNTO(ans,arr[x]+arr2[y]-z);
    }
    cout<<max(ans,0);
}

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

namespace ABC113B
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int N = Input.Int();
            int[] ints = Input.IntArray();
            int T = ints[0];
            int A = ints[1];
            int[] H = Input.IntArray();

            double diff = int.MaxValue;
            int ans = -1;
            for (int i = 0; i < H.Length; i++)
            {
                if (diff > Math.Abs(A - T + H[i] * 0.006))
                {
                    diff = Math.Abs(A - T + H[i] * 0.006);
                    ans = i;
                }
            }
            Console.WriteLine(ans + 1);
        }
    }
    
    
    internal static class Input
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

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

int main() {
  string a,b,c;
  cin>>a>>b>>c;
  char d = toupper(a[0]);
  char e = toupper(b[0]);
  char f = toupper(c[0]);
  cout<<d<<e<<f<<endl;
  return 0;
}

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

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "Yes" : "No")

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

const int siz = 2e5 + 10;
const int SIZ = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e18;
const string file = "3";



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

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    string s;
    cin >> s;

    if (s.back() == 's') {
        cout << s + "es" << "\n";
    }
    else {
        cout << s + "s" << "\n";
    }

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


Measured memory_bytes: 3660
sub f{$K=0;$K+=$_ for@_;$K}<>=~$";$s=f@@=glob<>;printf sort{$b-$a}grep{$d=$_;$'>=f@_[0..(@_=sort{$a-$b}map$_%$d,@@)-&f/$d-1]}map$s%$_?():($_,$s/$_),1..3e4

Measured memory_bytes: 3328
#include<stdio.h>
int main(){
  int n,m,k,i,j;
  scanf("%d%d",&n,&m);
  int a[m+1],b;
  for(i=0;i<m;i++)
    a[i]=0;
  for(i=0;i<n;i++){
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&b);
      a[b-1]++;
    }
  }
  int count=0;
  for(i=0;i<m;i++)
    if(a[i]==n)
      count++;
  printf("%d\n",count);
  return 0;
}


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

MOD = 1000000007

if abs(N - M) > 1:
    print(0)
    exit(0)

dogs = 1
for i in range(1, N + 1):
    dogs *= i
    dogs %= MOD

monks = 1
for i in range(1, M + 1):
    monks *= i
    monks %= MOD

res = (dogs * monks) % MOD
if (N + M) % 2 == 0:
    res *= 2
    res %= MOD

print(res)


Measured memory_bytes: 39408
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	n = INT()
	if n == 0:
		print(0)
		sys.exit()
		
	ans = []
	while n != 0:
		ans.append((n % (-2))*(-1))
		if n%(-2) < 0:
			n = n//(-2) + 1
		else:
			n = n//(-2)

	print(*ans[::-1], sep = '')


if  __name__=='__main__':
    main()


Measured memory_bytes: 5144
S = gets.chomp

class Object
  def yield_self
    yield(self)
  end
end

def is_probably_month?(i)
  return i > 0 && i < 13
end

puts begin
  S.yield_self do |s|
    break "NA" unless S =~ /^[0-9]{4}$/
    head, tail = [ s[0..1], s[2..3] ].map(&:to_i)
    break "AMBIGUOUS" if is_probably_month?(head) && is_probably_month?(tail)
    break "MMYY" if is_probably_month?(head)
    break "YYMM" if is_probably_month?(tail)
    "NA"
  end
end


Measured memory_bytes: 1788
package main

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

func main() {
	nextReader = newScanner()
	n := nextInt()
	s := nextString()

	r := strings.Replace(s, "ABC", "", -1)
	fmt.Println((n - len(r)) / 3)
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
h, w = map(int,input().split()) 
a = []
for i in range(h):
    a.append(list(str(input())))

tmp = [[0 for _ in range(w)] for _ in range(h)] 
for i in range(h):
    for j in range(w):
        if a[i][j] == '.':
            tmp[i][j] = 0
        else:
            tmp[i][j] = 1

memo = []
for i in range(h):
    if sum(tmp[i]) == 0:
        memo.append(i)
memo2 = []
for i in range(w):
    sum_tmp = 0
    for j in range(h):
        sum_tmp += tmp[j][i]
    if sum_tmp == 0:
        memo2.append(i)

for i in range(h):
    if not i in memo:
        for j in range(w):
            if not j in memo2:
                print(a[i][j], end = '')
        print('')


Measured memory_bytes: 4596
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int ans=0;
  int cnt=0;
  rep(i,S.size()){
    if(S[i]=='2'){
      cnt++;
      ans+=(i==((N-1)&i));
      ans%=2;
    }
  }
  if(ans){
    cout<<1<<endl;
    return 0;
  }
  if(cnt){
    cout<<0<<endl;
    return 0;
  }
  rep(i,S.size()){
    if(S[i]=='3'){
      ans+=(i==((N-1)&i));
      ans%=2;
    }
  }
  ans*=2;
  cout<<ans<<endl;
}

Measured memory_bytes: 1412