akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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;
}

signed main() {
  init();
  ll N;
  cin >> N;

  string ans = "";
  while (N > 0) {
    ll a = N % 26;
    if (a == 0) {
      a = 26;
      N -= 1;
    }
    char c = 'a' + a - 1;
    ans += c;
    N /= 26;
  }
  REVERSE(ans);
  COUT(ans);
  return 0;
}

Measured memory_bytes: 3560
/* Header {{{ */
#include <bits/stdc++.h>
using namespace std;

typedef long long readtype;
typedef long long var;
typedef long double let;

readtype read() {
  readtype a = 0, c = getchar(), s = 0;
  while (!isdigit(c)) s |= c == '-', c = getchar();
  while (isdigit(c)) a = a * 10 + c - 48, c = getchar();
  return s ? -a : a;
}

#ifdef LOCAL_LOGGER
#define logger(...) fprintf(stderr, __VA_ARGS__)
#define abortif(v, ...) if (v) {logger("Error in Line %d, Function '%s()'.\nInfo: ", __LINE__, __FUNCTION__); logger(__VA_ARGS__); exit(0);}
#else
#define logger(...);
#define abortif(v, ...);
#endif
/* }}} */

const int N = 101;

struct Point {
  let x, y;
  friend let Times(Point a, Point b) {
    return a.x * b.y - a.y * b.x;
  }
  friend Point operator - (Point a, Point b) {
    return (Point) {a.x - b.x, a.y - b.y};
  }
};

bool CheckConvex(int n, Point *point) {
  if (Times(point[2] - point[1], point[3] - point[2]) < 0) 
    reverse(point + 1, point + n + 1);
  for (int i = 1; i < n - 1; ++i) {
    if (Times(point[i + 1] - point[i], point[i + 2] - point[i + 1]) < 0) 
      return false;
  }
  if (Times(point[n] - point[n - 1], point[1] - point[n]) < 0) return false;
  return true;
}

Point ReadPoint() {
  Point p;
  scanf("%Lf%Lf", &p.x, &p.y);
  return p;
}

Point point[N];

int main() {
// #ifndef ONLINE_JUDGE
//   freopen("CGL_3_B.in", "r", stdin);
//   freopen("CGL_3_B.out", "w", stdout);
// #endif
// #ifdef LOCAL_LOGGER
//   freopen("CGL_3_B.log", "w", stderr);
// #endif
  int n = read();
  for (int i = 1; i <= n; ++i) point[i] = ReadPoint();
  puts(CheckConvex(n, point) ? "1" : "0");
  return 0;
}

/* ==== Makefile ==== {{{
CompileAndRun:
	make Compile
	make Run

Compile:
	g++ -o CGL_3_B CGL_3_B.cpp -g -Wall -DLOCAL_LOGGER

CompileUF:
	g++ -o CGL_3_B CGL_3_B.cpp -g -Wall -DLOCAL_LOGGER -fsanitize=undefined

Run:
	./CGL_3_B < CGL_3_B.in > CGL_3_B.out
==================
}}} */



Measured memory_bytes: 3240
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;
ll mod=1000*1000*1000+7;
const ll inf=1e18;

int n;

vi graf[nax];

ll dol[nax];
ll gor[nax];

ll wyn[nax];

void dfs1(int v, int oj)
{
	for (int &i : graf[v])
	{
		if (i==oj)
		{
			swap(i, graf[v].back());
			graf[v].pop_back();
			break;
		}
	}
	dol[v]=1;
	for (int i : graf[v])
	{
		dfs1(i, v);
		dol[v]=(dol[v]*dol[i])%mod;
	}
	dol[v]=(dol[v]+1)%mod;
}

ll pre[nax];
ll suf[nax];

void dfs2(int v, int oj)
{
	int r=graf[v].size();
	pre[0]=suf[r+1]=1;
	for (int i=1; i<=r; i++)
		pre[i]=(pre[i-1]*dol[graf[v][i-1]])%mod;
	for (int i=r; i; i--)
		suf[i]=(suf[i+1]*dol[graf[v][i-1]])%mod;
	ll mno=gor[v];
	//~ debug() << v;
	//~ debug() << range(pre+1, pre+1+r);
	//~ debug() << range(suf+1, suf+1+r);
	for (int i=1; i<=r; i++)
	{
		ll x=(pre[i-1]*suf[i+1])%mod;
		x=(x*mno+1)%mod;
		gor[graf[v][i-1]]=x;
	}
	wyn[v]=gor[v]%mod;
	for (int i : graf[v])
		wyn[v]=(wyn[v]*dol[i])%mod;
	for (int i : graf[v])
	{
		dfs2(i, v);
	}
}

int main()
{
	scanf("%d%lld", &n, &mod);
	for (int i=1; i<n; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		graf[a].push_back(b);
		graf[b].push_back(a);
	}
	dfs1(1, 0);
	gor[1]=1;
	dfs2(1, 0);
	
	for (int i=1; i<=n; i++)
		printf("%lld\n", wyn[i]);
	return 0;
}


Measured memory_bytes: 41848
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a=[[i,x] for i,x in enumerate(a)]
b=[[i,x] for i,x in enumerate(b)]
a.sort(key=lambda x:x[1])
b.sort(key=lambda x:x[1])
mod=pow(10,9)+7
kc=set(())
kr=set(())
ans=1
for i in range(n*m,0,-1):
  if not b:
    if a[-1][1]==i:
      r,j=a.pop()
      ans*=len(kc)
      kr.add(r)
    elif a[-1][1]<i:
      ans*=len(kr)*len(kc)-(n*m-i)
    else:
      print(0)
      exit()
  elif not a:
    if b[-1][1]==i:
      c,j=b.pop()
      ans*=len(kr)
      kc.add(c)
    elif b[-1][1]<i:
      ans*=len(kr)*len(kc)-(n*m-i)
    else:
      print(0)
      exit()
  elif a[-1][1]==i and b[-1][1]==i:
    r,_=a.pop()
    c,_=b.pop()
    kc.add(c)
    kr.add(r)
  elif a[-1][1]<i and b[-1][1]==i:
    c,_=b.pop()
    kc.add(c)
    ans*=len(kr)
  elif a[-1][1]==i and b[-1][1]<i:
    r,_=a.pop()
    kr.add(r)
    ans*=len(kc)
  elif a[-1][1]<i and b[-1][1]<i:
    ans*=len(kr)*len(kc)-(n*m-i)
  else:
    print(0)
    exit()
  ans%=mod
  #print(a,b,i,ans)
  if not a and not b:
    for j in range(1,i):
      ans*=j
      ans%=mod
    break
print(ans)


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

  string s;
  cin >> s;

  if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3])printf("Yes\n");
 else if(s[0] == s[2] && s[2] != s[1] && s[1] == s[3])printf("Yes\n");
 else if(s[0] == s[3] && s[3] != s[1] && s[1] == s[2])printf("Yes\n");
 else printf("No\n");

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  string s;
  cin >> s;
  int n = s.size();
  int cnt1 = 0;
  rep(i,n) {
    if (i % 2 == 0 && s[i] != '0') cnt1++;
    if (i % 2 == 1 && s[i] != '1') cnt1++;
  } 
  int cnt2 = 0;
  rep(i,n) {
    if (i % 2 == 0 && s[i] != '1') cnt2++;
    if (i % 2 == 1 && s[i] != '0') cnt2++;
  } 
  cout << min(cnt1, cnt2) << endl;
}

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

Measured memory_bytes: 3760
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>  // std::greater<T>()

using namespace std;

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから

// func declaration
template <class T> void printVec(vector<T>);
template <class T> void calcVec(vector<T>&, int, char);
bool checkMultiple(vector<int>&, int);

// const
const int INF = 10000000;

/*MEMO
辞書順
abc < abcd, atcoder < atlas
*/

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    REP(i, N) cin >> vec.at(i);

    int res = INF;
    REP(i, N) {
        int count = 0;
        int num = vec.at(i);

        if (num%2 != 0) {
            res = 0;
            break;
        }

        while (num%2 == 0) {
            num /= 2;
            count++;
        }

        if (count < res) res = count;
    }
    cout << res << endl;
    
    return 0;
}

// function
template <class T> void printVec(vector<T> vec) {
    // 1要素ずつ、空白・改行なしで出力
    REP(i, vec.size()) {
        cout << vec.at(i);
    }
    cout << endl;
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    if (ch == '+') {
        REP(i, vec.size()) {
            vec.at(i) += num;
        }
    } else if (ch == '-') {
        REP(i, vec.size()) {
            vec.at(i) -= num;
        }
    } else if (ch == '*') {
        REP(i, vec.size()) {
            vec.at(i) *= num;
        }
    } else if (ch == '/'){
        REP(i, vec.size()) {
            vec.at(i) /= num;
        }
    } else if (ch == '%') {
        REP(i, vec.size()) {
            vec.at(i) %= num;
        }
    }
}

bool checkMultiple(vector<int> &vec, int num) {
    // vecの中身が、numの倍数かどうかのチェック
    int count = 0;
    REP(i, vec.size()) {
        if (vec.at(i)%num != 0) count++;
    }
    return (count == 0);
}


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

using namespace std;

using ll = long long;
using vi = vector <int>;
using vll = vector <ll>;
using vvi = vector <vi >;
using pii = pair <int, int>;
using pll = pair <long, long>;
using vpi = vector <pii >;

#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define dg(x) cout << #x << " = " << x << endl

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

    ll x, k, d;
    cin >> x >> k >> d;
    if (x >= 0)
    {
        if (d > x)
        {
            if (k % 2)
                cout << abs(x - d) << endl;
            else
                cout << x << endl;
        }
        else if (x / d >= k)
            cout << x - (d * k) << endl;
        else
        {
            ll a = x % d;
            ll b = d - a;
            k -= x / d;
            if (k % 2 == 0)
                cout << a << endl;
            else
                cout << b << endl;
        }
    }
    else
    {
        if (abs(x) < d)
        {
            if (k % 2 == 0)
                cout << abs(x) << endl;
            else
                cout << x + d << endl;
        }
        else if (abs(x) / d >= k)
            cout << abs(x + (d * k)) << endl;
        else
        {
            ll a = abs(x) % d;
            ll b = d - a;
            k -= abs(x) / d;
            if (k % 2 == 0)
                cout << a << endl;
            else
                cout << b << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int r;
  cin >> r;
  cout << 3*pow(r, 2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string s;
int main(){
    int z,x,i,j;
    bool k=false;
    cin>>x;
    for( i=1;i<=9;i++)
    {
    for(j=1;j<=9;j++){
        z=j*i;
        if(x==z){k=true;}
    }
    }
    if(k){cout<<"Yes";}else{cout<<"No";}
return 0;}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code
  int n;
  char q = '0';
  int ans = 0;
  cin >> n;
  rep(i,n)
  {
    char u;
    cin >> u;
    if(q != u)
    {
      ans++;
    }
    q = u;
  }
  cout << ans;
}

Measured memory_bytes: 256
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);
const long double PI=3.14159265358979;

// Required random number generators

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    READV(K);
    READAR(A,N);
    ll pref_2[N]={0};
    FORI(i,0,N)
    {
        pref_2[i]=max(pref_2[i],A[i]);
        if(i>0)
        {
            pref_2[i]+=pref_2[i-1];
            A[i]+=A[i-1];
        }
    }
    ll ans=0;
    FORI(i,0,N)
    {
        if(i+K-1<N)
        {
            ll sum=A[i+K-1]+pref_2[N-1]-pref_2[i+K-1];
            ll sum1=pref_2[N-1]-pref_2[i+K-1];
            if(i>0)
            {
                sum-=A[i-1];
                sum+=pref_2[i-1];
                sum1+=pref_2[i-1];
            }
            ans=max({ans,sum,sum1});
        }
    }
    cout<<ans<<endl;

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


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int>ai(N+1,0);

  for(int i=0;i<N;i++){
    cin >> ai.at(i);
  }
  sort(ai.begin(),ai.end());
  reverse(ai.begin(),ai.end());

  int count_Alice=0,count_Bob=0;
  for(int i=0;i<(N+1)/2;i++){
    count_Alice+=ai.at(2*i);
    count_Bob+=ai.at(2*i+1);
  }
  cout << count_Alice-count_Bob << endl;
}


Measured memory_bytes: 256
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ld long double


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}

typedef long long int ll;
#define int ll
#define endl '\n'
const ll mod =1e9+7;
const ll MAX_NODES =200001;
const ll MAX_LOG =50;
const ll inf = 1e18+123;
const int maxn = 2000001;
int32_t main()
{

   IOS
  int k,a,b;
  cin>>k>>a>>b;
  if(a%k == 0)
    {
      cout<<"OK"<<endl;
      return 0;
    }
  int mul = a+(k-a%k);
   if(mul<=b){
     cout<<"OK"<<endl;
   }
   else{
     cout<<"NG";
   }
  
} 


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

int main() {
  string s;
  cin >> s;
  
  int ans = 700;
  for( int i = 0; i < 3; i++ ){
    if( s.at(i) == 'o' ) ans += 100;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define fi first
#define se second
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef long double ld;
typedef string st;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e14;                                                                                           
ll mpow(ll a,ll b,ll p=MOD){a=a%p;ll res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}             
const ll N=51;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  st s;
  cin>>s;
  if(s.length()==2)
  {
    cout<<s;
  }
  else{
    reverse(all(s));
    cout<<s;
  }
}
//nothing is impossible

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll P = 1000000007;
struct mint
  {ll v;
  mint() : v(0) {}
  mint(ll a) : v(a) {}
  mint operator*(mint b) {return this->v * b.v % P;}
  mint operator+(mint b) {return (this->v + b.v) % P;}
  mint operator-(mint b) {return *this + (P - b.v);}};
mint f(ll b, ll n) {if (n <= 0) return 1; auto p = f(b, n / 2); return p * p * (n % 2 ? b : 1);}
int main()
  {int N; cin >> N;
  map<pair<int, int>, pair<int, int>> m;
  int z = 0;
  for (int i = 0; i < N; ++i)
    {ll A, B; cin >> A >> B;
    if (A == 0 && B == 0) {++z; continue;}
    if (A == 0) {m[{0, 1}].first++; continue;}
    else if (B == 0) {m[{0, 1}].second++; continue;}
    ll a = abs(A), b = abs(B);
    ll g = gcd(a, b); a = a / g; b = b / g;
    if ((A > 0 && B > 0) || (A < 0 && B < 0)) m[{a, b}].first++;
    else m[{b, a}].second++;}
  mint ans = 1;
  for (auto p : m) ans = ans * (f(2, p.second.first) + f(2, p.second.second) - 1);
  ans = ans - 1 + z;
  cout << ans.v << endl;}

Measured memory_bytes: 16136
import math

def gcd(a,b):
    """Compute the greatest common divisor of a and b"""
    while b > 0:
        a, b = b, a % b
    return a
 
def lcm(a, b):
    """Compute the lowest common multiple of a and b"""
    return a * b / gcd(a, b)
 

def f(b,n):
	if n < b:
		return n
	return f(b, n//b) + n%b
 

s = input().strip()
ans = int(s[0])*100+int(s[1])*10+int(s[2])

for i in range(1, len(s)-2):
    if(abs(int(s[i])*100+int(s[i+1])*10+int(s[i+2]) - 753) < abs(ans - 753)):
        ans = int(s[i])*100+int(s[i+1])*10+int(s[i+2])

print(abs(753-ans))

Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <array>
#include <utility>
#include <climits>
using namespace std;

int rnd(int &a, int &b){
	static const int C = ~(1u << 31);
	static const int M = (1 << 16) - 1;
	a = 36969 * (a & M) + (a >> 16);
	b = 18000 * (b & M) + (b >> 16);
	return (C & ((a << 16) + b)) % 1000000;
}

int main(){
	int m, n, a, b, x, y, z;
	while(scanf("%d%d%d%d", &m, &n, &a, &b), m | n){
		vector<array<int,3>> v(n + m);
		for(int i = 0; i < m; ++i){
			scanf("%d%d%d", &x, &y, &z);
			v[i][0] = x;
			v[i][1] = -y;
			v[i][2] = -z;
		}
		for(int i = m; i < n + m; ++i){
			v[i][0] = rnd(a, b);
			v[i][1] = -rnd(a, b);
			v[i][2] = -rnd(a, b);
		}
		sort(v.begin(), v.end());
		int ans = 0;
		vector<map<int,int>> mps(m + n + 3);
		mps[0][100] = 100;
		for(size_t i = 1; i < mps.size(); ++i){
			mps[i][INT_MIN] = INT_MAX;
		}
		for(int i = 0; i < m + n; ++i){
			y = v[i][1];
			z = v[i][2];
			int left = 1, right = ans + 1;
			while(left < right){
				int mid = (left + right + 1) >> 1;
				const auto &mpm = mps[mid - 1];
				auto it = mpm.upper_bound(y);
				if(it != mpm.end() && it->second > z){
					left = mid;
				}
				else{
					right = mid - 1;
				}
			}
			
			auto &mpl = mps[left];
			for(auto it = mpl.upper_bound(y); ; ){
				--it;
				if(it->second > z){
					break;
				}
				it = mpl.erase(it);
			}
			
			int &t = mpl.insert(make_pair(y, z)).first->second;
			t = max(t, z);
			ans = max(ans, left);
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 37032
#include<cstdio>
#include<cmath>
int main()
{
    long long n;
    scanf("%lld",&n);
    int a=int(sqrt(n));
    while(n%a)
        a=a-1;
    a=n/a;
    int s=0;
    while(a>0)
        s=s+1,a/=10;
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main() {
  int n , a, b,ac(0),bc(0);

  cin >> n >> a >> b;
  vector<char> c(n);

  for(int i = 0;i < n ; i++){
      cin >> c.at(i);
  }

  for(int i = 0; i < n ;i++){

    if(c.at(i) == 'a'){
        if(ac < (a+b)){
            cout << "Yes" << endl;
            ac++;
        }else{
            cout << "No" << endl;
        }
    }

    if(c.at(i) == 'b'){
        if(ac < (a+b) && bc < b){
            cout << "Yes" << endl;
            ac++;
            bc++;
        }else{
            cout << "No" << endl;
        }
    }
    

    if(c.at(i) == 'c'){
          cout << "No" << endl;
      }
    }
  
}
   

Measured memory_bytes: 768
'use strict'
function main(input) {
  input = input.trim().split('\n')
  const DG = input.shift().split(' ').map(v => Number(v))
  input = input.map(v => v.split(' ').map(v => Number(v)))
  let ans = -1
  for (let i = 0; i < Math.pow(2, DG[0]); i++) {
    let flag = ('0000000000' + i.toString(2)).slice(-1 * DG[0])
    let max = -1
    let score = DG[1]
    let count = 0
    for(let j = 0; j < DG[0]; j++) {
      if (flag[j] === '1') {
        let point = (j+1) * 100
        score -= point * input[j][0] + input[j][1]
        count += input[j][0]
      } else {
        max = j
      }
    }
    if (score > 0 && ~max) {
      let point = (max+1) * 100
      let num = Math.ceil(score / point)
      num = input[max][0] > num ? num : input[max][0]
      count += num
      score -= point * num
    }
    if (score <= 0 && (!~ans || ans > count)) {
      ans = count
    }
  }
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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


int main(){
  int n, m; cin >> n >> m;
  vector<pair<int, int>> p(m);
  rep(i, m){
    cin >> p[i].first >> p[i].second;
  }
  sort(p.begin(), p.end());
  int ans = 0, maxa = -1, minb = -1;
  rep(i, m){
    int a = p[i].first, b = p[i].second;
    if(a < minb){
      maxa = max(maxa, a);
      minb = min(minb, b);
    }
    else{
      maxa = a;
      minb = b;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4056
n=int(input())
l=[]

for i in range(n):
  x_=input()
  if x_ not in l:
    l.append(x_)
    
  else:
    print('No')
    exit()
    
alpha_list=[chr(i) for i in range(97,123)]

for i in range(len(l)-1):
  if l[i][-1]==l[i+1][0]:
    continue
    
  else:
    print('No')
    exit()
    
print('Yes')

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

int main() {
  int k, x;
  cin >> k >> x;

  int s, g;
  s = x - k + 1;
  g = x + k - 1;

  for(int i = s; i <= g; i++) {
    cout << i << " ";
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n,k;
  cin >> n >> k;
  
  ll v[n];
  for(int i=0;i<n;i++)cin >> v[i];

  ll r=min(n,k);
  vector<ll> G;
  ll s=0;

  for(int a=0;a<=r;a++){
    for(int b=0;b<=r-a;b++){
        G={};
        ll l=0;
        for(int i=0;i<a;i++){  
          G.push_back(v[i]);
          l+=v[i];
        }
        for(int i=0;i<b;i++){
          G.push_back(v[n-1-i]);
          l+=v[n-1-i];
        }
        sort(G.begin(),G.end());
        for(int i=0;i<min(k-a-b,(ll) G.size());i++){
          if(G[i]<0)l-=G[i];
        }
        s=max(s,l);
    }
  }

  cout << s << endl;
  

}

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

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

    int ans = 0;
    for (int i = 1; i <= N; i += 2)
    {
        int cnt = 0;
        for (int j = 1; j <= i; j++)
        {
            if (i % j == 0)
            {
                cnt++;
            }
        }
        if (cnt == 8)
            ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////


int main(){
    ll n;
    cin >> n;
    ll a[n] = {};
    inrep(n,a);

    ll sum = 0;
    rep(i,0,n)sum += a[i];

    ll l = 0;
    ll ans = linf;
    rep(i,0,n-1){
	l += a[i];
	ll r = sum - l;

	//PS(l);P(r);
	ans = min(ans, abs(l - r));
    }
    P(ans);
    return  0;
}


Measured memory_bytes: 1792
N=int(input())
S=[input() for _ in range(N)]

def solve(N,S):
  st=[tuple(x) for x in S]
  ch=list(zip(*st))
  ans=0
  for i in range(N):
    if st==ch:
      ans+=N
    st=st[-1:]+st[:-1]
    ch=[row[-1:] + row[:-1] for row in ch]
  return ans

print(solve(N,S))

Measured memory_bytes: 5332
n, m = map(int, input().split())
lp, ls = [0] * m, [0] * m
for i in range(m):
    lp[i], ls[i] = input().split()

lpu = list(set(lp))
lac = [0] * n
lwa = [0] * n

for j in range(m):
    p = int(lp[j]) - 1
    if lac[p] == 0:
        if ls[j] == 'AC':
            lac[p] = 1
        else:
            lwa[p] += 1

print(sum(lac), sum(x * y for x, y in zip(lac, lwa)))

Measured memory_bytes: 21868
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
typedef long long int ll;
#define iceil(a,b) (x+y-1)/y
#define min(x,y)(x<y?x:y)
 
using namespace std;
typedef pair<int, int> P;


int main() {
	FAST;

	int n;
	cin >> n;

	vector<int> a;
	a.resize(n);
	rep(i,n) cin >> a[i];

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

	int ans = a[n-1] - a[0];

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
using namespace std;

const unsigned long long BASE = 1e9 + 7;

int main()
{
    int x;
    cin >> x;
    int clip[] = { 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000 };
    for (int i = 0; i < 8; i++)
    {
        if (x >= clip[i] && x < clip[i + 1])
        {
            cout << 8 - i << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3640
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var s = sc.nextInt();
        var dic = new Dictionary<int, int>();
        var i = 0;
        while (true) {
            i++;
            if (dic.ContainsKey(s)) {
                WriteLine(i);
                return;
            } else {
                dic.Add(s, 1);
            }

            if (s % 2 == 0) {
                s /= 2;
            } else {
                s = (3 * s) + 1;
            }

        }
    }
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


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

typedef long long int64;

int64 solve(int64 n, int64 m) {
	if (n % 3 == 0) return 0;
	int64 s1, s2, s3;
	int64 best = m;
	for (int i = 1; i < m; ++i) {
		s1 = n * i;
		s2 = (m - i) * (n / 2);
		s3 = (m - i) * ((n + 1) / 2);
		best = min(best, max(s1, max(s2, s3)) - min(s1, min(s2, s3)));
	}
	return best;
}

int main() {
    int64 n, m;
    cin >> n >> m;
    cout << min(solve(n, m), solve(m, n));
}

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

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

using namespace std;

#define AND 0
#define OR  1

pair<bool,vector<vector<int>>> solve(int n,vector<int> s,vector<int> t,vector<int> u,vector<int> v){
	vector<vector<int>> res(n,vector<int>(n,-1));

	vector<int> R,C;
	int rcnt[2]={},ccnt[2]={};
	rep(i,n){
		if(s[i]==AND && u[i]==1){
			rep(j,n) res[i][j]=1;
			rcnt[1]++;
		}
		else if(s[i]==OR && u[i]==0){
			rep(j,n) res[i][j]=0;
			rcnt[0]++;
		}
		else R.emplace_back(i);
	}
	rep(j,n){
		if(t[j]==AND && v[j]==1){
			rep(i,n) res[i][j]=1;
			ccnt[1]++;
		}
		else if(t[j]==OR && v[j]==0){
			rep(i,n) res[i][j]=0;
			ccnt[0]++;
		}
		else C.emplace_back(j);
	}

	if(R.size()==1){
		int tar=u[R[0]];
		for(int x:C){
			if(rcnt[v[x]]>0) res[R[0]][x]=tar;
			else             res[R[0]][x]=v[x];
		}
	}
	else if(C.size()==1){
		int tar=v[C[0]];
		for(int y:R){
			if(ccnt[u[y]]>0) res[y][C[0]]=tar;
			else             res[y][C[0]]=u[y];
		}
	}
	else if(R.size()>=2 && C.size()>=2){
		rep(i,R.size()) rep(j,C.size()) res[R[i]][C[j]]=(i+j)%2;
	}

	// check
	rep(i,n){
		int z;
		if(s[i]==AND){
			z=1;
			rep(j,n) z&=res[i][j];
		}
		else{
			z=0;
			rep(j,n) z|=res[i][j];
		}
		if(z!=u[i]) return {false,{}};
	}
	rep(j,n){
		int z;
		if(t[j]==AND){
			z=1;
			rep(i,n) z&=res[i][j];
		}
		else{
			z=0;
			rep(i,n) z|=res[i][j];
		}
		if(z!=v[j]) return {false,{}};
	}
	return {true,res};
}

int main(){
	int n; scanf("%d",&n);
	vector<int> s(n),t(n);
	vector<unsigned long long> u(n),v(n);
	rep(i,n) scanf("%d",&s[i]);
	rep(j,n) scanf("%d",&t[j]);
	rep(i,n) scanf("%llu",&u[i]);
	rep(j,n) scanf("%llu",&v[j]);

	unsigned long long ans[500][500]={};
	rep(b,64){
		vector<int> u2(n),v2(n);
		rep(i,n){
			u2[i]=u[i]>>b&1;
			v2[i]=v[i]>>b&1;
		}
		auto tmp=solve(n,s,t,u2,v2);
		if(!tmp.first) return puts("-1"),0;
		rep(i,n) rep(j,n) if(tmp.second[i][j]==1) ans[i][j]+=1ULL<<b;
	}
	rep(i,n) rep(j,n) printf("%llu%c",ans[i][j],j<n-1?' ':'\n');

	return 0;
}


Measured memory_bytes: 8612
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long int lli;
typedef vector<lli> vi;
typedef pair<lli, lli> ii;

ii max(vi arr) {
  lli ret = 0;
  lli argmax = -1;
  for (lli i=0; i < arr.size(); i++) {
    if (ret < arr[i]) {
      ret = arr[i];
      argmax = i;
    }
  }
  return ii(ret, argmax);
}

ii max(vi arr, lli avoid) {
  lli ret = 0;
  lli argmax = -1;
  for (lli i=0; i < arr.size(); i++) {
    if (ret < arr[i] && i != avoid) {
      ret = arr[i];
      argmax = i;
    }
  }
  return ii(ret, argmax);
}

lli changes(vi a, bool even_first) {
  lli begin = even_first ? 0 : 1;
  lli num = 0;
  vi freq(100005, 0);
  for (lli i=begin; i<a.size(); i += 2) {
    num ++;
    freq[a[i]] ++;
  }
  lli x1 = num - max(freq).first;
  /* cout << "x1 = " << x1 << endl; */
  lli avoid = max(freq).second;
  /* cout << "avoid = " << avoid << endl; */

  begin = even_first ? 1 : 0;
  num = 0;
  freq.clear();
  freq.resize(100005, 0);
  for (lli i=begin; i<a.size(); i += 2) {
    num ++;
    freq[a[i]] ++;
  }
  lli x2;
  if (max(freq, avoid).second == -1) {
    x2 = num;
    /* cout << "x2 = " << x2 << endl; */
  } else {
    x2 = num - max(freq, avoid).first;
    /* cout << "x2 = " << x2 << endl; */
  }
  return x1 + x2;
}

int main(int argc, char ** argv) {
  lli n;
  cin >> n;
  vi a(n, 0);
  for (int i=0; i<n; i++) {
    cin >> a[i];
  }

  /* cout << changes(a, true) << endl; */
  /* cout << changes(a, false) << endl; */
  cout << min(changes(a, true), changes(a, false)) << endl;
  return 0;
}


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

using namespace std;
long long rm=998244353ll;
long long mdpw(long long b,long long ex){
    long long ret=1ll;
    long long pw=b;
    while(ex){
        if(ex&1){
            ret*=pw;
            ret%=rm;
        }
        pw*=pw;
        pw%=rm;
        ex>>=1;
    }

    return ret;
}
int main()
{///{}
    long long n,m,k;
    cin>>n>>m>>k;
    if(n==1ll){
        cout<<m<<'\n';
        return 0;
    }
    long long ans=0ll;
    ans+=m*mdpw(m-1,n-1);
    ans%=rm;
    long long kcnt=1;
    long long ncnt=n-1;
    long long C=ncnt;
        C%=rm;
    for(int ik=1;ik<=k;ik++){
        ans+=(C*((m*mdpw(m-1,n-1-ik))%rm))%rm;
        ans%=rm;
        ncnt--;
        kcnt++;
        C*=ncnt;
        C%=rm;
        C*=mdpw(kcnt,rm-2);
        C%=rm;
        ///cout<<ncnt<<'\n';
    }
    cout<<ans<<'\n';
    return 0;
}
/***
60522 114575 7559
*/


Measured memory_bytes: 3604
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll dp[100005][2];
int main(){
  string s;cin>>s;
  ll x=s.length();
  ll i,j;
  dp[0][0]=1;
  rep(i,x){
    if(s[i]=='0'){
      dp[i+1][0]=dp[i][0];
      dp[i+1][1]=dp[i][1]*3;
    }
    else{
      dp[i+1][0]=dp[i][0]*2;
      dp[i+1][1]=dp[i][1]*3;
      dp[i+1][1]+=dp[i][0];
    }
    dp[i+1][0]%=mod;
    dp[i+1][1]%=mod;
  }

  cout<<(dp[x][0]+dp[x][1])%mod<<endl;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;
	ll W;
	cin>>n>>W;
	vector<ll> w(n),v(n);
	vector<ll> t[4];
	for(int i=0;i<n;++i){
		cin>>w[i]>>v[i];
		if(i) w[i]-=w[0];
	}
	ll w0=w[0];
	w[0]=0;
	for(int i=0;i<n;++i)
		t[w[i]].push_back(v[i]);
	for(int i=0;i<4;++i)
		sort(t[i].begin(),t[i].end(),greater<ll>());
	ll sum[4]={0},res=0;
	for(ll i=0;i<=int(t[0].size());++i){
		if(i) sum[0]+=t[0][i-1];
		sum[1]=sum[2]=sum[3]=0;
		for(ll j=0;j<=int(t[1].size());++j){
			if(j) sum[1]+=t[1][j-1];
			sum[2]=sum[3]=0;
			for(ll k=0;k<=int(t[2].size());++k){
				if(k) sum[2]+=t[2][k-1];
				sum[3]=0;
				for(ll g=0;g<=int(t[3].size());++g){
					if(g) sum[3]+=t[3][g-1];
					ll weights=i*w0+j*(w0+1LL)+k*(w0+2LL)+g*(w0+3LL);
					if(weights<=W)
						res=max(res,sum[0]+sum[1]+sum[2]+sum[3]);
				}
			}
		}
	}
	cout<<res<<'\n';
}




Measured memory_bytes: 3668
#include <stdlib.h>
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
#define ll long long
const ll INF=0x3f3f3f3f;
#define mod 109
using namespace std;
//priority_queue
const ll Maxn=1e5;
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
ll kc(ll a,ll b)
{
    ll c=1;
    while(b)
    {
        if(b&1)c=(c*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return c;
}
bool cmp(double x,double y)
{
    return x>y;
}

int main()
{ ios::sync_with_stdio(false);

 string s;
 cin>>s;
 if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2]||s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1]||s[1]!=s[0]&&s[0]==s[3]&&s[1]==s[2])cout<<"Yes\n";
 else cout<<"No\n";
}


Measured memory_bytes: 256
#include <cstdio>
int main (int argc, char const* argv[])
{
	int S=0,T=0,P;
	for(int i=0;i<4;i++) {
		scanf("%d",&P);
		S+=P;
	}
	for(int i=0;i<4;i++) {
		scanf("%d",&P);
		T+=P;
	}
	printf("%d\n",S>=T?S:T);
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    if(count(a.begin(),a.end(),0)!=0){
        cout<<0<<endl;
        return 0;
    }
    ll ans=1;
    rep(i,n){
        if(a[i]<=(ll)1e18/ans){
            ans*=a[i];
        }
        else{cout<<-1<<endl; return 0;}
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  long a,b,k;
  cin >> a >> b >> k;
  if(a >= k){
    cout << a-k << " " << b << endl;
  }else{
    cout << 0 << " ";
    long t = b - (k-a);
    if(t < 0) t = 0;
    cout << t << endl;
  }
}




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

int main()
{
  i64 n, a, b, c, d;
  string s;
  cin >> n >> a >> b >> c >> d >> s;
  s = "#" + s + "#";
  bool ok = true, pass = false;
  for (i64 i = a; i < c; i++)
    if (s.substr(i, 2) == "##")
      ok = false;
  for (i64 i = b; i < d; i++)
    if (s.substr(i, 2) == "##")
      ok = false;
  for (i64 i = b; i <= d; i++)
    if (s.substr(i - 1, 3) == "...")
      pass = true;
  if (ok && (d < c ? pass : true))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 772
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iostream>
#include <set>
#include <string>
#include <utility>

using namespace std;

int main() {
  int a, b, c, num;

  cin >> a >> b >> c >> num;

  int sum = 0;

  if (a <= num) {
    sum += a;
    num -= a;
  } else {
    sum += num;
    num = 0;
  }

  if (b <= num) {
    num -= b;
  } else {
    num = 0;
  }

  if (c <= num) {
    sum -= c;
  } else {
    sum -= num;
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3188
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
#include "tuple"

#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

ll n, a, b, ans = 0, ansmem;
vector<bool>B(100000, false), Bmem;
bool AAA = false, BBB = false,memAAA,memBBB;
vector<pair<ll, pair<int, bool>>>V;
priority_queue<pair<ll,pair<int,bool>>,vector<pair<ll, pair<int, bool>>>,greater<pair<ll, pair<int, bool>>>>q;
int main() {
	cin >> n;
	rep(n) {
		cin >> a >> b;
		q.push(mkp(a, mkp(i, true)));
		q.push(mkp(b, mkp(i, false)));
	}
	rep(n-2) {
		ans += q.top().first;
		B[q.top().second.first] = true;
		if (q.top().second.second)
			AAA = true;
		else BBB = true;
		q.pop();
	}
	for (int i = 0; i < 4; ++i) {
		V.push_back(q.top());
		q.pop();
	}
	Bmem = B;
	memAAA = AAA;
	memBBB = BBB;
	ansmem = ans;
	ll mn = llmax;
	for (int i = 0; i < 3; ++i) {
		for (int j = i + 1; j < 4; ++j) {
			B = Bmem;
			AAA = memAAA;
			BBB = memBBB;
			ans = ansmem;
			ans += V[i].first;
			B[V[i].second.first] = true;
			if (V[i].second.second)
				AAA = true;
			else BBB = true;
			ans += V[j].first;
			B[V[j].second.first] = true;
			if (V[j].second.second)
				AAA = true;
			else BBB = true;
			if (!AAA || !BBB) {
				mn = min(mn, ans);
			}
			else {
				for (int k = 0; k < n; ++k) {
					if (!B[k]) {
						mn = min(mn, ans);
						break;
					}
				}
			}
		}
	}
	cout << mn << endl;
	return 0;
}


Measured memory_bytes: 6516
#include<bits/stdc++.h>
#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--)
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;

int main(){
  ll n,l;
  cin >> n >> l;
  vector<ll> x(n),a(n);
  rep(i,n)cin >> x[i];
  rep(i,n)cin >> a[i];

  vector<ll> cur(l+1,0);
  cur[l] = 1;

  rrep(i,n){
    vector<ll> nxt(l+1,0);
    ll sum = cur[l];
    rrep(j,l){
      if(j<x[i])break;
      if( a[i]>0 && (j-x[i])%a[i] == 0 ){
	nxt[j] += sum; nxt[j] %= mod;
      }else if(a[i]==0 && j==x[i]){
	nxt[j] += sum; nxt[j] %= mod;
      }
      sum += cur[j]; sum %= mod;
    }
    cur = nxt;
  }

  ll res = 0;
  rep(i,l)(res += cur[i]) %= mod;
  cout << res << endl;
}

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

#define ll long long
#define mx  40005
#define mod 1000000009
#define lim 10000000
#define inf 2000000000
#define N 18
#define eps 100000
#define PI acos(-1)

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;cin>>n;

	string s[n+5];
	map<string,int>mp;

	for(int i=0;i<n;i++)
		cin>>s[i];
	char last=s[0][s[0].size()-1];
	mp[s[0]]=1;

	bool flag=true;

	for(int i=1;i<n;i++)
	{
	   char cur=s[i][s[i].size()-1];
        if(mp[s[i]] || last!=s[i][0])
	   {
	   	flag=false;break;
	   }
	   mp[s[i]]=1;
	   last=cur;

	}

	if(flag)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256