akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
//#define int long long


//booooooooooooost
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)



LL inv_mod(LL a, LL m)
{
	LL b, x, u, q, tmp;

	b = m; x = 1; u = 0;
	while (b > 0) {
		q = a / b;
		tmp = u; u = x - q * u; x = tmp;
		tmp = b; b = a - q * b; a = tmp;
	}

	return (x < 0) ? m + x : x;
}




signed main() {

	string s;
	int K;
	vector<int> arr;
	cin >> s >> K;
	REP(i, s.size()) {
		arr.PSB(('z' + 1 - s[i]) % 26);
	}

	REP(i, s.size()) {
		if (K >= arr[i]) {
			s[i] = 'a';
			K -= arr[i];
		}
	}
	if (K > 0) {
		s[s.size() - 1] = s[s.size() - 1] + (K % 26);
	}
	cout << s << endl;



	return 0;
}

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

int main()
{
	int64_t x, y, z, k;
	cin >> x >> y >> z >> k;
	vector<int64_t> a(x);
	vector<int64_t> b(y);
	vector<int64_t> c(z);
	for (int i = 0; i < x; i++) {
		cin >> a.at(i);
	}
	for (int i = 0; i < y; i++) {
		cin >> b.at(i);
	}
	for (int i = 0; i < z; i++) {
		cin >> c.at(i);
	}

	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	sort(b.begin(), b.end());
	reverse(b.begin(), b.end());
	sort(c.begin(), c.end());
	reverse(c.begin(), c.end());

	vector<int64_t> sum;
	for (int i = 1; i <= x; i++) {
		for (int j = 1; j <= y; j++) {
			for (int l = 1; l <= z; l++) {
				if (i * j * l > k) {
					break;
				} else {
					sum.push_back(a.at(i - 1) + b.at(j - 1) + c.at(l - 1));
				}
			}
		}
	}

	sort(sum.begin(), sum.end());
	reverse(sum.begin(), sum.end());
	for (int i = 0; i < k; i++) {
		cout << sum.at(i) << endl;
	}

}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, a, ans = 0;
  cin >> n;
  rep(i, n) {
    cin >> a;
    if (i % 2 == 0 && a % 2 == 1) ans++;
  }

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


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<pair<int, int>> all;
	for (int i = 0; i < N; i++) {
		int t, d;
		cin >> t >> d; --t;
		all.emplace_back(d, t);
	}
	sort(all.rbegin(), all.rend());
	priority_queue<int, vector<int>, greater<int>> nex;
	priority_queue<int> add;
	vector<int> used(N);
	ll sum = 0, var = 0;
	for (int i = 0; i < N; i++) {
		if (i < K) {
			if (!used[all[i].second]) {
				++var;
				used[all[i].second] = true;
				sum += all[i].first;
			}
			else {
				sum += all[i].first;
				nex.push(all[i].first);
			}
		}
		else {
			if (!used[all[i].second]) {
				used[all[i].second] = true;
				add.push(all[i].first);
			}
		}
	}
	ll res = sum + var * var;
	while (!nex.empty() && !add.empty()) {
		sum += add.top() - nex.top();
		add.pop(), nex.pop();
		++var;
		res = max(res, sum + var * var);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1908
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    int mx = 2e9, ans = 0;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(x <= mx){
            ans++;
            mx = x;
        }
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define fo(i,s,e) for (int i=(s); i < (e); i++)
#define all(obj) (obj).begin(), (obj).end()
/*卍卍卍 #define int long long 卍卍卍*/
signed main () {
  int n,k,q,a;cin>>n>>k>>q;
  vector<int> v(n,k-q);
  rep(i,q) {
    cin>>a;
    v[a-1]+=1;
  }
  rep(i,n) cout << (v[i]<1 ? "No" : "Yes") << endl;
}

Measured memory_bytes: 3792
#include <stdio.h>

int main(void) {
  int n;
  scanf("%d", &n);
  int A[n+1];
  int data[n+1];
  for(int i = 1;i <= n;i++) {
    scanf("%d", A + i);
    data[i] = 0;
  }
  long ret = 0;
  for(int i = 1;i <= n;i++) {
    if(i + A[i] < n)data[i + A[i]]++;
  }
  for(int i = 1;i <= n;i++) {
    if(i - A[i] > 0) ret += data[i - A[i]];
  }

  printf("%ld\n", ret);
  return 0;
}

Measured memory_bytes: 3676
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^8 -> 8回
// double pi = M_PI or acos(-1)
// printf("%.10f\n", ans);

int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i, n) { // 0-index
        int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        tmp1--; tmp2--;
        x.at(i) = tmp1; y.at(i) = tmp2;
    }
    vector<int> numbers;
    rep(i, n) numbers.push_back(i);  // 0-index

    double sum = 0;
    double numOfPertterns = 0;
    do {
        for (int i = 0; i < n - 1; i++) {
            int pre = numbers.at(i); int lat = numbers.at(i+1);
            double hoge = sqrt(pow((x.at(pre) - x.at(lat)), 2) + pow((y.at(pre) - y.at(lat)), 2));
            sum += hoge;
        }
        numOfPertterns++;
    } while (next_permutation(numbers.begin(), numbers.end()));

    double ans = sum / numOfPertterns;

    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}


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

int main (){
	int n,cnt=0;
    int a[2000];
	scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    sort(a,a+n);
    for(int i1=0;i1<n;i1++){
        for(int i2=i1+1;i2<n;i2++){
            for(int i3=i2+1;i3<n;i3++){
                if(a[i1]+a[i2]>a[i3]&&a[i1]+a[i3]>a[i2])cnt++;
                else if(a[i1]+a[i2]<=a[i3])break;
            }
        }
    }
    printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a > b) {
		if (c >= b && c <= a) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	else if (c >= a && c <= b) {
		cout << "Yes" << endl;
		return 0;
	}
    cout << "No" << endl;
	return 0;
}

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

using namespace std;

const int N = 1e5 + 10;
long long A[N];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    int n;
    cin >> n;
    map<int, long long> qtd;
    long long sum = 0LL;
    for(int i = 0; i < n; i++) {
        cin >> A[i];
        sum += A[i];
        qtd[A[i]]++;
    }
    int q;
    cin >> q;
    while(q--) {
        int b, c;
        cin >> b >> c;
        long long qtd_ = qtd[b];
        qtd[b] = 0, qtd[c] += qtd_;
        long long b_ = b * qtd_;
        long long c_ = c * qtd_;
        long long ans = sum - b_;
        ans += c_;
        sum = ans;
        cout << ans << "\n";
    }
    
    return 0;
}


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

typedef long long ll;
typedef unsigned long long llu;
typedef long double ldo;
#define forz(iter,n)	for(ll iter=0;iter<n;++iter)
#define rep(iter,s,e)	for(ll iter=s;iter<e;++iter)
#define urep(iter,s,e)	for(ll iter=s;iter>=e;--iter)
#define MOD				(ll)998244353
#define pp				pair<ll,ll>
#define vii				vector<int>
#define vll				vector<ll>
#define vpp				vector<pp>
#define vss				vector<string>
#define take(A,n)		{forz(iter,n)cin>>A[iter];}
#define pb				push_back
#define pob				pop_back
#define eb				emplace_back
#define pf				push_front
#define pof				pop_front
#define mkp				make_pair
#define all(a)			a.begin(),a.end()
#define ff				first
#define ss				second
#define lcm(a,b)		(a*b)/__gcd(a,b)
#define bs(v,x)			binary_search(all(v),x)
#define ub(v,x)			upper_bound(all(v),x)
#define lb(v,x)			lower_bound(all(v),x)
#define zoom			ios_base::sync_with_stdio(false);cin.tie(NULL);
template <class C> void setmin(C &a,C b){if(a>b)a=b;}
template <class C> void setmax(C &a,C b){if(a<b)a=b;}
template <class C> void printv(vector<C> vec,string end=" "){for(auto const&iter:vec)cout<<iter<<end;if(end!="\n")cout<<endl;}
template <class C> void printv(set<C> setc,string end=" "){for(auto const&iter:setc)cout<<iter<<end;if(end!="\n")cout<<endl;}
template <class C> void print(C A[],ll n,string end=" "){forz(iter,n)cout<<A[iter]<<end;if(end!="\n")cout<<endl;}
//for(auto const&x:mp)

ll po(ll _x_,llu _y_,llu _mod_=MOD)
{
	if(_y_==0)
		return 1;
	ll _p_=po(_x_,_y_/2,_mod_)%_mod_;
	_p_=(_p_*_p_)%_mod_;
	return ((_y_&1)?(_x_*_p_)%_mod_:_p_);
}
class Solution
{
	public:
	void SolutionFunc()
	{
		ll n;
		cin>>n;
		vll d(n);
		map<ll,ll> mp;
		forz(i,n)
		{
			cin>>d[i];
			mp[d[i]]++;
		}
		if((d[0]!=0)||(mp[0]>1))
		{
			cout<<0<<endl;
			return;
		}
		bool lev=false;
		ll ans=1;
		rep(i,1,n-1)
		{
			if(mp[i]==0)
			{
				lev=true;
			}
			if((lev)&&(mp[i]>0))
			{
				cout<<0<<endl;
				return;
			}
			if(!lev)
			{
				// cout<<ans<<endl;
				ans=(po(mp[i-1],mp[i])*ans)%MOD;
			}
		}
		cout<<ans<<endl;
	}
};
int main()
{
	zoom;
	Solution ob;
	ll t=1;
	// cin>>t;
	forz(t1,t)
	{
		// cout<<"Case #"<<t1+1<<": ";
		ob.SolutionFunc();
	}
	return 0;
}

Measured memory_bytes: 7296
#[allow(unused)]
use std::io::Write;
use std::collections::HashMap;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let n: usize = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.parse().unwrap()
    };

    let sqrt_n = (n as f64).sqrt() as usize + 1;

    let mut a = 0;
    for i in 0..(n + 1) {
        if n % (sqrt_n - i) == 0 {
            a = sqrt_n - i;
            break;
        }
    }

    println!("{}", a + (n / a) - 2);
}

// fn prime_sieve(n: usize) -> Vec<usize> {
//     let mut table: Vec<usize> = vec![0; (n + 1) as usize];
//     let mut primes: Vec<usize> = Vec::new();
//
//     for i in 2..(n+1) {
//         if table[i as usize] == 0 {
//             primes.push(i);
//             for j in 2..n {
//                 if i * j > n {
//                     break
//                 }
//                 table[(i * j) as usize] = 1
//             }
//         }
//     }
//
//     primes
// }
//
// fn prime_factor(n: usize) -> HashMap<usize, usize> {
//     let mut factors = HashMap::new();
//
//     let primes = prime_sieve((n as f64).sqrt() as usize);
//     let mut rest = n;
//     for p in primes {
//         while rest % p == 0 {
//             let count = factors.entry(p).or_insert(0);
//             *count += 1;
//             rest /= p;
//         }
//     }
//     if rest != 1 {
//         factors.insert(rest, 1);
//     }
//
//     factors
// }


Measured memory_bytes: 4352
n, k = map(int, input().split())
s = input()

arr = []
cnt = 0
c = s[0]
for i in range(n):
    if c != s[i]:
        if c == '0':
            arr.append(-cnt)
        else:
            arr.append(+cnt)
        c = s[i]
        cnt = 1
    else:
        cnt += 1
if c == '0':
    arr.append(-cnt)
else:
    arr.append(+cnt)

# if the beginning of arr is negative, attach prefix 0
if arr[0] < 0:
    arr = [0] + arr

s_arr = [0]
for val in arr:
    s_arr.append(s_arr[-1] + abs(val))

max_v = -1
m = len(arr)
for i in range(0, m, 2):
    max_v = max(max_v, s_arr[min(m, i+2*k+1)] - s_arr[i])
print(max_v)

Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long 
#define pi 3.1415926536
using namespace std;
const ll N=1e5+5;
void solve()
{ll n,k,l,h,r,z,w,mini,maxi=INT_MAX,prev;
  cin>>n;
  while(n)
  {
  	if(n%10==7)
  	{
  		cout<<"Yes";
  		return;
	  }
	  n/=10;
  }
  cout<<"No";
}
  
int main()
{
  fast
  //for(ll i=0;i<=9;i++)
  //cal(1,3234566667,i);
  //sort(v.begin(),v.end());
  //fact();
  //chk();
ll t=1;
//cin>>t;
//SieveOfEratosthenes();
//cout<<"ok";
while(t--)
{ //cout<<"ok";

solve();
 //cout<<ma<<endl;
}
return 0;}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int D=2,N=1010,P=1000000007;
int i,j,k,n,m,n1,n2,x,y,z;
ll K;
char a[N][N];
struct matrix {
	int a[D][D];
	void clear() {
		memset(a,0,sizeof a);
	}
	matrix operator * (const matrix &n) const {
		matrix t;
		t.clear();
		int i,j,k;
		for (k=0;k<D;k++)
			for (i=0;i<D;i++)
				for (j=0;j<D;j++) t.a[i][j]=((ll) a[i][k]*n.a[k][j]+t.a[i][j])%P;
		return t;
	}
} A,B;
int ksm(int x,ll y) {
	int z=1;
	for (;y;y>>=1,x=(ll) x*x%P) if (y&1) z=(ll) z*x%P;
	return z;
}
int main() {
	scanf("%d%d%lld",&n,&m,&K);
	if (K==0) return puts("1"),0;
	for (i=1;i<=n;i++) {
		scanf("%s",a[i]+1);
		for (j=1;j<=m;j++) if (a[i][j]=='#') x++;
	}
	for (i=1;i<=n;i++) if (a[i][1]=='#' && a[i][m]=='#') n1++;
	for (j=1;j<=m;j++) if (a[1][j]=='#' && a[n][j]=='#') n2++;
	if (n1 && n2) return puts("1"),0;
	if (!n1 && !n2) return printf("%d\n",ksm(x,K-1)),0;
	if (n1) {
		for (i=1;i<=n;i++)
			for (j=1;j<m;j++) if (a[i][j]=='#' && a[i][j+1]=='#') y++;
		z=n1;
	}
	else {
		for (j=1;j<=m;j++)
			for (i=1;i<n;i++) if (a[i][j]=='#' && a[i+1][j]=='#') y++;
		z=n2;
	}
	A.a[0][0]=A.a[1][1]=1;
	B.a[0][0]=x;
	B.a[0][1]=y;
	B.a[1][1]=z;
	K--;
	for (;K;K>>=1,B=B*B) if (K&1) A=A*B;
	printf("%d\n",(A.a[0][0]+P-A.a[0][1])%P); 
}

Measured memory_bytes: 1152
package main

import (
	_"bufio"
	"fmt"
	_"os"
	_"strconv"
)

func main() {
	var x, a, b int
	fmt.Scan(&x, &a, &b)
	switch {
		case b-a <= 0:
			fmt.Println("delicious")
			break
		case b-a <= x:
			fmt.Println("safe")
			break
		default:
			fmt.Println("dangerous")
			break
	}
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(500000)
MOD = 10**9+7

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

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, L = mi()
    S = [input() for i in range(N)]
    S.sort()
    print(*S, sep='')

 

if __name__ == '__main__':
    main()


Measured memory_bytes: 9032
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

int main(void){
    string S;
    cin>>S;
    if((S[5]=='1' || S[6]>'4')) cout <<"TBD" << endl;
    else cout << "Heisei" << endl;
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++) cin >> B[i];
    
    auto check = [](int a, int b, vector<int>& avail){
        bitset<51> ok;
        ok[a] = 1;
        for(int i=a; i>0; i--) if(ok[i]) for(int d : avail) ok[i%d] = 1;
        return (ok[b] == 1);
    };
    
    vector<int> use;
    bool ok_once = false;
    for(int k=51; k>0; k--){
        vector<int> avail = use;
        for(int j=k-1; j>0; j--) avail.push_back(j);
        bool ok = true;
        for(int i=0; i<N; i++) ok &= check(A[i], B[i], avail);
        if(ok) ok_once = true;
        if(!ok) use.push_back(k);
    }
    int64_t ans = -1;
    if(ok_once){
        ans = 0;
        for(int a : use) ans += 1LL<<a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    static int[] h = new int[100010];
    static int[] dp = new int[100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return b;
        }
        return a;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        k = sc.nextInt();
        Arrays.fill(dp, Integer.MAX_VALUE);
        int res = Integer.MAX_VALUE;
        dp[0] = 0;
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }

        for (int i = 1; i < n; i++) {
            for (int j = 1; j <= i && j <= k; j++) {
                dp[i] = chmin(dp[i], dp[i - j] + Math.abs(h[i] - h[i - j]));

            }
        }
        System.out.println(dp[n - 1]);
    }
}


Measured memory_bytes: 61176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

struct mint{
    static const long long MOD = 1000000007;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

mint operator*(long long l, mint r){ return r * l; }

std::ostream& operator<<(std::ostream& stream, const mint& m){
    stream << m.v;
    return stream;
}

struct mintcomb{
    vector<mint> fact;
    vector<mint> ifact;
    mintcomb(ll n) : fact(n + 1, 1), ifact(n + 1, 1) {
        for(ll i = 2; i <= n; ++i){
            fact.at(i) = fact.at(i - 1) * i;
            ifact.at(i) = fact.at(i).inv();
        }
    }

    mint factorial(ll k) const { return fact.at(k); }
    mint permutation(ll k, ll l) const {
        return fact.at(k) * ifact.at(k - l);
    }
    mint combination(ll k, ll l) const {
        return fact.at(k) * ifact.at(l) * ifact.at(k - l);
    }
};

int main(){
    ll n, m;
    cin >> n >> m;
    mintcomb mc(m);
    mint ans = 0;
    REP(k, n + 1){
        ans += (k % 2 == 0 ? 1 : -1) * mc.combination(n, k) * mc.permutation(m - k, n - k); 
    }
    ans *= mc.permutation(m, n);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11112
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
int a[200000],b[200000];
int main(void)
{
	int n,m,i,s;
	scanf("%d",&n);
	FOR(i,0,n) scanf("%d",a+i);
	scanf("%d",&m);
	FOR(i,0,m) scanf("%d",b+i);
	qsort(a,n,sizeof(int),comp);
	qsort(b,m,sizeof(int),comp);
	s=0;
	FOR(i,0,m){
		while(s<n&&b[i]!=a[s]) s++;
		if(s==n){
			puts("NO");
			return 0;
		}
		s++;
	}
	puts("YES");
	return 0;
}


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

#define  F  first
#define  S  second
#define  pb push_back
#define  mp make_pair
typedef long long int ll;
const int N = 1e6+6;

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


    int a,b;cin>>a>>b;
    if( (a*b)&1 )cout<< "Yes\n";
    else cout<< "No\n";











    return 0;
}


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

using namespace std;

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

  vector<int> d;
  for (int i = 0; i < k; ++i) {
    int a;
    cin >> a;
    d.push_back(a);
  }

  int p = n;
  while (true) {
    int pt = p;
    bool f = false;
    while (pt > 0) {
      int d1 = pt % 10;
      pt /= 10;
      if (find(d.begin(), d.end(), d1) != d.end()) {
        f = true;
      }
    }
    if (!f) break;
    ++p;
  }

  cout << p << endl;

  return 0;
}


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

int main () {

  int n, sum = 0;
  cin >> n;
  vi ans;
  string aux;
  cin >> aux;
  ans.push_back(sum);
  for (size_t i = 0; i < n; i++) {
    aux[i] == 'I' ? ++sum : --sum;
    ans.push_back(sum);
  }
  sort(ans.rbegin(), ans.rend());
  cout << ans[0] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repr(i, a, n) for (ll i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  ll ans = 1e15;
  int sq = sqrt(n + 1);
  rep(i, 1, sqrt(n + 1)) {
    if (n % i) continue;
    ll a = i;
    ll b = n / i;
    ans = min(ans, a + b - 2);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#pragma GCC optimize ("O3")

inline static int gl(void){
    int x = 0;
    for(;;){
        unsigned int c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}

inline static void pl(unsigned int s){
    char str[9];
    int pos=9;
    if(s==0){
        putchar_unlocked('0');
        return;
    }
    do{
        pos--;
        str[pos]=s%10+48;
        s/=10;
    }while(s!=0);
    for(; pos<9; pos++){
        putchar_unlocked(str[pos]);
    }
}

inline static int sp(char* str, unsigned short i){
    if(i>99){
        char c0 = i%10; i/=10;
        char c1 = i%10; i/=10;
        str[0] = i+48;
        str[1] = c1+48;
        str[2] = c0+48;
        return 3;
    }else if(i>9){
        char c0 = i%10; i/=10;
        str[0] = i+48;
        str[1] = c0+48;
        return 2;
    }else{
        str[0] = i+48;
        return 1;
    }
}

char a[501];
unsigned short out[1000000];
char buffer[8*1024*1024];

int main(void){
    const int h=gl(), w=gl();
    int p = 0;
    int pos=0;
    {
        char haveCoin = 0;
        short old_y, old_x;
        for(int i=1; i<=h; i++){
            for(int j=1; j<=w; j++){
                int t = getchar_unlocked() - 48;
                getchar_unlocked();
                a[j] = t;
            }
            if(i%2==1){
                for(int j=1; j<=w; j++){
                    if(haveCoin){
                        /*
                           out[4*pos+0]=old_y;
                           out[4*pos+1]=old_x;
                           out[4*pos+2]=i;
                           out[4*pos+3]=j;
                           pos++;
                           */
                           pos++;
                        p += sp(buffer+p, old_y)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, old_x)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, i)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, j)+1; buffer[p-1] = '\n';
                    }
                    haveCoin ^= a[j]&1;
                    old_y = i;
                    old_x = j;
                }
            }else{
                for(int j=w; j>0; j--){
                    if(haveCoin){
                        /*
                           out[4*pos+0]=old_y;
                           out[4*pos+1]=old_x;
                           out[4*pos+2]=i;
                           out[4*pos+3]=j;
                           pos++;
                           */
                           pos++;
                        p += sp(buffer+p, old_y)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, old_x)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, i)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, j)+1; buffer[p-1] = '\n';
                    }
                    haveCoin ^= a[j]&1;
                    old_y = i;
                    old_x = j;
                }
            }
        }
    }
    pl(pos); putchar_unlocked('\n');
    fwrite(buffer, p, 1, stdout);
    return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <string>

using namespace std;

int main(){
    char X, Y;

    cin >> X >> Y;

    if(X < Y)
    {
        cout << '<' << endl;
    }
    else if(X == Y)
    {
        cout << '=' << endl;
    }
    else
    {
        cout << '>' << endl;
    }

    return 0;
}

Measured memory_bytes: 256
A, B, C = list(map(int, input().split()))

if A * C <= B:
    print(C)
    exit(0)

result = 0
if A > B:
    print(result)
    exit(0)

while result * A <= B :
    if (result + 1) * A > B:
        break
    result +=1

print(result)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextLine() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, e := strconv.Atoi(nextLine())
	if e != nil {
		panic(e)
	}
	return i
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		num = nextInt()
		nums = append(nums, num)
	}
	return
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func sumSlice(nums []int) int {
	sum := 0
	for _, n := range nums {
		sum += n
	}
	return sum
}

func binarySearch(target int, list []int) int {
	left := 0
	right := len(list) - 1
	mid := (left + right) / 2

	for {
		if list[mid] < target {
			left = mid + 1
		} else {
			right = mid
		}
		mid = (left + right) / 2
		if left >= right {
			break
		}
	}
	return mid
}

func main() {
	scanner.Split(bufio.ScanWords) // switch to separating by space
	// scanner.Buffer([]byte{}, 1000000009) // switch to read large size input
	N := nextInt()
	stones := scanNums(N)

	// stones := make([]int, 0)
	notFoundNumber := 0
	count := 0
	found := false

	for i := 1; i <= N; i++ {
		found = false
		for idx, v := range stones {
			if i == v {
				stones = stones[idx+1:]
				count += idx
				found = true
				break
			}
		}
		if found == false {
			count += len(stones)
			notFoundNumber = i
			break
		}
	}

	if notFoundNumber == 1 {
		count = -1
	}

	fmt.Println(count)
}


Measured memory_bytes: 8320
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String[] s = new String[n];
		int[] p = new int[n];
		int[] o = new int[n];

			for (int i = 0; i < n; i++) {
			s[i] = sc.next();
			p[i] = sc.nextInt();
			o[i] = i+1;
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (s[i].compareTo(s[j]) < 0) {
					String tmps = s[j];
					s[j] = s[i];
					s[i] = tmps;
					int tmpp = p[j];
					p[j] = p[i];
					p[i] = tmpp;
					int tmpo = o[j];
					o[j] = o[i];
					o[i] = tmpo;
				}
				if (s[i].equals(s[j])) {
					if (p[i] > p[j]) {
						int tmpp = p[j];
						p[j] = p[i];
						p[i] = tmpp;
						int tmpo = o[j];
						o[j] = o[i];
						o[i] = tmpo;
					}
				}
			}

		}

		for (int i = 0; i < n; i++) {
//			System.out.print(s[i] + " " + p[i] + " ");
			System.out.println(o[i]);
		}
		sc.close();
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

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

int main()
{
    ll n, k;
    cin >> n >> k;
    int j;
    double sum = 0;
    ll cnt = 0;
    for (int i = 1; i <= n; i++)
    {
        j = i;
        cnt = 0;
        while (j < k)
        {
            j = j * 2;
            cnt++;
        }
        sum += (double)1 / (pow(2, cnt) * n);
    }
    cout << fixed << setprecision(15) << sum << endl;
}

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

int main() {
  map<int, int> MA;
  vector<int> V1 = {1,3,5,7,8,10,12};
  vector<int> V2 = {4,6,9,11};
  vector<int> V3 = {2};
  for (auto v : V1) MA[v] = 1;
  for (auto v : V2) MA[v] = 2;
  for (auto v : V3) MA[v] = 3;
  int x, y;
  cin >> x >> y;
  cout << ((MA[x] == MA[y]) ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 3556
#include <iostream>

int main()
{
	std::string junban;

	std::cin >> junban;

	for (int i = 0; i < static_cast<int>(junban.length()); i++)
	{
		if (i % 2 == 1 && junban.at(i) == 'R')
		{
			std::cout << "No" << std::endl;

			break;
		}

		if (i % 2 == 0 && junban.at(i) == 'L')
		{
			std::cout << "No" << std::endl;

			break;
		}

		if (i == static_cast<int>(junban.length() - 1))
		{
			std::cout << "Yes" << std::endl;
		}
	}


}

Measured memory_bytes: 256
#include "stdio.h"

int main(int argc, char const *argv[])
{
    int K, A, B, yes = 0;
    scanf("%d\n%d %d", &K, &A, &B);
    for(; A <= B; A++) {
        if (A % K == 0) {
            yes++;
            break;
        }
    }
    printf(yes ? "OK\n" : "NG\n");
    return 0;
}


Measured memory_bytes: 1708
dp = [0] * 50
dp[0] = 1
for i in range(30):
  dp[i + 1] += dp[i]
  dp[i + 2] += dp[i]
  dp[i + 3] += dp[i]

while True:
  n = input()
  if n == 0:
    break
  print ((dp[n] + 9) / 10 + 364) / 365

Measured memory_bytes: 4216
n=int(input())
A=list(map(int,input().split()))
cnt=0
ans=0
for i in range(n):
  if A[i]<0:
    cnt+=1
if cnt%2==0:
  for j in range(n):
    ans+=abs(A[j])
else:
  B=[]
  for k in range(n):
    B.append(abs(A[k]))
  for l in range(n):
    ans+=abs(A[l])
  ans-=2*min(B)
print(ans)

Measured memory_bytes: 14412
#include <stdio.h>
int main(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<=b && a<=c){
        printf("%d ",a);
    	if(b<=c)
        	printf("%d %d\n",b,c);
    	else
        	printf("%d %d\n",c,b);
    }else if(c<=b){
        printf("%d ",c);
    	if(a<=b)
        	printf("%d %d\n",a,b);
    	else
        	printf("%d %d\n",b,a);
    }else if(a<=c)
	printf("%d %d %d\n",b,a,c);
    else
	printf("%d %d %d\n",b,c,a);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
using namespace std;

int main(){
    string s;
    int K;
    cin >> s >> K;
    int t = s.size();
    priority_queue<string, vector<string>, greater<string>> pq;
    set<string> spq;
    for (int i = 0; i < t; i++){
        for (int j = 1; (j <= t - i && j <= 5); j++){
            string l = s.substr(i, j);
            if (!spq.count(l)){
                pq.push(l);
                spq.insert(l);
                
                if (pq.size() > 6){
                    vector<string> a(5);
                    for (int i = 0; i < 5; i++){
                        a.at(i) = pq.top();
                        pq.pop();
                    }
                    pq.pop();
                    for (int i = 0; i < 5; i++){
                        pq.push(a.at(i));
                    }
                }
                 
            }
        }
    }
    /*
    int h = pq.size();
    for (int i = 0; i < h; i++){
        string z = pq.top();
        pq.pop();
        cout << z << endl;
    }
     */
    for (int i = 0; i < K - 1; i++){
        pq.pop();
    }
    string z = pq.top();
    cout << z << endl;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int b[200010],w[200010];
int main(void){
    long long ans = 0;
    string s;
    cin >> s;
    if(s[0] == 'B') b[0] = 1;
    if(s[0] == 'W') b[0] = 0;
    for(int i = 1;i < s.length();i++){
        if(s[i] == 'B'){
            b[i] = (b[i-1]+1);
        }else{
            b[i] = b[i-1];
        }
    }
    for(int i = 0;i < s.length();i++){
        if(s[i] == 'W'){
            ans += b[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1412
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

ll two[100100], thr[100100];
const ll mod = 1e9+7;


ll fact[100100], finv[100100];

ll ncksum[100100];

ll nCk(ll n, ll k){
    if(n < k) return 0;
    return fact[n] * (finv[k]*finv[n-k]%mod) %mod;
}

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


ll inv(ll x){
    return modpow(x, mod-2);
}

void prepare(){
    ll tmp = 1;
    REP(i, 100100){
        two[i] = tmp;
        tmp *= 2; tmp = (tmp%mod);
    }
    tmp = 1;
    REP(i, 100100){
        thr[i] = tmp;
        tmp *= 3; tmp = (tmp%mod);
    }
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s; cin >> s;
    prepare();
    ll ans = 0; ll one_cnt = 0; ll dig = s.size();
    REP(i, s.size()){
        if(s[i] == '1'){
            ans = (ans + (two[one_cnt] * thr[dig-1-i])%mod) % mod;
            one_cnt++;
        }
    }
    ans = (ans + two[one_cnt])%mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2000
//#include <bits/stdc++.h>
 
#include <iostream>
#include <algorithm>
 
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <cstring>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>
 
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>
 
 
using namespace std;
#define int long long
 
typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;
 
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
 
const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll INFLL = 1LL<<62;
const double EPS = 1e-12;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;
 
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) (0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false

int k, a, b;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	cin >> k >> a >> b;
	if (a >= k) {
		cout << 1 << endl;
		return 0;
	}
	if (a <= b) {
		cout << -1 << endl;
		return 0;
	}
	int diff = a - b;
	if ((k - a) % diff == 0) cout << (k - a) / diff * 2  + 1 << endl;
	else cout << ((k - a) / diff + 1) * 2 + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

int main(int argc, char *argv[]) {
	string S;
	cin >> S;

	long ans = 0;	
	for (int i = 0; i < (1 << (S.size() - 1)); i++) {
		long n = 0;
		for (int j = 0; j < S.size(); j++) {
			n *= 10;
			n += S[j] - '0';
			if (i & (1 << j)) {
				ans += n;
				n = 0;
			}
		}
		ans += n;
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int h,w;
    cin >> h >> w;
    vector<vector<char>> s(h,vector<char>(w));
    rep(i,h) {
        rep(j,w) {
        cin >> s.at(i).at(j);
        }
    }
    const vector<int> dx = {1,0,-1,0,1,-1,-1,1};
    const vector<int> dy = {0,1,0,-1,1,1,-1,-1};
    rep(i,h) {
        rep(j,w) {
            if (s.at(i).at(j) == '#') continue;
            int num = 0;
            rep(d,8) {
                int ni = i + dy.at(d);
                int nj = j + dx.at(d);
                if ( ni < 0 or ni >= h) continue;
                if ( nj < 0 or nj >= w) continue;
                if (s.at(ni).at(nj) == '#') num++;
            }
            s.at(i).at(j) = char(num + '0');
        }
    }
    rep(i,h) {
        rep(j,w) {
                cout << s.at(i).at(j);
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;
int main(void) {
  lld n, m, q, a[50], b[50], c[50], d[50], x = 0, e[10] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, k, s;
  cin >> n >> m >> q;

  for (lld i = 0; i < q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  while (1) {
    s = 0;
    for (lld i = 0; i < q; i++) {
      if (e[b[i] - 1] - e[a[i] - 1] == c[i]) {
        s += d[i];
      }
    }
    if (s > x) {
      x = s;
    }
    e[n - 1]++;
    for (k = n - 1; k >= 0; k--) {
      if (e[k] > m) {
        if (k == 0) {
          goto exit;
        }

        e[k - 1]++;
        e[k] = 1;
      } else {
        break;
      }
    }
    for (lld i = k + 1; i < n; i++) {
      if (e[i] < e[i - 1]) {
        e[i] = e[i - 1];
      }
    }
  }
  exit:
  cout << x << "\n";
}

Measured memory_bytes: 3620
#include <stdio.h>
int main()
{ int n, count;
unsigned long long int factorial=1;
while(scanf("%d",&n)==1)
{
     if ( n== 0)
     printf("1\n");
     else
     {
         for(count=1;count<=n;++count)
     { factorial=factorial*count;}
      printf("%llu\n",factorial);
      }
      }
      return 0;
       }

Measured memory_bytes: 1024
import copy
def bubblesort(c, n):
    for i in range(n):
        for j in range(n-1, i, -1):
            if c[j][1] < c[j-1][1]:
                c[j], c[j-1] = c[j-1], c[j]
                
def selectionsort(c, n):
    for i in range(n):
        minj = i
        for j in range(i, n):
            if c[j][1] < c[minj][1]:
                minj = j
        if i != minj:
            c[i], c[minj] = c[minj], c[i]
            
            
n = int(input())
a = input().split()
b = copy.copy(a)

bubblesort(a,n)
for i in range(n-1):
    print(a[i], end=' ')
print(a[-1])
print('Stable')
selectionsort(b,n)
for i in range(n-1):
    print(b[i], end=' ')
print(b[-1])
if a == b:
    print("Stable")
else:
    print("Not stable")


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

using namespace std;
using ll = long long;

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

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int k, s;
    cin >> k >> s;

    int cnt = 0;
    
    for (int x = 0; x < k + 1; x++) {
        for (int y = 0; y < k + 1; y++) {
            int z = s - x - y;
            if (0 <= z && z <= k) cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
const int N = (int)5e5 + 5;
typedef struct node{
    int s, e, val, pos;
    bool operator<(const node& n) const{
        if(e != n.e) return e < n.e;
        return val > n.val;
    }
    node(){};
    node(int ss, int ee, int v, int p){
        s = ss, e = ee, val = v, pos = p;
    }
}node;
 
int occs[N], tree[N], n, ans[N];
 
void update(int x, int val){
    while(x <= n){
        tree[x] += val;
        x += x & -x;
    }
}
 
int query(int x){
    int ret = 0;
    while(x > 0){
        ret += tree[x];
        x -= x & -x;
    }
    return ret;
}
 
int main()
{
    int q, s, e;
    vector<node> v;
    scanf("%d", &n);
    scanf("%d", &q);
    for(int i = 1; i <= n; i++){
        scanf("%d", &s);
        v.push_back(node(i, i, s, -1));
    }
    
    for(int i = 0; i < q; i++){
        scanf("%d %d", &s, &e);
        v.push_back(node(s, e, 0, i));
    }
 
    sort(v.begin(), v.end());
 
    for(int i = 0;i < v.size(); i++){
        if(v[i].val == 0){
            ans[v[i].pos] = query(v[i].e) - query(v[i].s - 1);
        }else{
            if(occs[v[i].val] != 0) update(occs[v[i].val], -1);
            update(v[i].s, 1);
            occs[v[i].val] = v[i].s;
        }
    }
 
    for(int i = 0; i < q; i++){
        printf("%d\n", ans[i]);
    }
 
    return 0;
}

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

vector<int> z_algorithm(const string &s) {
  int n = s.size();
  vector<int> res(n);
  for (int i = 1, j = 0; i < n; i++) {
    if (i + res.at(i - j) < j + res.at(j)) {
      res.at(i) = res.at(i - j);
    } else {
      int k = max(0, j + res.at(j) - i);
      while (i + k < n && s.at(k) == s.at(i + k)) k++;
      res.at(i) = k;
      j = i;
    }
  }
  res.at(0) = n;
  return res;
}

int main() {
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    string tmp = S.substr(i);
    auto lcp = z_algorithm(tmp);
    for (int j = 0; j < (int) tmp.size(); j++) {
      int l = min(lcp.at(j), j);
      ans = max(ans, l);
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <vector> 
#include <algorithm>


using namespace std;
int main()
{
	int N; 
	cin >> N;
	vector<long long> a(N);
	long long NC=0,x=0;
	for (int i = 0;i < N;i++) {
		cin >> a[i];
		NC += a[i];
	}
	long long ans = 2000000000;
		for (int j = 0;j < N;j++) {
			x += a[j];
			if (j + 1 < N)ans = min(ans, abs(NC - 2 * x));
		}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifdef LOCAL
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define debug(x) ;
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

ll dp[3010][3010][2];

int main(){
  int n, a[SIZE];

  scanf("%d", &n);

  for(int i=0;i<n;i++){
    for(int j=0;j<=n;j++){
      dp[i][j][0] = dp[i][j][1] = -LLINF;
    }
  }

  for(int i=0;i<n;i++){
    scanf("%d", a+i);
    dp[i][i][n%2] = 0;
  }

  for(int i=1;i<=n;i++){
    for(int j=0;j+i<=n;j++){
      for(int k=0;k<2;k++){
        dp[j][i+j][k] = max(dp[j][i+j][k], -dp[j+1][i+j][!k] + a[j]);
        dp[j][i+j][k] = max(dp[j][i+j][k], -dp[j][i+j-1][!k] + a[i+j-1]);
      }
    }
  }

  cout << dp[0][n][0] << endl;

  return 0;
}


Measured memory_bytes: 141568