akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

        public int nextInt() {return Integer.parseInt(next());}

        public long nextLong() {return Long.parseLong(next());}

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

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    static class DSU {
        int[] root;
        int[] rank;

        public DSU(int n) {
            root = new int[n];
            rank = new int[n];
            for(int i=0;i<n;i++) {
                root[i] = i;
            }
        }

        public int find(int x) {
            if(root[x] == x) {
                return x;
            }
            else {
                return find(root[x]);
            }
        }

        public void unite(int x, int y) {
            x = find(x);
            y = find(y);
            if(x == y) {
                return;
            }
            if(rank[x] < rank[y]) {
                root[x] = y;
            }
            else {
                root[y] = x;
                if(rank[x] == rank[y]) {
                    rank[x]++;
                }
            }
        }

        public boolean same(int x, int y) {
            return find(x) == find(y);
        }
    }

	public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int n = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();
        pw.println(((b - a) & 1) == 0 ? "Alice" : "Borys");
        
        pw.close();
    }
}


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

signed main() {
  int a, b;
  cin >> a >> b;

  if (a >= 13) {
    cout << b << endl;
  } else if (a >= 6) {
    cout << b / 2 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
//control+option+n to run!
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define NEGFOR(i, a, b) for (ll i = (a); i > (b); i--)
#define vll vector<long long>
#define sll set<long long>
#define ld long double
#define inf 1000000000000000000;
#define mll multiset<long long>
#define nn << "\n"
#define F(i, b) for (ll i = 0; i < b; i++)
//10^8 operations per second
//greatest int is 2,147,483,647
//greates long long is 9.22337204e18
//ALL FUNCTIONS SHOULD BE LL!!!!
int n, m;
ll co=0;
vector<int> v[500002];
bool visited[500002];
void dfs(int node)
{
  co++;
    visited[node] = true;
    for (int i = 0; i < v[node].size(); ++i)
    {
        int nxt = v[node][i];
        if (visited[nxt] == false)
            dfs(nxt);
    }
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n >> m;

  for (int i = 1; i <= m; ++i)
  {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  vll vec;
  for (int i = 0; i < n; ++i)
  {
    if (visited[i] == false)
    {
      dfs(i);
      vec.pb(co);
      co=0;
    }
  }
  ll x=vec.size();
  sort(vec.begin(),vec.end());
  ll currdelete=0;
  ll ans=0;
  FOR(i,0,vec.size()){
    ans+=vec[i]-currdelete;
    currdelete=vec[i];
  }
  cout<<ans;

  cout << "\n"; //GET RID OF THIS FOR THE ACTUAL PROGRAM!!!!
}


Measured memory_bytes: 28008
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(b % a == 0){
			System.out.println(a + b);
		}else{
			System.out.println(b - a);
		}
	}
}

Measured memory_bytes: 24912
#include <stdio.h>

int main() {
	printf("1x1=1\n1x2=2\n1x3=3\n1x4=4\n1x5=5\n1x6=6\n1x7=7\n1x8=8\n1x9=9\n2x1=2\n2x2=4\n2x3=6\n2x4=8\n2x5=10\n2x6=12\n2x7=14\n2x8=16\n2x9=18\n3x1=3\n3x2=6\n3x3=9\n3x4=12\n3x5=15\n3x6=18\n3x7=21\n3x8=24\n3x9=27\n4x1=4\n4x2=8\n4x3=12\n4x4=16\n4x5=20\n4x6=24\n4x7=28\n4x8=32\n4x9=36\n5x1=5\n5x2=10\n5x3=15\n5x4=20\n5x5=25\n5x6=30\n5x7=35\n5x8=40\n5x9=45\n6x1=6\n6x2=12\n6x3=18\n6x4=24\n6x5=30\n6x6=36\n6x7=42\n6x8=48\n6x9=54\n7x1=7\n7x2=14\n7x3=21\n7x4=28\n7x5=35\n7x6=42\n7x7=49\n7x8=56\n7x9=63\n8x1=8\n8x2=16\n8x3=24\n8x4=32\n8x5=40\n8x6=48\n8x7=56\n8x8=64\n8x9=72\n9x1=9\n9x2=18\n9x3=27\n9x4=36\n9x5=45\n9x6=54\n9x7=63\n9x8=72\n9x9=81\n");
	return 0;
}

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

using namespace std;

int h[1000006];
int dp[1000006];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  dp[n - 1] = 0;
  for (int i = n - 2; i >= 0; i--) {
    dp[i] = 1e9;
    for (int j = 1; j <= k && i + j < n; j++) {
      dp[i] = min(dp[i], abs(h[i + j] - h[i]) + dp[i + j]);
    }
  }
  cout << dp[0] << '\n';

  return 0;
}

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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)



typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
//////////////////////////

void no(){
    cout<<-1<<endl;exit(0);
}

ll SOLVE(){
    ll n;cin>>n;
    ll a[n+1];rep(i,0,n)cin>>a[i];
    if(n==0){
        if(a[0]==1)cout<<1<<endl;
        else cout<<-1<<endl;
        return 0;
    }
    if(a[0]!=0){
        no();
    }
    ll ma[n+1];
    ma[0]=1;
    rep(i,1,n){
        ma[i]=(ma[i-1]-a[i-1])*2;
        chmin(ma[i],inf/2);
        if(ma[i]<=0){
            no();
        }
    }
    if(ma[n]<a[n]){
        no();
    }
    ma[n]=a[n];
    for(ll i=n-1;i>=0;i--){
        chmin(ma[i],ma[i+1]+a[i]);
    }
    ll ans=0;
    rep(i,0,n){
        if(ma[i]<0)no();
        ans+=ma[i];
    }
   // rep(i,0,n)cout<<ma[i]<<" ";cout<<endl;
    cout<<ans<<endl;
    
    
    return 0;
}

int main(){fastio
    
    clock_t start = clock();
    SOLVE();
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    cerr<<endl<<time<<"ms"<<endl;
    
    return 0;
}



Measured memory_bytes: 5376
fun main(args: Array<String>) {
    val (m,s) = readLine()!!.split(" ").map(String::toInt)
    var r = 0
    for (i in 0..m) {
        for (j in 0..m) {
            if(s - i - j in 0..m) r += 1
        }
    }
    println(r)
}

Measured memory_bytes: 37860
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int n;
		int m;
		String id_str;

		int[] a = new int[10];
		int[] dp = new int[10];
		int[] dp_temp = new int[10];

		Arrays.fill(dp, 0);
		dp[0] = 1;
		Arrays.fill(dp_temp, 0);

		Scanner sc = new Scanner(System.in);

		n = sc.nextInt();

		id_str = sc.next();
		m = sc.nextInt();
		for(int i=0; i<m; i++) a[i] = sc.nextInt();

		sc.close();

		char[] id_char = new char[n];
		id_char = id_str.toCharArray();


		for(int i=0; i<n; i++){
			Arrays.fill(dp_temp, 0);

//			for(int k=0; k<10; k++){
//				System.out.println(dp[k]);
//
//			}
//			System.out.println("------------------------------");

			if(id_char[n-1-i] == '*'){
				for(int j=0; j<m; j++){
					if(i%2==0){
						for(int k=0; k<10; k++){
							dp_temp[(k+a[j])%10] += dp[k];
						}
					}else{
						for(int k=0; k<10; k++){
							dp_temp[(k+a[j]*2-9*(a[j]/5))%10] += dp[k];
						}

					}
//					for(int k=0; k<10; k++){
//					System.out.println(dp_temp[k]);
//
//				}
//				System.out.println("------------------------------");
				}

			}else{

				if(i%2==0){
					for(int k=0; k<10; k++){

//						System.out.println(id_char[n-1-i]);
//						System.out.println(dp[k]);

						dp_temp[(k+(id_char[n-1-i]-'0'))%10] = dp[k];
					}
				}else{
					for(int k=0; k<10; k++){
						dp_temp[(k+(id_char[n-1-i]-'0')*2-9*((id_char[n-1-i]-'0')/5))%10] = dp[k];
						//System.out.println(((id_char[n-1-i]-'0')*2-9*((id_char[n-1-i]-'0')/5))%10);
					}
//					for(int k=0; k<10; k++){
//						System.out.println(dp_temp[k]);
//
//					}
//					System.out.println("------------------------------");
				}

			}
			for(int k=0; k<10; k++){
				dp[k] = dp_temp[k];
			}

		}

		System.out.println(dp[0]);

	}

}

Measured memory_bytes: 25804
def main():
    a,b,c,d = (int(x) for x in input().split())
    i = 1
    while a > 0 and c > 0:
        if i%2 != 0:
            c -= b
        else:
            a -= d
        i += 1
    if a <= 0: print('No')
    else: print('Yes')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = input()
sS = set(S)
if "N" in sS or "S" in sS:
    if not ("N" in sS and "S" in sS):
        print('No')
        quit()
if "W" in sS or "E" in sS:
    if not ("W" in sS and "E" in sS):
        print('No')
        quit()
print('Yes')

Measured memory_bytes: 9052
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
const int MAX=1000001;

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    
    int count=0;
    for(int num=1;num<=n;num++){
        int i=1;
        int sum=0;
        while(i<=num){
            sum+=(num%(i*10))/i;
            i*=10;
        }
        if(a<=sum&&sum<=b) count+=num;
    }

    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll n, a, b, ans = 0;
    cin >> n >> a >> b;
    for(ll i = 1;  i <= n; i++){
        ll x = i, s= 0;
        while(x){
            s += x%10;
            x /= 10;
        }
        if(s >= a && s <= b) ans += i;
    }
    cout << ans;
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
S = input()
before = ""

count = 0
i = 0
while i < len(S):
    for l in range(1, len(S) - i):
       if S[i:i+l] != before and S[i:i+l] != S[i+l:]:
           count += 1
           before = S[i:i+l]
           break
    i += l

print(count+1)


Measured memory_bytes: 3500
<?php
fscanf(STDIN, "%d", $N);
$array = explode(" ", trim(fgets(STDIN)));

foreach($array as $value){
    if($value % 2 == 0){
        if($value % 3 != 0 && $value % 5 != 0){
            echo "DENIED";
            exit;
        }
    }
}
echo "APPROVED";



Measured memory_bytes: 5240
#include<bits/stdc++.h>
using namespace std;
 
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
 
#define ll  long long int
#define all(v) v.begin(),v.end()
#define pb push_back
#define S second
#define F first
#define die() return 0;
 
#define md         1000000007
#define M           1000011
#define N 			12

ll f(vector<ll> v,ll val){

	ll cnt=0,i;
	vector<ll> v2=v;
	reverse(all(v2));
	for(i=0;i<v.size();++i){
		// ll k=val/v[i];
		ll x=-1;
		if(v[i]==0){
			if(val>=0)cnt+=v.size()-1;
			continue;

		}
		else if(v[i]>0){
			ll p=v.size();
			for(;p>=1;p/=2){
				while(x+p<v.size()&&v[i]*v[x+p]<=val)x+=p;
			}
		if(x!=-1&&(v[i]<=v[x]))--x;
		++x;

	}
	else{
			ll p=v.size();
			for(;p>=1;p/=2){
				while(x+p<v.size()&&abs(v[i])*v2[x+p]>=-1*val)x+=p;
			}

		if(x!=-1&&(v[i]>=v2[x]))--x;
		++x;



	}
	cnt+=x;

	}
	return cnt/2;

}
int solve(){
	ll n,i,j,k,m,x;
	cin>>n>>k;
	vector<ll> v(n);
	for(i=0;i<n;++i)cin>>v[i];
	sort(all(v));
	ll ans=1e18;
	ll p=1e18;
	x=-1e18;
	// cout<<f(v,6)<<"aa\n";
	// die();
	for(;p>=1;p/=2){
		while(x+p<=1e18&&f(v,x+p)<k)x+=p;

	}
	cout<<++x<<"\n";

	die();



}
 
 
int main(){
 
 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;
    t=1;
    // prec();
    // cin>>t;
 
    while(t--){
    	solve();
    }
 
 
 
 
 
    die();
}

Measured memory_bytes: 5016
#include<stdio.h>
int main(){
int i,n,k,j;
scanf("%d",&n);
char S[n][51];
int az[n][27];
for(i = 0; i < n; i++) {
  for(k = 0; k < 27; k++) {
  az[i][k] = 0;
  }
}
for(i = 0; i < n; i++) {
scanf("%s", S[i]);
for(k = 0; S[i][k] != '\0'; k++) {
az[i][S[i][k] - 'a']++;
}
}
int temp = az[0][0];
for(i = 0; i < 27; i++) {
  for(k = 1; k < n; k++) {
    if(temp - az[k][i] > 0) {
    temp = az[k][i];
    }
  }
  for(j = 0; j < temp; j++){
  printf("%c", 'a' + i);
  }
  temp = az[0][i + 1];
}
return 0;
}

Measured memory_bytes: 128
#include <cmath>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>

using namespace std;

#define forsn(i,s,n) for (int i = (s);i < (int)(n);i++)
#define forn(i,n) forsn(i,0,n)
#define dforsn(i,s,n) for (int i = (n-1);i >= (int)(s);i--)
#define dforn(i,n) dforsn(i,0,n)
#define all(v) (v).begin(), (v).end()
#define F first
#define S second

typedef long long int tint;

int a[10000];
int b[10000];
int d[10000];

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

	int n; cin >> n;
	forn(i,n) cin >> a[i];
	forn(i,n) cin >> b[i];
	forn(i,n) d[i] = b[i] - a[i];
	sort(d, d + n);
	
	tint ops = 0;
	
	forn(i,n) {
		if (d[i] < 0) ops += abs(d[i]);
		else {
			ops = max(0LL, ops - (d[i] / 2));
		}
	}

	if (ops == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <functional>
#include <algorithm>

int main() {
  int N, K;
  std::cin >> N >> K;
  long long ans = 0;
  for (int b = K + 1; b <= N; ++b) {
    ans += (N / b) * (b - K);
    if (K) {
      ans += N % b >= K ? N % b - K + 1 : 0;
    } else {
      ans += N % b >= K ? N % b - K : 0;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    ll N, M;
    scanf("%lld %lld", &N, &M);
    ll ans = 0;
    if (2 * N < M)
    {
        ans += N;
        M -= 2 * N;
        ans += M / 4;
        printf("%lld\n", ans);
        return 0;
    }
    else
    {
        ans += M / 2;
        printf("%lld\n", ans);
        return 0;
    }
    return 0;
}


Measured memory_bytes: 3760
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int size = s.length();
        if (size < 2) {
            System.out.println(0);
            return;
        }

        int half = size / 2;
        int p = half - 1;
        if (size % 2 != 0) {
             half = size / 2 + 1;
             p = half - 2;
        }
        int ans = 0;
        while (p>=0) {
            if (s.charAt(p) != s.charAt(half)) ans++;
            p--;
            half++;
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 23764
using System;
class Program{
  static void Main(){
    Console.ReadLine();
    var output = "APPROVED";
    foreach(var input in Console.ReadLine().Split(' ')){
      var src = int.Parse(input);
      if(src%2 == 0){
        if(src%3!=0 && src%5!=0)
          output = "DENIED";
      }
    }
    Console.WriteLine(output);
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int h,w;
    cin >> h >> w;
    char a[h][w];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> a[i][j];
        }
    }

    for(int i=0; i<h+2; i++){
        for(int j=0; j<w+2; j++){
            if(i==0 ||i==h+1 || j==0 || j==w+1){
                cout << "#" << "";
            }
            else{
                cout << a[i-1][j-1];
            }

        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int k, x;
  cin >> k >> x;
  if (k * 500 >= x){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import Data.List
main :: IO ()
main = do
    [a,b] <- getLine >>= return . (map (read :: String -> Double)) . words
    let x = filter (isIn (10 * b) (10 * (b+1))) $ filter (isIn (12.5 * a) (12.5 * (a+1))) [0..1000]
    putStrLn . show $ if x == [] then -1 else minimum x

isIn :: Double -> Double -> Int -> Bool
isIn a b n = a <= x && x < b where x = fromIntegral n

Measured memory_bytes: 508
#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()
{
    int N, X, Y;
    cin >> N >> X >> Y;
    vector<int> cs(N);
    for (int i = 1; N - i > 0; i++)
        cs[i] = N - i;
    for (int i = 1; i < N; ++i)
        for (int j = i + 1; j <= N; ++j)
            if (j - i > abs(X - i) + 1 + abs(Y - j))
            {
                --cs[j - i];
                ++cs[abs(X - i) + 1 + abs(Y - j)];
            }
    for (int k = 1; k < N; ++k)
        cout << cs[k] << endl;
    return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;

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

using namespace std;

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

  while (n >= 0)
  {
    if (n % 4 == 0)
    {
      cout << "Yes" << endl;
      return 0;
    }
    n -= 7;
  }

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
  int a[10010][10010];
int main(){
 int n,m,x; ll ans=9999999999999;
  cin>>n>>m>>x;
  vector<int> c(n);
  rep(i,n){
    cin>>c[i];
    rep(j,m)cin>>a[i][j];
  }
  rep(i,1<<n){
    ll cost=0; vector<ll> t(m); rep(j,m) t[j]=0; bool flag=true;
   rep(j,n){
    if(i>>j&1){
     cost += c[j];
      rep(k,m) t[k] += a[j][k];
    }
   }
   rep(j,m){
     if(t[j]<x) flag = false;
   }
    if(flag) ans=min(ans,cost);
  }
  if(ans==9999999999999){
  cout<<-1<<endl;
  }else{
  cout<<ans<<endl;
  }
}


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

int main(void){
    int n;
    cin >> n;
    int k = n;
    //sum
    int sum = 0;
    while(n > 0){
        sum = sum + (n % 10);
        n /= 10;
    }
    //cout << sum;
    if(k % sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
//#define INF 1145141919810893//810114514
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define rollcall cout<<"I'm Sucu."<<endl
#define int long long 




signed main(){
    int N,C;
    int D[32][32];
    int c[502][502];
    int S[3][32]={};//3で割ってi余る中に色jがいくつあるか
    cin >> N >> C;
    REP(i,C){REP(j,C){cin >> D[i][j];}}
    REP(i,N){REP(j,N){cin >> c[i][j];c[i][j]--;}}
    
    REP(i,N){REP(j,N){
      S[(i+j)%3][c[i][j]]++;  
    }}
    //REP(k,C){REP(i,C){REP(j,C){D[i][j]=min(D[i][j],D[i][k]+D[k][j]);}}}
    //REP(i,C){REP(j,C){cout << D[i][j] << " ";}cout << endl;}cout << endl<<endl;
    int sum=0,Ans=810114514;
    REP(i,C){
        REP(j,C){
            if(i==j)continue;
            REP(k,C){//0をi、1をj、2をkで塗るの全探索
                if(i==k)continue;
                if(j==k)continue;
                sum=0;
                REP(l,C){
                    sum+=S[0][l]*D[l][i];
                    sum+=S[1][l]*D[l][j];
                    sum+=S[2][l]*D[l][k];
                }
                Ans=min(sum,Ans);
                //cout << i+1 << " "<<j+1 << " "<<k+1 << "  "<<sum << endl;
            }
        }
    }
    cout << Ans << endl;
	return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=55,p=1000000007;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,ans,f[N][N],C[N][N];
void check(int &x,int y){x=(x+y<p) ? (x+y) : (x+y-p);}
int main(){
	n=read();
	for (int i=0;i<=n;i++){
		C[i][0]=1;
		for (int j=1;j<=i;j++)
		check(C[i][j]=C[i-1][j],C[i-1][j-1]);
	}
	f[1][0]=f[1][1]=n;
	for (int i=1;i<n;i++)
	for (int j=0;j<=i;j++)
	for (int k=j+2*(!j);i+k<=n;k+=2){
		int y=(k-j)/2;
		for (int x=0;x<=k;x++)
		check(f[i+k][abs(y-x)],(ll)f[i][j]*C[n-i][k]%p*C[k][x]%p);
	}
	
	printf("%d\n",f[n][0]);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ab = 21
m = 0
for i in a:
    m += b[i-1]
    if i == ab + 1:
        m += c[i-2]
    ab = i
print(m)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long i=0;i<n;i++)
int main(){
  long n,k; cin>>n>>k;
  long a[n]; rep(i,n) cin>>a[i];
  long ans=0; long sub=0;
  long p=1000000007;
  long x=k*(k+1)/2%p;
  long y=k*(k-1)/2%p;
  
  rep(j,n){
    for(long l=0;l<n;l++){
     if(a[j]>a[l] && j<l) {ans=ans+x;}
     if(a[j]>a[l] && j>l) {ans=ans+y;}
    }
  }
  cout<<ans%p<<endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ans = [0 for _ in range(m+1)]
for i in range(n):
    ll = list(map(int, input().split()))
    for l in ll[1:]:
        ans[l] += 1
count = 0
for i in ans:
    if i == n:
        count += 1
    else:
        pass
print(count)


Measured memory_bytes: 3060
K = int(input())
S = input()

S = list(S)
out = []
flag = 0
for i in range(K):
    if i >= len(S):
        flag = 1
        break
    out.append(S[i])


if (i+1 != len(S)) and flag == 0:
    out.append('...')

print(''.join(out))


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> b(n - 1);
  ll ans = 0;
  for (int i = 0; i < n - 1; i++) cin >> b[i];
  ans += b.front() + b.back();
  for (int i = 0; i < n - 2; i++) ans += min(b[i], b[i + 1]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 520300
#define M 998244353
using namespace std;
typedef long long ll;
ll n,a,b,k,c[maxn],d,p,q,ans;

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

ll pow_(ll x,ll y){
    ll rt=1;
    while(y){
        if (y&1) rt=rt*x%M;
        x=x*x%M;
        y>>=1;
    }
    return rt;
}

int main(){
    cin >> n >> a >> b >> k;
    c[0]=1; for (int i=1;i<=n;i++) c[i]=c[i-1]*(n-i+1)%M*pow_(i,M-2)%M;
    d=gcd(a,b); //cout << d << endl;
    if (k%d) {
        cout << 0 << endl;
        return 0;
    }
    if ((a+b)*n<k){
        cout << 0 << endl;
        return 0;
    }
    a/=d; b/=d; k/=d;
    //cout << a << ' ' << b << ' ' << k << endl;
    while ((k-a*p)%b) p++;
    q=(k-a*p)/b;
    while (q>=0){
        if (p<=n&&q<=n)(ans+=c[p]*c[q])%=M;
        p+=b; q-=a;
    }
    cout << ans << endl;
}


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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

long	gcd(long A, long B) {
	while (0!=B) {
		A %=B;
		swap(A, B);
	}
	return A;
}

long	lcm(long A, long B) {
	long G=gcd(A, B);
	return A/G*B;
}

long	GCD(vector<long> &A) {
	long B=A.at(0);
	for (long i=1; i<A.size(); i++)
		B =gcd(B, A.at(i));
	return B;
}

long	LCM(vector<long> &A) {
	long B=A.at(0);
	for (long i=1; i<A.size(); i++)
		B =lcm(B, A.at(i));
	return B;
}

#define	MOD 1000000007

int	main() {
	long N, M;
	cin >>N >>M;
	vector<long> A(N, 0);
	vector<long> A2(N, 0);
	for (int i=0; i<N; i++) {
		long a;
		cin >>a;
		A.at(i)=a/2;
		A2.at(i)=a;
	}
	long L=LCM(A);
	long L2=LCM(A2);
	for (int i=0; i<N; i++)
		if (0==(L/A.at(i))%2) {
			cout <<0 <<endl;
			return 0;
		}
	long K=M/L;
	K -=M/L2;
	cout <<K <<endl;
	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <stack>
#include <queue>
#include <deque>
#include <iomanip>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <bitset>

/*----------------------------------------------------------------*/

using ld = long double;
using vld = std::vector<ld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using str = std::string;
using vstr = std::vector<str>;
using vb = std::vector<bool>;
using vvb = std::vector<vb>;

/*----------------------------------------------------------------*/

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }
template<typename T> T sqr(T a) { return a * a; }

/*----------------------------------------------------------------*/

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

/*----------------------------------------------------------------*/

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; sqr(i) <= n; i++)
        if (n % i == 0) return false;
    return true;
}
ll popcnt(ll n) {
    n = ((n & 0xaaaaaaaaaaaaaaaa) >> 1) + (n & 0x5555555555555555);
    n = ((n & 0xcccccccccccccccc) >> 2) + (n & 0x3333333333333333);
    n = ((n & 0xf0f0f0f0f0f0f0f0) >> 4) + (n & 0x0f0f0f0f0f0f0f0f);
    n = ((n & 0xff00ff00ff00ff00) >> 8) + (n & 0x00ff00ff00ff00ff);
    n = ((n & 0xffff0000ffff0000) >> 16) + (n & 0x0000ffff0000ffff);
    n = ((n & 0xffffffff00000000) >> 32) + (n & 0x00000000ffffffff);
    return n;
}

/*----------------------------------------------------------------*/

void solve();

/*----------------------------------------------------------------*/

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

    solve();
}

void solve() {
    ll n; std::cin >> n;

    vvll g(n);
    for (ll i = 0; i < n; i++) {
        ll u, k; std::cin >> u >> k;
        u--;
        for (ll j = 0; j < k; j++) {
            ll v; std::cin >> v; v--;
            g[u].push_back(v);
        }
    }

    vll dist(n, -1); dist[0] = 0;

    auto bfs = [&](ll x) {
        std::deque<ll> next;
        next.push_back(x);
        while (!next.empty()) {
            ll cur = next.front();
            next.pop_front();
            for (ll i : g[cur])
                if (dist[i] == -1) {
                    dist[i] = dist[cur] + 1;
                    next.push_back(i);
                }
        }
    };

    bfs(0);

    for (ll i = 0; i < n; i++)
        std::cout << i + 1 << ' ' << dist[i] << '\n';
}



Measured memory_bytes: 3220
#include<iostream>
#include<vector>
#include<algorithm>
#define ll long long
using namespace std;

int main() {
	ll n, c, k, t, count = 0,ans=0;
	cin >> n >> c >> k;
	ll prev_t = 0;
	vector<ll> tt(n);
	for (int i = 0; i < n; i++) {
		cin >> tt[i];
	}sort(tt.begin(), tt.end());
	for (int i = 0; i < n; i++) {
		t=tt[i];
		count++;
		//cout << "t=" << t << " count=" << count <<" prev_t="<<prev_t<< endl;
		if (prev_t == 0) {
			prev_t = t;
		}
		else if(!(t - prev_t <= k && count <= c))  {
			//cout << "だめです" << endl;
			count = 1;
			ans++;
			prev_t = t;
		}
	}
	cout << ans+1 << endl;
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int n;
char s[200005];
long long cnt[50];
main() {
    int i;
    long long ans;
    scanf(" %s",s);
    n = strlen(s); ans = (long long)n*(n+1)/2;
    for(i=0;i<n;i++) cnt[s[i]-'a']++;
    for(i=0;i<26;i++) ans -= cnt[i]*(cnt[i]+1)/2;
    printf("%lld",ans+1);
}


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int S; cin >> S;
	vector<ll> dp(20001);
	dp[3] = 1; dp[4] = 1; dp[5] = 1;
	for(int i = 6; i <= S; i++) dp[i] = (dp[i - 1] + dp[i - 3]) % mod;
	cout << dp[S] << endl;
	return 0;
}


Measured memory_bytes: 3636
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))

from collections import deque
q=deque([])
for i in range(n):
  for j in range(a[i]):
    q.append(i+1)

cnt=0
for i in range(h):
  s=[]
  for i in range(w):
    p=q.popleft()
    s.append(p)
  cnt+=1
  if cnt%2==0:
    s.reverse()
    for num in s:
      print(num,end=" ")
    print()
  else:
    for num in s:
      print(num,end=" ")
    print()
    


Measured memory_bytes: 75364
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;
use std::io::Write;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readvec<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readlines<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
    }
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
            fn parse(s: &str) -> ($($t),*) {
                let mut tokens = s.split_whitespace();
                ($($t::parse(tokens.next().unwrap())),*)
            }
        }
    }
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

const WALL: u8 = '#' as u8;
const ROOM: u8 = '.' as u8;
const INF: usize = 10000000;

const DX: [i32; 4] = [0, -1, 0, 1];
const DY: [i32; 4] = [-1, 0, 1, 0];

fn main() {
    let (h, w): (usize, usize) = read();
    let map: Vec<Vec<u8>> = readlines(h).into_iter().map(|s: String| s.into_bytes()).collect();

    let mut dp = vec![vec![INF; w]; h];
    let mut que = VecDeque::new();
    que.push_back(0);
    que.push_back(0);
    dp[0][0] = 1;
    while que.len() >= 2 {
        let y = que.pop_front().unwrap();
        let x = que.pop_front().unwrap();
        let base = dp[y][x];

        for d in 0..4 {
            let ty = y as i32 + DY[d];
            let tx = x as i32 + DX[d];
            if ty < 0 || tx < 0 || ty >= h as i32 || tx >= w as i32 {
                continue;
            }
            let ty = ty as usize;
            let tx = tx as usize;
            if map[ty][tx] == WALL {
                continue;
            }
            if dp[ty as usize][tx as usize] == INF {
                dp[ty as usize][tx as usize] = base+1;
                que.push_back(ty);
                que.push_back(tx);
            }
        }
    }

    let mut total = 0;
    for i in 0..h {
        for j in 0..w {
            if map[i][j] == ROOM {
                total += 1;
            }
        }
    }
    if dp[h-1][w-1] == INF {
        println!("-1")
    } else {
        println!("{}", total - dp[h-1][w-1])
    }
}

Measured memory_bytes: 4352
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N, A, B;
	
	cin >> N >> A >> B;

	int a[3];
	memset(a, 0, sizeof(a));

	rep(i, N)
	{
		int v;
		cin >> v;
		if (v <= A)
		{
			a[0]++;
		}
		else if (v <= B)
		{
			a[1]++;
		}
		else
		{
			a[2]++;
		}
	}
	//cout << a[0] << " " << a[1] << " " << a[2] << endl;

	int tmp = min(a[0], a[1]);
	tmp = min(tmp, a[2]);

	cout << tmp << endl;

	
	return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc=new Scanner(System.in);
		HashMap<Integer,Integer>attendanceNumber=new HashMap<>();
		
		//クラスの人数
		int N=sc.nextInt();
		
		for(int i=1;i<=N;i++) {
			//iが登校順、scが出席番号
			attendanceNumber.put(sc.nextInt(),i);
		}
	
		for(int i=1;i<=N;i++) {
			if(attendanceNumber.containsKey(i)) {
				System.out.print(attendanceNumber.get(i)+" ");
			}
		}
	}
}


Measured memory_bytes: 72648
N=int(input())
dp=[[0 for i in range(3)] for j in range(N+1)]

for i in range(N):
  a,b,c=map(int,input().split())
  dp[i+1][0]=max(dp[i][1]+a,dp[i][2]+a)
  dp[i+1][1]=max(dp[i][0]+b,dp[i][2]+b)
  dp[i+1][2]=max(dp[i][1]+c,dp[i][0]+c)
  
print(max(dp[N]))


Measured memory_bytes: 25340
//P3A
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll x,ans = 1;
	ll MOD = 1E9+7;
	cin >> x;
	for(int i = 1;i <= x;i++){
		ans = ans*i%MOD;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
const long long INF = 1e18+5;
int main() {
	long int n,W;
	cin>>n>>W;
	vector<long long> value(n), weight(n);
	long long sum = 0;
	for(int i=0;i<n;i++) {
		cin>>weight[i] >> value[i];
		sum+=value[i];
	}
	vector<vector<long long>> dp(n+1, vector<long long> (sum+1,INF));
	//minimum possible weight obtainable from i to n-1
	 //with 0 items you can obtain 0 weight
	dp[0][0] = 0;
	for(int i=1;i<=n;i++) {
		for(int j=0;j<=sum;j++) {
			if(j<value[i-1]) {
				dp[i][j] = dp[i-1][j];
			} else {
				dp[i][j] = min(dp[i-1][j], dp[i-1][j-value[i-1]] + weight[i-1]);
			}
		}
	}
	//debug()<<imie(dp);
	long long ans = -1;
	for(long long i=0;i<=sum;++i) {
		if(dp[n][i]<=W) {
			ans = max(ans,i);
		}
	}
	cout<<ans;
}


Measured memory_bytes: 83040
#include <iostream>
using namespace std;
long long Q, S, H, D, N;
void Solve()
{
    H = min(min(H, 2 * S), 4 * Q);
    long long ans = 0;
    if(H * 2 > D)
    {

        ans += (N / 2) * D;
        if(N % 2 == 1)
            ans += H;
    }
    else
    {
        //long long ans = 0;
        ans += N * H;
    }
    cout << ans << "\n";
}
int main()
{
    cin >> Q >> S >> H >> D;
    cin >> N;
    Solve();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }

    return true;
}
int mn, mx;
int main(void){
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> vec(m);
    rep(i, m) {
        cin >> vec[i];
        (vec[i] > x ? ++mx : ++mn);
    }
    cout << min(mx, mn) << endl;
    return 0;
}

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

int main(void) {
	int k, s; cin >> k >> s;
	int a, b, sum = 0;

	for (a = 0; a <= k; a++) {
		for (b = 0; b <= k; b++) {
			if (s - (a + b) >= 0 && s - (a + b) <= k) { sum += 1; }
		}
	}
	cout << sum << endl;
	return 0;
}



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

signed main(){
	int n,dp[1000010] = {1,1,1,2},ans = 0;
	cin >> n;
	for(int i = 4;i <= n;i++) dp[i] = (dp[i - 4] + dp[i - 2] + dp[i - 1]) % MOD;
	for(int i = 0;i < n - 2;i++) (ans += dp[i] * ((n - 1) * (n - 1) % MOD + i + 2)) %=  MOD;
	(ans += dp[n - 2] * ((n - 1) * (n - 1) % MOD + n - 1)) %= MOD;
	(ans += dp[n - 1] * n) %= MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  int ans=0;
  if(A==B&&B==C){
    if(A%2==0&&B%2==0&&C%2==0){
      cout<<-1<<endl;
      return 0;
    }
  }
  int i=0;
  for(;A%2==0&&B%2==0&&C%2==0;i++){
    int a=A;
    int b=B;
    int c=C;
    A=0;
    B=0;
    C=0;
    A=b/2+c/2;
    B=a/2+c/2;
    C=a/2+b/2;
  }
  cout<<i<<endl;
}

Measured memory_bytes: 3624
# import copy
# In general, DP problems can often be thought of as a decision making process, where you make some "local" decision and your state after that 
# local decision becomes some state you have previously calculated the answer for. So, when you are on a given state, you try all the local 
# decisions you can, and take the one that results in the best answer (or in this case, sum up the number for each local decision to get the 
# total count for the current state).

# Your dp state characterization is correct: dp[i][j] represents the number of ways of distributing j candies among the first i people. 
# Now, say you are trying to calculate dp[i][j]. What is the "local decision" that you must make at this state? It will just be how many 
# candies you want to give to the i'th person (in fact, deciding what to do with the i'th person is often the decision that must be made 
# when your dp state deals with "something among the first i people"). So, say you want to give the i'th person k candies, where k is 
# somewhere between 0 and min(ai, j) (we can't give them more than ai candies because of the problem constraint, and can't give them more 
# than j candies because we only have j candies). Then, we see that if we give k candies to person i, then the number of ways to do 
# that is dp[i - 1][j - k] (because we precisely want to find the number of ways to distribute j - k candies to the first i - 1 people). 
# If we sum up these numbers over all the k from 0 to min(ai, j), then we should get the count for dp[i][j].

# You'll notice, though, that this results in O(NK) states and O(K) operations per state, or O(NK2) runtime, which is too slow. 
# There is something about the state transitions that allows you to calculate the sum over all the different local decisions much faster, 
# in fact in O(1). Can you think of what to do? Hint: all of the local decisions for a given dp[i][j] recurse into a contiguous block 
# in the dp[i - 1] row.

N, K = map(int,  input().split())
A = list(map(int,  input().split()))
dp = [[0 for k in range(K+1)] for n in range(N)]
# pref = [0 for k in range(K+1)]
# sSum = [0 for n in range(N)]
# sSum[N-1] = A[N-1]
# for n in range(N-2, -1, -1):
# 	sSum[n] = sSum[n+1] + A[n]
mod = int(1e9+7)
dp[N-1][0] = 1
# pref[0] = 1
for k in range(1, K+1):
	if k > A[N-1]:
		dp[N-1][k] = 0
		# pref[k] = 0
	else:
		dp[N-1][k] = 1
		# pref[k] = 1
# print(pref)
for n in range(N-2, -1, -1):
	ans = 0
	for k in range(A[n]+1):
		ans += dp[n+1][k]%mod
		ans = ans
		dp[n][k] = ans%mod
	# print(dp)
	for k in range(A[n]+1,K+1):
		# print(n, k ,ans, dp[n+1][k], dp[n+1][k-A[n]-1])
		ans = (ans%mod + dp[n+1][k]%mod - dp[n+1][k-A[n]-1]%mod + mod)%mod
		dp[n][k] = ans%mod
	# pref = copy.deepcopy(dp[n])
# print(dp)
print(dp[0][K])


Measured memory_bytes: 171400
using System;
using System.Linq;

namespace AtCoderMake.ABC168
{
    class ABC168B
    {
        static void Main(string[] args)
        {
            var k = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            if (s.Length > k)
            {
                Console.WriteLine(s.Substring(0, k)+"...");
            }
            else
            {
                Console.WriteLine(s);
            }
        }
    }
}


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

int main(){
  int n;
  string s;
  cin>>n;
  cin>>s;
  if(n%2!=0){
    cout<<"No";
    return 0;
  }
  for(int i=0;i<n/2;i++){
  	if(s[i]!=s[i+n/2]){
      cout<<"No";
	  return 0;
    }
  }
  cout<<"Yes";
}

Measured memory_bytes: 256
using System;

namespace AtCoder
{
	public class ProblemA
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());

			long ans = 1;

			for (int i = 2; i <= n; i++)
			{
				ans *= i;
				ans %= 1000000007;
			}

			Console.WriteLine(ans);
		}
	}
}


Measured memory_bytes: 27212