akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int h,w,k;
string s[15];
int imos[15][1010];

void solve(){
    cin >> h >> w >> k;
    rep(i,h){
        cin >> s[i];
    }
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='1') imos[i+1][j+1]+=1;
        }
    }
    rep(i,h+1){
        rep(j,w){
            imos[i][j+1]+=imos[i][j];
        }
    }
    rep(i,h){
        rep(j,w+1){
            imos[i+1][j]+=imos[i][j];
        }
    }
    // rep(i,h+1){
    //     rep(j,w+1){
    //         cout << imos[i][j] << " ";
    //     }
    //     cout << "" << endl;
    // }
    int m=(1 << (h-1));
    int ans_=mod;
    rep(S,m){
        //cout << S << endl;
        vector<int> li(1,0);
        rep(i,h-1){
            if(S&(1 << i)){
                li.push_back(i+1);
            }
        }
        li.push_back(h);
        int s=li.size();
        int ans=s-2,b=0;
        rep(i,w+1){
            //cout << i << " " << b << endl;
            rep(j,s-1){
                //cout << imos[li[j+1]][i]-imos[li[j+1]][b]-imos[li[j]][i]+imos[li[j]][b] << endl;
                if(imos[li[j+1]][i]-imos[li[j+1]][b]-imos[li[j]][i]+imos[li[j]][b]>k){
                    b=i-1;
                    ans+=1;
                    rep(j_,s-1){
                        if(imos[li[j_+1]][i]-imos[li[j_+1]][b]-imos[li[j_]][i]+imos[li[j_]][b]>k){
                            ans=mod;
                            break;
                        }
                    }
                    break;
                }
            }
        }
        //cout << ans << endl;
        ans_=min(ans_,ans);
    }
    cout << ans_ << endl;
}

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

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

int main () {
    int N,m=0,X,count=1;
    cin >> N >> X;
    vector<int> L(N);
    for(int i=0;i<N;i++){
        cin >> L[i];
        m+=L[i];
        if(X>=m) count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

			int intx = scanner.nextInt();

			if (0 <= intx && intx < 86400) {
				int inth = intx / 3600;
				int intm = intx % 3600 / 60;
				int ints = intx % 3600 % 60;

				System.out.println(inth + ":" + intm + ":" + ints);
			} else {
				System.out.println("正しい数値を入力してください。");
			}
	}
}



Measured memory_bytes: 26312
#include <stdio.h>

void trace(int A[], int N) {
    for ( int i = 0; i < N; i++ ) {
        if ( i > 0)
            printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void insertionSort(int A[], int N) {
    int v;
    int j;

    for ( int i = 1; i < N; i ++ ) {
        v = A[i];
        j = i - 1;
        while ( j >= 0 && A[j] >  v) {
            A[j+1] = A[j];
            j --;
        }
        A[j+1] = v;
        trace(A, N);
    }

}

int main()
{
    int N, i, j;
    int A[100];

    scanf("%d", &N);
    for ( int i = 0; i < N; i++ ) {
        scanf("%d", &A[i]);
    }

    trace(A, N);
    insertionSort(A, N);

    return 0;
}




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

int main(){
  long long n,m;
  cin >> n >> m;
  if(n == 1 || m == 1){
    if(n == 1 && m == 1){
      cout << 1 << endl;
    }else{
      cout << max(m,n) - 2 << endl;
    }
  }else{
    cout << (n*m)-((n*m)-(n-2)*(m-2)) << endl;
  }

  return 0;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;


int n;
ull c;
// 返り値は
// {"ひたすら進んだ場合のmaxcalの寿司の位置", "ひたすら進んだ場合の最大摂取カロリー", "引き返す場合のmaxcalの寿司の位置", "引き返す場合の最大摂取カロリー"}
std::vector<std::vector<double>> solve(std::vector<std::vector<ull>> x){
	double nowcal = 0;
	double maxcal = 0;
	std::vector<std::vector<double>> ret(x.size(),std::vector<double> (2,0));
	for (size_t i = 1; i < x.size(); i++) {
		nowcal = nowcal + x[i][1] - (x[i][0] - x[i-1][0]);
		ret[i][0] = nowcal;
		maxcal = max(maxcal, nowcal - x[i][0]);
		ret[i][1] = maxcal;
	}
	return ret;
}


int main(int argc, char const *argv[]) {
	std::cin >> n >> c;
	// {"時計回りの距離", "反時計回りの距離", "カロリー"}
	std::vector<std::vector<ull>> x(n+1 ,std::vector<ull> (2,0));
	std::vector<std::vector<ull>> y(n+1 ,std::vector<ull> (2,0));
	x[0][0] = x[0][1] = 0;
	y[0][0] = y[0][1] = 0;
	for (size_t i = 0; i < n; i++) {
		std::cin >> x[i+1][0] >> x[i+1][1];
		y[i+1][0] = c - x[i+1][0];
		y[i+1][1] = x[i+1][1];
	}

	// x,yを小さい順にソート
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	// (反)時計回りに回った時にどこまで食うのが最もコスパが良いのか
	// (反)時計回りに回った時にどこまで食って戻るのが最もコスパが良いのかを探す
	std::vector<std::vector<double>> xx = solve(x);
	std::vector<std::vector<double>> yy = solve(y);

	double ans = 0;
	for (size_t i = 0; i < xx.size(); i++) {
		ans = max(ans, max(xx[i][0] + yy[n-i][1], yy[i][0] + xx[n-i][1]));
	}

	std::cout << (ull)ans << '\n';
	return 0;
}


Measured memory_bytes: 27608
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n = int(input())
    s = input()
    cnt = s.count('E')
    m = cnt
    for i in s:
        if i == 'E':
            cnt -= 1
        else:
            cnt += 1
        m = min(m, cnt)
    print(m)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include<stdio.h>
int main(void) {
	int x, y, z;

	scanf("%d", &x);
	scanf("%d", &y);
	scanf("%d", &z);

	int i;
	int people = 0;
	for (i = 0; x >= y; i++) {
		x = x - z;
		if (x > y&&x-y>=z) {
			x = x - y;
			people++;
		}
		else {
			break;
		}
	}

	printf("%d\n", people);
	return 0;
}

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

const ll mod = 1e9 + 7;
const ll b = 1069;

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

// s0中のs1を探す
int search_hash(string s0, string s1, int x) {
    ll l0 = s0.size(), l1 = s1.size();
    ll h0 = 0, h1 = 0, bp = mpow(b, s1.size());

    if (l0 < l1) return -1;

    for (int i = 0; i < l1; i++) {
        h0 = (h0 * b + s0[i]) % mod;
        h1 = (h1 * b + s1[i]) % mod;
    }
    for (int i = 0; i + l1 <= l0; i++) {
        if (h0 == h1 && i >= x + s1.size() && s0[i]==s1[0]) return i;
        if (i + l1 < s0.size()) h0 = (h0 * b + s0[i + l1] - s0[i] * bp % mod + mod) % mod;
    }
    return -1;
}

int n;

bool solve(int len, string s) {
    for (int i = 0; i + 2 * len <= s.size(); i++) {
        string s1 = s.substr(i, len);
        if (search_hash(s, s1, i) != -1) return true;
    }
    return false;
}

int binary_search(int ok, int ng, string s) {
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (solve(mid, s)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    return ok;
}

int main() {
    string s;
    cin >> n >> s;
    int ans = binary_search(-1, s.size(), s);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

int main() {
	int M, D;
	cin >> M >> D;
	int ans = 0;
	for (int i = 1; i <= M; ++i) {
		for (int j = 1; j <= D; ++j) {
			int k = j % 10;
			int l = j / 10;
			if (k >= 2 && l >= 2) {
				if (k * l == i) {
					++ans;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
const double eps = 1e-8;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto si : s) os << si << " "; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += (b % mod + mod)) %= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int x;
    cin >> x;
    cout << (x ^ 1) << endl;
}


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

#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1)
#define MAXS 100000
#define MOD 998244353
#define all(v) v.begin(),v.end()
#define pb push_back

using namespace std;
typedef long long ll;

int tc;


void solve(){

    ll n,m,a[200005],mx=0;
    cin>>n>>m;
    for(int i=0; i<m; i++){
        cin>>a[i];
    }
    sort(a,a+m);
    for(int i=0; i<m; i++){
        ll x;
        if(i==0){
            x=a[i]+(n-a[m-1]);
        }
        else x=abs(a[i]-a[i-1]);
        mx=max(mx,x);
    }
    cout<<n-mx<<endl;
}

int main()
{

    _fastIO;


    //cin>>tc; while(tc--)
    solve();

    return 0;
}


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

int main() {
  int N,A,B;
  
  cin >> N;
  
  vector<int> vec(N);
  
  for(int i=0;i<N;i++){
   cin >> vec.at(i); 
  }
  
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  int X,Y;
  X=0;
  Y=0;
  
  for(int j=0;j<N;j++){
    if(j%2==0){
      X += vec.at(j);
    }
    if(j%2==1){
      Y += vec.at(j);
    }
  }
  cout << X - Y << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;

int main() {
    int n; cin >> n;
    int a[n+2];
    a[0] = 0;
    int total = abs(a[0]);
    for(int i = 1;i < n+1;i++){
        cin >> a[i];
        total += abs(a[i]-a[i-1]);
    }
    total += abs(a[n]);
    a[n+1] = 0;
    
    for(int i = 1;i < n+1;i++){
       cout << total -  abs(a[i]-a[i-1]) - abs(a[i+1]-a[i]) + abs(a[i+1]-a[i-1]) << endl;
    }
}



Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void solve()
{
	int n;
	cin>>n;
	ll sum=0;
	for(int i=1;i<=n;i++)
	{
		if(i%3 && i%5)
		sum+=i;
	}
	cout<<sum;
}
int main()
{
//	int t;cin>>t;
//	while(t--)
	solve();
}


Measured memory_bytes: 3592
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let m: i32 = read();
    let d: i32 = read();

    let mut ans = 0;
    for i in 1..m + 1 {
        for j in 1..d + 1 {
            if j % 10 >= 2 && j / 10 >= 2 && (j % 10) * (j / 10) == i {
                ans += 1;
            }
        }
    }

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
/**
	*    author:  accesss_denied
	**/
	#include <bits/stdc++.h>
	using namespace std;
	#define ll long long int
	#define ff first
	#define ss second
	#define pb push_back
	#define endl "\n"
	#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	ll mod=1e9+7;			
	ll inf=1e18;

	int main() {
				fast
				// #ifndef ONLINE_JUDGE
				// freopen("input.txt","r",stdin);
				// freopen("output.txt","w",stdout);
				// #endif

				ll t;
				t=1;
				while(t--)
				{
					ll n;
					cin>>n;
					ll a[n],b[n];
					for(ll i=0;i<n;i++)
					{
                        cin>>a[i]>>b[i];
                    }
                    ll flag=0;
					for(ll i=0;i<n-2;i++)
					{
                        if(a[i]==b[i] and a[i+1]==b[i+1] and a[i+2]==b[i+2])
                        flag=1;
                    }
                    if(flag)
                    cout<<"Yes";
                    else
                    cout<<"No";
					
				}
				return 0;
			}	




Measured memory_bytes: 3644
import java.util.Scanner;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		int N = s.length();
		System.out.println("" + s.charAt(0) + (N - 2) + s.charAt(N - 1));
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    string a,b;
    a = s.substr(0,s.length()/2);
    b = s.substr((s.length()+1)/2,s.length()/2);
    reverse(ALL(b));
    int answer = 0;
    REP(i,s.length()/2){
        if(a[i]!= b[i])answer++;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a,b,c,swap;
	scanf("%d %d %d",&a,&b,&c);
    if(a>b){
		swap=a;
		a=b;
		b=swap;
	}
	if(b>c){
		swap=b;
		b=c;
		c=swap;
	}
	if(a>b){
		swap=a;
		a=b;
		b=swap;
	}	
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596
import java.awt.Point;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.Stack;
import java.io.IOException;

class MyScanner {
    BufferedReader br;

    MyScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public int intLine() throws IOException {
        return Integer.parseInt(br.readLine());
    }

    public String line() throws IOException {
        return br.readLine();
    }

    public int[] intArray() throws IOException {
        String[] in = br.readLine().split(" ");
        int n = in.length;
        int[] res = new int[n];
        for(int i = 0; i < n; i++) {
            res[i] = Integer.parseInt(in[i]);
        }
        return res;
    }
}

class Pair implements Comparable<Pair> {
    long t;
    int i;

    Pair(long t, int i) {
        this.t = t;
        this.i = i;
    }

    public int compareTo(Pair p) {
        return t > p.t? 1 : -1;
    }
}

public class Main {
    public static void main(String[] args) throws IOException {
        MyScanner sc = new MyScanner();

        int[] in = sc.intArray();
        int n = in[0];
        int m = in[1];

        List<List<Integer>> job = new ArrayList<>();
        for(int i = 0; i < m; i++) {
            job.add(new ArrayList<>());
        }
        for(int i = 0; i < n; i++) {
            in = sc.intArray();
            int a = in[0];
            int b = in[1];
            if(m - a >= 0) job.get(m - a).add(b);
        }

        long ans = 0;
        PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
        for(int i = m - 1; i >= 0; i--) {
            for(int x : job.get(i)) {
                pq.add(x);
            }
            if(!pq.isEmpty()) ans += pq.poll();
        }
        
        System.out.println(ans);

        sc.br.close();
    }
}


Measured memory_bytes: 54520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
const int INF=1e9+5;
const int N=50+5;
const int mod=998244353;

int h,w;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>h>>w;
	vector<string> s(h);
	for(int i=0;i<h;++i) cin>>s[i];
	vector<vector<int>> dp(h,vector<int>(w,INF));
	if(s[0][0]=='#') dp[0][0]=1;
	else dp[0][0]=0;
	for(int i=0;i<h;++i){
		for(int j=0;j<w;++j){
			if(i>0){
				if(s[i][j]=='.'){
					dp[i][j]=min(dp[i][j],dp[i-1][j]);
				}
				else if(s[i-1][j]=='.'){
					dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
				}
				else{
					dp[i][j]=min(dp[i][j],dp[i-1][j]);
				}
			}
			if(j>0){
				if(s[i][j]=='.'){
					dp[i][j]=min(dp[i][j],dp[i][j-1]);
				}
				else if(s[i][j-1]=='.'){
					dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
				}
				else{
					dp[i][j]=min(dp[i][j],dp[i][j-1]);
				}
			}
		}
	}
	cout<<dp[h-1][w-1];				
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<algorithm>
using namespace std;
int g[21];
int t[21];
//pair<pair<int,int>,int>p[21];
//int conv[];
int bp[1<<20];
int main(){
	int a,b;
	for(int i=0;i<(1<<20);i++)bp[i]=__builtin_popcount(i);
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<a;i++)
			g[i]=0;
		for(int i=0;i<a;i++){
			int c;scanf("%d%d",t+i,&c);
			for(int j=0;j<c;j++){
				int d;scanf("%d",&d);
				g[i]+=1<<d;
			}
		}
	//	for(int i=0;i<a;i++)p[i]=make_pair(t[i],g[i]),;
	//	std::sort(p,p+a);
	//	for(int i=0;i<a;i++){
	//		t[i]=p[a-1-i].first;
	//		g[i]=p[a-1-i].second;
	//	}
		int sum=0;
		for(int i=0;i<a;i++)sum+=t[i];
		int ret=999999999;
		for(int i=0;i<(1<<a);i++){
			int q=bp[i];
			if(ret<=q)continue;
			int s=sum;
			bool ok=true;
			for(int j=0;j<a;j++){
				if(i&(1<<j)){
					if((i&g[j])!=g[j]){ok=false;break;}
				}else{
					s-=t[j];
					if(s<b){ok=false;break;}
				}
			}
			if(ok)ret=q;
		}
		printf("%d\n",ret);
	}
}

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

using namespace std;

using int64 = long long;

constexpr int64 P = 1000000007;

// Verified: ABC133E, ABC132D, ABC130E
struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 x) : x(x) {}
  FiniteField() : x(0) {}
  int64 Value() { return x; }
  inline FiniteField operator+(FiniteField o) {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

vector<FiniteField> MakeFactorialTable(int n) {
  vector<FiniteField> values(n + 1);
  values[0] = 1;
  for (int i = 1; i <= n; i++) {
    values[i] = values[i - 1] * i;
  }
  return values;
}

FiniteField Power(FiniteField x, int p) {
  if (p < 0) return FiniteField(1) / Power(x, -p);
  FiniteField value = 1;
  while (p) {
    if (p % 2) value *= x;
    x *= x;
    p /= 2;
  }
  return value;
}

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

  int n, k;
  cin >> n >> k;
  if (k > n) {
    cout << 0 << endl;
    return 0;
  }

  auto factorials = MakeFactorialTable(k + 1);
  FiniteField value = 0;
  for (int i = 0; i <= k; i++) {
    value += Power(i, n) * Power(P - 1, k - i)
        * factorials[k] / factorials[i] / factorials[k - i];
  }
  cout << value.Value() << endl;
}



Measured memory_bytes: 3216
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define debug(x) cerr<<#x<<'='<<x<<endl
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=2e5+10;

    void main()
    {
        int n=qread();long double f1=qread(),x=qread(),ans=0;;
        while(n)
        {
            ans+=f1+(n+n-1)/2.0*x;
            f1=((n+n+2)*f1+x*5)/(n+n);
            x=(n+2)*x/n;n--;
        }printf("%.10Lf",ans);
    }
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


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

int main() {
  long long int N,K;
  cin >> N >> K;

  vector<long long int> H(N);

  for(int i=0;i<N;i++){
    cin >> H[i];
  }

  sort(H.begin(),H.end());
  reverse(H.begin(),H.end());

  if(N<=K){
    for(int i=0;i<N;i++){
    H[i] =0;}
  }

  else {for(int i=0;i<K;i++){
    H[i] =0;
  }}

  

  long long int ans =0;

  for(int i=0;i<N;i++){
    ans+=H[i];
  }
  cout << ans << endl;

}

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

using namespace std;

const long long mod = 1e9 + 7;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  
  int r = 0;
  int g = 0;
  int b = 0;
  long long count = 1;
  for(int i = 0; i < N; i++){
    int t = 0;
    if(r == A[i]) t++;
    if(g == A[i]) t++;
    if(b == A[i]) t++;
    if(r == A[i]) r++;
    else if(g == A[i]) g++;
    else b++;
    count *= (long long)t;
    count %= mod;
  }
  
  cout << count << endl;
}

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

int main() {
	// your code goes 
    int n,m,a,b; cin >> n >> m;
    vector<int> arr[n];
    vector<int> degree(n,0);
    while(m-->0){
        cin >>  a >> b;
        a--;b--;
        arr[a].push_back(b);degree[b]++;
    }
    vector<int> dis(n,0);
    
    queue<int> q;
    for(int e=0;e<n;e++){
        if(degree[e]==0)q.push(e);
    }
    while(!q.empty()){
        int a = q.front();
        q.pop();
        for(int b:arr[a]){
        dis[b]=max(dis[b],dis[a]+1);
        degree[b]--;
        if(degree[b]==0)q.push(b);
            }
    }
    int maxi=0;
    for(int e=0;e<n;e++){
        maxi=max(maxi,dis[e]);
    }
    cout << maxi;
	return 0;
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll 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;
}
vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int main(){

    int n, k;
    cin >> n >> k;

    vector<int> v;
    int tmp;
    while((n/k != 0)){
        tmp = n % k;
        v.push_back(tmp);
        n /= k;
    }
    v.push_back(n);
    cout << v.size()  << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

int res;

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

    string S,T;
    cin >> S>>T;
    res = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if(S[i]!=T[i]){
            res++;
        }
    }
    cout << res << endl;
return 0;
}

Measured memory_bytes: 3780
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <queue>
using namespace std;
int main(void){
	string s;
	int i,j;
	cin>>s;
	for(i=0;i<s.size();i++){
		for(j=0;j<s.size();j++){
			if(s[i]==s[j]&&i!=j){
				cout<<"no"<<endl;
				return 0;
			}
		}
	}
	cout<<"yes"<<endl;
	return 0;
}


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


int main () {
  const ll inf=1LL<<60;
  ll dp[100010];
  for(int i=0;i<10010;++i) dp[i]=inf;
  dp[0]=0;
  int N,cost=0;
  cin>>N;
  int h[N];
  rep(i,N) cin>>h[i];
  dp[1]=abs(h[0]-h[1]);
  for(int i=2;i<N;i++){
    dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i-1]-h[i]));
  }
  cout<<dp[N-1]<<endl;
  
}

Measured memory_bytes: 1408
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
//#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
                        
using namespace std;
                        
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
                        
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define ghost signed
#define left left228
#define right right228
#define complex complex228
#define count count228
#define sin sin228
#define list list228

const int N = 555;

int color[N][N];

void f(vector<int> v, int C = 1) {
	if (v.empty()) return;
	if ((int)v.size() == 1) return;
	vector<int> L, R;
	int m = ((int)v.size() - 1) / 2;
	for (int i = 0; i <= m; ++i) L.push_back(v[i]);
	for (int i = m + 1; i < (int)v.size(); ++i) R.push_back(v[i]);
	for (int a : L) {
		for (int b : R) {
			color[min(a, b)][max(a, b)] = C;
		}
	}
	f(L, C + 1);
	f(R, C + 1);
}

ghost main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int n;
	cin >> n;
	vector<int> v;
	for (int i = 1; i <= n; ++i) v.push_back(i);
	f(v);
	for (int i = 1; i < n; ++i) {
		for (int j = i + 1; j <= n; ++j) cout << color[i][j] << ' ';
		cout << '\n';
	}
	return 0;
} // kek ;
// Ого! Кажетсья это $#@!



















Measured memory_bytes: 2688
N=int(input())
a=[]
for i in range(N):
    a.append(list(map(int,input().split())))

p= a[0][0] - a[0][1] - a[0][2] 

if p % 2 != 0 or p < 0:
    print('No')
    exit()

for i in range(1,N):
    route = abs(a[i][1]-a[i-1][1])+abs(a[i][2]-a[i-1][2])
    time = a[i][0] - a[i-1][0]
    b = time - route
    if  b % 2 != 0 or b < 0:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 27300
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd 
/****************************/
using namespace std;
int h,w;
char ch[110][110];
int dp[110][110];
int main()
{
	ios::sync_with_stdio(0);
	cin>>h>>w;
	rep(i,h)
	{
		rep(j,w)
		{
			cin>>ch[i][j];
		}
	}
	rep(i,110)
	{
		rep(j,110)
		{
			dp[i][j]=1e9;
		}
	}
	if(ch[0][0]=='#')
	{
		dp[0][0]=1;
	}
	else
	{
		dp[0][0]=0;
	}
	rep(i,h)
	{
		rep(j,w)
		{
			if(ch[i][j]=='#')
			{
				if(i>0) 
				{
					dp[i][j]=min(dp[i][j],dp[i-1][j]+(ch[i-1][j]=='.'));
				}
				if(j>0) 
				{
					dp[i][j]=min(dp[i][j],dp[i][j-1]+(ch[i][j-1]=='.'));
				}
			}
			else
			{
				if(i>0) 
				{
					dp[i][j]=min(dp[i][j],dp[i-1][j]);
				}
				if(j>0) 
				{
					dp[i][j]=min(dp[i][j],dp[i][j-1]);
				}
			}
		}
	}
	cout<<dp[h-1][w-1];
	return 0;
}

Measured memory_bytes: 384
import sys

input = sys.stdin.readline

A, B, M = map(int, input().strip().split())

A = list(map(int, input().strip().split()))
B = list(map(int, input().strip().split()))
ans = min(A) + min(B)
query = [list(map(int, input().strip().split())) for i in range(M)]
for i, q in enumerate(query):
    x, y, m = q
    ans = min(A[x-1]+B[y-1]-m, ans)
print(ans)


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)

typedef long long lint;

template< typename DATA >
class SegmentTree {
private:
	int size__;
	vector< DATA > data;
	
	inline int left_t(int k) {
		return (k << 1) + 1;
	}
	
	inline int right_t(int k) {
		return (k << 1) + 2;
	}
	
	inline int center(int l, int r) {
		return (l + r) >> 1;
	}
	
public:
	SegmentTree(int n, DATA ini) {
		for (size__ = 1; size__ < n; size__ <<= 1);
		data.assign(2 * size__ - 1, ini);
	}
	
	DATA calc(DATA d1, DATA d2) {
		return max(d1, d2);
	}
	
	void update(int k, DATA a) {
		k += size__ - 1;
		data[k] = a;
		
		while (k > 0) {
			k = (k - 1) >> 1;
			data[k] = calc(data[left_t(k)], data[right_t(k)]);
		}
	}
	
	DATA query(int a, int b) {
		return query(a, b, 0, 0, size__);
	}
	
	DATA query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return 0;
		if (a <= l && r <= b) return data[k];
		return calc(query(a, b, left_t(k), l, center(l, r)),
					query(a, b, right_t(k), center(l, r), r));
	}
	
	int size() {
		return size__;
	}
};

lint n, x[100010];

signed main() {
	cin >> n;
	for_(i,0,n) cin >> x[i];
	
	SegmentTree< lint > st(n + 10, 0);
	for_(i,0,n) st.update(x[i], x[i] + st.query(0, x[i] + 1));
	cout << n * (n + 1) / 2 - st.query(0, n + 1) << endl;
}

Measured memory_bytes: 3908
#include <stdio.h>
int main()
{
	int x;
	int a[9];
	for(int i=0;i<9;i++)
	{
		scanf("%d",&a[i]);
	}
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&x);
		for(int t=0;t<9;t++)
	    {
		if(a[t]==x)
		{
			a[t]=-1;
		}
	    }
	}
	if((a[0]==a[1]&&a[2]==a[1])||(a[3]==a[4]&&a[4]==a[5])||(a[6]==a[7]&&a[7]==a[8]))printf("Yes");
	else if((a[0]==a[3]&&a[3]==a[6])||(a[1]==a[4]&&a[4]==a[7])||(a[2]==a[5]&&a[5]==a[8]))printf("Yes");
	else if((a[0]==a[4]&&a[4]==a[8])||(a[2]==a[4]&&a[4]==a[6]))printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z,k,d;
    cin>>x>>k>>d;
    x = abs(x);
    if(k>=x/d){
        y = x%d;
        z = (x-y)/d;
        k-=z;
        if(k%2==0){
            cout<<abs(y);
        }
        else{
            cout<<abs(y-d);
        }
    }
    else{
        cout<<x-k*d;
    }


    return 0;
}

Measured memory_bytes: 3620
#include <cstdio>

int main() {
    int x, y;
    for(int i = 1;; i++) {
        scanf("%d%d", &x, &y);
        if (x == 0 && y == 0) {
            break;
        }
        if(x < y) {
            printf("%d %d\n", x, y);
        }
        else {
            printf("%d %d\n", y, x);
        }
    }
}


Measured memory_bytes: 2572
#include <iostream>


using namespace std;


int main()
{
	int A, B, C;	// A:ログインでもらえるコイン数 B:月曜から日曜まで連続ログインでもらえるコイン数 C:ほしいコインの枚数

	cin >> A >> B >> C;

	int day = 0;
	int sum_coin = 0;
	for(day = 1; day <= C; day++){
		sum_coin += A;

		if(!(day % 7))
			sum_coin += B;

		if(C <= sum_coin)
			break;
	}

	cout << day << endl;

	return 0;
}


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

int main(){
  string s;
  cin >> s;
  if(s.length()!=19)
    return -1;
  if(s[5]!=','||s[13]!=',')
    return -1;

  s[5]=' ';
  s[13]=' ';

  cout << s << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2010;
vector <int> adj[MAXN];
bitset <MAXN> b;
int k, limit;
int dfs(int v, int l) {
    if (l > limit || b[v])
        return 0;
    b[v] = true;
    int res = 1;
    for (auto i : adj[v])
        res += dfs(i, l + 1);
    b[v] = false;
    return res;
}
int main () {
    int n, k, a1, a2;
    cin >> n >> k;
    for (int i = 1; i < n; ++i) {
        cin >> a1 >> a2;
        adj[a1].push_back(a2);
        adj[a2].push_back(a1);
    }
    if (k % 2 == 0) {
        limit = k / 2;
        int res = 0;
        for (int i = 1; i <= n; ++i)
            res = max(res, dfs(i, 0));
        return cout << n - res, 0;
    }
    limit = k / 2;
    int res = 0;
    for (int v = 1; v <= n; ++v)
        for (auto i : adj[v]) {
            b[i] = true;
            int cnt = dfs(v, 0);
            b[i] = false;
            b[v] = true;
            cnt += dfs(i, 0);
            b[v] = false;
            res = max(res, cnt);
        }
    cout << n - res;
    return 0;
}

Measured memory_bytes: 512
import itertools
import math

def main():
    lists = []
    i=0
    N= int(input())
    while i < N:
        a = [int(j) for j in input().split()]
        lists.append(a)
        i+=1
    ans=0
    length=0
    for line in itertools.permutations(lists):
        a = []
        b = []
        for data in line:
            if len(b) ==0:
                b = data
                continue
            else:
                a = b
                b = data
                length = math.sqrt(((b[0]-a[0])**2)+((b[1]-a[1])**2))
                ans+=length
    print(ans/math.factorial(N))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (cons (subseq str 0 pos)
              (split x (subseq str (+ pos size))))
        (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defmacro aif (expr then else)
  `(let ((it ,expr))
     (if it ,then ,else)))

(defmacro awhen (expr &rest then)
  `(aif ,expr (progn ,@then) nil))

(defun comulative (function list &key base)
  (if base
      (comulative function (cons base list))
      (do ((lst (cdr list) (cdr lst))
           (acc (list (car list))))
          ((null lst) (reverse acc))
        (push (funcall function (car acc) (car lst)) acc))))

(defun binary-search (function left right
                      &optional
                        (eps 1)
                        (average-function (lambda (x y) (ash (+ x y) -1))))
  (if (<= (abs (- left right)) eps)
      right
      (let ((mid (funcall average-function left right)))
        (if (funcall function mid)
            (binary-search function left mid eps average-function)
            (binary-search function mid right eps average-function)))))

(defun arithmetic-mean (&rest body)
  (/ (apply #'+ body) (length body)))

(defvar +MOD+ (+ (expt 10 9) 7))

(defun mapa-b (fn a b &optional (step 1))
  (do ((i a (+ i step))
       (result nil))
      ((> i b) (nreverse result))
    (push (funcall fn i) result)))

(defun map0-n (fn n)
  (mapa-b fn 0 n))

(defun map1-n (fn n)
  (mapa-b fn 1 n))

(defun read-string (&optional (stream *standard-input*))
  (labels ((is-empty (x)
             (or (char= x #\space) (char= x #\newline))))
    (loop for char = (read-char stream)
          with result
          when (is-empty char)
            do (return (concatenate 'string (nreverse result)))
          do (push char result))))


(defun main (a b ab x y)
  (labels ((cul-cost (ab-time)
             (+ (* ab-time ab)
                (* (max 0 (- x (ash ab-time -1))) a)
                (* (max 0 (- y (ash ab-time -1))) b))))
    (reduce #'min (map0-n #'cul-cost (* (max x y) 2)))))


(let ((a (read))
      (b (read))
      (ab (read))
      (x (read))
      (y (read)))
  (princ (main a b ab x y)))


Measured memory_bytes: 23736
#include<queue>
#include<iostream>
#include<algorithm>
using namespace std;
struct puzzle{
	int cube[31];
	int count;
};
int check(int p[]){
	int flag = 0;
	int c[31] = {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 6, 6, 6, 5, 5, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3 };
	for (int i = 1; i <= 30; i++){
		if (p[i] != c[i]) flag = 1;
	}
	if (flag == 1) return 0;
	else return 1;
}
int main(){
	int N, puzzl;
	queue<puzzle> q;
	cin >> N;
	for (int i = 0; i < N; i++){
		puzzle k;
		for (int i = 1; i <= 30; i++){
			cin >> puzzl;
			k.cube[i] = puzzl;
		}
		k.count = 0;
		q.push(k);
		if (check(k.cube)) {
			cout << k.count << endl;
		}
		else {
			while (!q.empty()){
				puzzle temp;
				puzzle t;
				t = q.front();
				q.pop();
				temp = t; // ????????¢
				swap(temp.cube[1], temp.cube[28]); swap(temp.cube[2], temp.cube[29]);
				swap(temp.cube[3], temp.cube[30]); swap(temp.cube[16], temp.cube[15]);
				swap(temp.cube[21], temp.cube[19]); temp.count += 1;
				if (check(temp.cube)) {
					cout << temp.count << endl;
					break;
				}
				q.push(temp);
				temp = t; //???????????¢
				swap(temp.cube[7], temp.cube[22]); swap(temp.cube[8], temp.cube[23]);
				swap(temp.cube[9], temp.cube[24]); swap(temp.cube[18], temp.cube[13]);
				swap(temp.cube[10], temp.cube[12]); temp.count += 1;
				if (check(temp.cube)) {
					cout << temp.count << endl;
					break;
				}
				q.push(temp);
				temp = t; // ????????¢
				swap(temp.cube[1], temp.cube[24]); swap(temp.cube[4], temp.cube[27]);
				swap(temp.cube[7], temp.cube[30]); swap(temp.cube[21], temp.cube[10]);
				swap(temp.cube[16], temp.cube[18]); temp.count += 1;
				if (check(temp.cube)) {
					cout << temp.count << endl;
					break;
				}
				q.push(temp);
				temp = t;
				swap(temp.cube[3], temp.cube[22]); swap(temp.cube[6], temp.cube[25]);
				swap(temp.cube[9], temp.cube[28]); swap(temp.cube[19], temp.cube[12]);
				swap(temp.cube[15], temp.cube[13]); temp.count += 1;
				if (check(temp.cube)) {
					cout << temp.count << endl;
					break;
				}
				q.push(temp);
			}
		}
		while (!q.empty()) q.pop();
	}
	return 0;
}

Measured memory_bytes: 3836
#pragma GCC optimize ("-O3")
    #include <bits/stdc++.h>  
     
    using namespace std;
     
    typedef long long ll;
    typedef long double ld;
    typedef pair<int,int> p32;
    typedef pair<ll,ll> p64;
    typedef pair<double,double> pdd;
    typedef vector<ll> v64;
    typedef vector<int> v32;
    typedef vector<vector<int> > vv32;
    typedef vector<vector<ll> > vv64;
    typedef vector<vector<p64> > vvp64;
    typedef vector<p64> vp64;
    typedef vector<p32> vp32;
    ll MOD = 998244353;
    #define forn(i,e) for(ll i = 0; i < e; i++)
    #define forsn(i,s,e) for(int i = s; i < e; i++)
    #define rforn(i,s) for(ll i = s; i >= 0; i--)
    #define rforsn(i,s,e) for(ll i = s; i >= e; i--)
    #define ln "\n"
    #define dbg(x) cout<<#x<<" = "<<x<<ln
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define INF 1e18
    #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
    #define all(x) (x).begin(), (x).end()
    #define sz(x) ((ll)(x).size())
     
    ll mpow(ll a, ll b){
        if(b >= (MOD-1)) b %= (MOD-1);
        if(b==0) return 1;
        ll t1 = mpow(a,b/2);
        t1 *= t1;
        t1 %= MOD;
        if(b%2) t1 *= a;
        t1 %= MOD;
        return t1;
    }
     
    ll mpow(ll a, ll b, ll p){
        if(b==0) return 1;
        ll t1 = mpow(a,b/2,p);   t1 *= t1;
        t1 %= p;
        if(b%2) t1 *= a;
        t1 %= p;
        return t1;
    }
    ll modinverse(ll a, ll m){
        ll m0 = m; 
        ll y = 0, x = 1; 
        if (m == 1) return 0; 
        while (a > 1){
            ll q = a / m; 
            ll t = m; 
            m = a % m, a = t; 
            t = y; 
            y = x - q * y; 
            x = t; 
        }
        if (x < 0) x += m0; 
        return x; 
    }
    ll range(ll l, ll r){
        return l + rand()%(r-l+1);
    }
    
    int main()
    {
        ll t=1;//cin>>t;
        while(t--)
        {
            string a;cin>>a;
            for(int i=0;i<a.length();i++)
            {
                if(a[i]=='?')cout<<'D';
                else cout<<a[i];
            }
            cout<<endl;
        }
    }

Measured memory_bytes: 3756
import java.util.*;
public class Main{

     public static void main(String []args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        System.out.println(solve(n));
        
     }
     
     public static int solve(int n) {
         int res = 0;
         if(n<1000) {
             res = 1000-n;
            return res;
        }
        
        if(n%1000==0) {
            return 0;
        }
        
        res = 1000-(n%1000);
        
        return res;
     }
}

Measured memory_bytes: 35848
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int N,M;cin>>N>>M;
    char A[N][N],B[M][M];
    REP(i,N){
        REP(j,N)cin>>A[i][j];
    }
    REP(i,M){
        REP(j,M)cin>>B[i][j];
    }
    bool ans=false;
    for(int i=0;i<=N-M;i++){
        for(int j=0;j<=N-M;j++){
            bool ok=true;
          	REP(k,M){
                REP(l,M){
                    if(A[k+i][l+j]!=B[k][l])ok=false;
                }
            }
            if(ok){
              ans=true;
              break;
            }
        }
        if(ans)break;
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a>12){
        cout << b;
    }else if(a>5){
        cout << b/2;
    }else
        cout << "0";
    return 0;
}

Measured memory_bytes: 256