akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <string>
#include <typeinfo>
#include <algorithm>
#include <set>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())


using namespace std;

int main(){
	string a,b;
	int c,d;
	cin>>a>>b;
	a=a+b;
	c = stoi(a);
	d=(int)sqrt((double)c);
	if(d*d==c)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
l=sorted(l)
ans=0
for i in range(n):
    if l[i][1]<=m:
        ans+=l[i][0]*l[i][1]
        m=m-l[i][1]
    else:
        ans+=l[i][0]*m
        m=0
        print(ans)
        exit()
print(ans)

Measured memory_bytes: 28656
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int n, p, m=0, ans=0;
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> p;
        m = max(p, m);
        ans += p;
    }
    cout << ans - m/2 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9+10;
const ll inf_l = 1e18;
const int MAX = 1e5;

template<class iter>
pair<complex<double>,float> sed(iter left, iter right, int seed = 1333) {
    const int n = right - left;
    const double eps = 1e-6;

    assert(n >= 1);
    if (n == 1) return {*left,float(0)};
    
    mt19937 mt(seed);
    shuffle(left,right,mt);

    iter ps = left;
    using CD = complex<double>;
    using circle = pair<CD,double>;

    auto cross = [](const CD &a, const CD &b) -> double {
        return a.real()*b.imag()-b.real()*a.imag();
    };

    auto make_circle_3 = [&](const CD &a, const CD &b, const CD &c) -> circle {
        double A = norm(b-c), B = norm(a-c), C = norm(a-b), S = cross(b-a,c-a);
        CD p = (A*(B+C-A)*a + B*(C+A-B)*b + C*(A+B-C)*c) / (4*S*S);
        double r2 = norm(p-a);
        return {p,r2};
    };

    auto make_circle_2 = [](const CD &a, const CD &b) -> circle {
        CD c = (a+b)/(double)(2);
        double r2 = norm(c-a);
        return {c,r2};
    };

    auto in_circle = [&](const CD &a, const circle &c) -> bool {
        return norm(a-c.first) <= c.second + eps;
    };

    circle c = make_circle_2(ps[0],ps[1]);
    for (int i = 2; i < n; i++) {
        if (!in_circle(ps[i],c)) {
            c = make_circle_2(ps[i],ps[0]);
            for (int j = 1; j < i; j++) {
                if (!in_circle(ps[j],c)) {
                    c = make_circle_2(ps[i],ps[j]);
                    for (int k = 0; k < j; k++) {
                        if (!in_circle(ps[k],c)) {
                            c = make_circle_3(ps[i],ps[j],ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}

int main() {
    int n; cin >> n;
    vector<complex<double>> data(n);
    rep(i,n) {
        double x, y; cin >> x >> y;
        data[i] = complex<double> {x,y};
    }
    double ans = sed(all(data)).second;
    ans = sqrt(ans);
    printf("%.10f\n",ans);
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int cnt = 0;
  rep(i,n-2) {
    if (s.substr(i,3) == "ABC") cnt++;
  }
  cout << cnt << endl;
}


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


int main(){
	string S;
	cin >> S;
	int N = S.size();
	vector<int> chil(N, 0);
	
	//Rのみ考えて、RLの変更点まで連続したRが偶数個か奇数個判定し、加算(左から攻める)
  	int cntR = 1;
	for(int i = 1; i < N; i++){
		if(S.at(i) == 'R'){
			cntR++;
		}
		if(S.at(i) == 'L'){
			if(cntR % 2 == 0){
				chil.at(i) += cntR / 2;
				chil.at(i - 1) += cntR / 2;
			} else {
				chil.at(i) += cntR / 2;
				chil.at(i - 1) += (cntR - cntR / 2);
			}
			cntR = 0;
		}
	}
	
	//Lのみ考えて、Rと同様の操作(右から攻める)
  	int cntL = 1;
	for(int i = N - 2; i >= 0; i--){
		if(S.at(i) == 'L'){
			cntL++;
		}
		if(S.at(i) == 'R'){
			if(cntL % 2 == 0){
				chil.at(i) += cntL / 2;
				chil.at(i + 1) += cntL / 2;
			} else {
				chil.at(i) += cntL / 2;
				chil.at(i + 1) += (cntL - cntL / 2);
			}
			cntL = 0;
		}
	}
	
	for(int i = 0; i < N; i++) cout << chil[i] << " ";
  	cout << endl;
}


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

struct stairway{int start, end, num_step;};

int main(){
	int n, k;
	int a[100000];
	stairway b[100000];
	for(;;){
		cin >> n >> k;
		if(n == 0 && k == 0) break;
		bool flag = false;
		for(int i = 0; i < k; i++){
			cin >> a[i];
			if(a[i] == 0){
				flag = true;
			}
		}

		sort(a, a + k);
		int s, t;
		int index = 0;
		if(flag) s = 1;
		else s = 0;
		for(;;){
			t = s;
			while(t < k && a[t + 1] == a[t] + 1){
				t++;
			}
			b[index].start = a[s];
			b[index].end = a[t];
			b[index].num_step = a[t] - a[s] + 1;
			s = t + 1;
			index++;
			if(t >= k - 1) break;
		}

		int max_step = 0;
		if(flag == false){
			for(int i = 0; i <= index; i++){
				if(b[i].num_step > max_step) max_step= b[i].num_step;
			}
		}else{
			for(int i = 0; i <= index; i++){
				if(i <= index - 1 && b[i].end + 2 == b[i + 1].start && b[i].num_step + b[i + 1].num_step + 1 > max_step){
					max_step = b[i].num_step + b[i + 1].num_step + 1;
				}
				if(b[i].num_step > max_step){
					max_step = b[i].num_step;
				}
			}
		}

		cout << max_step << endl;
	}
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <cstdint>

int main() {
    int A, B, C;
    std::cin >> A >> B >> C;
    
    if (A==B) std::cout << C << std::endl;
    else if (B==C) std::cout << A << std::endl;
    else std::cout << B << std::endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a <= c && c <= b) {
            System.out.println("Yes");
            return;
        }
        if (b <= c && c <= a) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
cs int N = 6e3 + 50;
int n, A[N], B[N], c[N], tr[N]; 
char S[N]; string f[N];
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%d%s",&n,S+1);
	for(int i=1,a=0,b=0; i<=n+n; i++)
	if(S[i]=='a') A[c[i]=++a]=i;
	else B[c[i]=++b]=i;
	for(int i=1; i<=n; i++) tr[min(A[i],B[i])]=i;
	for(int i=n; i>=1; i--){
		if(A[i]>B[i]){
			int j=B[i];
			while(A[c[j]]>B[c[j]]){
				if(c[j]>i&&B[c[j]]>A[c[j]-1]) break;
				if(c[j]>=i) f[i]+=S[j]; ++j;
			} f[i]+=f[c[j]];
		} else f[i] = "ab" + f[tr[B[i]+1]];
		f[i] = max(f[i], f[i+1]);
	} cout << f[1]; return 0;
}

Measured memory_bytes: 14720
// Last Change: 04/12/2019 22:29:26.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  int A, B;
  cin >> A >> B;

  if (A % 2 == 0 or B % 2 == 0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int N;
    static int[] B;

    static void input()
    {
        cin = new Scanner();
        N = cin.nextInt();
        B = cin.ArrayInt(N - 1);
    }
    static void solve()
    {
        input();

        int[] A = Enumerable.Repeat(int.MaxValue, N).ToArray();
        for(int i = 0; i < N - 1; i++)
        {
            A[i] = Min(B[i], A[i]);
            A[i + 1] = Min(B[i], A[i + 1]);
        }
        WriteLine(A.Sum());
    }
    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[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 13268
//#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int a, b;
    cin >> a >> b;

    int c = 1;
    while(b / c > 0) {
        c *= 10;
    }

    REP(i, 1000) {
        if (i * i == a * c + b) {
            print("Yes");
            return 0;
        }
    }

    print("No");

    
}


Measured memory_bytes: 3664
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pt;
const int N=1e6+5;
const int M=2e3+5;
const int INF=0x7fffffff;
const int mod=1e9+7;
const int bb=18;
const double eps=1e-10;
const double pi=acos(-1);
int n,m;
char str[N];
int f[N+100];
map<string,int> mm;
vector<string> v;
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int main()
{
    scanf("%s",str+1);
    LL ans=0;
    int len=strlen(str+1);
    FOR(i,1,len){
        f[i]=str[len-i+1]-'0';
    }
    FOR(i,1,len+15){
        if(f[i]>=10){
            f[i]-=10;
            f[i+1]++;
        }
        if(f[i]>=6){
            ans+=10-f[i];
            f[i+1]++;
        }
        else if(f[i]==5){
            ans+=5;
            if(f[i+1]>=5){
                f[i+1]++;
            }
        }
        else ans+=f[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5120
#include <stdio.h>
 
int main()
{ 
  int a, b, r, tmp;
  scanf("%d%d", &a,&b);

  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }  
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  printf("%d\n", b); 
  return 0;
}

Measured memory_bytes: 592
#include <stdio.h>
#define MAXSIZE 100

void insertionSort(int a[],int size);
void printArray(int a[],int size);

int main(void){
    int i,size,array[MAXSIZE];
    scanf("%d",&size);

    for(i=0;i<size;i++){
        scanf("%d",&array[i]);
    }

    insertionSort(array,size);

    return 0;
}

void insertionSort(int a[],int size){
    int i,j,temp;
    for(i=0;i<size;i++){
        temp=a[i];
        for(j=i;j>0&&a[j-1]>temp;j--){
            a[j]=a[j-1];
        }
        a[j]=temp;
     	printArray(a,size);
    }
}

void printArray(int a[],int size){
    int i;
    printf("%d",a[0]);
    for(i=1;i<size;i++){
    printf(" %d",a[i]);
    }
    printf("\n");
}






Measured memory_bytes: 2108
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//素数かどうかを判定する関数.
int isprime(long long int n){
	if (n == 1) return 0;
    for (long long int i=2;i*i <= n;i++){
        if (n % i == 0) return 0;
    }
    return 1;
}
int main()
{
	int x;
	cin >> x;
	for (long long int i = x;;i++){
		if(isprime(i) == 1){
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}

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

def ans(a,b):
  for i in range(a + 1):
    for j in range(a - i + 1):
      if i * 10000 + j * 5000 + (a - i - j) * 1000 == b:
        return(i, j, a-i-j)
  return(-1, -1, -1)

A = ans(N, Y)

print(A[0], A[1], A[2])

Measured memory_bytes: 3064
//Patwari26
//#include template<t> as mine
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=200005;
vi link(N),siz(N,1);
ll find(ll x)
{
    while(x!=link[x]) x=link[x];
    return x;
}
bool same(ll i,ll j)
    {return find(i)==find(j);}
void unite(ll a,ll b)
{
    a=find(a);
    b=find(b);
    if(siz[a]<siz[b]) swap(a,b);
    siz[a]+=siz[b];
    link[b]=a;
}
void solve(){
    ll n,m,x,y;
    cin>>n>>m;
    rep(i,1,n) link[i]=i;
    rep(i,1,m){
        cin>>x>>y;
        if(!same(x,y)) unite(x,y);
    }
    ll maxx=0;
    ll cc[n+1];
    memset(cc,0,sizeof(cc));
    rep(i,1,n) cc[find(i)]++;
    rep(i,1,n) maxx=max(maxx,cc[i]);
    cout<<maxx<<endl;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    // time
    return 0;
}

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

using namespace std;

int main(){
	int N;
	cin >> N;
	
	int box[56] = {};

	int idx = 0;
	for(int i = 31; i <= 10000 && idx <= 55; i += 30){
		bool l = true;
		for(int j = 3; j <= sqrt(i); j += 2){
			if(i % j == 0){
				l = false;
				break;
			}
		}
		if(l) box[idx++] = i;
	}

	for(int i = 0; i < N - 1; ++i){
		cout << box[i] << " ";
	}
	cout << box[N - 1] << endl;
}


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

typedef long long ll;

void solve() {
    int N;
    cin >> N;
    int d2 = 0, d4 = 0, a;
    rep(i, N) {
        cin >> a;
        if (a % 4 == 0) d4++;
        else if (a % 2 == 0) d2++;
    }
    if (d4 >= N / 2) cout << "Yes" << endl;
    else if (d2 >= N - d4 * 2) cout << "Yes" << endl;
    else cout << "No" << endl; 
    return;
}

int main() {
    solve();
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <stack>
#include <string>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <list>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int t = 0;

void Merge(int A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1], R[n2];
  for (int i = 0; i <= n1-1; i++ ) L[i] = A[left + i];
  for (int i = 0; i <= n2-1; i++ ) R[i] = A[mid + i];
  L[n1] = 1000000000;
  R[n2] = 1000000000;
  int i = 0;
  int j = 0;
  for (int k = left; k <= right-1; k++) {
    if (L[i] <= R[j]) {
		A[k] = L[i];
        i = i + 1;
		t++;
	} else { 
		A[k] = R[j];
        j = j + 1;
		t++;
	}
  }
}

void MergeSort (int A[], int left, int right){
  if (left+1 < right) {
	  int mid = (left + right)/2;
      MergeSort(A, left, mid);
      MergeSort(A, mid, right);
      Merge(A, left, mid, right);
  }
}

int main() {
	int n;
	cin >> n;
	int a[n];
	for( int i = 0; i < n; i++) cin >> a[i];
	MergeSort(a, 0, n);
	for( int i = 0; i < n; i++) {
		if( i ) cout << " " <<a[i];
		else cout << a[i];
	}
	cout <<endl << t <<endl;
	return 0;
}

Measured memory_bytes: 5064
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 5e2+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
	ll n;
	cin >> n;
	vector<ll> v(n), mx(n);
	for(int i = 0; i < n;i++)
	{
		cin >> v[i];
		mx[i] = v[i];
		if(i)
			mx[i] = max(mx[i], mx[i-1]);
	}
	ll ans = 0;
	for(int i = 0; i < n;i++)
	{
		ans += mx[i]-v[i];
	}
	cout << ans << '\n';
}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

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

int N, M;
pair<int, int> PD[10010];

int main() {
  while (cin >> N >> M && N) {
    int d, p;
    for (int i=0; i<N; ++i) {
      cin >> d >> p;
      PD[i] = make_pair(p, d);
    }
    
    sort (PD, PD+N);
    reverse(PD, PD+N); // sort in descending order

  int S = 0;
  for (int i=0; i<N; ++i)
    S += PD[i].first * PD[i].second; // When money runs out, S is the answer

  for (int i = 0; i<N; ++i) {
    if (M <= 0) break;
    int guarded = min(M, PD[i].second);
    S -= PD[i].first * guarded;
    M -= guarded;
  }
  cout << S << endl;
  }
}

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

using namespace std;


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

	if(k<a) cout<<a-k<<" "<<b<<endl;
	else if(k<=a+b) cout<<0<<" "<<b-(k-a)<<endl;
	else cout<<0<<" "<<0<<endl;

	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)


def input():
    return sys.stdin.readline()[:-1]


N, K = map(int, input().split())
H = [0]*N
for i in range(N):
    H[i] = int(input())

H.sort()
ans = 10**10
for i in range(N-(K-1)):
    ans = min(ans, H[i+(K-1)]-H[i])
print(ans)


Measured memory_bytes: 7472
import java.util.*;
class Main{
    public static void main(String[] args){
Scanner in = new Scanner(System.in);
       int a = in.nextInt();
       int b = in.nextInt();
       int c = in.nextInt();
       
       if (a == 5 || a==7 || b == 5 || b == 7 || c == 5 || c == 7)
           if (a + b + c == 17)
                System.out.printf("YES");
            else
                System.out.printf("NO");
       else
            System.out.printf("NO");
       
       
               
    }
    
}

Measured memory_bytes: 35696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template<typename T1, typename T2>
void chmax(T1 &a, const T2 &b) {
  if (a < b) a = b;
}
template<typename T1, typename T2>
void chmin(T1 &a, const T2 &b) {
  if (a > b) a = b;
}
template<typename T>
void printv(const vector<T> &s) {
  for (int i = 0; i < (int) (s.size()); ++i) {
    cout << s[i];
    if (i != (int) (s.size()) - 1) cout << " ";
  }
  cout << "\n";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
struct Time {
  int s, t, u;
  ll hash;
  Time(int s, int t, int u) : s(s), t(t), u(u) {}
};
bool operator<(const Time &t1, const Time &t2) {
  return t1.hash < t2.hash;
}
void add_elm(int i, int s, int t, int u, vector<set<Time>> &v) {
  for(int j=0;j<60;++j) {
    if ((s+j)%5 == (t+j)%60/12) {
      auto now = Time((s + j) / 5 % 12, (t + j) % 60, (u + j) % 60);
      now.hash = 60 * 60 * now.s + 60 * now.t + now.u;
      v[i].insert(now);
    }
  }
}
bool solve() {
  int n;
  cin >> n;
  if(n == 0) return false;
  vector<set<Time>> v(n);
  for(int i=0;i<n;++i) {
    int s, t, u;
    cin >> s >> t >> u;
    add_elm(i, s, t, u, v);
    add_elm(i, s, u, t, v);
    add_elm(i, t, s, u, v);
    add_elm(i, t, u, s, v);
    add_elm(i, u, s, t, v);
    add_elm(i, u, t, s, v);
  }
  vector<ll> a(n);
  vector<set<Time>::iterator> pos(n);
  for(int i=0;i<n;++i) {
    pos[i] = v[i].begin();
  }
  ll l = LINF, r = 0;
  int argmi = -1;
  for(int i=0;i<n;++i) {
    a[i] = pos[i]->hash;
    pos[i]++;
    if (l > a[i]) {
      l = a[i];
      argmi = i;
    }
    chmax(r, a[i]);
  }
  ll ans = r - l;
  ll ansl = l, ansr = r;
  while (1) {
    if (pos[argmi] == v[argmi].end()) break;
    a[argmi] = pos[argmi]->hash;
    pos[argmi]++;
    ll l = LINF, r = 0;
    for(int i=0;i<n;++i) {
      if (l > a[i]) {
        l = a[i];
        argmi = i;
      }
      chmax(r, a[i]);
    }
    if (ans > r - l) {
      ans = r - l;
      ansl = l;
      ansr = r;
    } else if(ans == r - l && ansl > l) {
      ansl = l;
      ansr = r;
    }
  }
  printf("%02lld:%02lld:%02lld ", ansl / 3600 % 12, ansl / 60 % 60, ansl % 60);
  printf("%02lld:%02lld:%02lld\n", ansr / 3600 % 12, ansr / 60 % 60, ansr % 60);
  return true;
}
int main() {
  while(1) {
    if(!solve()) break;
  }
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;

int n, m;
int a[N];
multiset<int> Set;

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	int mx = a[n];
	if (a[n - 1] != mx) return 0 * puts("Impossible");
	for (int i = 1; i <= n - 2; ++i) {
		Set.insert(a[i]);
	}
	int mi = N;
	for (int i = 2; i <= mx; ++i) {
		int tmp = max(i - 1, mx - i + 1);
		mi = min(mi, tmp);
		set<int>::iterator it;
		it = Set.find(tmp);
		if (it == Set.end()) return 0 * puts("Impossible");
		Set.erase(it);
	}
	if (Set.size() == 0) return 0 * puts("Possible");
	int x = *Set.begin();
	int y = *Set.rbegin();
	if (x < mi + 1) return 0 * puts("Impossible");
	if (y > mx) return 0 * puts("Impossible");
	return 0 * puts("Possible");
}


Measured memory_bytes: 256
#include <cstdio>
#include <cassert>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <iostream>
using namespace std;

void erase1(multiset<int> &s, int x) {
    auto it = s.find(x);
    if (it != s.end()) s.erase(it);
}

const int INF = 1<<30;

vector<int> solve(int H, int W, const int *L, const int *R) {
    map<int, int> m;
    multiset<int> distances;
    vector<int> ans(H);
    for (int i = 0; i < W; i++) {
        m[i] = 0;
        distances.insert(0);
    }
    for (int h = 0; h < H; h++) {
        int l = L[h], r = R[h];
        auto it = m.lower_bound(l);
        int d = INF;
        while (it != m.end() && it->first <= r) {
            d = min(d, it->second + r + 1 - it->first);
            erase1(distances, it->second);
            it = m.erase(it);
        }
        if (d < INF && r < W - 1) {
            if (it == m.end() || it->first > r + 1) {
                m[r+1] = d;
                distances.insert(d);
            } else if (d < it->second) {
                erase1(distances, it->second);
                distances.insert(d);
                m[r+1] = d;
            }
        }
        ans[h] = distances.empty() ? -1 : *distances.begin() + h + 1;
    }
    return ans;
}

vector<int> check(int H, int W, const int *L, const int *R) {
    int dp[H+1][W];
    fill(dp[0], dp[0]+W, 0);
    for (int i = 1; i <= H; i++) {
        dp[i][0] = L[i-1] == 0 ? INF : dp[i-1][0];
        for (int j = 1; j < W; j++) {
            if (j < L[i-1]) dp[i][j] = min(dp[i-1][j], dp[i][j-1] + 1);
            else if (j <= R[i-1]) dp[i][j] = dp[i][j-1] + 1;
            else dp[i][j] = min(dp[i-1][j], dp[i][j-1] + 1);
        }
    }

    vector<int> ans(H);
    for (int h = 0; h < H; h++) {
        ans[h] = h + 1 + *min_element(dp[h+1], dp[h+1] + W);
        if (ans[h] >= INF) ans[h] = -1;
    }
    return ans;
}


int main() {
    int H, W; scanf("%d %d", &H, &W);
    int L[H], R[H];
    for (int i = 0; i < H; i++) {
        scanf(" %d %d ", &L[i], &R[i]);
        L[i]--; R[i]--;
    }
    vector<int> ans = solve(H, W, L, R);
    for (int x : ans) printf("%d\n", x);

    // vector<int> expect = check(H, W, L, R);
    // for (int x : expect) cerr << x << endl;
    // for (int i = 0; i < H; i++) assert(ans[i] == expect[i]);
}


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

int main()
{
   int a = 0;
   int b = 0;
   int d = 0;
   int r = 0;
   double f = 0.0;

   cin >> a >> b;

   if((a >= 1) && ( a <= 1000000000) && ( b >= 1) && ( b <= 1000000000))
   {
      d = a / b;
      r = a % b;
      f = ((double)a / (double)b);
      cout << d << " " << r << " " << fixed << f <<endl;
   }
} 


Measured memory_bytes: 3284
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std; using namespace placeholders;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector< int > VI;
typedef vector< vector< int > > VVI;
typedef vector< string > VS;
typedef stringstream SS;
typedef pair< int, int > PII;
typedef vector< pair< int, int > > VPII;
#define VT( T ) vector< T >
#define VVT( T ) vector< vector< T > >
#define LIM( T ) numeric_limits< T >

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; };
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &e : c )
#define ALL( c ) ( c ).begin(), ( c ).end()
#define AALL( a, t ) ( t* )a, ( t* )a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + p, ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

constexpr int MOD = 1000000007;

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

	int N, T;
	cin >> N >> T;

	VI ds( N );
	cin >> ds;

	sort( ALL( ds ) );

	LL res = 1;
	for ( int i = 0, j = 0; i < N; ++i )
	{
		for ( ; j < N && ds[j] - ds[i] <= T; ++j );
		( res *= j - i ) %= MOD;
	}

	cout << res << endl;

	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	vector<ll> a(4);
	REP(i, 4) cin >> a[i];
	sort(a.begin(), a.end());
	cout << (a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9?"YES":"NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <string>

#define FOR(i, n) for (int i = 0; i < n; i++)
#define FORN(i, n, s) for (int i = s; i < n; i++)
#define OUT(s) cout << s << endl;
#define IN(a) cin >> a;
#define PACK(a, n) \
  for (int i = 0; i < n; i++) cin >> a[i];
#define PACKN(a, n, s) \
  for (int i = s; i < n; i++) cin >> a[i];
#define LIST(a, n) \
  for (int i = 0; i < n; i++) cout << "[" << i << "] " << a[i] << endl;

using namespace std;

int main() {
  int N;
  IN(N);
  char S[N];
  PACK(S, N);
  short int b = 0x0;
  FOR(i, N) {
    if (S[i] == 'P') {
      b |= 0x01;
    } else if (S[i] == 'G') {
      b |= 0x02;
    } else if (S[i] == 'W') {
      b |= 0x04;
    } else if (S[i] == 'Y') {
      b |= 0x08;
    }
  }

  int c = b != 0 ? 1 : 0;
  while (b &= (b - 1)) c++;
  OUT((c == 4 ? "Four" : "Three"));
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        while(true){
            try{
                int n=Integer.parseInt(br.readLine());
                int count=0;
                boolean[] map=new boolean[n];
                Arrays.fill(map, true);
                map[0]=false;
                for(int i=2;i*i<=n;i++){
                    if(map[i-1]){
                        for(int j=2;j*i<=n;j++){
                            map[i*j-1]=false;
                        }
                    }
                }for(int i=0;i<map.length;i++){
                    if(map[i]) count++;
                }System.out.println(count);
            }catch(Exception e){System.exit(0);}
        }
    }
    
}

Measured memory_bytes: 39688
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define F first
#define S second
const int N = 2266;
vector<int> g[N];
vector<pii> e;
int vis[N], tt;
int dfs(int u, int d)
{
    if (!d)
        return 1;
    int ans = 1;
    for (int v : g[u]) if (vis[v] != tt) {
        vis[v] = tt;
        ans += dfs(v, d-1);
    }
    return ans;
}
int main()
{
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
        e.emplace_back(u,v);
    }
    int ans = 0;
    if (k & 1) {
        for (pii p : e) {
            ++tt;
            vis[p.F] = vis[p.S] = tt;
            ans = max(ans, dfs(p.F,k/2) + dfs(p.S,k/2));
        }
    } else {
        for (int u = 1; u <= n; ++u) {
            ++tt;
            vis[u] = tt;
            ans = max(ans, dfs(u,k/2));
        }
    }
    cout << n - ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

typedef long double ld;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed;
  cout << setprecision(10);
  ld n;
  cin >> n;
  ld kek = n / 3.0;
  cout << kek * kek * kek << '\n';
  return 0;
}

Measured memory_bytes: 256
import re


s_dash = input()
t = input()
for i in reversed(range(len(s_dash)-len(t)+1)):
    matchobj = re.match(s_dash[i:i+len(t)].replace("?", "[a-z]"), t)
    if matchobj:
        _s = list(s_dash)
        _s[i:i+len(t)] = t
        print("".join(_s).replace("?", "a"))
        exit()
print("UNRESTORABLE")
exit()



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

typedef long long ll;

vector <ll> v;
int n;
ll k,a[100005];

pair<bool,ll> check(ll val){
	ll tot=0,ret1=0ll,ret2=0ll; 
	int t=0,t2=0;
	for(int i=0;i<n;i++){
		ll sum=v[0]+v[i];
		if(sum>=val) t2++;
		if(sum>val) t++;
	}
	ret1+=t; ret2+=ll(a[t-1]+ll(ll(t)*v[0]));
	tot+=t2-t;
	for(int i=1;i<n;i++){
		while(t){
			ll sum=v[i]+v[t-1];
			if(sum<=val) t--;
			else break;
		}
		while(t2){
			ll sum=v[i]+v[t2-1];
			if(sum<val) t2--;
			else break;
		}
		ret1+=t;
		ret2+=a[t-1]+ll(ll(t)*v[i]);
		tot+=t2-t;
	}
	bool f1=(ll(ret1+tot)>=ll(k));
	ll f2=ll(ret2+ll(ll(k-ret1)*val));
//	cout<<val<<" "<<ret2<<" "<<ret1<<endl;
	return make_pair(f1,f2);
}

int main(){
	scanf("%d%lld",&n,&k);
	for(int i=0;i<n;i++){
		ll x; scanf("%lld",&x);
		v.push_back(x);
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	a[0]=v[0];
	for(int i=1;i<n;i++) a[i]=v[i]+a[i-1];
	ll low=0ll,high=2*v[0]+1ll,ans=0;
	while(low<high){
		ll mid=(low+high)/2ll;
		pair<bool,ll> p=check(mid);
		if(p.first){
			ans=p.second;
			low=mid+1;
		}
		else 
			high=mid;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1908
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
	long long n, k, b, ans = 0;
	cin >> n >> k;
	for (b = k + 1; b <= n; b++) {
		ans += (b - k) * ((n + 1 - b) / b);
		ans += b - max(1ll , k);
		ans += max(0ll, (n + 1) % b - k);
	}
	cout << ans << "\n";
	return 0;
}

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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int n;
int a[100001];

int main(){
  scanf("%d",&n);
  for(int i = 1;i<=n;i++){
    scanf("%d",&a[i]);
  }
  int now = 1;
  int cnt = 0;
  while(now!=2){
    if(cnt > n){
      cnt = -1;
      break;
    }
    now = a[now];
    cnt++;
  }
  printf("%d\n",cnt);
}


Measured memory_bytes: 768
#include<stdio.h>
#include<string.h>
int main(){
  int n,i,count=0,count2=0,m;
  char a[1000],t[10];
    
    scanf("%s",t);
  n=strlen(t);
  
  while(1){
    
    scanf("%s",a);
  m=strlen(a);
  
  if(n==m){
    count=0;
    for(i=0;i<m;i++){
      if(t[i]==a[i] || t[i]+32==a[i] ||t[i]==a[i]+32) count++;
      if(count==m) count2++;
    }
  }
  
  if(a[0]=='E' && a[1]=='N' && a[2]=='D' && a[3]=='_' && a[4]=='O' && a[5]=='F' && a[6]=='_' && a[7]=='T' && a[8]=='E' && a[9]=='X' && a[10]=='T') break;
  }
  
  printf("%d\n",count2);
  
  return 0;
}



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

const int MAX = 200001;
const int mod = 998244353;

long long fac[MAX], fac_inv_mod[MAX],inv_mod[MAX];

void comb_init(){
    fac[0] = fac[1] = 1;
    fac_inv_mod[0] = fac_inv_mod[1] = 1;
    inv_mod[1]=1;
    for(int i=2; i<MAX; i++){
        fac[i] = fac[i-1] * i % mod;
        inv_mod[i] = mod - inv_mod[mod%i] * (mod / i) % mod;
        fac_inv_mod[i] = fac_inv_mod[i-1] * inv_mod[i] % mod;
    }
}

long long comb(int n, int k){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return fac[n] * (fac_inv_mod[k] * fac_inv_mod[n-k] % mod) % mod;
}

int main(){
    comb_init();
    int n,m,k; cin>>n>>m>>k;
    long long ans = 0;
    long long base = m;
    for (int i=0; i<n-k-1;i++) base=base*(m-1)%mod;

    for(int j=0; j<=k; j++){
        long long tmp = base*comb(n-1,k-j) % mod;
        ans = (ans+tmp)%998244353;
        base = base*(m-1)%mod;
    }
    if (ans < 0) ans += 998244353;
    cout << ans << endl;
}

Measured memory_bytes: 8332
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int len = s.length();
        int count = 0;
        for(int i=0; i<len/2; i++) {
            char c1 = s.charAt(i);
            char c2 = s.charAt(len - i - 1);
            if(c1 != c2) {
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
    
#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
    
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
    
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
    
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

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

    queue<LL> memo;
    REP1(i, 10) memo.push(i);

    REP(i, N-1) {
        LL now = memo.front();
        memo.pop();

        if(now % 10 != 0) memo.push(now * 10L + (now % 10) - 1);
        memo.push(now * 10L + (now % 10));
        if(now % 10 != 9) memo.push(now * 10L + (now % 10) + 1);
    }

    cout << memo.front() << endl;
}

Measured memory_bytes: 5176
import sys

for line in sys.stdin:
    try:
        a,b,c = [int(x) for x in line.split()]
        if (a**2+b**2) == c**2:
            print('YES')
        elif (a**2+c**2) == b**2:
            print('YES')
        elif (b**2+c**2) == a**2:
            print('YES')
        else:
            print('NO')
    except(ValueError):
        continue

Measured memory_bytes: 7664
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[100005];
int gcd(int a,int b)
{
    if (b==0) return a;
    return gcd(b,a%b);
}
void write(int x)
{
    if (x==0) puts("First");
    else puts("Second");
    return;
}
void dfs(int s,int f,int now)
{
	//printf("%d %d %d %d\n",s,f,now,a[f]);
    if ((n-s)&1) 
    {
        write(now);
        return;
    }
    if (s>1) 
    {
        write(1-now);
        return;
    }
    a[f]--;
    if (a[f]==0) 
    {
    	write(1-now);
    	return;
	}
    int g=a[1];
    for (int i=2; i<=n; i++) g=gcd(g,a[i]);
    s=0;
    for (int i=1; i<=n; i++)
    {
        a[i]/=g;
        if (a[i]&1) s++,f=i;
    }
    dfs(s,f,1-now);
}
int main()
{
    scanf("%d",&n);
    int s=0,f=0;
    for (int i=1; i<=n; i++) 
    {
        scanf("%d",&a[i]);
        if (a[i]&1) s++,f=i;
    }
    dfs(s,f,0);
    return 0;
}

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

using namespace std;

int main(){
	int m, mn, mx;
	while(cin>>m>>mn>>mx, m|mn|mx){
		int P[205], diff=0, ans=0;
		rep(i,m) cin >> P[i+1];
		for(int i=mn; i<=mx; i++){
			if( P[i] - P[i+1] >= diff ){
				ans = i;
				diff = P[i] - P[i+1];
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
int n,k,i,w[150];
bool cmp(const int&a,const int&b){
	return a<b;
}
int main(){
	scanf("%d %d",&n,&k);
	for (i=1;i<=n;i++)
		scanf("%d",&w[i]);
	sort(w+1,w+n+1,cmp);
	for (i=1;i<=n;i++)
		if (k>=w[i]) k-=w[i];
		else break;
	if (i==n+1&k>0) i--;
	printf("%d",i-1);
}

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

using namespace std;
using ll = long long;


int main()
{
    int n; cin >> n;vector<int> a(n); 
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] -= (i + 1);
    }
    sort(a.begin(), a.end());
    ll med = a[n / 2];
    ll sum = 0;

    for(int i = 0; i < n; i++) {
        sum += abs(a[i] - med);
    }
    cout << sum << endl;
}

Measured memory_bytes: 1024
#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 EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long ll;

using namespace std;

int main(){

    int N,K;
    cin>>N>>K;
    ll h[200000]={0};
    REP(i,N){
        cin>>h[i];
    }
    sort(h,h+N,greater<int>());
    REP(i,K){
        h[i]=0;
    }
    ll ans=0;
    REP(i,N){
        ans+=h[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5088
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define Min(_A,_B) ((_A)<(_B)?(_A):(_B))
#define Abs(_A) ((_A)>0?(_A):(-(_A)))
#define INF 0x3f3f3f3f

int n;
int a[200005];
void init(){
    scanf("%lld",&n);
    long long sm=0,b;
    for(int i=1;i<=n;++i){
        scanf("%lld",&a[i]);
        a[i]-=i;
    }
    sort(a+1,a+1+n);
    if(n&1){
        b=a[(n>>1)+1];
    }else{
        b=(a[(n>>1)]+a[(n>>1)+1])>>1;
    }
    long long ans=0;
    for(int i=1;i<=n;++i){
        ans+=Abs(a[i]-b);
    }
    printf("%lld",ans);
}
int main(){
    init();
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    // vector<double> a(n);
    double count;
    double in;
    for (int i = 0; i < n; i++)
    {
        cin >> in;
        count += 1.0 / in;
    }
    count = 1.0 / count;
    cout << setprecision(15)<<count;
}

Measured memory_bytes: 256