akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

const int64_t INF = 1LL << 60;

template<class T>
void WarshallFloyd(vector<vector<T>> &G, T INF) {
    for(int i = 0; i < G.size(); ++i) G[i][i] = 0;
    for(int k = 0; k < G.size(); ++k) {
        for(int i = 0; i < G.size(); ++i) {
            for(int j = 0; j < G.size(); ++j) {
                if(G[i][k] == INF || G[k][j] == INF) continue;
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }
}

int main() {
    int N; cin >> N;
    vector<vector<int64_t>> A(N, vector<int64_t>(N));
    rep(i, N) rep(j, N) cin >> A[i][j];
    vector<vector<int64_t>> B(A);
    WarshallFloyd(B, INF);
    if(A != B) {
        cout << -1 << '\n';
        return 0;
    }
    rep(k, N) rep(i, N) rep(j, N) {
        if(i == j || i == k || j == k) continue;
        if(A[i][j] == A[i][k] + A[k][j]) {
            B[i][j] = 0;
        }
    }
    int64_t ans = 0;
    rep(i, N) for(int j = i + 1; j < N; ++j) {
        if(B[i][j]) ans += A[i][j];
    }
    cout << ans << '\n';
    return 0;
}


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

int a,b;
int main(){
cin >> a >> b;
if (a<0){
  if (b>=0){
    cout << "Zero";
  }
  else{
    if((b-a)%2 == 0){
       cout << "Negative";
    }
    else{
       cout << "Positive";
    }
  }
}
else{
  cout << "Positive";
}


return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map(String::toLong)
    val a = readLine()!!.split(' ').map(String::toInt).toMutableList()
    a.add(0, 0)
    val visited = LongArray(n.toInt() + 1) { 0 }

    var start = 0L
    var end = 0L
    var cur = 1
    for (i in 1..n) {
        if (visited[cur] != 0L) {
            start = visited[cur]
            end = i
            break
        } else {
            visited[cur] = i
            cur = a[cur]
        }
    }

    cur = 1
    if (k <= start) {
        for (i in 0 until k) {
            cur = a[cur]
        }
    } else {
        val tk = (k - start + 1) % (end - start)
        for (i in 0 until (start - 1)) {
            cur = a[cur]
        }
        for (i in 0 until tk) {
            cur = a[cur]
        }
    }
    println(cur)
}

Measured memory_bytes: 64212
/**akshaykumar99**/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
template<typename T> using id_setp = tree<pair<T,T>,null_type,less<pair<T,T>>,rb_tree_tag,tree_order_statistics_node_update> ;

#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+1;
 
typedef long long ll;
typedef long double ld;
 
int main()
{
    IOS();

	int a[6]={100,101,102,103,104,105};
	int x;
	cin>>x;
	if(x<100)
	{
		cout<<"0\n";
		return 0;
	}
	int z=x%100,w=x/100;
	if(w*5>=z)
		cout<<1;
	else
		cout<<0;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#pragma comment(linker,"/STACK:102400000,102400000")
#define INF 0x3f3f3f3f
#define maxm 1500
typedef long long ll;
using namespace std;
int mp[maxm][maxm]{0};
int t[maxm][maxm]{0};
int calRectangle(int (&vec)[maxm],int w,int time)
{
    int result=0;
    stack<int> stk;
    vec[w+1]=0;
    //if(true){for(int i=1;i<=w;i++)cout<<vec[i]<<" ";cout<<endl;}
    for(int i=1;i<=w+1;i++)
    {
        if(stk.empty()||vec[stk.top()]<=vec[i])
            stk.push(i);
        else
        {
            int temp=stk.top();
            stk.pop();
            result=max(result,vec[temp]*(stk.empty()?(i-1):(i-stk.top()-1)));
            i--;
        }
    }
    //cout<<result<<endl;
    return result;
}
int main()
{
    int h,w,pt,res=0;
    cin>>h>>w;
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
            cin>>mp[i][j];
    for(int j=1;j<=w;j++)
    {
        pt=1;
        for(int i=1;i<=h;i++)
            if(!mp[i][j])
                t[i][j]=pt++;
            else
            {
                t[i][j]=0;
                pt=1;
            }
    }
    //for(int i=1;i<=h;i++){for(int j=1;j<=w;j++)cout<<t[i][j]<<" ";cout<<endl;};
    for(int i=1;i<=h;i++)
        res=max(res,calRectangle(t[i],w,i));
    cout<<res<<endl;
    return 0;
}
//Do not use memset !



Measured memory_bytes: 19524
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define F               first
#define S               second
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18 + 1
#define endl            '\n'
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define forI(i,a,n)     for(int i=a;i<=n;i++)
#define forD(i,a,n)     for(int i=n;i>=a;i--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void init(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

int dp[102][100005];

int compute(int *a, int n, int k){
    forI(i, 0, k)   dp[1][i] = (i > a[1]) ? 0 : 1;

    forI(i, 2, n){
        forI(j, 0, k){
            if(j == 0)
                dp[i][j] = dp[i-1][j];
            else
                dp[i][j] = (mod + dp[i][j-1] + dp[i-1][j] - 
                            ((j-a[i]-1 >= 0) ? dp[i-1][j-a[i]-1] : 0))%mod;
        }
    }

    return dp[n][k];
}

void solve(){
    int n, k;   cin>>n>>k;
    mk(a, n+1, int);    forI(i, 1, n)   cin>>a[i];
    memset(dp, -1, sizeof dp);
    int ways = compute(a, n, k);
    cout<<ways<<endl;
}   

int32_t main(){
    init();
    // w(t) 
    solve();
    return 0;
}

Measured memory_bytes: 83364
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;
long long a,b,n,ans;
int main()
{
  scanf("%lld",&n);
  for(int i=0;i<n;i++)
  {
    scanf("%lld%lld",&a,&b);
    ans+=b-a+1;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <iomanip>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>
#include <random>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define endl '\n'

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7;
const int MAXN = static_cast<int>(1e6) + 17;

int n, m;
vector<int> g[MAXN];
int used[MAXN];
deque<int> ans;

bool read() {
    if (!(cin >> n >> m))
        return false;

    forn (i, m) {
        int u, v;
        cin >> u >> v;
        g[u - 1].push_back(v - 1);
        g[v - 1].push_back(u - 1);
    }

    return true;
}

void dfs1(int v) {
    used[v] = true;

    for (auto to : g[v])
        if (!used[to]) {
            ans.push_front(to);
            dfs1(to);
            break;
        }
}

void dfs2(int v) {
    used[v] = true;

    for (auto to : g[v])
        if (!used[to]) {
            ans.push_back(to);
            dfs2(to);
            break;
        }
}

void solve() {
    ans.push_back(0);
    ans.push_back(g[0][0]);
    used[0] = used[g[0][0]] = true;
    dfs1(0);
    dfs2(g[0][0]);
    cout << sz(ans) << endl;

    for (auto i : ans)
        cout << i + 1 << ' ';

    cout << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::mt19937 rand('S' + 'E' + 'R' + 'E' + 'Z' + 'H' + 'K' + 'A');

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 32896
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
#define dwn(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

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

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

class unionFindTree {
private:
	vector <int> tree;
	vector <int> rank;
	vector <int> elem;
public:
	unionFindTree() {}

	unionFindTree(int sz) {
		tree = vector <int> (sz);
		rank = vector <int> (sz, 0);
		elem = vector <int> (sz, 0);
		for(int i = 0; i < tree.size(); i++)
			tree[i] = i;
	}

	unionFindTree(const unionFindTree &o) {
		tree = o.tree;
		rank = o.rank;
		elem = o.elem;
	}

	unionFindTree &operator=(const unionFindTree &o) {
		tree = o.tree;
		rank = o.rank;
		elem = o.elem;
		return (*this);
	};

	int root(int x) {
		return tree[x] == x ? x : tree[x] = root(tree[x]);
	}

	bool same(int a, int b) {
		return root(a) == root(b);
	}

	void unite(int a, int b) {
		a = root(a);
		b = root(b);
		if(a == b)return;

		if(rank[a] < rank[b]) swap(a, b);

		tree[b] = a;
		rank[a] += rank[a] == rank[b];
		elem[a] += elem[b];
	}

	int size() {
		return tree.size();
	}

	int size(int a) {
		return elem[root(a)];
	}
};

int n, m;
vector <int> p, x, y;

int main() {
	cin >> n >> m;
	p = vector <int> (n);
	rep (i, n) {
		cin >> p[i];
		p[i]--;
	}
	x = y = vector <int> (m);
	unionFindTree tree(n);
	rep (i, m) {
		cin >> x[i] >> y[i];
		tree.unite(x[i] - 1, y[i] - 1);
	}

	int cnt = 0;
	rep (i, n) cnt += tree.root(i) == tree.root(p[i]);
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 2560
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int b, d[32];
void square(int,int);

int main() {
	int n;
	while (fscanf(stdin, "%d", &n),n!=0) {
		b = 0;
		square(n, n);
	}
	return 0;
}
void square(int a,int m){
	int i;
	if (a == 0) {
		fprintf(stdout, "%d", d[0]);
		for (i = 1; i < b; i++) {
			fprintf(stdout, " %d", d[i]);
		}
		puts("");
	}
	for (i = a; i > 0; i--) {
		if (i <= m) {
			d[b++] = i;
			square(a - i, i);
			b--;
		}
	}
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
  ll n;
  cin >> n;
  vll a(n);
  ll s=0;
  rep(i,0,n) {
    cin >> a[i];
    s=s^a[i];
  }
  rep(i,0,n-1) {
    cout << (s^a[i]) << " ";
  }
  cout << (s^a[n-1]) << endl;
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 4776
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 1;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregion

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

  int n;
  cin >> n;
  ll a[200010];
  rep(i, n) cin >> a[i];
  a[n] = 0;
  if (a[0] != 0)
  {
    cout << -1 << endl;
    return 0;
  }
  ll sum = 0;
  rep(i, n)
  {
    if (a[i + 1] - a[i] >= 2)
    {
      cout << -1 << endl;
      return 0;
    }
    if (a[i + 1] - a[i] < 1)
    {
      sum += a[i];
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m;
ll a[100010]={0};
ll sum[100010]={0};
ll res=1e18;
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++)
	{
		cin >>a[i+1];
		sum[i+1]=sum[i]+a[i+1]-a[i];
	}
	for (int i=0;i<=n-m;i++)
	{
		ll r=sum[i+m]-sum[i+1]+min(abs(a[i+1]),abs(a[i+m]));
		res=min(res,r);
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int x = *max_element(a.begin(), a.end());
    int y = a[0];
    int mx = 1001001001;
    rep(i, n) {
        if (x == a[i]) continue;
        int dist = min(abs(a[i] - x/2), abs((x-a[i]) - x/2));
        if (chmin(mx, dist)) y = a[i];
    }
    cout << x << " " << y << endl;
}

Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    static Scanner cin;

    // メンバ変数---
    int N;
    int[] students;
    int[] index;
    // -------------

    void calc()
    {
        N = cin.nextInt();
        students = new int[N];
        index = new int[N];
        for(int i = 0;i < N; i++)
        {
            students[i] = cin.nextInt();
            index[i] = i + 1;
        }


        Array.Sort(students, index);

        foreach(var i in index)
        {
            Console.Write(i);
            Console.Write(' ');
        }
        Console.Write(Environment.NewLine);

    }

    void Write(string v)
    {
        Console.WriteLine(v);
    }

    void Write(int v)
    {
        Console.WriteLine(v);
    }

    void Write(double v)
    {
        Console.WriteLine(v);
    }
    void Write(long v)
    {
        Console.WriteLine(v);
    }

    int Pow(int x, int y)
    {
        return (int)Math.Pow(double.Parse(x.ToString()), double.Parse(y.ToString()));
    }

    double Pow(double x, double y)
    {
        return Math.Pow(x, y);
    }

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

Measured memory_bytes: 24656
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,j=1;
  cin >> n >> k;
  for(int i=0;i<n;i++){
    if(k>j)j*=2;
    else j+=k;
  }
  cout << j;
  /*
  for(int i=0;i<=50000;i++){
    j=i*27/25;
    if(j==n){
      cout << i;
      return 0;
    }
  }
  cout << ":(";
  /*
  int n,m;
  cin >> n >> m;
  char a[n+2][m+2];
  for(int i=0;i<=n+1;i++){
    if(i==0||i==n+1){
      for(int j=0;j<m+2;j++){
        cout << "#";
      }
      cout << endl;
    }
    cout << "#";
    for(int jj=1;jj<=m;jj++){
      cin >> a[i][jj];
      cout << a[i][jj];
    }
    cout << "#" << endl;
  }*/
}


Measured memory_bytes: 256
n=int(input())
a=[]
for i in range(n):
  a.append(int(input()))
m=max(a)
x=[i for i, x in enumerate(a) if x == m]
if(len(x)>=2):
  for i in range(n):
    print(m)
else:
  a.remove(m)
  M=max(a)
  for i in range(n):
    if(i==x[0]):
      print(M)
    else:
      print(m)

Measured memory_bytes: 20456
//2020-04-09 16:04:39
//#pragma GCC optimize("-Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//order_of_key(x) : number of items less than x
//find_by_order(x) : iterator to x

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()

const ld pi=3.14159265359;
ll INF=1e18+10;
ll MOD=998244353;
ll mod=1e9+7;

inline ll add(ll a,ll b,ll m){
    if((a+b)>=m)return (a+b)%m;
    return a+b;
}

inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ll n,cost;cin>>n>>cost;
    vector<ll>v(n);
    ll mn=INF,sum=0;
    rep(i,0,n)cin>>v[i],mn=min(mn,v[i]),sum+=v[i];
    cost-=sum;
    ll ans=n;
    ans+=(cost/mn);
    cout<<ans;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

static const string KEYENCE = "keyence";

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int r = n - KEYENCE.size();
  bool ok = false;
  for (int i = 0; i <= n - r; i++) {
    string s2 = s.substr(0, i);
    string s3 = s.substr(i + r, n - i - r);
    string tmp = s2 + s3;
    if (tmp == KEYENCE) {
      ok = true;
      break;
    }
  }
  cout << (ok ? "YES" : "NO") << endl;
  return 0;
}


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

#define  int long long

using namespace std;

int n, m;

int sum(vector<int> x, vector<int> y, vector<int> z) {
  vector<int> t;
  for(int i=0;i<n;i++) {
    t.push_back(x[i]+y[i]+z[i]);
  }
  sort(t.begin(), t.end(), greater<int>());
  int sum = 0;
  for(int i=0;i<m;i++) {
    sum += t[i];
  }
  return sum;
}

signed main() {
  cin >> n >> m;
  vector<int> x, y, z, xminus, yminus, zminus;
  for(int i=0;i<n;i++) {
    int p, q, r;
    cin >> p >> q >> r;
    x.push_back(p);
    xminus.push_back(-p);
    y.push_back(q);
    yminus.push_back(-q);
    z.push_back(r);
    zminus.push_back(-r);
  }

  int result = 0;

  //+++
  result = sum (x, y, z);
  //++-
  result = max(result, sum (x, y, zminus));
  //+-+
  result = max(result, sum (x, yminus, z));
  //+--
  result = max(result, sum (x, yminus, zminus));
  //-++
  result = max(result, sum (xminus, y, z));
  //-+-
  result = max(result, sum (xminus, y, zminus));
  //--+
  result = max(result, sum (xminus, yminus, z));
  //---
  result = max(result, sum (xminus, yminus, zminus));
  
  cout << result << endl;
  
  
}

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


using namespace std;
using ll = long long;
const int N = 1e6 + 600;



int main() {
    int n,a[206],b[206],c[206];
    cin >> n;
    for(int i = 0; i < n; ++i)
            cin >> a[i];
    for(int i = 0; i < n; ++i)
            cin >> b[i];
    for(int i = 0; i < n - 1; ++i)
            cin >> c[i];
    int ans = 0;
    for(int i = 0; i < n; ++i){
            a[i]--;
            ans += (b[a[i]]);
            if(i && a[i] == a[i - 1] + 1){
                    ans += c[a[i - 1]];
            }
    }
    cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <stack>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <functional>
//#include <unordered_set>
#define INF 2147483647
#define MAXN  100005
#define PII pair<int, int>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
PII	v[MAXN];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef local_debug
	ifstream inputs("input.txt");
	cin.rdbuf(inputs.rdbuf());
	freopen("input.txt", "r", stdin);
#endif
	int n, c, k, d;
	while (cin >> n >> c >> k) {
		for (int i = 0; i < n; i++)
		{
			cin >> d;
			v[i].first = d;
			v[i].second = d + k;
		}
		sort(v, v + n, [](PII a, PII b) {
			return a.second < b.second;
		});
		int e = v[0].second;
		int t = 0, cnt = 0;
		for (int i = 1; i < n; i++)
		{
			if (e >= v[i].first)
			{
				t++;
				if (t == c)
				{
					t = 0;
					cnt++;
					e = v[i].second;
				}
			}
			else
			{
				cnt++;
				t = 0;
				e = v[i].second;
			}
		}
		cout << cnt + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less

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

#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define show(x) cerr << #x << " = " << x << "\n"
#define mem( a , b ) memset( a , b , sizeof a )
#define popcnt(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)
#define SZ(a) (int)a.size()
#define ll  long long
#define ld  long double
#define vii vector  <ll>
#define dqi deque   <ll>
#define sii set     <ll>
#define vpi vector  <pii>
#define mii map     <ll,ll>
#define pii pair    <ll,ll>
#define pi  pair    <int,int>
#define pb  push_back
#define F   first
#define S   second
#define L   length()
#define OO  (ll)1e18
#define EPS 1e-9
using namespace std;
using namespace __gnu_pbds;
void ONLINE__JUDGE();

typedef tree<ll, null_type, less<ll>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
pii swapii( pii pr ){ return { pr.S , pr.F }; }
ll binEXP( ll x , ll pw , ll MOD = LLONG_MAX );
int dx[] = {  0 ,  0 , -1 , +1 , -1 , +1 , -1 , +1 };
int dy[] = { -1 , +1 ,  0 ,  0 , -1 , +1 , +1 , -1 };

const ll MOD = 1e9 + 7;
const ll MAX = 1e2 + 9;

double x ,y;

int main()
{
    //FASTIO ONLINE__JUDGE();

    cin >> x >> y; y = 2*y + 1;
    cout << ceil( x/y );
    return 0;
}


void ONLINE__JUDGE()
{
    #ifndef ONLINE_JUDGE
    freopen( "inp.c"         , "r" , stdin  );
    //freopen( "OutPut.txt"   , "w" , stdout );
    #endif // ONLINE_JUDGE
}

ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
	int main() {
	int a;
	cin>>a;
	int d=0;
	vector<int> b(a),c(a);
	for (int i = 0; i < a; ++i){
        cin>>b.at(i);
	}
    for (int i = 0; i < a; ++i){
        cin>>c.at(i);
	}
	for (int i = 0; i < a; ++i)
	{
		if(b.at(i)-c.at(i)>0)
         d+=b.at(i)-c.at(i);
	}
	cout<<d;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n=int(input())
a_list=list(map(int,input().split()))
a_13=0
a_2=0
a_0=0
for i in a_list:
    m=i%4
    if m==0:
        a_0+=1
    elif m==2:
        a_2+=1
    else:
        a_13+=1
if a_0>=a_13:
    print('Yes') 
else:
    if a_0==a_13-1 and a_0+a_13==n:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 58736
#include <string>
#include <iostream>
using namespace std;
int p, q, visit[1000000];
int main() {
	while (cin >> p >> q) {
		string s;
		for (int i = 0; i < q; i++) visit[i] = -1; visit[p] = 0;
		for (int i = 0; ; i++) {
			p *= 10, s += p / q + 48, p %= q;
			if (p == 0) {
				cout << s << endl; s = "-1"; break;
			}
			if (visit[p] != -1) {
				cout << s << endl;
				for (int j = 0; j < visit[p]; j++) cout << ' ';
				for (int j = visit[p]; j <= i; j++) cout << '^';
				cout << endl; break;
			}
			visit[p] = i + 1;
		}
	}
}

Measured memory_bytes: 7012
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long s=0,n,a,b;
	cin>>n;
	for(long long i=0;i<n;i++)
	{
		cin>>a>>b;
		s+=b-a+1;
	}
	cout<<s<<endl;
}

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

typedef long long ll;
ll n, h[200010], a[200010], bit[200010], ans;

void update(ll p, ll v){
	for(ll i=p; i<=n; i+=i&-i)
		bit[i] = max(bit[i], v);
}

ll rangemax(ll p){
	ll res = 0;
	for(ll i=p; i>0; i-=i&-i)
		res = max(res, bit[i]);
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=1; i<=n; ++i) cin >> h[i];
	for(int i=1; i<=n; ++i) cin >> a[i];
	for(int i=1; i<=n; ++i){
		ll t = rangemax(h[i]-1) + a[i];
		ans = max(ans, t);
		update(h[i], t);
	}
	cout << ans << "\n";
}

Measured memory_bytes: 4992
from collections import deque
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))

    plus = []; minus = []
    for a in A:
        if a >= 0:
            plus.append(a)
        if a < 0:
            minus.append(a)
        
    plus.sort()
    minus.sort()
    plus = deque(plus)
    minus = deque(minus)

    if N == 2:
        if A[0] >= A[1]:
            ans = A[0] - A[1]
            print(ans)
            print(A[0], A[1])
        else:
            ans = A[1] - A[0]
            print(ans)
            print(A[1], A[0])
        return

    anslist = []
    if len(plus) == 0:
        stmp = minus.popleft()
        ltmp = minus.pop()
        anslist.append((ltmp, stmp))
        ans = ltmp - stmp
        plus.append(ans)
        N -= 1
    elif len(minus) == 0:
        stmp = plus.popleft()
        ltmp = plus.pop()
        anslist.append((stmp, ltmp))
        ans = stmp - ltmp
        minus.append(ans)
        N -= 1
    else:
        pass

    for _ in range(N):
        if len(minus) > 1:
            ltmp = plus.pop()
            stmp = minus.pop()
            anslist.append((ltmp, stmp))
            plus.append(ltmp - stmp)
        elif len(plus) > 1:
            ltmp = plus.popleft()
            stmp = minus.popleft()
            anslist.append((stmp, ltmp))
            minus.append(stmp - ltmp)
        else:
            ltmp = plus.popleft()
            stmp = minus.popleft()
            anslist.append((ltmp, stmp))
            ans = ltmp - stmp
            break
    print(ans)
    for s in anslist:
        print(*s)

if __name__ == "__main__":
    main()


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

int N;
vector<vector<int>> tree;
vector<vector<int>> dist;
map<pair<int,int>, int> mp;

void getPath(int u, int v, int d, vector<int>& path){
    for(int next: tree[u]){
        if(next == v){
            path.push_back(mp[{u, next}]);
            return;
        }
        if(dist[next][v] == d-1){
            path.push_back(mp[{u, next}]);
            getPath(next, v, d-1, path);
        }
    }
}

int kthbit(int A, int K) { return (A >> K) & 1; }

int main(){
    cin >> N;
    tree.resize(N);
    dist = vector<vector<int>>(N, vector<int>(N, 1e9));
    for(int i=0; i<N-1; i++){
        int a, b;  cin >> a >> b;
        a--;  b--;
        dist[a][b] = 1;
        dist[b][a] = 1;
        dist[a][a] = 0;  dist[b][b] = 0;
        tree[a].push_back(b);
        tree[b].push_back(a);
        mp[{a, b}] = i;
        mp[{b, a}] = i;
    }

    for(int k=0; k<N; k++)for(int i=0; i<N; i++)for(int j=0; j<N; j++){
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }

    int M;  cin >> M;
    vector<vector<int>> paths(M);
    for(int i=0; i<M; i++){
        int u, v;  cin >> u >> v;
        u--;  v--;
        getPath(u, v, dist[u][v], paths[i]);
    }

    ll ans = 0;
    for(int m=1; m<(1<<M); m++){
        vector<int> selected;
        int tempM = m;
        for(int i=0; i<M; i++){
            if(tempM%2 == 1){
                selected.push_back(i);
            }
            tempM/=2;
        }

        vector<bool> inserted(N-1, false);
        int c = 0;
        for(int s: selected){
            for(int p: paths[s]){
                if(!inserted[p]){
                    inserted[p] = true;
                    c++;
                }
            }
        }

        ans += (ll)pow(-1, selected.size() + 1)*(1ll << (N-1-c));
    }
    ans = (1ll << (N-1)) - ans;

    cout << ans << endl;
}


Measured memory_bytes: 512
PROGRAM piyo
      IMPLICIT NONE
      integer(16) :: x,money=100,i,ans
      
      read*,x
      
      i = 0
      do while(.true.)
        i = i + 1
        money = money + money/100
        
        if( money>=x )then
          ans = i
          exit
        end if
      end do
      
      print*,ans
      
      
      
      
      END PROGRAM

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll K;
    string S;
    cin >> K >> S;
    if(S.size() > K) {
        string temp = string(S.begin(), S.begin() + K);
        cout << temp << "..." << endl;
    } else {
        cout << S << endl;
    }
    return 0;
}


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

bool dfs(int bit, string &T) {
  if(T > S) return true;
  if(S.substr(0, T.size())  != T && T <= S) return false;
  for(int i = 0; i < 26; ++i) {
    if((bit >> i) & 1) continue;
    T.push_back((char)(i+'a'));
    if(dfs(bit | (1 << i), T)) return true;
    T.pop_back();
  }
  return false;
}

int main() {
  cin >> S;
  string ans;
  if(dfs(0, ans)) {
    std::cout << ans << std::endl;
  } else {
    std::cout << -1 << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define abrep(i, a, b) for(int i = (a); i < (b); i++)
#define max(a, b) ((a) > (b))? (a) : (b)


int N;
int A[3][101];

int main() {
    cin >> N;
    abrep(i, 1, 2 + 1) {
        abrep(j, 1, N + 1) {
            scanf("%d", &A[i][j]);
            A[i][j] += max(A[i-1][j], A[i][j-1]);
        }
    }
    cout << A[2][N] << endl;
}


Measured memory_bytes: 256
def e_this_message_will_self_destruct_in_5s():
    from collections import Counter
    N = int(input())
    A = [int(i) for i in input().split()]

    add = [j + a for j, a in enumerate(A, 1)]
    diff = [k - a for k, a in enumerate(A, 1)]
    count = Counter(diff)
    return sum([count[p] for p in add])

print(e_this_message_will_self_destruct_in_5s())

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1000000007
#define PI 3.14159265

#define MAX 501

vector<int> vec[MAX];

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

    int n , m , q;
    cin >> n >> m >> q;
    int l , r;
    for (int i = 0; i < m; i++) {
        cin >> l >> r;
        vec[l].pb(r);
    }
    for (int i = 1; i <= n; i++) {
        sort(all(vec[i]));
    }

    int ans = 0;
    for (int i = 0; i < q; i++) {
        cin >> l >> r;
        ans = 0;
        for (int j = l; j <= r; j++) {
            //for (auto it : vec[j]) cout << it << " ";
            //cout << "hi" << endl;
            int ind = lower_bound(all(vec[j]) , r + 1) - vec[j].begin();
            //cout << ind << " ";
            ans += (ind);
        }
        //cout << endl;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

vector<pair<ll,ll>> prime_factor(ll n){
    vector<pair<ll,ll>> p;
    for(ll i=2;i*i<=n;i++){
        if(n % i != 0) {
            //cout << i << endl;
            continue;
        }

        ll ex=0;
        while(n % i == 0){
            ex++;
            n /= i;
        }
        p.push_back(make_pair(i,ex));
    }

    if(n != 1){
        p.push_back(make_pair(n,1));
    }

    return p;
}

int main(){
    ll n;
    cin >> n;
  
    const auto &prime = prime_factor(n);
    ll cnt=0;
    for(auto p : prime){
        ll e=1;
        for(ll i=1;i<=p.second;i += e){
            cnt++;
            e++;
        }
    }
  
    cout << cnt << endl;
  
    return(0);
}

Measured memory_bytes: 3608
from collections import deque
N=int(input())

tree = {i: set() for i in range(1, N+1)}
for i in range(N-1):
    a,b = map(int,input().split())
    tree[a].add(b)
    tree[b].add(a)

inl = list(map(int,input().split()))
inl.sort()

res = [0]*(N+1)
qu = deque([1])
res[1] = inl.pop()

while qu:
    i = qu.popleft()
    for j in tree[i]:
        if res[j] == 0:
            res[j] = inl.pop()
            qu.append(j)

print(sum(res[2:]))
for i in res[1:]:
    print(i, end=' ')
print('')


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

int main(){
    string S,T,U;
    int A,B;

    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if(S == U){
        A--;
    }else if(T == U){
        B--;
    }

    cout << A <<" " << B << endl;

    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>

int gcd(int a,int b){
    if(a%b==0) return b;
    return gcd(b,a%b);
}

int main(void){
    int num;
    scanf("%d",&num);
    long total=0;
    for(int i=1;i<=num;i++){
        for(int j=1;j<=num;j++){
            int g=gcd(i>=j ? i : j, i<j ? i : j);
            for(int k=1;k<=num;k++){
                total += gcd(g>=k ? g : k, g<k ? g :k);
            }
        }
    }
    printf("%ld\n",total);
}

Measured memory_bytes: 1736
#include<stdio.h>

int main() {
	long long int N = 0;
	int x = scanf("%lld", &N);
	long long int sum = 0;
	for (int i = 1;i <= N;++i) {
		if (i%3 != 0 && i%5 != 0) {
			sum += i;
		}	
	}
	
	printf("%lld\n", sum);
	return 0;
}


Measured memory_bytes: 1736
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))
ans = []
c = 1
for i in a:
    for j in range(i):
        ans.append(c)
    c += 1
for i in range(H):
    for j in range(W):
        if i % 2 == 0:
            print(ans[i * W + j], end = "")
        else:
            print(ans[i * W + W - 1 - j], end = "")
        if j < W - 1:
            print(" ", end = "")
        else:
            print()

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
typedef vector<int> vi;typedef vector<vi> vvi;typedef pair<int,int> pii;typedef vector<pii> vpii;
typedef long long ll;

typedef vector<ll> vl;typedef vector<vl> vvl;

const long long mod = 1000000007;

long long powMod(long long x, long long y) {
  long long r = 1, a = x % mod;
  while (y) {
    if (y & 1) r = (r * a) % mod;
    a = a * a % mod;
    y /= 2;
  }
  return r;
}

void Main() {
  int N, K;
  scanf("%d%d", &N, &K);
  vi A(N), B(N);
  rep(i, N) scanf("%d", &A[i]);
  rep(i, N) scanf("%d", &B[i]);

  vvl dp(N+1, vl(K+1));
  dp[0][0] = 1;

  // ppow[i][j] : i^j
  vvl ppow(401, vl(K+1));
  rep(i, 401) {
    ppow[i][0] = 1;
    rep(j, K) {
      (ppow[i][j+1] = ppow[i][j] * i % mod) %= mod;
    }
  }

  // spow[i][j] : 0^j + 1^j + 2^j + ... + (i-1)^j
  vvl spow(401+1, vl(K+1));
  rep(i, 401) {
    rep(j, K+1) {
      spow[i+1][j] = (spow[i][j] + ppow[i][j]) % mod;
    }
  }

  rep(i, N) rep(j, K+1) {
    // dp[i][j] : i-1 番までに j 個
    int a = A[i];
    int b = B[i];
    rep(k, j+1) {
      // i番がk個
      // p : (1^k + 2^k + 3^k + ...b^k) - (1^k + 2^k + 3^k + ... + (a-1)^k) = a^k + (a+1)^k + ... + b^k
      ll p = (spow[b+1][k] - spow[a][k] + mod) % mod;
      (dp[i+1][j] += dp[i][j-k] * p) %= mod;
    }
  }

  ll ans = dp[N][K];

  _p("%lld\n", ans);
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 4096
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
# 10 ** 7 might cause MLE
fac = [-1] * (10**6+1)
inv = [-1] * (10**6+1)
finv = [-1] * (10**6+1)

fac[0] = fac[1] = 1
inv[1] = 1
finv[0] = finv[1] = 1

mod = 998244353
p = mod

def initNCMMod(limit):
    for i in range(2, limit):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod

def NCMMod(n, k):
    if n < k:
        return 0
    if (n < 0 or k < 0):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

initNCMMod(3 * (10**5))
def main():
    n, m, k = LI()
    if m == 1:
        if k >= n-1:
            print(1)
        else:
            print(0)
        return
    m1l = [0] * (n+1)
    m1l[0] = 1
    for i in range(n):
        m1l[i+1] = (m1l[i] * (m-1)) % p
    cnt = 0
    for l in range(k+1):
        x = (m1l[n-l] * m * inv[m-1]) % p
        x *= NCMMod(n-1, l)
        cnt += x
        cnt %= p
    print(cnt % p)




main()



Measured memory_bytes: 70516
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int sub(int a,vector<char>b,int c,int d){
  if(c%2019==0&&c!=0)return 1;
  return sub(a+1,b,c+b[d]*a,d+1);
}
int main(){ 
  long long int a,b,c,d,e;cin>>a>>b>>c>>d>>e;
  if(c*2<=a+b){
    if(max(d,e)==d){
      if(c*2>=a)cout<<c*2*e + a*(d-e);
      else cout<<c*2*d;
    }
    else {
      if(c*2>=b)cout<<c*2*d+b*(e-d);
      else cout<<c*2*e;
    }
  }
  else cout<<a*d+b*e;
}


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

#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair

#define forn(i,s,n) for(i=s;i<n;i++)
#define all(c)  c.begin(),c.end()
#define boost ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(0);srand(time(NULL));
#define tc(t) ll t;cin >> t; while(t--)
/* cout << fixed << setprecision(12) << ans << endl;*/
#define pii pair<long long,long long>
#define vii vector<pii>
#define vvi vector<vector <long long> >

#define ff first
#define ss second

#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vector<int> , greater<int> >

#define deb1(x) cout<<#x<<" : "<<x<<endl;
#define deb2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define deb3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
#define deba(a,n) for(ll i=0;i<n;++i) {  cout<<a[i]<<" "; };cout<<"\n"

#define MOD 1000000007
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN


int main()
{
 boost;
 ll n;
 cin >> n;
 vector<ll> h(n);
 ll i;
 forn(i,0,n)
 cin >> h[i];
 
vector<ll> dp(n,0);
dp[0]=0;

dp[1]=abs(h[1]-h[0]);
 forn(i,2,n)
 {
 	dp[i]=min( dp[i-2]+ abs(h[i-2]-h[i]) , dp[i-1]+ abs(h[i-1]-h[i]) );
 	
 }
  
 cout << dp[n-1] << endl;

}






Measured memory_bytes: 1792
from collections import Counter

n = int(input())
s = input()

res = 0 
for i in range(n):
    temp = 0 
    c1 = Counter(s[:i])
    c2 = Counter(s[i:])
    for c in c1.keys():
        if c in c2.keys():
            temp += 1
    if temp > res:
        res = temp
print(res)

Measured memory_bytes: 3316
#include<map>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int n;
  int mx;
  map<long long,int> a;
  while(cin>>n&&n){
    mx=-1;
    a.clear();
    for(i=0;i<n;i++){
      long long p;
      cin>>p;
      a[p]++;
      if(mx==-1||a[mx]<a[p])
	mx=p;
    }
    if(a[mx]>n/2)
      cout<<mx<<endl;
    else
      cout<<"NO COLOR"<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
n = int(input())
a = [int(x) for x in input().split()]
cnt = 1
flg = False
ans = 0
for i in range(n):
    if a[i] == cnt:
        flg = True
        cnt += 1
    else:
        ans += 1
if flg:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 26268
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;

ll y[10000005];

int main() {
    int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    string s; cin >> s;

    for(int i = a; i < d-1; i++){
        if(s[i] == '#' && s[i+1] == '#'){
            cout << "No" << endl;
            return 0;
        }
    }

    if(c > d){
        for(int i = max(0,b-2); i < d-1; i++){
            if(s[i] == '.' && s[i+1] == '.' && s[i+2] == '.'){
                cout << "Yes" << endl;
                return 0;
            }
        }

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




Measured memory_bytes: 3720