akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<ll,int>
#define F first
#define S second
#define ld long double
int const M=1000+10,M2=1e3+10,mod=1e9+7,inf=1e9+10;
int cnt=1;
vector<int>ans1,ans2;
void fans(int x)
{
	if(x==0)return;
	if(x%2==0)fans(x-1);
	else
		fans(x/2);
	if(x%2==0)
	{
		reverse(ans1.begin(),ans1.end());
		ans1.pb(cnt);
		reverse(ans1.begin(),ans1.end());
		ans2.pb(cnt);
		cnt++;
	}
	else
	{
		ans1.pb(cnt);
		ans2.pb(cnt);
		cnt++;
	}
}
int32_t main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	//n++;
	fans(n);
	cout<<ans1.size()*2<<endl;
	for(int i=0;i<ans1.size();i++)cout<<ans1[i]<<" ";
	for(int i=0;i<ans2.size();i++)cout<<ans2[i]<<" ";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll h[100000];
ll tmp[100000];
ll n,a,b;
bool judge(ll k){
  for(int i=0;i<n;++i){
    tmp[i]=h[i]-b*k;
  }    
  ll cnt=0;
  for(int i=0;i<n;++i){
    if(tmp[i]>0){
      cnt+=tmp[i]/(a-b);
      if(tmp[i]%(a-b))
	++cnt;
    }
  }
  return (cnt<=k);
}
int main(){
  cin>>n>>a>>b;
  for(int i=0;i<n;++i)
    cin>>h[i];
  sort(h,h+n);
  reverse(h,h+n);
  ll lb=0;
  ll ub=1<<30;
  for(int i=0;i<61;++i){
    ll k = (lb+ub)/2;
    if(judge(k))
      ub = k;
    else
      lb = k;
  }
  cout << ub << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<math.h>
using namespace std;

int main() {
	int N, X;
	cin >> N >> X;
	int m[109];
	for (int i = 0; i < N; i++) {
		cin >> m[i];
		X -= m[i];
	}
	sort(m, m + N);
	cout << N + X / m[0];
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
  int a1,a2,a3;
  scanf("%d",&a1);
  scanf("%d",&a2);
  scanf("%d",&a3);
  if(a1+a2+a3>=22) {
    printf("bust\n");
  } else {
    printf("win\n");
  }
  
  return 0;
  

}


Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  char X,Y;
  cin>>X>>Y;
  if(X>Y)cout<<'>'<<endl;
  else if(X<Y)cout<<'<'<<endl;
  else cout<<'='<<endl;
  return 0;
}


Measured memory_bytes: 256
//   PIGMEISTER™   //

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define modinv(x) powah(x,mod-2)
#define ncr(n,r) (((fact[n]*modinv(fact[n-r]))%mod*modinv(fact[r]))%mod)
#define factorial fact.pb(1);sidha(i,1,MAX)fact.pb((fact[i-1]*i)%mod)
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod (ll)1000000007
//#define mod (ll)998244353
#define MAX 100005

int main()
{
    jaldi;
    
    long double r;
    cin >> r;
    long double pi = 3.141592;
    cout << fixed << setprecision(10) << (double)2*pi*r;
    
    return 0;
}


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

int main (){
    int N, M;
    cin>>N>>M;
    vector<vector<int>> Jobs(M);
    for(int i=0; i<N; i++){
        int A, B;
        cin>>A>>B;
        if(A<M+1){
            Jobs.at(A-1).push_back(B);
        }
    }
    
    long long Sum=0;
    priority_queue<int> Can;
    for(int i=0; i<M; i++){
        while(!Jobs.at(i).empty()){
            Can.push(Jobs.at(i).at(Jobs.at(i).size()-1));
          	Jobs.at(i).pop_back();
        }
        if(!Can.empty()){
            Sum += Can.top();
            Can.pop();
        }
    }
    cout<<Sum<<endl;

}

Measured memory_bytes: 5632
package main

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

func gcd(A int, B int) int {

	if B == 0 {
		return A
	}
	return gcd(B, A%B)
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - Skip
	var N, X int
	fmt.Scanf("%d %d", &N, &X)

	sc.Split(bufio.ScanWords)
	x := make([]int, N)
	for i := 0; i < N; i++ {
		x[i] = nextInt()
	}

	diff := make([]int, N)
	for i := 0; i < N; i++ {
		diff[i] = int(math.Abs(float64(X - x[i])))
	}

	var ans int = diff[0]
	for i := 1; i < N; i++ {
		ans = gcd(ans, diff[i])
	}

	fmt.Println(ans)
}


Measured memory_bytes: 5040
module.exports=function(r){var e={};function t(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=r,t.c=e,t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},t.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},t.t=function(r,e){if(1&e&&(r=t(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var o in r)t.d(n,o,function(e){return r[e]}.bind(null,o));return n},t.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(e,"a",e),e},t.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},t.p="",t(t.s=0)}([function(r,e,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(r,e,t){"use strict";function n(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=[],n=!0,o=!1,u=void 0;try{for(var i,f=r[Symbol.iterator]();!(n=(i=f.next()).done)&&(t.push(i.value),!e||t.length!==e);n=!0);}catch(r){o=!0,u=r}finally{try{n||null==f.return||f.return()}finally{if(o)throw u}}return t}(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}r.exports=function(r){for(var e=Number(r[0]),t=[],o=[],u=0;u<e;u++){var i=n(r[u+1].split(" ").map(function(r){return Number(r)}),2),f=i[0],a=i[1];t.push(f),o.push(a)}for(var l=new Map,c=0;c<e;c++)for(var p=0;p<e;p++)if(c!=p){var s=`${t[c]-t[p]}:${o[c]-o[p]}`;l[s]||(l[s]=0),l[s]++}var d=0;for(var v in l)l[v]>d&&(d=l[v]);var y=e-d;console.log(y)}},function(r,e){r.exports=require("fs")}]);

Measured memory_bytes: 11724
n,m=[int(x) for x in input().split()]
edges=[[] for x in range(n)]
for i in range(m):
    a,b=[int(x)-1 for x in input().split()]
    edges[a].append(b)
    edges[b].append(a)
def ans(path):
    if len(path)==n:
        # print([x+1 for x in path])
        return 1
    res=0
    for i in range(n):
        if not i in path and  i in edges[path[-1]]:
            res+=ans(path+[i])
    return res
print(ans([0]))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	int N, K; cin >> N >> K;
	map<int, int>mp;
	rep(i, N) {
		int a; cin >> a;
		mp[a]++;
	}
	vector<int>vec;
	for (auto p : mp) {
		vec.push_back(p.second);
	}
	SORT(vec);
	int ans = 0;
	rep(i, vec.size() - K) {
		ans += vec[i];
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 10748
class BIT():
    def __init__(self, n):
        self.size = n
        self.bit = [0] * (n + 1)

    def _sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def add(self, i, val):
        i += 1
        while i <= self.size:
            self.bit[i] += val
            i += i & -i

    def get_sum(self, l, r):
        return self._sum(r) - self._sum(l)


n = int(input())
a = list(map(int, input().split()))
bit = BIT(n)
for i in range(n):
    bit.add(i, a[i])

a = [[a[i], i] for i in range(n)]
a = sorted(a, reverse=True)
INF = 10 ** 18

l = 0
r = n - 1
dp = [[-INF] * (n + 1) for i in range(n + 1)]
dp[0][0] = 0
for ind in range(n):
    val, i = a[ind]
    # left
    for j in range(n):
        dp[ind + 1][j + 1] = max(dp[ind][j] + abs(i - j) * val, dp[ind + 1][j + 1])
    # right
    for j in range(n):
        r_cnt = ind - j
        dp[ind + 1][j] = max(dp[ind][j] + abs(n - i - r_cnt - 1) * val, dp[ind + 1][j])

print(max(dp[-1]))

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

#define INF 1e9
using namespace std;

int main() {

    int N, M, X, Y; cin >> N >> M >> X >> Y;

    int max_x = -INF;
    for (int i = 0; i < N; ++i) {
        int x; cin >> x;
        max_x = max(max_x, x);
    }
    max_x = max(max_x, X);

    int min_y = INF;
    for (int j = 0; j < M; ++j) {
        int y; cin >> y;
        min_y = min(min_y, y);
    }
    min_y = min(min_y, Y);

    if (max_x < min_y) {
        cout << "No War" << endl;
    } else {
        cout << "War" << endl;
    }
}

Measured memory_bytes: 256
using System;

class CF2016QBB
{
	static public void Main(string[] args)
	{
		int N, A, B;
		string[] vals = Console.ReadLine().Split(' ');
		N = int.Parse(vals[0]);
		A = int.Parse(vals[1]);
		B = int.Parse(vals[2]);
		string S = Console.ReadLine();

		int passed = A + B;
		int passedb = B;

		foreach(var c in S)
		{
			switch(c)
			{
				case 'a':
					if(passed > 0)
					{
						passed--;
						Console.WriteLine("Yes");
					}
					else
					{
						Console.WriteLine("No");
					}
					break;

				case 'b':
					if(passed > 0 && passedb > 0)
					{
						passed--;
						passedb--;
						Console.WriteLine("Yes");
					}
					else
					{
						Console.WriteLine("No");
					}
					break;

				case 'c':
					Console.WriteLine("No");
					break;
			}
		}
	}
}


Measured memory_bytes: 15548
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
    int w, h, n, x, y, a, ans=0;
    bool brd[103][103];
    memset(brd, false, sizeof(brd)); //false... white, true...black
    cin>>w>>h>>n;
    for (int i=0; i<n; i++)
    {
        cin>>x>>y>>a;
        if (a==1)
        {
            if (x==0) continue;
            for (int j=1; j<=x; j++) for (int k=1; k<=h; k++) brd[j][k]=true;
        }
        if (a==2)
        {
            if (x==w) continue;
            for (int j=x+1; j<=w; j++) for (int k=1; k<=h; k++) brd[j][k]=true;
        }
        if (a==3)
        {
            if (y==0) continue;
            for (int j=1; j<=y; j++) for (int k=1; k<=w; k++) brd[k][j]=true;
        }
        if (a==4)
        {
            if (y==h) continue;
            for (int j=y+1; j<=h; j++) for (int k=1; k<=w; k++) brd[k][j]=true;
        }
    }
    for (int i=1; i<=w; i++)
    {
        for (int j=1; j<=h; j++) if (!brd[i][j]) ans++;
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "Jin.hpp"
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define debug(var) std::cout << #var << " : " << var;

int main(){

	int N,A,B; std::cin >> N >>A >>B;

	if(N * A > B)std::cout << B;
	else std::cout << N*A;

	return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	//tmp = input[1].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
    var n = parseInt(input[0], 10);
    var p = input;
    p.shift();
    var maps = {};
    var m = 1;
    var str1 = [];
    var str2 = "";


    for(var i =0; i<n; i++){
        var str = p[i];
        if(!maps[str]){
            maps[str] = {'str':str,'count':1};
        }
        if(maps[str]){
            maps[str]['count'] +=1;
            var k = maps[str]['count'];
            if(k>m){
                m=k;
            }

        }
    }

    for(var obj in maps){
        if(maps[obj]['count']==m){
            str1.push(maps[obj]['str']);
        }
    }
    
    if(str.length>1){
        str2 = str1.slice();
        str2.sort();
        for(var j=0;j<str2.length;j++){
            console.log(str2[j]);
        }

    }else{
        console.log(str1);
    }
    

    

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


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


int main(){
	string s;
	cin>>s;
	
	for(int i=0;i<s.size();i++){
		if(s[i]==s[i+1]){
			cout<<i+1<<" "<<i+2;
			return 0;
		}
	}
	
	for(int i=0;i<s.size();i++){
		if(s[i]==s[i+2]){
			cout<<i+1<<" "<<i+3;
			return 0;
		}
	}
	
	cout<<-1<<" "<<-1;
}

Measured memory_bytes: 512
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;

namespace 水色コーダーに俺はなった{
    class Inonoa{

        /* ここに書け */
        static void Main(){
            char[] s = IChars();
            char[] t = IChars();

            for(int i=0;i<s.Length;i++){
                if(s[i]!=t[i]){
                    WriteLine("No");
                    return;
                }
            }
            WriteLine("Yes");
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

Measured memory_bytes: 25876
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	int a,b; cin >> a >> b;
	int answer = max(a + b, max(a - b, a * b));
	cout << answer << endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
int main() {
	cin >> N >> K;
	vl L(100001);
	for (i = 0; i < N; i++) {
		ll a, b;
		cin >> a >> b;
		L[a - 1] += b;
	}
	for (i = 0; i <= 100000; i++) {
		K -= L[i];
		if (K <= 0) {
			cout << i + 1;
			exit(0);
		}
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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; }

bool compare(string a, string b) {
    if (a.size() > b.size()) return true;
    else if (a.size() < b.size()) return false;
    else {
        for (long long i = 0; i < a.size(); i++) {
            if (a[i] > b[i]) return true;
            else if (a[i] < b[i]) return false;
        }
    }
    return true;
}


string add(string a, string b) {
    bool x = false, y = false;
    if (a[0] == '-') x = true;
    if (b[0] == '-') y = true;

    if (x && y) return '-' + add(a.substr(1, a.size()-1), b.substr(1, b.size()-1));
    else if (x) return add(b, a);
    // 'a - b' or 'a + b'

    if (y) b = b.substr(1, b.size()-1);
    if (y && !compare(a, b)) {
        return '-' + add(b, '-' + a);
    }

    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());

    string res = "";
    long long up = 0;

    for (long long i = 0; i < max(a.size(), b.size()); i++) {
        long long tmp = up;
        if (i < a.size()) {
            tmp += (a[i] - '0');
        }
        if (i < b.size() && b[i] != '-') {
            if (y) tmp -= (b[i] - '0');
            else tmp += (b[i] - '0');
        }

        if (tmp < 0) {
            res.push_back((10 + tmp) + '0');
            up = -1;
        }
        else if (tmp > 9) {
            res.push_back((tmp - 10) + '0');
            up = 1;
        }
        else {
            res.push_back(tmp + '0');
            up = 0;
        }
    }

    if (up > 0) res.push_back(up + '0');

    reverse(res.begin(), res.end());

    long long begin = 0;
    while (res[begin] == '0') begin++;
    
    if (res.size() == begin) return "0";
    else return res.substr(begin, res.size() - begin);
}

int main(){
    string a, b;
    cin >> a >> b;
    if (b[0] == '-') b = b.substr(1, b.size() - 1);
    else b = '-' + b;
    cout << add(a, b) << endl;
    return 0;
}


Measured memory_bytes: 3912
#include <iostream>

using namespace std;

int main() {
    int k, sum;
    while (cin >> k) {
        if (k == 0) break;
        sum = 0;
        for (int i = 0; i < k * (k-1) / 2; i++) {
            int t; cin >> t;
            sum += t;
        }
        cout << sum / (k-1) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_4_B
// Kahn's algorithm
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(int argc, char **argv)
{
        int V, E;
        cin >> V >> E;
        vector<vector<pair<int, int>>> A(V);
        vector<int> B(V);
        for (int i = 0; i < E; i++) {
                int s, t;
                cin >> s >> t;
                A[s].push_back({t, 0});
                B[t]++;
        }
        int edges = E;
        vector<int> L;
        queue<int> S;
        for (int i = 0; i < V; i++)
                if (!B[i])
                        S.push(i);
        while (!S.empty()) {
                auto c = S.front();
                S.pop();
                L.push_back(c);
                for (auto &a: A[c]) {
                        if (a.second)
                                continue;
                        a.second = 1;
                        edges--;
                        if (--B[a.first] == 0)
                                S.push(a.first);
                }
        }
        if (edges > 0) {
                cout << "Found cyclic path" << endl;
        }
        else {
                for (auto l: L)
                        cout << l << endl;
        }
        return 0;
}

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


int main()
{
	int n = 0;
	int a = 0;
	int x = 0;
	cin >> n;
	cin >> a;
	x = n % 500;
	if (x <= a) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
    return 0;
}



Measured memory_bytes: 256
/*
 * Author       : YangDavid
 * Created Time : 2019年10月05日 星期六 20时05分06秒
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


ll calc(string str) {
    vector<pair<char, int> > v;
    for(auto c : str) {
        if(v.empty() || c != v.back().first) {
            v.emplace_back(c, 1);
        } else v.back().second++;
    }
    int cnt = 0;
    for(auto g : v) cnt += g.second / 2;
//    cout << "Calc " << str << " = " << cnt << endl;
    return cnt;
}
string s;
ll n, k;
int main() {
    cin >> s >> k;
    n = s.length();
    int same = true;
    for(auto c: s) if(c != s[0]) same = false;
    if(same) {
        ll cnt = (n * k) / 2;
        printf("%lld\n", cnt);
        return 0;
    }
    string s2 = s, s3 = "", s4 = "";
    while(s2.back() == s[0]) s2.pop_back(), s3 += s[0];
    s4 = s3 + s2;
    printf("%lld\n", calc(s2) + (k - 1) * calc(s4) + (s3.length() / 2));

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main 
{
	static int n, s, count;
	public static void DFS(int sum, int pre, int depth)
	{
		if(depth > n || sum > s)
		{
			return;
		}
		else if(n == depth && s == sum)
		{
			++count;
			return;
		}
		else
		{
			for(int i = pre + 1; i < 10; ++i)
			{
				DFS(sum + i, i, depth + 1);
			}
		}
	}
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			n = stdIn.nextInt();
			s = stdIn.nextInt();
			if(n == 0 && s == 0)
			{
				break;
			}
			count = 0;
			for(int i = 0; i < 10; ++i)
			{
				DFS(i, i, 1);
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 18060
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;
// static const int max_n = 110;
// static const llong max_cost = 2000000000000000;
// // vector<vector<llong>> matrix(max_n, vector<llong>(max_n, 0));
// // vector<vector<llong>> adj_matrix(max_n, vector<llong>(max_n, max_cost));
// vector<vector<pair<llong, int>>> adj_list(max_n);
// vector<llong> distance_table(max_n, max_cost);
// set<pair<llong, int>> points_sort_x;
// set<pair<llong, int>> points_sort_y;

// int N;



int main(){
    // int u, v;
    // bool updated = false;
    ll N, M;
    scanf("%lld %lld", &N, &M);

    ll ans = N * (N - 1) / 2 + M * (M-1) / 2;

    printf("%lld\n", ans);

    return 0;

}

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

int main(){
	int ver, hor;
	cin >> ver >> hor;
	cout << ver * hor <<  " " << (ver + hor) * 2 << endl;
	//cout << (a*b) << " "<< (a+b)*2 << endl;
	
	return 0;
}


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

int main(){
	char trash;
	double x[4], y[4];
	while(cin >> x[0] >> trash >> y[0]){
		double a,b,c,d,e,f,t,r;
		for(int i = 1; i < 4; i++){
			cin >> trash >> x[i] >> trash >> y[i];
		}
		a = y[2]-y[0];
		b = -x[2]+x[0];
		e = -1*(y[0]*(x[2]-x[0])-x[0]*(y[2]-y[0]));
		c = y[3]-y[1];
		d = -x[3]+x[1];
		f = -1*(y[1]*(x[3]-x[1])-x[1]*(y[3]-y[1]));
		t = (e*d-b*f)/(a*d-b*c);
		r = (a*f-c*e)/(a*d-b*c);
		if(x[2] < x[0]){
			swap(x[0],x[2]);
		}
		if(x[3] < x[1]){
			swap(x[1],x[3]);
		}
		if(y[2] < y[0]){
			swap(y[0],y[2]);
		}
		if(y[3] < y[1]){
			swap(y[1],y[3]);
		}
		if((t >= x[0] && t <= x[2]) && (t >= x[1] && t <= x[3]) && (r >= y[0] && r <= y[2]) && (r >= y[1] && r <= y[3])){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 1224
# ABC 065 D Built?
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)

    def find_root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.find_root(self.root[x])
            return self.root[x]
        
    def unite(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
                
    def is_same_group(self, x, y):
        return self.find_root(x) == self.find_root(y)

    def count(self, x):
        return -self.root[self.find_root(x)]


N=int(input())
towns=[]
for i in range(N):
    x,y=map(int,input().split())
    towns.append((x,y,i))
    
path=[]
A=sorted(towns,key=lambda x:x[0])
for i in range(N-1):
    path.append((A[i][2],A[i+1][2],min(abs(A[i][0]-A[i+1][0]),abs(A[i][1]-A[i+1][1]))))
A=sorted(towns,key=lambda x:x[1])
for i in range(N-1):
    path.append((A[i][2],A[i+1][2],min(abs(A[i][0]-A[i+1][0]),abs(A[i][1]-A[i+1][1]))))

path.sort(key=lambda x:x[2], reverse=True)
uf=UnionFind(N)
res=0
path_num=0
while 1:
    i,j,c=path.pop()
    if not uf.is_same_group(i,j):
        uf.unite(i,j)
        path_num+=1
        res+=c
    if path_num==N-1:
        break
print(res)

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

typedef long long ll;

int main() {
  ll N, M;
  cin >> N >> M;

  ll ans;
  if (N > M) {
    ans = M / 2;
  } else {
    if (M >= N * 2) {
      M -= N * 2;
      ans = N + M / 4;
    } else {
      ans = M / 2;
    }
  }

  // 解答
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	long long int A,B,C,D; 
	cin >> A >> B >> C >> D;
    long long int x[C+2][D+2];
    x[C][D]=1;
  	for(int j=1;j<D+2;j++){
    x[C+1][j]=0;
    }
    for(int i=1;i<C+2;i++){
    x[i][D+1]=0;
    }
    for(int j=D-1;j>0;j--){
    x[C][j]=(C*x[C][j+1]+j*x[C+1][j]+998244353-(C*j*x[C+1][j+1] %  998244353)) % 998244353;
    }
    for(int i=C-1;i>0;i--){
	    for(int j=D;j>0;j--){
    	x[i][j]=(i*x[i][j+1]+j*x[i+1][j]+998244353-(i*j*x[i+1][j+1] %  998244353)) %  998244353;
    	}
    }
    	cout << x[A][B] << endl;
}

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

int main() {
  int N; cin >> N;
  long sum = 0;
  for (int n = 1; n < N; n++) {
    long product = 1;
    int m = n;
    for (int i = 2; i <= m / i; i++) {
      int cnt = 0;
      while (m % i == 0) {
        m /= i;
        cnt++;
      }
      product *= cnt + 1;
    }
    if (m > 1) product *= 2;
    sum += product;
  }
  cout<<sum<<endl;
}

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

int main()
{
	int K;
	cin >> K;

	if (K % 2 == 0 || K % 5 == 0) 
	{
		cout << -1;
		return 0;
	}

	int ans = 0;
	int rem = K;
	while(true)
	{
		while(rem % 10 != 7) rem += K;
		rem /= 10;
		ans++;
		if (rem == 0) break;
	}
	cout << ans;
	cin >> K;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){

    int h, w;
    while(1){
        cin >> h >> w;
        if( h == 0 && w == 0 )break;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if( i % 2 == 0){
                    if(j % 2 == 0){
                        cout << '#';
                    }else{
                        cout << '.';
                    }
                }else{
                    if(j % 2 == 0){
                        cout << '.';
                    }else{
                        cout << '#';
                    }
                }
            }
            cout << endl;
        }
        cout << endl;

    }

}


Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>

using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int k,x;
  cin >> k >> x;
  for (int i = x - (k - 1); i < x + k; i++){
    cout << i << ' ';
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;

ll ans = 0;
ll N, M, Q;
vector<ll> A(Q), B(Q), C(Q), D(Q);

int dfs(vector<ll> AN){
    //for(int i = 0; i < AN.size(); i++) cout << AN[i] << " ";
    //cout << endl;
    if(AN.size() == N){
        ll score = 0;
        for(int i = 0; i < Q; i++){
            if(AN[B[i]-1] - AN[A[i]-1] == C[i]) score += D[i];
        }
        ans = max(ans, score);
        return 0;
    }
    int n = AN.size();
    ll temp = AN[n-1];
    for(int i = temp; i <= M; i++) {
        vector<ll> V = AN;
        V.push_back(i);
        dfs(V);
    }
    return 0;
}

int main(){
    cin >> N >> M >> Q;
    A.resize(Q);
    B.resize(Q);
    C.resize(Q);
    D.resize(Q);
    for(int i = 0; i < Q; i++) cin >> A[i] >> B[i] >> C[i] >> D[i];
    vector<ll> AN = {1};
    dfs(AN);
    cout << ans << endl;

}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var A = ReadArrayInt();
            var multiT = 0;
            var multiF = 0;
            for (int i = 0; i < N; i++)
            {
                if (A[i] % 4 == 0) multiF++;
                else if (A[i] % 2 == 0) multiT++;
            }
            var suc = false;
            if (multiF >= N / 2) suc = true;
            N = N - 2 * multiF;
            if (multiT >= N) suc = true;

            Console.WriteLine(suc ? "Yes" : "No");
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 19680
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long c = sc.nextLong();
		long k = sc.nextLong();
		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextLong();
		}
		Arrays.sort(arr);

		int wait = 1;
		long waitTime = arr[0];
		int result = 1;
		for(int i = 1; i < n; i++) {
			if(wait==c || arr[i] - waitTime > k) {
				result++;
				wait = 0;
				waitTime=arr[i];
			}
			wait++;
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 50144
n = int(input())
s = input()
point = [0]

def we_counter(pos):
  front = s[:pos]
  back = s[pos+1:]
  people = front.count('W') + back.count('E')
  return people


for i in range(n):
  if s[i] == 'W':
    point.append(point[i]-1)
  else:
    point.append(point[i]+1)

max_point = max(point)
pos = point.index(max_point)

print(we_counter(pos))


Measured memory_bytes: 15520
n = int(input())
a = []
for i in range(n):
  a1,a2 = map(int, input().split())
  a.append([a1+a2,a1,a2])
a.sort()
a.reverse()
ans = 0
for i in range(n):
  if i % 2 == 0:
    ans += a[i][1]
  else:
    ans -= a[i][2]
print(ans)

Measured memory_bytes: 23260
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };


int n, s, g, c;

string str;
string apple = "apple";
string peach = "peach";

int main() {
	getline( cin, str );
	for ( int i = 0; i < str.size() - 4; i++ ) {
		if ( str.substr( i, 5 ) == apple ) {
			for ( int j = i; j < i + 5; j++ ) {
				str[ j ] = peach[ j - i ];
			}
		}
		else if ( str.substr( i, 5 ) == peach ) {
			for ( int j = i; j < i + 5; j++ ) {
				str[ j ] = apple[ j - i ];
			}
		}
	}
	printf( "%s\n", str.c_str() );
	return 0;
}

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

int main() {
    int m, M, k;
    cin >> m >> M >> k;
  	
  	if((M-m+1) > k*2) {
      //cout << "up" << endl;
      rep(i, k) cout << m + i << endl;
      rep(i, k) {
        cout << M + 1 - k + i;
        if(i!=k-1) cout << endl;
      }
    }else{
      //cout << "under" << endl;
      rep(i, M-m+1) {
        cout << m + i ;
        if(i!=M-m) cout << endl;
      }
    }
  
  	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef _LOCAL
    #define test(x) cerr << #x << "=" << x << endl
#else
    #define test(x)
#endif

typedef long long LL;

const int N = 2e5+5;

int ans[N];

int main(){
    #ifdef _LOCAL
        freopen("data.in", "r", stdin);
    #endif
    string s;
    cin >> s;
    s.push_back('R');
    int left = 0, right = 0;
    int inpL, inpR;
    bool toLeft = false;
    for(int i = 0; i < s.size(); i ++){
        if(s[i] == 'R'){
            if(toLeft){
                int cur = left + right >> 1;
                int flo = (left + right) % 2;
                int times = max(left, right) - 1;
                int curLeft = cur, curRight = cur;
                if(left > right) curLeft += flo;
                else curRight += flo;
                if(times & 1) swap(curLeft, curRight);
                ans[inpL] = curRight;
                ans[inpR] = curLeft;
                right = 1;
                toLeft = false;
            }else{
                right ++;
            }
        }
        else{
            if(!toLeft){
                toLeft = true;
                inpL = i-1;
                inpR = i;
                left = 1;
            }else{
                left ++;
            }
        }
    }
    bool first = true;
    for(int i = 0; i < s.size() - 1; i ++){
        if(first) first = false;
        else printf(" ");
        printf("%d", ans[i]);
    }
    puts("");
    #ifdef _LOCAL
        fprintf(stderr, "T: %d ms\n", int(1000.0 * clock() / CLOCKS_PER_SEC));
    #endif
    return 0;
}

Measured memory_bytes: 1024
def compute_divisors(x):
    # https://atcoder.jp/contests/abc106/submissions/3028544
    divisors = set()
    for i in range(1, int(x ** 0.5) + 1):
        if x % i == 0:
            divisors.add(i)
            divisors.add(x // i)
    return divisors

N = int(input())
c = 0

for i in range(1, N+1, 2):
    if len(compute_divisors(i)) == 8:
        c += 1
print(c)


Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

#include <complex>
typedef complex<double> Point;
// O(n^2logn)
int MaxPointCircle(const vector<Point> points, double r) {
  const int n = points.size();
  int ret = 1;
  for (int i = 0; i < n; i++) {
    vector<pair<double, int> > radians;
    for (int j = 0; j < n; j++) {
      double d = abs(points[i] - points[j]) / 2.0;
      if (i == j || d * 2.0 - r * 2.0 > EPS) { continue; }
      Point center = (points[i] + points[j]) / 2.0;
      Point vect = (points[j] - points[i]) * Point(0, -1);
      vect /= abs(vect);
      double l = sqrt(r * r - d * d);
      Point c1 = center + vect * l;
      Point c2 = center - vect * l;
      double arg1 = arg(c1 - points[i]) - EPS;
      double arg2 = arg(c2 - points[i]) + EPS;
      radians.push_back(make_pair(arg1, (j + 1)));
      radians.push_back(make_pair(arg2, -(j + 1)));
    }
    if ((int)radians.size() / 2 < ret - 1) { continue; }
    sort(radians.begin(), radians.end());
    vector<bool> used(points.size(), false);
    int lsum = 1;
    REP(iter, 2) {
      REP(j, radians.size()) {
        int index = abs(radians[j].second) - 1;
        bool start = radians[j].second > 0 ? true : false;
        if (used[index] && !start) {
          used[index] = false;
          lsum--;
        } else if (!used[index] && start) {
          used[index] = true;
          lsum++;
        }
        ret = max(ret, lsum);
      }
    }
  }
  return ret;
}

int main() {
  int n;
  while (scanf("%d", &n), n) {
    vector<Point> points(n);
    REP(i, n) {
      double x, y;
      scanf("%lf %lf", &x, &y);
      points[i] = Point(x, y);
    }
    printf("%d\n", MaxPointCircle(points, 1.0));
  }
}

Measured memory_bytes: 0
#include <stdio.h>

int a[100010], cnt[100010];

int main(){
    int n, k, q;
    scanf("%d%d%d", &n, &k, &q);
    for(int i = 0; i < n; i++) a[i] = k;
    for(int i = 0; i < q; i++){
    	int x;
    	scanf("%d", &x);
    	cnt[x - 1]++;
    }
    for(int i = 0; i < n; i++){
    	a[i] -= (q - cnt[i]);
    	if(a[i] <= 0) printf("No\n");
    	else printf("Yes\n");
    }
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<limits.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int h[100000];
    int dp[100000];
    for(int i=0;i<n;i++){
        cin>>h[i];
        dp[i]=INT_MAX;
    }
    dp[0]=0;
    for(int p=0;p<n;p++){
        for(int q=1;q<=k;q++){
            if(p+q>=n)break;
            dp[p+q]=min(dp[p+q],dp[p]+abs(h[p]-h[p+q]));
        }
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC085A {
    class Program {
        static void Main(string[] args) {
            string input = Console.ReadLine();
            input = input.Remove(3, 1).Insert(3, "8");
            // Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
            // Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力
            Console.WriteLine(input);
        }
    }
}

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

#define int long long

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

const int MOD = 998244353;
auto add(ll a, ll b){return (a + b) % MOD;}
auto sub(ll a, ll b){return (a - b + MOD) % MOD;}
auto mult(ll a, ll b){return a * b % MOD;}
auto exp(ll n, ll p) {
  ll acc = 1;
  for (auto pwr = n; p; pwr = mult(pwr, pwr), p >>= 1)
    if (p & 1)
      acc = mult(acc, pwr);
  return acc;
}
auto mdiv(ll a, ll b){return mult(a, exp(b, MOD - 2));}

const int MAXN = 3 * 1e5;
ll factorial[MAXN + 5];
ll nck(ll n, ll k) {
  return mdiv(factorial[n], mult(factorial[k], factorial[n - k]));
}

ll brute(int i, ll n, ll m, ll k, int p = -1) {
  if (i == n) return 1;
  ll res = 0;
  rep(color, 1, m + 1) {
    if (color == p and k > 0) {
      res += brute(i + 1, n, m, k - 1, color);
    } else if (color != p) {
      res += brute(i + 1, n, m, k, color);
    }
  }
  return res;
}

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

  factorial[0] = 1;
  rep(i, 1, MAXN + 5) {
    factorial[i] = mult(factorial[i - 1], i);
  }

  int n, m, k;
  cin >> n >> m >> k;

  //ll expected = brute(0, n, m, k);
  
  ll total = exp(m, n);
  int sgn = 1;
  ll acc = 0;
  rep(i, k + 1, n) {
    //cout << "At : " << i << endl;
    ll rem = n - i;
    ll parts = n - 1 - i;
    assert(rem > 0);
    // ll choices = nck(n - 1, i);
    ll choices = nck(n - 1, i);
    ll ways = mult(m, exp(m - 1, rem - 1));
    
    auto delta = mult(choices, ways);
    //cout << i << ": " <<  rem << " " << choices << " " << ways << " " << delta << " " << sgn << endl;
    acc = add(acc, delta);
    /*
    if (sgn > 0) {
      acc = add(acc, delta);
    } else {
      acc = sub(acc, delta);
    }
    sgn = -sgn;
    */
  }
  //cout << "Total: " << total << endl;
  // cout << "Acc: " << acc << endl;
  auto res = sub(total, acc);
  cout << res << '\n';
  //cout << "Expected: " << expected << endl;
}


Measured memory_bytes: 6000
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<random>
#include<ctime>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int d;
vector<int> c;
vector<vector<int>> s;

//状態
struct STATE {
    vector<int> x;
};

// 状態の初期化
void init (STATE& state) {
    state.x.resize(d);
    rep(i, d) {
        state.x[i] = 0;
    }
}

// 状態遷移
void modify (STATE& state) {
    int j = rand() % d;
    state.x[j] = rand() % 26;
}

// 状態のスコア計算
int calc_score (STATE& state) {
    vector<int> last(26, 0);
    int res = 0;
    rep(i, d) {
        last[state.x[i]] = i + 1;
        res += s[i][state.x[i]];
    }
    rep(j, 26) {
        res -= c[j] * (d - last[j]);
    }
    return res;
}

const double TIME_LIMIT = 1.90;

// 山登り法
void mountain() {
    STATE state;
    init(state);
    double start_time = clock(); // 開始時刻
    while (true) { // 時間の許す限り回す
        double now_time = clock(); // 現在時刻
        if ((now_time - start_time) / CLOCKS_PER_SEC > TIME_LIMIT) break;

        STATE new_state = state;
        modify(new_state);
        int new_score = calc_score(new_state);
        int pre_score = calc_score(state);

        if (new_score > pre_score) { // スコア最大化の場合
            state = new_state;
        }
    }
    //出力
    rep(i, d) {
        cout << state.x[i] + 1 << endl;
    }
}

void solve() {
	cin >> d;
    c.resize(26);
    rep(i, 26) cin >> c[i];
    s.assign(d, vector<int>(26, 0));
    rep(i, d) {
        rep(j, 26) {
            cin >> s[i][j];
        }
    }
    mountain();
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3728
#include<iostream>
using namespace std;
#define BEFORE 4280
int main()
{
    int w;
    while(cin>>w)
    {
        if(w==-1)break;
        int kon = 0;
        if(w>=30)
        {
            kon = 1150+1250+1400+(w-30)*160;
        }
        else if(w >=20)
        {
            kon = 1150+1250+140*(w-20);
        }
        else if(w >=10)
        {
            kon = 1150+125*(w-10);
        }
        else
        {
            kon = 1150;
        }
        cout << BEFORE - kon << endl;
    }


    return 0;
}

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

int main() {
    long r, D, x2000;
    cin >> r >> D >> x2000;

    for(int i = 0; i < 10 ; i++)
    {
        x2000 = r * x2000 - D;
        cout << x2000 << endl;
    }
    return 0;  

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> s(N);
    for(int i=0; i<N; i++) {
        cin >> s[i];
    }

    int sum = accumulate(s.begin(), s.end(), 0);
    if(sum%10 != 0) {
        cout << sum << endl;
    } else {
        for(int i=0; i<N; i++) {
            s[i] = sum - s[i];
        }
        sort(s.rbegin(), s.rend());
        for(int i=0; i<N; i++) {
            if(s[i] % 10 != 0) {
                cout << s[i] << endl;;
                return 0;
            }
        }
        cout << 0 << endl;
    }
    return 0;
}


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

using namespace std;


int main()
{
	int a[3];
	for (int i = 0; i < 3; i++)
		cin >> a[i];
	sort(a, a + 3);
	cout << a[0] + a[1] << endl;
}

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

using namespace std;

int main() {
  int n[4];
  for (int i = 0; i < 4; i++)
    cin >> n[i];
  bool one = false, nine = false, seven = false, four = false;
  for (int i = 0; i < 4; i++) {
    switch (n[i]) {
    case 1:
      one = true;
      break;
    case 9:
      nine = true;
      break;
    case 7:
      seven = true;
      break;
    case 4:
      four = true;
    }
   }
  if (one && nine && seven && four)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256