akhauriyash/Code-Regression huggingface dataset:
import sys
stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces


Q, H, S, D = rl()
N = ri()
if 2 * Q < H:
    H = 2 * Q
if 2 * H < S:
    S = 2 * H
if 2 * S < D:
    D = 2 * S
answer = N // 2 * D + N % 2 * S
print(answer)
#30

Measured memory_bytes: 3064
N,M=map(int,input().split())
X=list(map(int,input().split()))
X.sort()
diff=[0]*(M-1)

for i in range(M-1):
    diff[i]=X[i+1]-X[i]
    
diff.sort()
if M-N>=0:
    ans=sum(diff[:M-N])
else:
    ans=0
print(ans)

Measured memory_bytes: 52904
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef unsigned long long ll;



int main(){
 string S,T;
 int flag = 1;
 cin >> S;
 cin >> T;

  for (int i = S.length()-T.length()+1; i>=0; --i){
    flag = 1;
    for(int j=0; j < T.length(); j++){
      if(S[i+j]!= T[j] && S[i+j]!='?'){
        flag=0;
      }
    }
    if(flag){
      for(int j=0; j < T.length(); j++){
        S[i+j]=T[j];
      }
      for(int j = 0; j < S.length(); j++){
      if(S[j] == '?')
        S[j]='a';
      }
      cout << S << endl;
      break;
    }
  }

  if(!flag){
    cout << "UNRESTORABLE\n";
  }
  
    
  return 0;
}



Measured memory_bytes: 256
//tanzim bin nasir
#include<bits/stdc++.h>
typedef long long ll;
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
int gcd(int a,int b)
{
    if(b==0)
    return a;
    else
    gcd(b,a%b);
}
ll lcd(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
ll x=1000000007;
int main()
{
    ll n;
    cin>>n;
    ll ans=1,a=1,b=1;
    ans=ans%x;
    for(ll i=1;i<=n;i++)
    {
        ans=ans*10;
        ans=(ans+x)%x;
        a=a*9;
        a=(a+x)%x;
        b=b*8;
        b=(b+x)%x;
    }
    cout<<(ans-2*a+4*x+b)%x<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

ll gcd(ll a, ll b){ return b==0?a:gcd(b,a%b);}

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

const int N = 100000+5;

int n;
int v[4][N];
bool vis[N][4];
int memo[N][4];

int DP(int pos, int now){
	if(pos == n) return 0;
	if(vis[pos][now]) return memo[pos][now];
	int ans = 0;
	for(int i=0; i<3; i++){
		if(i == now) continue;
		ans = max(ans, v[now][pos] + DP(pos+1,i));
	}
	vis[pos][now] = true;
	return memo[pos][now] = ans;
}

int main(){
	ri(n);
	for(int i=0; i<n; i++){
		for(int j=0; j<3; j++){
			ri(v[j][i]);
		}
	}
	int ans = 0;
	for(int i=0; i<3; i++){
		ans = max(ans, DP(0,i));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
    
#define int long long
    
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
    
using namespace std;
    
int dy[4]={1, 0, -1, 0};
int dx[4]={0, 1, 0, -1};

int32_t main(){
    int n, k, cnt=0;
    cin >> n >> k;
    vector<int> v(n), f(200005, INF);
    REP(i, n){
        cin >> v[i];
        if(f[v[i]]==INF){
            f[v[i]] = 1;
            cnt++;
        }
        else f[v[i]]++;
    }
    SORT(f);

    int ans=0;
    REP(i, cnt-k){
        ans+=f[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;

void main(){

    int ans = 0;
    while(true){
	auto s = readln();
	if(stdin.eof()) break;
	s = chomp(s);
	for(int i=0;i<s.length;i++){
	    char c = s[i];
	    if('1' <= c && c <= '9' ){
		int temp = 0;
		while('0' <= s[i+temp] && s[i+temp] <= '9'){
		    temp++;
		    if(i+temp==s.length) break;
		}
		ans += to!int(s[i..i+temp]);
		i += temp;
	    }
	}
    }
    writeln(ans);
}

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

using namespace std;
#define int long long
const int N = 1e6 + 10, MOD = 1e9 + 7;
int P[N], f[N], A[N], a[N], cnt[N], mark[N];

int mul(int a, int b) {return (a * b) % MOD;}
int Pow(int a, int b)
{
    int res = 1;
    for (; b; b>>=1, a = mul(a, a)) if (b & 1) res = mul(res, a);
    return res;
}

int func(int X)
{
    int x = X;
    while (f[x]) {
        A[f[x]]++;
        x/=f[x];
    }
    x = X;
    while (f[x]) {
        cnt[f[x]] = max(cnt[f[x]], A[f[x]]);
        A[f[x]]--;
        x/=f[x];
    }
}

int cal(int res, int X)
{
    int x = X;
    while (f[x]) {
        res = mul(res, Pow(f[x], MOD - 2));
        x/=f[x];
    }
    return res;
}

int32_t main()
{
    memset(P, 1, sizeof P);
    P[1] = f[1] = 0;
    for (int i = 1; i < N; i++) if (P[i]) {
        f[i] = i;
        for (int j = i * i; j < N; j+=i) P[j] = 0, f[j] = i;
    }
    int n; cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        func(a[i]);
    }
    int X = 1;
    for (int i = 1; i < N; i++) X = mul(X, Pow(i, cnt[i]));
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += cal(X, a[i]);
        ans %= MOD;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 34816
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
   int n;
   cin>>n;
   int p[n],m[n];
   rep(i,n){
       cin>>p[i];
       m[i]=p[i];
   }
   int ans=0;
   sort(m,m+n);
   rep(i,n){
       if(m[i]!=p[i]){
           ans++;
       }
   }
   if(ans<=2){
       cout<<"YES"<<endl;
   }
   else{
       cout<<"NO"<<endl;
   }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	int ans = 0;
	deque<char> stack;
	rep(i, s.length()) {
		if (stack.empty()) {
			stack.push_back(s[i]);
			continue;
		}

		if (stack.back() != s[i]) {
			ans += 2;
			stack.pop_back();
		}
		else {
			stack.push_back(s[i]);
		}
	}

	cout << ans << "\n";

	return 0;
}

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

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

    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            if(i * j == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;


}

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

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

  char state=s[0];
  int rev1=0;
  for(int i=1; i < s.size(); i++){
    if(s[i] != state){
      state = s[i];
      rev1 += 1;
    }
  }

  state=s[s.size()-1];
  int rev2=0;
  for(int i=s.size()-2; i >= 0; i--){
    if(s[i] != state){
      state = s[i];
      rev2 += 1;
    }
  }

  if(rev1 < rev2)
    cout << rev1 << endl;
  else
    cout << rev2 << endl;

  return 0;
}


Measured memory_bytes: 512
#![allow(unused)]

use std::{cell, cmp, collections, fmt, ops};

use cell::{Cell, RefCell};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use fmt::{Debug, Display};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        _input_inner!(iter, $($r)*)
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        _input_inner!(iter, $($r)*)
    };
}

macro_rules! _input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = _read_value!($iter, $t);
        _input_inner!($iter $($r)*)
    };
}

macro_rules! _read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(_read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| _read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        _read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        _read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[cfg(feature = "debug")]
macro_rules! d {
    ($($args: tt)*) => { dbg!($($args)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! d {
    ($($args:tt)*) => {};
}

mod num {
    //
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

mod bits {
    pub fn is_high(bits: u64, pos: u64) -> bool {
        bits & (1 << pos) != 0
    }
}

fn main() {
    input!(n: usize, lens: [i32; n]);

    let max = lens.iter().max().unwrap();
    let sum = lens.iter().sum::<i32>();

    if *max < sum - max {
        println!("Yes");
    } else {
        println!("No");
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}


Measured memory_bytes: 4352
// https://atcoder.jp/contests/keyence2020
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K, S;
    cin >> N >> K >> S;
    vector<int> ans;
    REP(i, K) ans.push_back(S);
    REP(i, N - K) {
        if (S == 1000000000) {
            ans.push_back(1);
        } else {
            ans.push_back(1000000000);
        }
    }
    REP(i, N) { cout << ans[i] << (i == N - 1 ? "\n" : " "); }

    return 0;
}


Measured memory_bytes: 2292
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
 
using namespace std;
 
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;}
 
const ll INF=1e9+7;

int main(){
    ll n;
    cin >> n;
    vector<ll> h(n);
    rep(i,n){
        cin >> h[i];
    }
    vector<ll> dp(n);
    for(ll i=1;i<n;i++){
        if(i==1){
            dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        }
        else{
            dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
} 

Measured memory_bytes: 1920
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<iomanip>
#include<map>
using namespace std;
typedef pair<int, pair<int, int> >PP;
typedef long long ll;
typedef pair<int, int>P;
typedef vector<int>vec;
int inf=-1;
ll mod = pow(10, 9) + 7;
 
vector<pair<char,int> >RLE(vector<char>a){
	vector<pair<char,int> >ret;
	int cnt=1;
	for(int i=1;i<a.size();i++){
		if(a[i]==a[i-1]){
			cnt++;
		}
		else{
			ret.push_back(pair<char,int>(a[i-1],cnt));
			cnt=1;
		}
	}
	ret.push_back(pair<char,int>(a[a.size()-1],cnt));
	return ret;
}

int main(){
    int n;cin>>n;
    string s;cin>>s;
    vector<char>a;
    for(auto i:s){
        a.push_back(i);
    }
    vector<pair<char,int> > ret=RLE(a);
    vector<char>ans;
    for(auto i:ret){
        ans.push_back(i.first);
    }
    cout<<ans.size()<<endl;
    return 0;
}

Measured memory_bytes: 1656
#include <stdio.h>
 
#define MAX 500000
#define INFTY 2000000000
 
void Merge(int[MAX], int, int, int);
void MergeSort(int[MAX], int, int);
 
int count = 0;
 
int main(){
 
  int i, n;
  int A[MAX];
 
  scanf("%d", &n);
 
  for(i =0; i < n; i++){
 
    scanf("%d", &A[i]);
 
  }
 
  MergeSort(A, 0, n);
   
  for(i = 0; i < (n - 1); i++){
       
    printf("%d ", A[i]);
 
  }
 
  printf("%d\n", A[i]);
 
  printf("%d\n", count);
  
  return 0;
 
}
 
void Merge(int A[MAX], int left, int mid, int right){
 
  int i, j, k;
 
  int n1, n2;
 
  n1 = mid - left;
  n2 = right - mid;
 
  int L[MAX], R[MAX];
 
  for(i = 0; i < n1; i++){
 
    L[i] = A[left + i];
 
  }
 
  for(i = 0; i < n2; i++){
 
    R[i] = A[mid + i];
 
  }
 
  L[n1] = INFTY;
  R[n2] = INFTY;
 
  i = 0;
  j = 0;
 
  for(k = left; k < right; k++){
 
    if(L[i] <= R[j]){
 
      A[k] = L[i];
 
      i++;
 
    }
    else{
 
      A[k] = R[j];
       
      j++;
 
    }
 
    count++;
 
  }
 
}
 
void MergeSort(int A[MAX], int left, int right){
 
  int mid;
 
  if((left + 1) < right){
 
    mid = (left + right) / 2;
 
    MergeSort(A, left, mid);
 
    MergeSort(A, mid, right);
 
    Merge(A, left, mid, right);
 
  }
 
}

Measured memory_bytes: 6504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0; i<n; i++)
int main()
{
	ll D,T,S;
	cin >> D >> T >> S;

	if(D<=T*S)
		cout << "Yes";
	else
		cout << "No";

	cin >> D;
	
	return 0;	
}


Measured memory_bytes: 3592
//package ABC171;
import java.util.*;
import java.io.*;
class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong();
		
		char ch[]=new char[27];
		for(int i=1;i<=26;i++)
		{
			ch[i]=(char)('a'+i-1);
		}
		HashMap<Long,Character> hm=new HashMap<>();
		
		for(long i=1;i<=26;i++)
		{
			hm.put(i,(char)('a'+i-1));
		}
		
		StringBuffer bf =new StringBuffer("");
		
		while(n>0)
		{
			long mod=n%26;
			if(n%26==0)
			{
				bf.append('z');
				n=n/26-1;
			}
			else
				{
				
				bf.append(hm.get(mod));
				n=n/26;
				}
			
		}
		bf.reverse();
		System.out.println(bf.toString());
		//System.out.println(Arrays.toString(ch));
		

	}

}


Measured memory_bytes: 36000
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

enum{N=200023};

const int mod = 1e9+7;

il ll qpow(ll a,ll b){
	ll ans= 1;
	for(; b; b>>=1,a=a*a%mod) if ( b&1 ) {
		ans= ans*a%mod;
	} return ans;
}
il ll inv(ll x){ return qpow(x,mod-2); }

ll fac[N],Invf[N];
il void init_fac(int n){
	n= min(n,mod-1);
	fac[0]= 1;
	rep(i,1,n) fac[i]=fac[i-1]*i%mod;
	Invf[n]= inv(fac[n]);
	rev_rep(i,n,1) Invf[i-1]=Invf[i]*i%mod;
}
il ll comp(ll n,ll m){
	if( n<m ) return 0;
	return fac[n]*Invf[m]%mod*Invf[n-m]%mod;
}

ll a[N];
ll f[N],pow2[N];

int main(){
	int n=ci();
	init_fac(n);
	rep(i,1,n) a[i]=ci();
	sort(a+1,a+n+1);
	ll ans=0;
	pow2[0]=1, pow2[1]=2;
	f[0]=0, f[1]=1;
	rep(i,2,n){
		pow2[i]= pow2[i-1]*2%mod;
		f[i]=(f[i-1]*2+pow2[i-2])%mod;
	}
	rep(i,1,n){
//		ll now=0;
//		rep(j,1,n-i+1) printf("%lld ",comp(n-i,j-1)*j),
//		now=(now+comp(n-i,j-1)*j)%mod;
//		printf("now %d %lld %lld\n",i,now,f[n-i+1]);
		ans=(ans+a[i]*pow2[i-1]%mod*f[n-i+1])%mod;
	}
	printf("%lld\n",ans*pow2[n]%mod);
	return 0;
}


Measured memory_bytes: 7936
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<double> xs(N);
  vector<string> us(N);
  for (int i = 0; i < N; i++) {
    cin >> xs[i] >> us[i];
  }

  double ans = 0.0;
  for (int i = 0; i < N; i++) {
    if (us[i] == "JPY") {
      ans += xs[i];
    } else if (us[i] == "BTC") {
      ans += (xs[i] * 380000.0);
    }
  }

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

Measured memory_bytes: 256
class D_Linked_List:
    class Node:
        def __init__(self, key, next = None, prev = None):
            self.next = next
            self.prev = prev
            self.key = key
 
    def __init__(self):
        self.nil = D_Linked_List.Node(None)
        self.nil.next = self.nil
        self.nil.prev = self.nil
 
    def insert(self, key):
        node_x = D_Linked_List.Node(key, self.nil.next, self.nil)
        self.nil.next.prev = node_x
        self.nil.next = node_x
 
    def _listSearch(self, key):
        cur_node = self.nil.next
        while (cur_node != self.nil) and (cur_node.key != key):
            cur_node = cur_node.next
        return cur_node
 
    def _deleteNode(self, node):
        if node == self.nil:
            return None
        node.prev.next = node.next
        node.next.prev = node.prev
 
    def deleteFirst(self):
        self._deleteNode(self.nil.next)
 
    def deleteLast(self):
        self._deleteNode(self.nil.prev)
 
    def deleteKey(self, key):
        node = self._listSearch(key)
        self._deleteNode(node)
 
    def show_keys(self):
        cur_node = self.nil.next
        keys = []
        while cur_node != self.nil:
            keys.append(cur_node.key)
            cur_node = cur_node.next
        print(' '.join(keys))
 
 
import sys
 
d_ll = D_Linked_List()
 
for i in sys.stdin:
    if 'insert' in i:
        x = i[7:-1]
        d_ll.insert(x)
    elif 'deleteFirst' in i:
        d_ll.deleteFirst()
    elif 'deleteLast' in i:
        d_ll.deleteLast()
    elif 'delete' in i:
        x = i[7:-1]
        d_ll.deleteKey(x)
    else:
        pass
 
d_ll.show_keys()


Measured memory_bytes: 227552
#include<stdio.h>

int main(void){
	int n,k;

	while(0==0){
		scanf("%d",&n);
		if(n==0)break;
		n=1000-n;
		k=0;
		k += n /500;  
		n =n%500;
		k += n/100;   
		n =n%100;
		k += n/50;    
		n =n%50;
		k += n/10;    
		n =n%10;
		k += n/5;     
		k += n%5;
		printf("%d\n",k);
	}
	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m, c;
  cin >> n >> m >> c;
  vi b(m);
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    vi a(m);
    int sum = 0;
    for (int j = 0; j < m; j++) {
      cin >> a[j];
      sum += a[j] * b[j];
    }
    if (sum + c > 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    //    ifstream in("input.txt");
    //    cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    int cnt = 0;
    
    for (int i = 1; i <= n; ++i)
    {
        if (i % 2 == 0) continue;
        int cnt8 = 0;
        for (int j = 1; j <= i; ++j)
        {
            if (i % j == 0) ++cnt8;
        }
        if (cnt8 == 8) ++cnt;
    }
    
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <queue>
#include <memory>
#include <fstream>

#pragma GCC optimize("no-stack-protector,Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,popcnt,abm,mmx,tune=native,avx,avx2")

#define int long long
#define ld long double
#define eb emplace_back
#define pb pop_back
#define mp make_pair
#define ss second
#define ff first
#define sqr(x) (x) * (x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair < int, int >
#define vi vector < int >
#define vvi(x, y) vector < vi > (x, vi(y))

typedef int(*func)(int a, int b);

using namespace std;

random_device rd;
mt19937 get_rand(rd());

template < typename T1, typename T2 >
istream& operator>>(istream& in, pair < T1, T2 >& p) {
	in >> p.ff >> p.ss;
	return in;
}

template < typename T1, typename T2 >
ostream& operator<<(ostream& out, pair < T1, T2 >& p) {
	out << p.ff << ' ' << p.ss;
	return out;
}

template < typename T1 >
istream& operator>>(istream& in, vector < T1 >& v) {
	for (int i = 0; i < sz(v); i++)
		in >> v[i];
	return in;
}

template < typename T1 >
ostream& operator<<(ostream& out, vector < T1 >& v) {
	for (int i = 0; i < sz(v); i++)
		out << v[i] << ' ';
	out << '\n';
	return out;
}

int gcd(int a, int b) {
	return (!a ? b : gcd(b % a, a));
}

const int INF = 1e9 + 7;
const int B = 100003;
const int MOD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.14159265358979323;
const int MAXLL = 9223372036854775807;


signed main() {
	//ifstream cin("kdivision.in");
	//ofstream cout("kdivision.out");
#ifdef _LOCAL
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	srand(time(NULL));

	int ttt = 1;
	//cin >> ttt;
	while (ttt--) {
		int a, b, n;
		cin >> a >> b >> n;
		int x = min(b - 1, n);
		cout << (a * x) / b << '\n';
	}
	return 0;
}

Measured memory_bytes: 3608
MAX = 10000000000000001
AL = 26

N = int(input())

d = 1
ds = list()
while d <= MAX:
    ds.append(d)
    d = d * AL

ress = list()
for d in ds[-1::-1]:
    m = int(N / d)
    ress.append(m)
    N -= m * d

for _ in range(20):
    for i in range(len(ress) - 1):
        if ress[i] > 0 and ress[i + 1] == 0:
            ress[i] -= 1
            ress[i + 1] = 26

alphas = list(' abcdefghijklmnopqrstuvwxyz')

print(''.join([alphas[r] for r in ress]).strip())


Measured memory_bytes: 9216
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
// Problem https://atcoder.jp/contests/abc113/tasks/abc113_b

int solver(int aN,int gT,int mT,vector<int> h){
    float minDT=10000.0; // 最小温度差
    int result=-1; // 結果の場所。最終的に1を足す
    for(int j=0;j<aN;j++){
        float diffTemperture;
        diffTemperture = abs(gT-(mT-h[j]*0.006));
        if(diffTemperture<minDT){
            minDT=diffTemperture;
            result = j;
        }
    }
    return result+1;
}
int main(void){
    int N,T,A,answer;
    cin >> N >> T >> A;
    vector<int> H(N);
    for(int j=0;j<N;j++){
        cin >> H.at(j);
    }
    answer = solver(N,A,T,H);
    cout << answer << endl;
}

Measured memory_bytes: 256
#![allow(unused)]

use std::cmp;
use std::io::{self, BufRead};
use std::iter;

macro_rules! destruct_ {
  ($e: expr, ()) => (
    assert!($e.next().is_none())
  );
  ($e: expr, ($arg: ident, $( $args: ident, )*)) => (
    $arg = $e.next().unwrap();
    destruct_!($e, ($($args,)*))
  );
  ($e: expr, ($arg: ident $(, $args: ident )*)) => (
    $arg = $e.next().unwrap();
    destruct_!($e, ($($args,)*))
  );
}

macro_rules! into {
  ($e: expr, $($name: ident)*) => {
    let mut iter = $e.into_iter();
    destruct_!(iter, ($($name)*));
  }
}

macro_rules! get {
  ($i: ident) => (
    let stdin = io::stdin();
    let mut $i = Vec::new();
    for line in stdin.lock().lines() {
      $i.push(
        line
          .unwrap()
          .split_whitespace()
          .map(|a| a.parse().unwrap())
          .collect()
      );
    }
  )
}

macro_rules! p {
  ($a: expr) => (
    println!("{:?}", $a);
  )
}

fn main() {
  let stdin = io::stdin();
  let mut args: Vec<Vec<i32>> = Vec::new();
  for line in stdin.lock().lines() {
    args.push(
      line
        .unwrap()
        .split_whitespace()
        .map(|a| a.parse().unwrap())
        .collect()
    );
  }

  let mut ls = [0; 9];
  for a in args[1].iter() {
    match *a as i32 {
      1...399 => ls[0] += 1,
      400...799 => ls[1] += 1,
      800...1199 => ls[2] += 1,
      1200...1599 => ls[3] += 1,
      1600...1999 => ls[4] += 1,
      2000...2399 => ls[5] += 1,
      2400...2799 => ls[6] += 1,
      2800...3199 => ls[7] += 1,
      _ => ls[8] += 1,
    }
  }

  let mut n = 0;
  let mut z = 0;
  for i in 0 .. ls.len() {
    if i == 8 {
      z = ls[i];
    } else if ls[i] > 0 {
      n += 1;
    }
  }

  if n == 0 && z > 0 {
    println!("{} {}", 1, z);
  } else {
    println!("{} {}", n, n + z);
  }
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> ps(N);

    for (auto& p : ps) {
        std::cin >> p;
    }

    std::vector<int64_t> idx;
    for (int64_t i = 0; i < ps.size()-1; ++i) {
        if (ps.at(i) > ps.at(i+1)) {
            if (idx.empty()) {
                idx.push_back(i);
            } else {
                idx.push_back(i+1);
            }
        }
    }

    if (idx.size() == 0) {
        std::cout << "YES" << std::endl;
        return 0;
    }

    if (idx.size() != 2) {
        std::cout << "NO" << std::endl;
        return 0;
    }

    int64_t i = idx.at(0);
    int64_t j = idx.at(1);
    std::swap(ps.at(i), ps.at(j));

    for (int64_t i = 0; i < ps.size()-1; ++i) {
        if (ps.at(i) > ps.at(i+1)) {
            std::cout << "NO" << std::endl;
            return 0;
        }
    }

    std::cout << "YES" << std::endl;

    return 0;
}

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

int main(int argc, char *argv[])
{
    int X1, Y1, X2, Y2;
    std::cin >> X1 >> Y1 >> X2 >> Y2;

    int dx = X2 - X1;
    int dy = Y2 - Y1;

    std::cout << X2 - dy << " " << Y2 + dx << " " << X1 - dy << " " << Y1 + dx;

    return 0;
}

Measured memory_bytes: 256
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

int a[MAXN];

int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int n = readInt();
    for (int i = 1; i <= n; i++) {
    	a[i] = readInt();
    }
    ll ans = 0;
    ll sum = 0;
    for (int i = 1; i <= n; i++) {
    	if (!a[i]) {
    		ans += sum / 2;
    		sum = 0;
    	} else {
    		sum += a[i];
    	}
    }
    cout << ans + (sum / 2);
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string.h>
using namespace std;
char A[51][51];
char B[51][51];
bool isSame(int startI,int startJ,int bWide,int bHigh)
{
	int i,j;
	int bI=0,bJ=0;
	for (i=startI;i<startI+bHigh;i++){
		bJ=0;
		for (j=startJ;j<startJ+bWide;j++){
			if (A[i][j] != B[bI][bJ]){
				return false;
			}
			bJ++;
		}
		bI++;
	}
	return true;
}
int main(int argc, char* argv[])
{
	int N,M;
	cin>>N>>M;
	int i,j;

	for (i=0;i<N;i++){
		cin>>A[i];
	}
	for (i=0;i<M;i++){
		cin>>B[i];
	}
	
	size_t aWide=strlen(A[0]);
	size_t bWide=strlen(B[0]);
	int bHigh=M;
	for (i=0;i<=N-M;i++){
		for (j=0;j<=aWide-bWide;j++){
			if (isSame(i,j,bWide,bHigh)){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}

	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
D, X=map(int, input().split())

def chococount(a,d):
  c=d//a
  if d%a!=0:
    c+=1
  return c
  
choco=X
for i in range(N):
  A=int(input())
  choco+=chococount(A,D)

print(choco)

Measured memory_bytes: 3060
n = int(input())
p_ls = list(map(int, input().split(' ')))
cnt = 0
for i in range(1, len(p_ls) - 1):
    if (p_ls[i-1] < p_ls[i] < p_ls[i+1]) or (p_ls[i+1] < p_ls[i] < p_ls[i-1]):
        cnt += 1
print(cnt)

Measured memory_bytes: 9164
module mod_modulo_util
  implicit none
  integer(8), parameter :: md = 998244353_8
  integer(8), allocatable :: f(:), invf(:)
contains
  subroutine init(n)
    integer, intent(in) :: n
    integer :: i
    if (allocated(f)) deallocate(f)
    if (allocated(invf)) deallocate(invf)
    allocate(f(0:n),invf(0:n))
    f = 0_8
    invf = 0_8
    f(0) = 1_8
    do i = 1, n
      f(i) = mod(f(i-1)*int(i,8),md)
    end do
    invf(n) = inv(f(n))
    do i = n, 1, -1
      invf(i-1) = mod(invf(i)*int(i,8),md)
    end do
  end
  integer(8) function perm(n,k)
    integer, intent(in) :: n, k
    perm = 0_8
    if (k > n .or. n < 0 .or. k < 0) return
    perm = mod(f(n)*invf(n-k),md)
  end
  integer(8) function comb(n,k)
    integer, intent(in) :: n, k
    comb = mod(perm(n,k)*invf(k),md)
  end
  integer(8) function homo(n,k)
    integer, intent(in) :: n, k
    homo = comb(n+k-1,k)
  end
  function inv(n) result(y)
    integer(8), intent(in) :: n
    integer(8) :: a, b, x, y, t, q
    a = mod(n,md)
    b = md
    x = 0_8
    y = 1_8
    do while (b /= 0_8)
      q = a/b
      t = b
      b = mod(a,b)
      a = t
      t = y
      y = x
      x = t-q*x
    end do
    y = mod(mod(y,md)+md,md)
  end
  function pow(a,b) result(r)
    integer(8), intent(in) :: a
    integer, intent(in) :: b
    integer :: i
    integer(8) :: r, p
    r = 1_8
    p = a
    do i = 0, 32
      if (btest(b,i)) r = mod(r*p,md)
      p = mod(p*p,md)
    end do
  end
  integer(8) function fact(n)
    integer, intent(in) :: n
    fact = 0_8
    if (n < 0) return
    fact = f(n)
  end
end module mod_modulo_util
program banned_x
  use mod_modulo_util
  implicit none
  integer :: n, x, i, j, k, t, w
  integer(8) :: ans = 0_8, tmp
  read(*,*) n, x
  call init(3*n)
  do i = 0, n
    tmp = 0_8
    do j = 0, min(x-1,i)
      if (2*j < x-1) cycle
      k = i-j
      if (i < k) cycle
      t = j-k
      if (t >= 0) then
        w = x-1-j-k
        tmp = mod(tmp+comb(t,w),md)
      else if (2*j == x-1) then
        tmp = mod(tmp+1_8,md)
      end if
    end do
    do j = 0, x-2
      tmp = mod(tmp+comb(i,j-i),md)
    end do
    ans = mod(ans+mod(tmp*comb(n,i),md),md)
  end do
  write(*,'(i0)') ans
end program banned_x

Measured memory_bytes: 768
#include<iostream>
#include<string.h>
#include<math.h>
#include<algorithm>

using namespace std;

int main() {
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200) {
		cout << s << endl;
	}
	else{
		cout << "red" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

int main() {
  int D;
  cin >> D;
  for (int i = 0; i < D; i++){
    cout << D % 26 + 1 << endl;
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int cnt[200002];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,K;
    cin >> n >> K;
    vi a(n);
    rep(i,n){
        cin >> a[i];
        cnt[a[i]]++;
    }
    vi vec;
    srep(i,1,n+1){
        if(cnt[i]){
            vec.pb(cnt[i]);
        }
    }
    sort(all(vec));
    if(len(vec) < K){
        cout << "0\n";
    }else{
        int ans = 0;
        rep(i,len(vec)-K){
            ans += vec[i];
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 2936
#include<stdio.h>
int main(){
  int n;
  double a,count;
  scanf("%d",&n);
  if(n%2 == 0){
    printf("%f\n",0.5);
  }
  if(n%2 != 0){
    
    count = n/2 + 1;
    a = (double)count/(double)n;
    printf("%lf\n",a);
    
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=998244353;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  COMinit();
  ll n,m,k;
  cin >> n >> m >> k;
  ll ans=0;
  rep(i,k+1){
    ll res=m;
    res*=modpow(m-1,n-1-i);
    res%=MOD;
    res*=COM(n-1,i);
    res%=MOD;
    ans+=res;
    ans%=MOD;
  }
  cout << ans << endl;
    
    
    
  return 0;     
}


Measured memory_bytes: 15592
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int r, D, x; cin >> r >> D >> x;
    REP(i, 10){
        x = x * r - D;
        Out(x);
    }

    return 0;
}


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

using namespace std;

int main(void)
{
	int mt[10];

	

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


	sort(mt, mt + 10, greater<int>());
	
	for (int i = 0; i < 3; i++)
	{
		cout << mt[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1172
N, W = map(int, input().split())
w = [0]*N
v = [0]*N
for i in range(N):
    w[i], v[i] = map(int, input().split())


dp = [[0]*(W+1) for _ in range(N+1)]
#dp[ i ][ sum_w ] : 
#i-1 番目までの品物から重さが sum_w 以下となるように選んだときの、
#価値の総和の最大値
for i in range(N):
    for j in range(W+1):
        if j - w[i] >= 0:
            #dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]] + v[i])
            dp[i+1][j] = dp[i][j - w[i]] + v[i]

        dp[i+1][j] = max(dp[i][j], dp[i+1][j])

print(dp[N][W])


Measured memory_bytes: 120556
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//Hang in there!

using namespace std;


int main() {
	double H, W, N;
	cin >> H >> W >> N;
	double M = max(H, W);
	cout << ceil(N / M) << endl;
}



Measured memory_bytes: 256
fun main (args : Array<String>) {
	val s = readLine()!!.toString()
	val sList : MutableList<String> = mutableListOf()
	var count : Int = 0
	for (i in s) {
		sList.add(i.toString())
	}
	for (i in 0..(sList.size - 1) / 2) {
		val p1 = i
		val p2 = (sList.size - 1) - p1
		if (sList[p1] == sList[p2]) {
			continue
		} else {
			count++
			continue
		}
	}
	println("${count}")
}

Measured memory_bytes: 33556
import Prelude

main :: IO ()
main = do
    c <- getContents
    putStr $ unlines $ map solve $ lines c

solve :: String -> String
solve s = (show (f a b)) ++ " " ++ (show (g a b))
    where l = map read (words s)
          a = l !! 0
          b = l !! 1

f :: Int -> Int -> Int
f a b = if y == 0 then x else f y (mod x y)
    where x = max a b
          y = min a b

g :: Int -> Int -> Int
g a b = div (a*b) (gcd a b)

Measured memory_bytes: 4072
# ABC 089
def getInt(): return int(input())
def zeros(n): return [0]*n
def db(x): 
    global debug
    if debug: print(x)
debug = False
def genCombi(n, k): # nからk個を選ぶの0/1のリストを生成　[0]から変化
    bits = zeros(n)
    for i in range(2**n):
        cnt = 0
        for j in range(n):
            bits[j] = i%2
            if bits[j]==1: cnt+=1
            i //= 2
        if cnt==k: yield bits
            
N = getInt()
S = []
march = ['M','A','R','C','H']
dc = {'M':0,'A':0,'R':0,'C':0,'H':0,}
for i in range(N): 
    S.append(input())
    if S[i][0] in march:   dc[S[i][0]]+=1
db(S);db(dc)
cnt = 0
for c in genCombi(5,3):
    prod = 1
    for i in range(5): 
        if c[i]==1: prod *= c[i]*list(dc.values())[i]
    db(prod)
    cnt += prod
print(cnt)

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    int a, b, c, d; cin >> a >> b >> c >> d;

    cout << (max(a*b, c*d));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 998244353;

vector<long long int> inverse;
vector<long long int> f, f_inverse;

void factorial_Initialize(int max){
    vector<long long int> a(max+1,1);
    inverse = a;
    f = a;
    f_inverse = a;

    for (int i=2; i<=max; i++){
        inverse[i]   = MOD - inverse[MOD % i] * (MOD / i) % MOD;
        f[i]         = f[i-1]         * i          % MOD;
        f_inverse[i] = f_inverse[i-1] * inverse[i] % MOD;
    }
}

long long int nCr(int n, int r){
    if(n < r || r < 0) return 0;
    if (n >= f.size()){
        factorial_Initialize(n);
    }
    return f[n] * f_inverse[r] % MOD * f_inverse[n-r] % MOD;
}

int main(){
    long long int n, a, b, k;
    cin >> n >> a >> b >> k;

    factorial_Initialize(2*n);

    long long int ans = 0;
    for(int i=0; i<=n; i++){
        long long int x = k - a * i;
        if(x % b == 0 && x / b <= n){
            ans += nCr(n,i) * nCr(n, x/b) % MOD;
            ans %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 22012
def count_apper(str) :
    n = 0
    for c in str :
        if c.isupper() :
            n = n+1
    return n

str = input()
if (str[0] == "A") and (str.count("C") == 1) and (1 < str.find("C") < len(str)-1) and (count_apper(str) == 2) :
                print("AC")
                exit()
print("WA")
    

Measured memory_bytes: 2940