akhauriyash/Code-Regression huggingface dataset:
/*
    author:  Maksim1744
    created: 13.06.2020 15:08:24
*/

#include <bits/stdc++.h>

using namespace std;

#define ll   long long
#define ld   long double

#define mp   make_pair
#define pb   push_back
#define eb   emplace_back

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

template<typename T>             vector<T>& operator--            (vector<T>& v){for (auto& i : v) --i;            return  v;}
template<typename T>             vector<T>& operator++            (vector<T>& v){for (auto& i : v) ++i;            return  v;}
template<typename T>             istream& operator>>(istream& is,  vector<T>& v){for (auto& i : v) is >> i;        return is;}
template<typename T>             ostream& operator<<(ostream& os,  vector<T>& v){for (auto& i : v) os << i << ' '; return os;}
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p){is >> p.first >> p.second;        return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, pair<T, U>& p){os << p.first << ' ' << p.second; return os;}
template<typename T, typename U> pair<T,U> operator-(pair<T,U> a, pair<T,U> b){return mp(a.first-b.first, a.second-b.second);}
template<typename T, typename U> pair<T,U> operator+(pair<T,U> a, pair<T,U> b){return mp(a.first+b.first, a.second+b.second);}
template<typename T, typename U> void umin(T& a, U b){if (a > b) a = b;}
template<typename T, typename U> void umax(T& a, U b){if (a < b) a = b;}

#ifdef HOME
#define TAG_LENGTH       25
#define LR_LEFT          left
#define LR_RIGHT         right
#define LR_VALUE         value
#define LR_SECOND_VALUE  mn
#include "C:/C++ libs/print.cpp"
#else
#define showl            42;
#define shows            42;
#define show(...)        42;
#define showm(...)       42;
#define showt(...)       42;
#define printTree(...)   42;
#define printGraph(...)  42;
#define printLRTree(...) 42;
#define printMatrix(...) 42;
#define printWGraph(...) 42;
#define debug     if (false)
#endif

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

    int n;
    cin >> n;
    int k;
    cin >> k;
    vector<int> v(n);
    cin >> v;

    auto upd = [&](vector<int> &v) {
        vector<int> v1(n, 0);
        vector<int> ad(n, 0), dl(n, 0);
        for (int i = 0; i < n; ++i) {
            ad[max(0, i - v[i])]++;
            dl[min(n - 1, i + v[i])]++;
        }
        int cur = 0;
        for (int i = 0; i < n; ++i) {
            cur += ad[i];
            v1[i] = cur;
            cur -= dl[i];
        }
        return v1;
    };

    for (int i = 0; i < k; ++i) {
        auto v1 = upd(v);
        swap(v, v1);
        if (v == v1) {
            break;
        }
    }
    cout << v << '\n';

    return 0;
}


Measured memory_bytes: 6348
#include "bits/stdc++.h"
using namespace std;

int main(){
  int K, S;
  cin >> K >> S;
  int ans = 0;
  for(int i = 0; i <= K; i++){
    for(int j = 0; j <= K; j++){
      int m = S - i - j;
      if(m >= 0 && m <= K){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Custom Header <<<
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;
// >>>

char mat[2005][2005];
int row[2005][2005] {};
int col[2005][2005] {};

signed main()
{
    int H, W;

    cin >> H >> W;
    rep(i, 0, H) {
        cin >> mat[i];
    }

    rep(i, 0, H) {
        if (mat[i][0] != '#') row[i][0] = 1;
        for (int j = 1; j < W; ++j) {
            if (mat[i][j] == '#') continue;
            row[i][j] += row[i][j-1] + 1;
        }
        for (int j = W-2; j >= 0; --j) {
            if (mat[i][j] == '#') continue;
            chmax(row[i][j], row[i][j+1]);
        }
    }
    rep(j, 0, W) {
        if (mat[0][j] != '#') col[0][j] = 1;
        for (int i = 1; i < H; ++i) {
            if (mat[i][j] == '#') continue;
            col[i][j] += col[i-1][j] + 1;
        }
        for (int i = H-2; i >= 0; --i) {
            if (mat[i][j] == '#') continue;
            chmax(col[i][j], col[i+1][j]);
        }
    }

    int ans = 0;
    rep(i, 0, H) {
        rep(j, 0, W) {
            chmax(ans, col[i][j] + row[i][j] - 1);
        }
    }

    cout << ans << endl;


    return 0;
}

/* vim:set foldmethod=marker foldmarker=<<<,>>> : */


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
int tag[100000];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>tag[i];
    }
    int sum=0;
    for(int i=0;i<n;i++)
    {
        for(int j=n-1;j>i;j--)
        {
            if(tag[j]<tag[j-1])
            {
                swap(tag[j],tag[j-1]);
                sum++;
            }
        }
    }
    for(int i=0;i<n;i++)
    {
        if(i)cout<<' ';
        cout<<tag[i];
    }
    cout<<endl;
    cout<<sum<<endl;


}

Measured memory_bytes: 3100
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


enum INF = 10^^9;

void main() {
  try {
    for (; ; ) {
      const LA = readInt();
      const LB = readInt();
      const M = readInt();
      auto A = new int[LA];
      foreach (i; 0 .. LA) {
        A[i] = readInt();
      }
      auto B = new int[LB];
      foreach (i; 0 .. LB) {
        B[i] = readInt();
      }
      auto X = new int[M];
      auto Y = new int[M];
      auto C = new int[M];
      foreach (i; 0 .. M) {
        X[i] = readInt() - 1;
        Y[i] = readInt() - 1;
        C[i] = readInt();
      }
      
      int ans = INF;
      
      int AMin = INF;
      foreach (i; 0 .. LA) {
        chmin(AMin, A[i]);
      }
      int BMin = INF;
      foreach (i; 0 .. LB) {
        chmin(BMin, B[i]);
      }
      chmin(ans, AMin + BMin);
      
      // int ans = A.minElement + B.minElement;
      foreach (i; 0 .. M) {
        chmin(ans, A[X[i]] + B[Y[i]] - C[i]);
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 10404
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println((a - 1) * (b - 1));
    }
}

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

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

    if(n % (2 * d + 1) == 0) cout << n / (2 * d + 1) << endl;
    else cout << n / (2 * d + 1) + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] as = new long[n];
		long[] plus = new long[n];
		long[] minus = new long[n];
		for(int i=0; i<n; i++){
			as[i] = sc.nextLong();
			plus[i] = i+1+as[i];
			minus[i] = i+1-as[i];
		}
		Map<Long, Integer> map = new HashMap<>();
		for(long i: minus){
			Integer value = map.get(i);
			if(value == null) map.put(i, 1);
			else map.put(i, value+1);
		}
		long ans = 0;
		for(long i: plus){
			Integer value = map.get(i);
			if(value != null){
				ans += value;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 63280
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int n,a;
  vector<int> vec;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    vec.push_back(a);
  }
  vec.erase(unique(vec.begin(),vec.end()),vec.end());
  for(int i=0;i<vec.size()-1;i++) cout << vec[i] << " ";
  cout << vec[vec.size()-1] << endl;
  return(0);
}


Measured memory_bytes: 3528
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;
	int n; cin >> n;
	vector<int> a(n);
	cin >> a;
	REP(i, n){
		REP(j, n){
			REP(k, n){
				if(a[i]!=a[j] && a[i] != a[k] && a[j] != a[k] && a[i] < a[j] + a[k] && a[j] < a[i]+a[k] && a[k] < a[i]+a[j]) ans++;
			}
		}
	}
	cout << ans/6 << endl;
}

Measured memory_bytes: 3596
from bisect import bisect_left


def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    tree = [list() for _ in range(N)]
    for _ in range(N-1):
        u, v = [int(x) for x in input().split()]
        u -= 1
        v -= 1
        tree[u].append(v)
        tree[v].append(u)

    ans = [1] * N

    # dfs
    def dfs(u, par):
        nonlocal ans
        nonlocal dp
        pos = bisect_left(dp, A[u])
        old = dp[pos]
        dp[pos] = A[u]

        ans[u] = bisect_left(dp, float("inf")) - 1

        for v in tree[u]:
            if v == par:
                continue
            dfs(v, u)

        dp[pos] = old

    dp = [float("inf")] * (N+1)
    dp[0] = float("-inf")
    dfs(0, -1)

    for i in range(N):
        print(ans[i])


if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10**6)
    main()


Measured memory_bytes: 270916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    int N;
    string S;cin>>N>>S;
    for(int i=0;i<S.size();i++){
        S[i]+=N;
        if(S[i]>'Z') S[i]-=26;
      cout<<S[i];
    }
   cout<<endl;
}



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

#define   ipr         pair<int, int>
#define   pb            push_back
#define   ff            first
#define   ss            second
#define   fr(i, j, k)   for (int i = j; i < k; i++)
#define   rf(i, j, k)   for (int i = j; i >= k;i--)
#define   int           long long
#define 	ll 						unsigned long long
#define   ld            long double
#define   all(x)        x.begin(), x.end()
#define   rall(x)       x.rbegin(),x.rend()
#define   mp            make_pair
#define   inf           INT_MAX
#define   read_file();	freopen("input.txt", "r", stdin);	freopen("output.txt", "w", stdout);
#define   IOS           std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int mod  =  2019;
const ld  pi   =  acos(-1);
const int Maxn =  1000000000;

template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x<<endl;return out;}
template<class T> ostream& operator <<(ostream &out,set<T> &A){for(auto x:A) out<<x<<" ";return out;}
template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}

int32_t main(){ IOS
	int n, ans=0;	cin>>n;
	vector<bool > vis(n,false);	vector<vector<int> >g(n);	vector<int > par(n,0);	vector<ipr> A(n-1);
	fr(i,0,n-1){
		int u,v;	cin>>u>>v;
		u--;v--;
		g[u].pb(v);	g[v].pb(u);
		A[i] = mp(u,v);
	}
	map<ipr,int> my;
	queue<int> q;
	q.push(0);
	vis[0] = true;
	while(!q.empty()){
		int curr = q.front();	q.pop();
		int ting = 1;
		ans = max(ans, (int)g[curr].size());
		for(auto x : g[curr]){
			if(vis[x])	continue;
			if(par[curr] == ting)	ting++;
		  //cout << ting << " fine " << x << endl;
			my[mp(x,curr)] = my[mp(curr,x)] = par[x] = ting++;
			vis[x] = true;
			q.push(x);
		}
	}
	cout << ans << endl;
	for(auto x : A)	cout << my[x] << endl;
	return 0;
}


Measured memory_bytes: 21376
def main():
    a, b, k = map(int, input().split())

    if a >= k:
        remain_a = a - k
        remain_b = b
    else:
        remain_a = 0
        if k - a >= b:
            remain_b = 0
        else:
            remain_b = b - (k - a)

    print(remain_a, remain_b)


if __name__ == "__main__":
    main()


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


i64 N, K;
string s;

int main() {
    cin >> N >> K;
    cin >> s;
    K--;
    s[K] = 'a' + (s[K] - 'A');
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;
const auto MOD = 1000000007;
const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef vector<int> VI;
typedef vector<long long> VLL;


int n, m;



int main() {
	cin >> n;
	vector<string> s(n);
	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}
	sort(s.begin(), s.end());
	vector<long long>num;
	string temp = s[0];
	num.push_back(1);
	for (int i = 1; i < n; i++)
	{
		if (s[i] != temp) {
			num.push_back(1);
			temp = s[i];
		}
		else {
			num.back()++;
		}
	}
	long long ans=0;
	for (int i = 0; i < num.size(); i++)
	{
		if (num[i] > 1)ans += (num[i] * (num[i] - 1)) / 2;
	}
	cout << ans << endl;
}

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

int main() {
    string S, T;
    cin >> S >> T;
    vector<vector<int>> V(26);
    for (int i = 0; i < S.length(); i++) V.at(S.at(i) - 'a').push_back(i);
    long ans = 0;
    for (int i = 0, cur = -1; i < T.length(); i++) {
        int t = T.at(i) - 'a';
        if (!V.at(t).size()) return cout << -1 << "\n", 0;
        int it = upper_bound(V.at(t).begin(), V.at(t).end(), cur) - V.at(t).begin();
        if (it == V.at(t).size()) {
            ans += V.at(t).at(0) - cur + S.length();
            cur = V.at(t).at(0);
        } else {
            ans += V.at(t).at(it) - cur;
            cur = V.at(t).at(it);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define ll long long                  // Short form for long long
#define ld long double                // Short form for long double
typedef pair<ll, ll> pii;              // Pair of long long
typedef vector<ll> vi;                // Vector of long long
typedef vector<vi> vvi;               // Vector of vector of long long
typedef vector<pii> vii;               // Vector of pairs
typedef vector<vii> vvii;             // Vector of vector of pairs
#define pq priority_queue             // Max heap (To convert to min heap, use negative sign before every value)
#define ff first                      // For pairs
#define ss second                     // For pairs
#define pb push_back                  // Pushback to vector
#define mp make_pair                  // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end() // Mainly used by me in sorting

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

ll mod = 1e9 + 7;
ll t=1;

vvi adj;
ll n,m,x,y;
vi dp,vis;


void dfs(int i){
    vis[i]=1;
    ll dist=0;
    for(auto u:adj[i]){
        if(vis[u]){dist = max(dist,dp[u]+1);continue;}
        dfs(u);
        dist = max(dist,dp[u]+1);
    }
    dp[i] = dist;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // cin>>t;
    while(t--){
        cin>>n>>m;
        adj.resize(n+1);
        dp.resize(n+1);
        vis.resize(n+1,0);
        for(int i=0;i<m;i++){
            cin>>x>>y;
            adj[x].pb(y);
        }
        ll ans=0;
        for(int i=1;i<=n;i++){
            if(!vis[i])dfs(i);
            ans = max(ans,dp[i]);
        }
        cout<<ans;
    }
    return 0;
}    

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

#define IOS cin.tie(0);ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vs      vector<string>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)     for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 200;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//

signed main(){
    CIN(N);
    int ans=0,cur=0;
    vi H(N);VCIN(H);
    Rep(i,1,N){
        if(H[i]>H[i-1])cur=0;
        else{cur++;chmax(ans,cur);}
    }
    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 640
from bisect import*
n,*l=map(int,open(0).read().split())
l.sort()
#print(l)
ans=0
for i in range(n):
    for j in range(i+1,n):
#        print(max(bisect_left(l,l[i]+l[j])-j-1,0),l[i]+l[j])
        ans+=max(bisect_left(l,l[i]+l[j])-j-1,0)
print(ans)

Measured memory_bytes: 42972
#ABC 045 C - たくさんの数式

#まずは全部の和を出してから足す
s = input()
#print(s)

n = len(s)
#print(n)
#長さnだとn-1桁の2進数が欲しい。2^n-1通り試さないと行けない

hoge = '0' + str(n-1) + 'b'
cnt = 0

for i in range(2 ** (n-1)):
#    print("計" + str(cnt))
    sep = s
    bn_str = format(i, hoge)
#    print(bn_str)
    for j in range(n-1):
        if bn_str[j] == "1":
            cnt += int(sep[:j+1])
            sep = "0" * (j+1) + sep[j+1:]
            #0うめしないと2回以上切ったときにエラーが出る
#            print(cnt)
#            print(sep)
    cnt += int(sep)
print(cnt)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;

int main(){
  int n,k;cin>>n>>k;
  int a;
  vector<int>v(200005);
  rep(i,n){
    cin>>a;
    v[a]++;
  }
  sort(all(v),greater<int>());
  cout<<n-accumulate(v.begin(),v.begin()+k,0)<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cctype>

using namespace std;
int main() {
	char ch;
	int cnt[26] = {};

	while (cin >> ch) {
		ch = tolower(ch);
		if (isalpha(ch)) {
			cnt[ch - 'a']++;
		}
	}

	for (int i = 0; i < 26; i++) {
		cout << (char)(i+'a') << " : " << cnt[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1140
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
const double EPS = 10e-9;
int main()
{
    unsigned long long a, b, c;
    cin>>a>>b>>c;
    if(a + b > c)
        cout<<"No"<<endl;
    else if(2 * a * b + 2 *c  * a + 2 * c * b < c*c + a*a + b*b)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y, ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        if(y%2==0)
         return (p*p)%z;
        else
        return (x*((p*p)%z))%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
ll po(ll x)
{
    ll c=0;
    while(x>0)
    {
        x=x&(x-1);
        c++;
    }
    return c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    string s;
    cin>>s;
    int c=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='A')
        c++;
    }
    if(c==0||c==3)
    cout<<"No";
    else
    cout<<"Yes";}
    
    
    
    

Measured memory_bytes: 3628
s = gets.chomp

while not s.empty? do
    if s.end_with?("dream") or s.end_with?("erase")
        s = s[0..-6]
    elsif s.end_with?("dreamer")
        s = s[0..-8]
    elsif s.end_with?("eraser")
        s = s[0..-7]
    else
        puts "NO"
        exit
    end
end
puts "YES"


Measured memory_bytes: 72536
import sys
readline = sys.stdin.buffer.readline

n = int(readline())
lst1 = list(map(int,readline().split()))

heikin = sum(lst1)//n
ans = 10**9
for i in (heikin,heikin+1):
    res = 0
    for j in lst1:
        res += (i-j)**2

    ans = min(ans,res)

print(ans)


Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>

using namespace std;

int main(int argc, char *argv[]) {
  int arrow;
  while (true) {
    cin >> arrow;
    if (arrow == 0)
      break;
    arrow /= 4;
    int res = 0;
    for (int i = 0; i < arrow; i++) {
      int p;
      cin >> p;
      res += p;
    }
    cout << res << endl;
  }
  return 0;
}

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

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

    int a = n / 100;
    int b = n - a * 100;

    if (b > a * 10 + a) {
        a++;
    }

    a = a * 100 + a * 10 + a;

    cout << a << endl;

    return 0;
}


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

using namespace std;

#define endl            "\n"
#define sz(x)          (int) (x.size())
#define all(v)          v.begin(), v.end()
#define isOdd(n)       (n&1)
#define pow(n, m)      (ll)powl(n, m)
#define clr(x, val)     memset(x, val, sizeof(x))

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



int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    ll a, b, c, d; cin >> a >> b >> c >> d;
    cout <<  max({a * c, a * d, b * c, b * d});
    return 0;
}


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

int main() {
  long a, b, c, d, cd = 0, r[1000000]; //cdはcとdの最小公倍数
  cin >> a >> b >> c >> d;
  r[0] = max(c, d) % min(c, d);
  if (r[0] == 0)
    cd = c * d / min(c, d);
  else {
    r[1] = min(c, d) % r[0];
    for (int j = 0;; j++) {
      if (r[j + 1] == 0) {
        cd = c * d / r[j];
        break;
      }
      else {
        r[j + 2] = r[j] % r[j + 1];
        if (r[j + 2] == 0) {
          cd = c * d / r[j + 1];
          break;
        }
      }
    }
  }
  cout << (b - (b / c + b / d - b / cd))
    - (a - 1 - ((a - 1) / c + (a - 1) / d - (a - 1) / cd));
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]){
    int a;
    int b;
    int x;
    int y;
    scanf("%d %d",&a,&b);
    x=a*b;
    y=2*(a+b);
    printf("%d %d\n",x,y);
    return 0;
}

Measured memory_bytes: 596
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)    
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int d,t,s;
    cin>>d>>t>>s;
    if((s*t)>=d)
    cout<<"Yes";
    else
    cout<<"No";
}

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

#define int long long

int32_t main() {
	int n,w;
	cin>>n>>w;
	//items.first contains weight and item.second contains value
	vector<pair<int,int> > items(n);
	for(int i=0;i<n;i++) {
	    cin>>items[i].first;
	    cin>>items[i].second;
	}
	vector<vector<int> > dp(n,vector<int>(w+1,0));
	if(items[0].first <= w) {
	    dp[0][items[0].first] = items[0].second;
	}
	for(int i=1;i<n;i++) {
	    for(int j=0;j<=w;j++) {
	        dp[i][j] = dp[i-1][j];
	        if(j-items[i].first >=0) {
	            dp[i][j] = max(items[i].second + dp[i-1][j-items[i].first],dp[i][j]);
	        }
	    }
	}
	int ans = 0;
	for(int i=0;i<=w;i++) {
	    ans = max(ans,dp[n-1][i]);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 82292
# Your code here!

nums = Array.new(1000000){0}
n = gets.to_i

i=0

while(1) do
    i+=1
    if(nums[n]>0)
        break
    else
        nums[n]+=1
        if(n%2==0)
            n/=2
        else
            n = 3*n+1
        end
    end
end

puts i

Measured memory_bytes: 9596
#include <iostream>
#include <map>
#include <vector>
using namespace std;

map<int, vector<int>> mp;
int point[3][35];
int main() {
	int N, C, change[35][35], p; cin >> N >> C;
	for(int i=1; i<=C; ++i){
	    for(int j=1; j<=C; ++j) cin >> change[i][j];
	}
	for(int i=0; i<3; ++i) for(int j=0; j<=C; ++j) mp[i].push_back(0);
	for(int i=1; i<=N; ++i){
	    for(int j=1; j<=N; ++j){
	        cin >> p;
	        ++mp[(i+j)%3][p];
	    }
	}
	for(int i=0; i<3; ++i){
	    for(int j=1; j<=C; ++j){
	        for(int k=1; k<=C; ++k) point[i][k] += mp[i][j]*change[j][k];
	    }
	}
	long ans=(long) point[0][1]+point[1][2]+point[2][3];
	for(int i=1; i<=C; ++i){
	    for(int j=1; j<=C; ++j){
	        if(i!=j){
	            int mn=-1;
	            for(int k=1; k<=C; ++k){
	                if(i!=k && j!=k){
	                    if(mn<0) mn=point[2][k];
	                    else mn=min(mn, point[2][k]);
	                }
	            }
	            ans=min(ans, (long) point[0][i]+point[1][j]+mn);
	        }
	    }
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
def min_times(stations, n):
    times = []
    for i in range(n - 1):
        ci, si, fi = stations[i]
        t = si + ci
        for j in range(i + 1, n - 1):
            cj, sj, fj = stations[j]
            if t < sj:
                t = sj + cj
            else:
                waiting = fj - (t - sj) % fj if (t - sj) % fj != 0 else 0
                t += waiting + cj
        times.append(t)
    times.append(0)
    return times


if __name__ == '__main__':
    n = int(input())
    stations = [list(map(int, input().split())) for _ in range(n - 1)]
    for i in min_times(stations, n):
        print(i)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, c, d; cin >> a >> b >> c >> d;
  ll ans = max({a*c, b*d, a*d, b*c});
  cout << ans << endl;
}

Measured memory_bytes: 3664
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d,e,k;
	cin>>a>>b>>c>>d>>e>>k;
	int f=0;
	if(b-a>k||c-a>k||d-a>k||e-a>k||c-b>k||d-b>k||e-b>k||d-c>k||e-c>k||e-d>k)
	f=1;
	if(f==0)
	cout<<"Yay!";
	else
	cout<<":("; 
} 

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

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

#define MAX_SIZE 5000

using namespace std;

bool matrix[MAX_SIZE+2][MAX_SIZE+2];

void ope(bool matrix[][MAX_SIZE+2],long r,long c){
  int ii,jj;
  for(ii=-1;ii<=1;ii++){
	for(jj=-1;jj<=1;jj++){
	  matrix[r+ii][c+jj] = !matrix[r+ii][c+jj];
	}
  }
}

long getNum(bool matrix[][MAX_SIZE+2],long n,long m){
  int ii,jj;
  long cnt = 0;
  for(ii=1;ii<=n;ii++){
	for(jj=1;jj<=m;jj++){
	  if(matrix[ii][jj]){
		cnt++;
	  }
	}
  }
  return cnt;
}


int main(){
  long n,m;
  long ii,jj;
  long cnt = 0;
  cin >> n >> m;

  memset(matrix,false,sizeof(bool)*(MAX_SIZE+2)*(MAX_SIZE+2));

  if(n<=10 && m <= 10){
	for(ii=1;ii<=n;ii++){
	  for(jj=1;jj<=m;jj++){
		ope(matrix,ii,jj);
	  }
	}
	cnt = getNum(matrix,n,m);
  }
  else if(n==1){
	cnt = m -2;
  }
  else if(m==1){
	cnt = n -2;
  }
  else{
	cnt = n * m;
	cnt = cnt - (2*n + 2*m -4);
  }
  //cout << getNum(matrix,n,m);


  //
  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 24704
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		 Scanner scan = new Scanner(System.in);
		 int k=scan.nextInt();
		 int a=scan.nextInt();
		 int b=scan.nextInt();
		 int c=(b/k)*k;
		 if(a<=c) System.out.println("OK");
		 else System.out.println("NG");
		
	}

}


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

int main(){
    long long n,w;
    cin >> n >> w;
    vector<long long> v[4];
    long long w1,v1;
    cin >> w1 >> v1;
    v[0].push_back(v1);
    for(int i=1; i<n; i++){
        long long a,b;
        cin >> a >> b;
        v[a-w1].push_back(b);
    }
    for(int i=0; i<4; i++){
        sort(v[i].begin(),v[i].end(),greater<long long>());
    }
    long long sum[4][n+1];
    for(int i=0; i<4; i++){
        sum[i][0] = 0;
        for(int j=0; j<v[i].size(); j++){
            sum[i][j+1] = sum[i][j] + v[i][j];
        }
    }
    long long ans = 0;
    for(long long p=0; p<=v[0].size(); p++){
        for(long long q=0; q<=v[1].size(); q++){
            for(long long r=0; r<=v[2].size(); r++){
                for(long long s=0; s<=v[3].size(); s++){
                    if(w1*(p+q+r+s)+q+2*r+3*s <= w){
                        ans = max(ans,sum[0][p]+sum[1][q]+sum[2][r]+sum[3][s]);
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll h,w,ans=0;
  cin >> h >> w;
  ans += h*(w/2);
  if(w%2==1){
    ans += (h+1)/2;
  }
  if(w==1||h==1) ans = 1;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];
int getChar(char ch) {
	if (ch == 'A') return 1;
	else if (ch == 'C')return 2;
	else if (ch == 'G')return 3;
	else if(ch == 'T')return 4;
	else return 0;
}

long long getKey(char str[]) {
	long long sum = 0, p = 1, i;
	for (i = 0; i < strlen(str); i++) {
		sum += p*(getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }

int find(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for (i = 0;; i++) {
		h = (h1(key) + i *h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0)return 0;
	}
	return 0;
}

int insert(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for (i = 0;; i++) {
		h = (h1(key) + i *h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0) {
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

int main() {
	int i, n, h;
	char str[L], com[9];
	for (i = 0; i < M; i++)H[i][0] = '\0';
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %s", com, str);

		if (com[0] == 'i') {
			insert(str);
		}
		else {
			if (find(str)) {
				printf("yes\n");
			}
			else { printf("no\n"); }
		}
	} return 0;
}

Measured memory_bytes: 14916
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <deque>
#include <complex>
#include <queue>
#include <set>
#include <map>

using namespace std;

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

typedef long long ll;

int N;

int main() {

  cin >> N;
  bool nogt1flag = true;
  deque<int> a;
  int zeros = 0, ones = 0, twos = 0, threes = 0, over3 = 0;
  rep(i, N) {
    int in; cin >> in;
    if(in == 0) { zeros++; }
    if(in == 1) { ones++; }
    if(in == 2) { twos++; }
    if(in == 3) { threes++; }
    if(in >= 2) { nogt1flag = false; }
    if(in >= 4) { a.push_back(in); over3++; }
  }

  if(nogt1flag) {
    if(ones == 0) {
      rep(i, N) cout << 0 << endl;
    }
    else {
      if(zeros % 2 == 0) {
        rep(i, zeros) cout << 0 << endl;
        rep(i, ones) cout << 1 << endl;
      }
      else {
        rep(i, zeros-1) cout << 0 << endl;
        cout << 1 << endl << 0 << endl;
        rep(i, ones-1) cout << 1 << endl;
      }
    }
    return 0;
  }

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

  int ikenie = -1;
  if(zeros % 2 && ones == 0) {
    if(twos > 0) { twos--; ikenie = 2; }
    else if(threes > 0) { threes--; ikenie = 3; }
    else { over3--; ikenie = a[0]; a.pop_front(); }
  }

  if(threes == 1 && twos > 0 && over3 == 0) {
    rep(i, twos-1) cout << 2 << endl;
    cout << 3 << endl;
    cout << 2 << endl;
    rep(i, threes-1) cout << 3 << endl;
    rep(i, a.size()) cout << a[i] << endl;
  }
  else {
    rep(i, twos) cout << 2 << endl;
    rep(i, threes) cout << 3 << endl;
    rep(i, a.size()) cout << a[i] << endl;
  }

  if(ones > 0) { // use wildcard 1
    if(zeros % 2 == 0) {
      rep(i, zeros) cout << 0 << endl;
      cout << 1 << endl;
    }
    else {
      rep(i, zeros-1) cout << 0 << endl;
      cout << 1 << endl;
      if(zeros) cout << 0 << endl;
    }
    rep(i, ones-1) cout << 1 << endl;
  }
  else {
    if(zeros % 2) {
      rep(i, zeros-1) cout << 0 << endl;
      cout << ikenie << endl << 0 << endl;
    }
    else if(zeros % 2 == 0) {
      rep(i, zeros) cout << 0 << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1208
#include <iostream>

using namespace std;

int main(){
	int n;
	double x1,x2,x3,x4;
	double y1,y2,y3,y4;
	cin >> n;
	while(n--){
		cin >> x1 >> y1;
		cin >> x2 >> y2;
		cin >> x3 >> y3;
		cin >> x4 >> y4;
	
	
		if( (x1-x2==0&&x3-x4==0) || (y1-y2==0&&y3-y4==0) ){
			cout << "YES" << endl;
			continue;
		}else if(x1-x2==0||x3-x4==0||y1-y2==0||y3-y4==0){
			cout << "NO" << endl;
			continue;
		}else{			
			if( (x1-x2)/(y1-y2) == (x3-x4)/(y3-y4) )
				cout << "YES" << endl;
			else
				cout << "NO" << endl;
		}
	}
}
	

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int n, m;
    cin >> n >> m;
    if (n == 1 && m == 1) out(1);
    else if (n == 1 || m == 1) out(n + m - 1 - 2);
    else if (n == 2 || m == 2) out(0);
    else out((ll)(n - 2) * (m - 2));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const ll mod = 1000000007;
const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

ll f[1000100], finv[1000100];

ll modpow(ll a,ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a) {
  return modpow(a, mod - 2);
}

ll nCr(ll n, ll r) {
  if (r < 0 || r > n) return 0;
  return f[n] * finv[n - r] % mod * finv[r] % mod;
}

ll nHr(ll n, ll r) {
  return nCr(n + r - 1, r);
}

void init() {
  f[0] = 1, finv[0] = 1;
  FOR(i, 1, 1000100) {
    f[i] = i * f[i - 1] % mod;
    finv[i] = modinv(f[i]);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll n, m, k;
  cin >> n >> m >> k;

  init();
  if (m == 1) {
    cout << (k == n - 1 ? 1 : 0) << '\n';
    return 0;
  }
  ll ans = modpow(m, n);
  FORR(i, n - 1, k + 1) {
    ll res = nCr(n - 1, i) * m % mod;
    res = res * modpow(m - 1, n - 1 - i) % mod;
    ans = (ans - res + mod) % mod;
  }
  cout << ans << '\n';





  
  return 0;
}

Measured memory_bytes: 19280
import java.nio.Buffer;
import java.util.Scanner;
import java.util.Vector;

public class Main {
    public static Scanner r=new Scanner(System.in);
    public static void main(String[] args) {
        int n=r.nextInt();
        long sum=0;
        long []cnt=new long[100005];
        for(int i=0;i<n;++i){
            int x=r.nextInt();
            ++cnt[x];
            sum+=x;
        }
        int q=r.nextInt();
        while(q-->0){
            int b=r.nextInt();
            int c=r.nextInt();
            long num=cnt[b];
            cnt[b]=0;
            cnt[c]+=num;
            sum=sum-num*b+num*c;
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 61092
#include <bits/stdc++.h>
#define int long long 
using namespace std;


signed main() {
int H, N, A;
cin >> H >> N;

int total = 0;
for( int i = 0; i < N; i++ ){
cin >> A;
total += A;
}

if( total >= H ) cout  << "Yes" << endl;
else cout << "No" << endl;

}
  

  

  

  



Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)
bc = [list(map(int, input().split())) for _ in range(M)]
bc = sorted(bc, key=lambda x:x[1], reverse=True)
idx = 0
for i in range(N):
  if A[i] < bc[idx][1]:
    bc[idx][0] -= 1
    A[i] = bc[idx][1]
  else:
    break
  if bc[idx][0] == 0:
    idx += 1
  if idx == len(bc):
    break

print(sum(A))


Measured memory_bytes: 33640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        	String strArr[] = br.readLine().split(" ");
            int a=Integer.parseInt(strArr[0]);
            int b=Integer.parseInt(strArr[1]);
            int c=Integer.parseInt(strArr[2]);

            int kazu=0;
            int res=0;

            for(int i=a; i<=b; i++){
            	res=c%i;
            	if(res==0){
            		kazu++;
            	}
            	res=0;
            }
            System.out.println(kazu);
    }
}

Measured memory_bytes: 24396
#include<iostream>
#include<vector>
#include<queue>
#include<map>
using namespace std;

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    map<int,int> light;
    vector<int> d(m);
    for(int i = 0; i < m; i++){
        cin >> d[i];
        light[--d[i]] = i;
    }
    int v[n][k];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < k; j++){
            cin >> v[i][j];
            v[i][j]--;
        }
    }
    vector<int> dp(1<<m, 1<<30);
    dp[(1<<m)-1] = 0;
    queue<int> q;
    q.push((1<<m)-1);
    while(!q.empty()){
        int j = q.front();  q.pop();
        if(j == 0){
            cout << dp[j] << endl;
            return 0;
        }
        for(int col = 0; col < k; col++){
            int nbit = 0;
            for(int x = 0; x < m; x++){
                if((j>>x)&1){
                    if(light.count(v[d[x]][col])){
                        nbit |= 1<<light[v[d[x]][col]];
                    }
                }
            }
            if(dp[nbit] == 1<<30){
                dp[nbit] = dp[j]+1;
                q.push(nbit);
            }
        }
    }
}


Measured memory_bytes: 3444
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <queue>
#include <deque>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define LL long long
#define Pair pair<int,int>
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=1e9+7;
const int INF=0x7ffffff;
const int magic=348;

struct node
{
	int left,right;
	LL tag;
	int cnt;
}tree[300048];

void build(int cur,int left,int right)
{
	tree[cur].left=left;tree[cur].right=right;
	tree[cur].tag=tree[cur].cnt=0;
	if (left!=right)
	{
		int mid=(left+right)>>1;
		build(cur*2,left,mid);
		build(cur*2+1,mid+1,right);
	}
}

void update(int cur,int left,int right,int st)
{
	if (left<=tree[cur].left && tree[cur].right<=right)
	{
		//cout<<cur<<' '<<left<<' '<<right<<' '<<tree[cur].left<<' '<<tree[cur].right<<endl;
		tree[cur].tag+=st+tree[cur].left-left;
		tree[cur].cnt++;
		//cout<<cur<<' '<<tree[cur].tag<<' '<<tree[cur].left<<' '<<tree[cur].right<<endl;
		return;
	}
	int mid=(tree[cur].left+tree[cur].right)>>1;
	if (left<=mid) update(cur*2,left,right,st);
	if (mid+1<=right) update(cur*2+1,left,right,st);
}

LL query(int cur,int pos)
{
	if (tree[cur].left==tree[cur].right)
	{
		return tree[cur].tag;
	}
	int mid=(tree[cur].left+tree[cur].right)>>1;LL res;
	if (pos<=mid) res=query(cur*2,pos); else res=query(cur*2+1,pos);
	res+=(pos-tree[cur].left)*tree[cur].cnt+tree[cur].tag;
	return res;
}

int n,m;
int a[100048];

int main ()
{
	int i;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	build(1,1,m);
	for (i=1;i<=n-1;i++)
	{
		//cout<<i<<endl;
		if (a[i]<a[i+1] && a[i+1]-a[i]>=2) update(1,a[i]+2,a[i+1],1);
		//cout<<i<<endl;
		if (a[i]>a[i+1])
		{
			if (a[i]+2<=m) update(1,a[i]+2,m,1);
			if (m-a[i]>=1)
				update(1,1,a[i+1],m-a[i]);
			else
				if (a[i+1]>=2) update(1,2,a[i+1],1);
		
		}
		//cout<<query(1,4)<<endl;
	}
	LL ans=0,res,ans_res=-1;
	for (i=1;i<=n-1;i++)
		if (a[i]<a[i+1]) ans+=a[i+1]-a[i]; else ans+=m-(a[i]-a[i+1]);
	//cout<<ans<<endl;
	for (i=1;i<=m;i++)
	{
		res=query(1,i);
		//cout<<res<<endl;
		if (res>ans_res) ans_res=res;
	}
	cout<<ans-ans_res<<endl;
	return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int F(ll A, ll B)
{
    int a=0,b=0;
    while(A>0){A/=10;++a;}
    while(B>0){B/=10;++b;}
    return max(a,b);
}

int main()
{
    ll n;
    cin >>n;

    int ans=12345678;
    for(ll i=1; i*i<=n; ++i)if(n%i==0)
    {
        ans = min(ans, F(i,n/i));
    }

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


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

int main() {
	int N; cin >> N;
	vector<int> V(N), C(N);
	for(int &k:V) cin >> k;
	for(int &k:C) cin >> k;
	int ans = 0;
	for(int i = 0 ; i < N ; i++){
		if(V[i] - C[i] > 0 ) ans += V[i] - C[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[]){
  int a,b;
  int sum=0;
  int i=0;
  
  if(scanf("%d %d",&a,&b) <2){
    fprintf(stderr, "error: ill-formed fraction.\n");
    exit(1);
  }
  
  
  while(i<2){
    if(a<=b){
      sum += b;
      b--;
    }
    else if(a>b){
      sum += a;
      a--;
    }
    i++;
  }
  
  printf("%d",sum);
}

Measured memory_bytes: 128