akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE2 solver = new TaskE2();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE2
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            int W = in.nextInt();
            int weights[] = new int[N];
            int values[] = new int[N];
            read(weights, values, in);

            // dp[i] -> min weight for value i
            long dp[][] = new long[N + 1][100_001];
            Arrays.fill(dp[0], Integer.MAX_VALUE);
            dp[0][0] = 0;

            for (int i = 1; i <= N; i++)
            { //iterate over items
                for (int j = 0; j <= 100_000; j++)
                { // value
                    if (j >= values[i - 1])
                    {
                        dp[i][j] = Math.min(dp[i - 1][j], dp[i - 1][j - values[i - 1]] + weights[i - 1]);
                    } else
                    {
                        dp[i][j] = dp[i - 1][j];
                    }
                }
            }
            int max = 0;
            for (int i = 100_000; i >= 0; i--)
            {
                if (dp[N][i] <= W)
                {
                    max = Math.max(max, i);
                }
            }
            out.print(max);
        }

        private void read(int[] weights, int[] values, Scanner in)
        {
            for (int i = 0; i < weights.length; i++)
            {
                weights[i] = in.nextInt();
                values[i] = in.nextInt();
            }
        }

    }
}



Measured memory_bytes: 127188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N;
	cin>>N;
	ll F[100];
	F[0] = F[1] = 1;
	for (int i = 2; i <= N; ++i){
		F[i] = F[i-1] + F[i-2];
	}
	cout<<F[N]<<endl;
}


Measured memory_bytes: 3112
import java.util.Scanner;

public class Main {
	static long fact[] = new long[1000002];
	static long factInv[] = new long[1000002];
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		final int MOD = 1_000_000_000 + 7;

		int x = sc.nextInt();
		int y = sc.nextInt();
		
		if((2*x - y) % 3 != 0 || (2*y - x) % 3 != 0) {
			System.out.println(0);
			return;
		}
		
		fact[0] = 1;
		factInv[0] = 1;
		for(int i = 0; i < fact.length - 1; i++){
			fact[i+1] = fact[i]*(i+1) % MOD; // n!(mod M)
	        factInv[i+1] = (int)(factInv[i]*repeatablePow(i+1, MOD-2, MOD) % MOD);
		}
		
		int forward = (2*y - x)/3;
		int right = (2*x - y)/3;
		
		if(forward < 0 || right < 0) {
			System.out.println(0);
			return;
		}

//		System.out.println(forward+" "+right);
		System.out.println(combination((x + y)/3, forward, MOD));
	}

	static long repeatablePow(int x, int n, int mod){
		if(n == 0){
			return 1;
		}
		long result = repeatablePow((int)((long)x*x%mod), n/2, mod);
		if(n % 2 == 1){
			result = result*x%mod;
		}
		return result;
	}
	
	static long combination(int a, int b, int mod){ //aCbをmod計算
	    if(a == 0 && b == 0)return 1;
	    if(a < b || a < 0)return 0;

	    long tmp = factInv[a - b]* factInv[b] % mod;
	    return tmp * fact[a] % mod;
	}
}


Measured memory_bytes: 41812
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);

    vector<bool> used(8, false);
    int cnt = 0;
    int cnt2 = 0;
    rep(i, n){
        if(1<=a.at(i) && a.at(i)<400){
            if(!used.at(0)){
                cnt++; 
                used.at(0) = true;
            }
        }
        else if(400<=a.at(i) && a.at(i)<800){
            if(!used.at(1)){
                cnt++; 
                used.at(1) = true;
            }

        }
        else if(800<=a.at(i) && a.at(i)<1200){
            if(!used.at(2)){
                cnt++; 
                used.at(2) = true;
            }

        }
        else if(1200<=a.at(i) && a.at(i)<1600){
            if(!used.at(3)){
                cnt++; 
                used.at(3) = true;
            }

        }
        else if(1600<=a.at(i) && a.at(i)<2000){
            if(!used.at(4)){
                cnt++; 
                used.at(4) = true;
            }
        }
        else if(2000<=a.at(i) && a.at(i)<2400){
            if(!used.at(5)){
                cnt++; 
                used.at(5) = true;
            }
       
        }
        else if(2400<=a.at(i) && a.at(i)<2800){
            if(!used.at(6)){
                cnt++; 
                used.at(6) = true;
            }
       
        }
        else if(2800<=a.at(i) && a.at(i)<3200){
            if(!used.at(7)){
                cnt++; 
                used.at(7) = true;
            }
        }
        else{
            cnt2++;
        }
        
    }
    
    if(cnt!=0) cout << cnt << " " << cnt+cnt2 << endl;
    else cout << 1 << " " << cnt2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll n;
    cin >> n;
    ll a[n];
    ll i;
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    for(i=0;i<n/2+n%2;i++){
        cout << a[n-1-2*i] << " ";
    }
    for(i=0;i<n/2;i++){
        cout << a[n%2+2*i] << " ";
    }
    return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#define rep_zero(i, n) for(int i=0; i<n; i++)
#define rep(i, n) for(int i=1; i<n; i++)
using namespace std;
typedef long long ll;

int main(){
    ll a, b, v, w, t;
    cin >> a >> v >> b >> w >> t;
    if(t*(v-w) >= abs(a-b)) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <limits>

int main()
{
    while (true) {
        int n;
        std::cin >> n;
        if (n == 0) break;

        int a[5000];
        for (int i = 0; i < n; ++i) std::cin >> a[i];

        int max = std::numeric_limits<int>::min();
        for (int i = 0; i < n; ++i) {
            int sum = a[i];
            if (max < a[i]) max = a[i];
            for (int j = i + 1; j < n; ++j) {
                sum += a[j];
                if (max < sum) max = sum;
            }
        }
        std::cout << max << std::endl;
    }
}

Measured memory_bytes: 1176
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<tuple>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(ll i = 1;i <=  n; i++)
#define rrep(i,n) for(ll i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(a) rbegin(a),rend(a)
typedef long long int ll;
typedef long double ld;
const ll INF = 1e18;
const double eps = 1e-8;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}int n, m, s, t, r, Q, b, c; vector<int> w;
int dp[310][310];
int rec(int l, int r) {
    if (dp[l][r] != -1) return dp[l][r];
    if (abs(l - r) <= 1) return 0;
    int res = 0;
    if (abs(w[l] - w[r - 1]) <= 1 && rec(l + 1, r - 1) == r - l - 2)
        res = r - l;
    for (int mid = l + 1; mid < r; mid++)
        res = max(res, rec(l, mid) + rec(mid, r));
    return dp[l][r] = res;
}
int main(void) {
    while (cin >> n, n) {
        w.resize(n); Fill(dp, -1);
        rep(i, n) cin >> w[i];
        cout << rec(0, n) << endl;
    }
}


Measured memory_bytes: 3472
n, a, b = map(int,input().split())

c = n // (a + b)
if c == 0:
    d = min(n, a + b)
else:
    d = n - (c * (a+b))

if d > a:
    ans = (c*a) + a
else:
    ans = (c*a) + d
    
print(ans)


Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <cassert>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using ld = long double;

#define st first
#define nd second

const int MAXN = 1e5 + 5, inf = 1e9;
const ll INF = 1e18, mod = 1e9 + 7;
const ld PI = 3.1415926535897932384626433832795;

int cnt[MAXN];
ll dp[105][MAXN], p[MAXN], a[MAXN], sum[105][MAXN];
bool vis[MAXN], used[MAXN];

vector<int> G[MAXN];
vector<ll> V;
set<ll> S;
map<ll, int> M;
stack<ll> St;
queue<ll> Q;

ll Sum(int i, int a, int b) {
    if (a <= 0) {
        return sum[i][b];
    }
    return ((sum[i][b] - sum[i][a - 1]) % mod + mod) % mod;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << setprecision(13) << fixed;

    //////////////////////////////////////////
    //////////////////////////////////////////

    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n;  i++) {
        cin >> a[i];
    }

    dp[0][0] = 1;
    fill(sum[0], sum[0] + k + 1, 1);
    for (int i = 1; i <= n; i++) {
        ll suma = 0;
        for (int j = 0; j <= k; j++) {
              dp[i][j] = Sum(i - 1, j - a[i], j);
              suma = (suma + dp[i][j]) % mod;
              sum[i][j] = suma;
        }
    }

    cout << dp[n][k] << "\n";
}


Measured memory_bytes: 164096
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    lines = []
    a = list(map(int, sys.stdin.readline().split()))
    b = list(map(int, sys.stdin.readline().split()))
    c = list(map(int, sys.stdin.readline().split()))
    lines.append(a)
    lines.append(b)
    lines.append(c)
    N = int(sys.stdin.readline().rstrip())
    S = [line.rstrip() for line in sys.stdin.readlines()]

    ret = []
    for s in S:
        for i in range(3):
            for j in range(3):
                if int(s) == lines[i][j]:
                    ret.append(str(i) + str(j))

    if "00" in ret and "01" in ret and "02" in ret:
        print("Yes")
    elif "10" in ret and "11" in ret and "12" in ret:
        print("Yes")
    elif "20" in ret and "21" in ret and "22" in ret:
        print("Yes")
    elif "00" in ret and "10" in ret and "20" in ret:
        print("Yes")
    elif "01" in ret and "11" in ret and "21" in ret:
        print("Yes")
    elif "02" in ret and "12" in ret and "22" in ret:
        print("Yes")
    elif "00" in ret and "11" in ret and "22" in ret:
        print("Yes")
    elif "02" in ret and "11" in ret and "20" in ret:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <algorithm>
#define N 201000
typedef long long ll;
template <typename T> inline void read(T &x) {
	x = 0; char c = getchar(); bool flag = false;
	while (!isdigit(c)) { if (c == '-')	flag = true; c = getchar(); }
	while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
	if (flag)	x = -x;
}
using namespace std;
const int P = 1e9 + 7;
const int inf = 987654321;
inline void MIN(int &a, int b) {
	if (b < a)	a = b;
}
int n, m;
char s[N];
namespace jzp1 {
	ll jie[N], jieni[N];
	inline ll get_c(int n, int m) {
		if (n < 0 || m < 0 || n - m < 0)	return 0;
		return jie[n] * jieni[m] % P * jieni[n - m] % P;
	}
	inline ll quickpow(ll x, int k) {
		ll res = 1;
		while (k) {
			if (k & 1)	res = res * x % P;
			x = x * x % P;
			k >>= 1;
		}
		return res;
	}
	inline void sol() {
		if (n == 1) { puts("1"); return ; }
		jie[0] = jieni[0] = 1;
		int up = n + 1;
		for (int i = 1; i <= up; ++i)	jie[i] = jie[i - 1] * i % P;
		jieni[up] = quickpow(jie[up], P - 2);
		for (int i = up - 1; i; --i)	jieni[i] = jieni[i + 1] * (i + 1) % P;
		ll res = 0;
		for (int i = 0; i <= n; ++i) {
			res = (res + get_c(n - i + 1, i) - get_c(n - i - 1, i - 2)) % P;
		}
		printf("%lld\n", (res % P + P) % P);
	}
}
ll f[N];
ll sum[N];
int main() {
	read(n), read(m);
	scanf("%s", s + 1);
	bool flag = false;
	int tmp = 0;
	for (int i = 1; i <= m; ++i)	if (s[i] != s[1]) { flag = true; tmp = i - 1; break; }
	if (!flag) { jzp1::sol(); return 0; }
	if (n & 1) { puts("0"); return 0; }
	int lst = 1, mn = tmp | 1;
	for (int i = 2; i <= m; ++i) {
		if (s[i] != s[1]) {
			if (lst & 1)	MIN(mn, lst);
			lst = 0;
			continue;
		}
		if (s[i] == s[i - 1])	++lst;
		else {
			if (lst & 1) MIN(mn, lst);
			lst = 1;
		}
	}
	n >>= 1;
	int k = (mn + 1) >> 1;
	MIN(k, n);
	f[0] = 1; sum[0] = 1;
	for (int i = 1; i <= n; ++i) {
		if (i <= k)	f[i] = sum[i - 1];
		else f[i] = (sum[i - 1] - sum[i - k - 1]) % P;
		sum[i] = (sum[i - 1] + f[i]) % P;
	}
	ll ans = 0;
	for (int i = 1; i <= k; ++i) {
		ans = (ans + f[n - i] * i) % P;
	}
	ans = (ans << 1) % P;
	printf("%lld\n", (ans % P + P) % P);
	return 0;
}

/*
3 3
BBB
//4

1 1
B
//1

12 10
RRRRBRRRRB
//78

6 5
RRBBR
//8
*/

Measured memory_bytes: 6528
import java.util.*;

class Main{
	
	int n, q;int count=0;
	int[] S ;int[] T;
	Scanner sc = new Scanner(System.in);
	
	void input(){
		n = sc.nextInt();
		S = new int[n];
		for(int i=0; i<n; i++){
			S[i] = sc.nextInt();
		}
		q = sc.nextInt();
		T = new int[q];
		for(int j=0; j<q; j++){
			T[j] = sc.nextInt();
		}
		search();
	}
	void search(){
		for(int i=0; i<q; i++){
			for(int j=0; j<n; j++){
				if(T[i]==S[j]){
					count=count+1;
					j=n;
				}
			}
		}
		output();
	}
	void output(){
		System.out.println(count);
	}
	
	public static void main(String[] args){
		new Main().input();
	}
}

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

public class Main {

	public static void main(String[] args) throws IOException {

		PrintWriter out = new PrintWriter(System.out);
		Scanner sc = new Scanner();
		int n=sc.nextInt();
		int maxN=(int) (1e5+5);
		int [][]f=new int [2][maxN];
		for(int i=0;i<n;i++)
			f[i%2][sc.nextInt()]++;
		int ans=n;
		ArrayList<Integer> []sorted=new ArrayList[2];
		for(int i=0;i<2;i++)
		{
			sorted[i]=new ArrayList();
			for(int j=0;j<maxN;j++)
				sorted[i].add(j);
			int z=i;
			Collections.sort(sorted[i], (a,b)->f[z][b]-f[z][a]);
		}
		for(int t1=0;t1<2;t1++)
			for(int t2=0;t2<2;t2++)
			{
				int a=sorted[0].get(t1),b=sorted[1].get(t2);
				if(a==b)
					continue;
				ans=Math.min(ans, n-f[0][a]-f[1][b]);
			}
		out.println(ans);
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

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

		Scanner(String f) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(f));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		double nextDobule() throws IOException {
			return Double.parseDouble(next());
		}

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


Measured memory_bytes: 45628
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

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

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

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

const ll mod = 1e9 + 7;
const ll IMF = 1LL<<29;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//


ll n,a,b,c;
ll inv[1010000], invF[1010000];
ll p,q;

ll mul(ll x, ll y){
        return (x*y) % mod;
}

ll pow(ll x, ll y){
        ll r = 1;
        while (y) {
                if (y & 1)r = r * x%mod;
                x = x * x%mod; 
                y >>= 1;
        }
        return r;
}

ll rev(ll x){
        return pow(x, mod-2);
}

ll comb(ll x, ll y){
        if(y < 0 || x < y) return 0;
        return mul(mul(inv[x], invF[x-y]), invF[y]);
}

ll totoro(ll x, ll y){
        return pow(p,x) * pow(q,y)%mod*comb(x+y,x)%mod;
}

int main(void){
        cin >> n >> a >> b >> c;
        inv[0] = 1;
        for(ll i = 1; i <= 1000000; i++){
                inv[i] = mul(inv[i-1],i);
        }
        invF[1000000] = rev(inv[1000000]);
        for(ll i = 1000000; i >= 1; i--){
                invF[i-1] = mul(invF[i],i);
        }

        p = mul(rev(a+b),a);
        q = mul(rev(a+b),b);

        ll res = 0;
        for(ll i = 0; i < n; i++){
                res = (res+totoro(n-1,i)*(n-1+i+1)%mod*p)%mod;
                res = (res+totoro(i,n-1)*(n-1+i+1)%mod*q)%mod;
        }

        ll ans;
        ans = res*(a+b+c)%mod*rev(a+b)%mod;

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


Measured memory_bytes: 16000
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        s: Chars,
    }

    solve(&s);
}

fn solve(s: &[char]) {
    let mut input: Vec<char> = Vec::new();
    for c in s.iter() {
        match c {
            &'0' => {
                input.push(*c);
            }
            &'1' => {
                input.push(*c);
            }
            _ => {
                input.pop();
            }
        }
    }

    for c in input {
        print!("{}", c);
    }
    println!("");
}


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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e16;

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

  LL ans;
  LL N, M;
  cin >> N >> M;

  if (N * 2 > M) {
    ans = M / 2;
  } else {
    ans = N;
    M -= 2 * N;
    ans += M / 4;
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
  "sort")
func main(){
var a,b,c,d,e,k int
  fmt.Scanf("%d",&a)
  fmt.Scanf("%d",&b)
  fmt.Scanf("%d",&c)
  fmt.Scanf("%d",&d)
  fmt.Scanf("%d",&e)
  fmt.Scanf("%d",&k)
  s:=[]int{
  a,
    b,
    c,
    d,
    e,
  }
  sort.Ints(s)
  n := "Yay!"
  for i:=1;i<=4;i++{
    t:=s[i]-s[0]
    if t>k{
      n=":("
      break
    } 
  }
  
  fmt.Println(n)

}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
#define print(x)        cout << (x) << endl
#define printa(x)       REP(i, x.size()) cout << x[i] << endl
typedef pair<ll, ll>    P;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    vector<int> a(n+1);
    REPN(i, 1, n+1) a[i] = s[i-1] - '0';

    int dp[n+1][2];    /* 0: ぴったり, 1: 多い */
    dp[0][1] = a[0] + 1;
    dp[0][0] = a[0];

    REP(i, n) {
        /* ぴったり払って終わる */
        dp[i+1][0] = dp[i][0] + a[i+1];
        /* おつりもらって終わる */
        dp[i+1][0] = min(dp[i+1][0], dp[i][1] + 10 - a[i+1]);

        /* 一枚多く支払って終わる */
        dp[i+1][1] = dp[i][0] + a[i+1] + 1;

        /* おつりをもらって終わる */
        /* 下の桁を考慮し9から引く */
        dp[i+1][1] = min(dp[i+1][1], dp[i][1] + 9 - a[i+1]);
    }

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

    return 0;
}

Measured memory_bytes: 13060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		if (n == 1) {
			out.println("Hello World");
		} else {
			int a = sc.nextInt();
			int b = sc.nextInt();
			out.println(a+b);
		}
		out.flush();

	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

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

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 21204
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    S = SS()
    K = I()

    ans = ''
    S_k = S[K-1]
    for i in S:
        if i == S_k:
            ans += i
        else:
            ans += '*'

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10048
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}
  
int main()
{
  int n,i,j;
  cin >> n;

  ll a[n+1];
  ll b[n];
  ll ans = 0;
  ll tmp = 0;

  rep(i,n+1){cin >> a[i];}
  rep(i,n){cin >> b[i];}

  rep(i,n){
      if(b[i] > a[i]){
          ans += a[i]; tmp = b[i] - a[i]; a[i] = 0;
          if(tmp > a[i+1]){
               ans += a[i+1]; a[i+1] = 0;
          }
          else{
              a[i+1] -= tmp; ans += tmp;
          }
      }
      else{
          ans += b[i]; a[i] -= b[i];
      }
  }

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


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

int main() {
  int n;
  cin >> n;
  
  if (n == 1) cout << n << endl;
  else if (2 <= n && n < 4) cout << 2 << endl;
  else if (4 <= n && n < 8) cout << 4 << endl;
  else if (8 <= n && n < 16) cout << 8 << endl;
  else if (16 <= n && n < 32) cout << 16 << endl;
  else if (32 <= n && n < 64) cout << 32 << endl;
  else cout << 64 << endl;
}  


Measured memory_bytes: 256
n = int(input())

f = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]

ans = -float("inf")
for i in range(1, 2**10):
    isOpen = []
    for j in range(10):
        if i & (1<<j):
            isOpen.append(1)
        else:
            isOpen.append(0)
    res = 0
    for j in range(n):
        cnt = 0
        for k in range(10):
            if isOpen[k] and f[j][k]:
                cnt += 1
        res += p[j][cnt]
    ans = max(ans, res)

print(ans) 


Measured memory_bytes: 3064
#N番目の数字を入力待機している
N = int(input())

#合計の変数にsumを使用
sum = 0
#入力してもらうNまで1ずつ増えていく。
for i in range(1, N + 1):
#3で割り切れない数字と、5で割り切れない数字の総和を求める
    if (i % 3 != 0) and (i % 5 != 0):
        sum += i

print(sum)

Measured memory_bytes: 8940
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    vin x(n),y(n);
    rep(i,n){
        cin>>x[i];
        y[i]=x[i];
    }
    sort(all(y));
    map<int,int> ans;
    int k=n/2;
    rep(i,k)ans[y[i]]=y[k];
    rep2(i,k,n)ans[y[i]]=y[k-1];
    rep(i,n)cout<<ans[x[i]]<<endl;
}

Measured memory_bytes: 13972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
int num[maxn];
 
int main()
{
  int n;
  while(cin>>n){
  	for(int i=0;i<n;i++)
      cin>>num[i];
    int ans=0, flag = 0;
    for(int i=0;i<n;i++){
      int temp = 0;
      for(int j=i+1;j<n;j++){
        if(num[j]<=num[j-1])
          temp++;
        else
          break;
      }
      ans = max(ans, temp);
      i = i + temp;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
const ll maxn=200010;

int N,sumr,sum;
string str;


int main()
{
	cin>>N;
	cin>>str;
	for(int i=0;i<N;i++)
	{
		if(str[i]=='R')	sumr++;
	}
	for(int i=0;i<sumr;i++)
	{
		if(str[i]=='W')	sum++;
	}
	cout<<sum;
	return 0;
}
/*
4
WWRR

2


8
WRWWRWRR

3
*/


Measured memory_bytes: 3468
import sys
import itertools
input = sys.stdin.readline


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


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def main():
    H, A = read_values()
    print((H - 1) // A + 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
N = int(input())

B = list(map(int, input().split()))

if N == 2:
	print(B[0]*2)
	exit(0)

A = [0 for i in range(N)]


for i in range(N-1):
	if i == 0:
		A[i] = B[i]
	elif i == N-2:
		A[i] = min(B[i-1], B[i])
		A[i+1] = B[i]
	else:
		A[i] = min(B[i-1], B[i])

a = sum(A)

print(a)


Measured memory_bytes: 3064
#include <stdio.h>

int isuruu(int year) {
	if((year%4==0 && year%100!=0) || year%400==0)return 1;
	else return 0;
}

int getmonthdays(int year,int month) {
	int days[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	if(month<1 || month>12)return 0;/*ツエツδ可ー*/
	if(month==2 && isuruu(year))return 29;/*ツ閏ツ年ツつゥツづつ２ツ個篠づ按づァ*/
	else return days[month-1];
}

int getnokoridays(int nowyear,int nowmonth,int nowday,int toyear,int tomonth,int today) {
	int currentyear,currentmonth,currentday;
	int result=0;
	currentyear=nowyear;
	currentmonth=nowmonth;
	currentday=nowday;
	if(nowyear>toyear ||
		(nowyear==toyear && nowmonth>tomonth) ||
		(nowyear==toyear && nowmonth==tomonth && nowday>today))
		return -getnokoridays(toyear,tomonth,today,nowyear,nowmonth,nowday);
	while(currentyear<toyear && !(currentyear+1==toyear &&
			(currentmonth>tomonth ||
			(currentmonth==tomonth && currentday>today)))) {
		result+=365;
		if(isuruu(currentmonth<=2?currentyear:currentyear+1))result++;
		currentyear++;
	}
	while(currentmonth!=tomonth) {
		result+=getmonthdays(currentyear,currentmonth);
		currentmonth++;
		if(currentmonth>12) {
			currentmonth-=12;
			currentyear++;
		}
	}
	result+=today-currentday;
	return result;
}

int main(void) {
	int fromy,fromm,fromd,toy,tom,tod;
	while(1) {
		scanf("%d %d %d %d %d %d",
			&fromy,&fromm,&fromd,&toy,&tom,&tod);
		if(fromy<0 || fromm<0 || fromd<0 || toy<0 || tom<0 || tod<0)break;
		printf("%d\n",getnokoridays(fromy,fromm,fromd,toy,tom,tod));
	}
	return 0;
}

Measured memory_bytes: 0
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};

int main () {
    int h, w, k; cin >> h >> w >> k;
    vector<vector<char>> mp(h, vector<char> (w));
    rep(i, h) rep(j, w) cin >> mp[i][j];
    int ans = 0;
    for (int i = 0; i < (1 << h); i++) {
        for (int j = 0; j < (1 << w); j++) {
            int cnt = 0;
            for (int l = 0; l < h; l++) {
                if ((i >> l) & 1) continue;
                for (int m = 0; m < w; m++) {
                    if ((j >> m) & 1) continue;
                    if (mp[l][m] == '#') cnt++;
                }
            }
            if (cnt == k) ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll N,T;
vector<P> ps;
ll dp[3010][3010];

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

  cin>>N>>T;
  rep(i,N){
    ll a,b;
    cin>>a>>b;
    ps.push_back(P(a,b));
  }
  sort(all(ps));

  rep(i,N+1)rep(j,T+1)dp[i][j]=-INF;
  dp[0][0]=0;
  ll res=0;
  rep(i,N)rep(j,T+1){
    maxch(dp[i+1][j],dp[i][j]);
    if(j+ps[i].fi<=T)maxch(dp[i+1][j+ps[i].fi],dp[i][j]+ps[i].se);
    if(j<T)maxch(res,dp[i][j]+ps[i].se);
  }

  rep(j,T+1)maxch(res,dp[N][j]);
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int n;
  cin >> n;
  vector<double> p(n);
  rep(i, n) {
    cin >> p[i];
  }

  vector<vector<double>> dp(n+1, vector<double>(n+1));

  dp[0][0] = 1;

  rep(i, n) {
    rep(j, i+1) {
      dp[i+1][j] += dp[i][j] * (1.0 - p[i]);
      dp[i+1][j+1] += dp[i][j] * p[i];
    }
  }

  double ans = 0;
  rep(i, n+1) {
    if (i > n-i) {
      ans += dp[n][i];
    }
  }

  printf("%.10lf\n", ans);
}


Measured memory_bytes: 70784
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define sz(x) ((int)(x).size())
#define int ll
#define el '\n'
typedef long long ll; typedef long double ld; typedef double dd;typedef vector<int> vi; typedef pair<int, int> pii;typedef pair<ll,ll> pll;
const ll INFLL=0x7f7f7f7f7f7f7f7f, MOD=1e9+7; const int INF=0x7f7f7f7f;
///if(///////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';
/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<int>> adj; vi vis, color; 
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline ll gcd(ll a, ll b){while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}


///////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());

ll n,a,b; cin>>n>>a>>b;
vv<ll> pos(n); for(int i=0;i<n;++i) cin>>pos[i];
ll ans=0;
for(int i=1;i<n;++i){
	ans+=min(b,a*(pos[i]-pos[i-1]));
}
cout<<ans<<el;

return 0;
}


Measured memory_bytes: 1024
s=input()

if s == 'SAT':
    print(1)
elif s == 'FRI':
    print(2)
elif s == 'THU':
    print(3)
elif s == 'WED':
    print(4)
elif s == 'TUE':
    print(5)
elif s == 'MON':
    print(6)
elif s == 'SUN':
    print(7)

Measured memory_bytes: 3060
//K-OS WITH THE OCDE

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <iostream>
#include <numeric>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <climits>

using namespace std;

typedef long long int ll;
typedef long double db;


#define TEST ll t; cin>>t; while(t--)
#define vell vector<ll>
#define pl pair<ll,ll>
#define all(v) v.begin(),v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define dbg(x)  cerr << #x << ": "<< x <<endl
#define dbg2(x,y) cerr<< #x <<": "<< x <<" || "<< #y << ": " << y << endl

#define endl "\n"
#define MAX 1e18
#define MIN INT_MIN
#define mod 1000000007



void solve()
{
     string s;
     cin >> s;
     ll f = 0;

     for(ll i=0 ; i<3 ; ++i) {
     	if(s[i] == 'R') {
     		ll j = i;
     		while(j < 3 && s[j] == 'R')
     			j++;

     		f = max(f , j - i);
     	}
     }

     cout << f;


}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);cin.tie(0);   
    //TEST
     solve();
}



Measured memory_bytes: 3668
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		String line;
		while ((line = reader.readLine()) != null) {
			if (line.isEmpty())
				break;
			StringTokenizer tokenizer = new StringTokenizer(line);
			double a = Double.parseDouble(tokenizer.nextToken());
			double b = Double.parseDouble(tokenizer.nextToken());
			int c = Integer.parseInt(tokenizer.nextToken());

			char[] result = String.valueOf(a / b).split("\\.")[1].toCharArray();
			int sum = 0;
			for (int i = 0; i < c && i < result.length; i++) {
				sum += result[i] - '0';
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 16988
def small(a, b):
    if a > b:
        return b
    else:
        return a


n = int(input())
h = list(map(int, input().split()))
INF = 10 ** 9
dp = [INF] * n
dp[0] = 0
for i in range(1, n):
    dp[i] = small(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
    if i > 1:
        dp[i] = small(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))
print(dp[-1])

Measured memory_bytes: 20640
import java.util.HashSet;
import java.util.Scanner;

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

        HashSet<Integer> hs = new HashSet<>();
        for(int i = 0; i < n; i++){
            hs.add(sc.nextInt());
        }

        String str = new String();
        if(hs.size() == n){
            str = "YES";
        } else{
            str = "NO";
        }

        System.out.println(str);
        sc.close();
    }
}

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

using namespace std;

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  
  if(A == B && A != C){
    puts("Yes");
  }else if(A == C && A != B){
    puts("Yes");
  }else if(B == C && A != B){
    puts("Yes");
  }else puts("No");
  
  return 0;
}

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

using namespace std;

int main(){
    int n,d;
    cin>>n>>d;
    int ans=0;
    while(n--){
        int p,q;
        cin>>p>>q;
        // p=abs(p),q=abs(q);
        long long dist=1ll*p*p+1ll*q*q;
        if(dist<=1ll*d*d){
            // cout<<dist<<endl;
            ++ans;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int n = Integer.parseInt(tokenizer.nextToken());
        String [] a = new String[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = input.readLine();
        }

        Arrays.sort(a);

        StringBuilder out = new StringBuilder();
        for (int i = 0; i < n; i++) {
            out.append(a[i]);
        }

        System.out.println(out);
    }
}


Measured memory_bytes: 20948
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	string S, T;
	cin >> S >> T;

	string ans;
	for (Int i = 0; i < N; i++) {
		ans += S[i];
		ans += T[i];
	}
	cout << ans << "\n";
}


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

int main(){
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif

	int n;
	long long x [100000];
	cin >> n;
	for(int i=0;i<n;i++){
		scanf("%lld", &x[i]);
	}
	int zero = 0;
	for(int i=0;i<n;i++){
		if(x[i]==0) zero++;
	}
	if(zero>0){
		cout << 0;
		return 0;
	}
	long long prod = 1;
	for(int i=0;i<n;i++){
		if(x[i] > (1000000000000000000/prod)){
			cout << -1;
			return 0;
		}
		prod *= x[i];
	}
	cout << prod;
	return 0;
}

Measured memory_bytes: 4552
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,w,x,y,z,a[200040],b[200040];
string s;
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout<<fixed<<setprecision(12);
	cin>>s;
	for(i=s.size();i--;)
	{
		if(s[i]<64)
		{
			if(s[i+1]^68||i&&s[i-1]==80)s[i]=68;
			else s[i]=80;
		}
	}
	cout<<s;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
const int N=1e5+5;
vector<int>v;
int n,k,a[N],ji=0,last,ans=-1,dp[N];
string s;
int main()
{
	cin>>n>>k;
	cin>>s;
	if(s[0]=='0')v.pb(0);
	last=s[0]-'0';
	for(int i=0;i<s.size();i++)
	{
		if(s[i]-'0'!=last)
		{
			v.pb(ji);
			last=s[i]-'0';
			ji=1;
		}
		else
			ji++;
	}
	v.pb(ji);
	for(int i=1;i<=v.size();i++)dp[i]=dp[i-1]+v[i-1];
	for(int i=0;i<v.size();i+=2)
	{
		int pnt=dp[min(i+2*k+1,(int)v.size())]-dp[i];
		ans=max(ans,pnt);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1272
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int d[510][510];

void f(int l,int r,int k){
	if(l+1==r)return;
	int m=(l+r)/2;
	rep(i,l,m)rep(j,m,r)d[i][j]=k;
	f(l,m,k+1);
	f(m,r,k+1);
}
int main(){
	int n;
	scanf("%d",&n);
	f(0,n,1);
	rep(i,0,n){
		rep(j,i+1,n)printf("%d ",d[i][j]);
		puts("");
	}
}

Measured memory_bytes: 1408
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
	while(true){
		int total;
		int hon;
		int booktotal=0;
		int book[9];
		int i=0;
		scanf("%d", &total);
		if(total==0) break;
		while(i<9){
			scanf("%d", &book[i]);
			booktotal = booktotal + book[i];
			i++;
		}
		hon = total - booktotal;
		printf("%d\n", hon);
	}
	return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    ll A,B,C,D;
    ll ans=0;
    ll X[4];
    string S,T;
int main(){
    cin>>A>>B;
    cout<<A-B+1;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  map<int,int> m;
  for(int i = 0; i < N; ++i){
    cin >> a[i];
    m[a[i]]++;
  }
  int cnt = 0;
  for(auto itr = m.begin(); itr != m.end(); itr++){
    if(itr->second > itr->first) cnt += itr->second - itr->first;
    if(itr->second < itr->first) cnt += itr->second;
  }
  cout << cnt << endl;

}


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

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    Integer h[]  = new Integer[n + 100];
    for (int i = 0; i < n; i++) {
      h[i]  = sc.nextInt();
    }
    int num = 0;
    for(int i = 0; i < n; i++){
      if(h[i] >= k) num ++;
    }
    System.out.println(num);
  }
}


Measured memory_bytes: 62120
#include<stdio.h>
typedef long long ll;

int main(void)
{
  ll a,b;
  int x;
  scanf("%lld %lld %d",&a,&b,&x);
  for(int i=0;i<x;i++){
    if(i%2==0||i==0){
      if(a%2==1){
        a--;
      }
      b+=a/2;
      a/=2;
    }else{
      if(b%2==1){
        b--;
      }
      a+=b/2;
      b/=2;
    }
  }

  printf("%lld %lld\n",a,b);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
  int i = 0;
  int height[10];
  int j, tmp;

  do{

    scanf("%d", &height[i]);
    if(height[i] >= 0 && height[i] <= 10000)
    i++;
  }while(i != 10);

  for(i = 0; i < 9; i++){
    for(j = i+1; j < 10; j++){
      if(height[i] <= height[j]){
	tmp = height[i];
	height[i] = height[j];
	height[j] = tmp;
      }
    }
  }

  for(i = 0; i < 3; i++)
    printf("%d\n", height[i]);

  return 0;
}

Measured memory_bytes: 600
import sys
input = sys.stdin.readline

from collections import deque


S = deque(input().strip())
q = int(input())

cnt = 0
for _ in range(q):
    query = input().strip()
    if query == "1":
        cnt += 1
    else:
        t, f, c = query.split()
        if cnt % 2 == 0:
            if f == "1":
                S.appendleft(c)
            else:
                S.append(c)
        else:
            if f == "1":
                S.append(c)
            else:
                S.appendleft(c)
ans = "".join(S)

print(ans if cnt % 2 == 0 else ans[::-1])


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

using namespace std;
double n,D,x,y,d;
int nr,i;
int main()
{
    cin>>n>>D;
    for(i=1;i<=n;i++)
    {
        cin>>x>>y;
        d=sqrt(x*x+y*y);
        if(d<=D)
            nr++;

    }
    cout<<nr;
    return 0;
}


Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
int main() {
    int H,W;
    cin>>H>>W;
    vector<vector<char>> S(H,vector<char>(W));
    int dx[8]={0,1,1,1,0,-1,-1,-1};
    int dy[8]={1,1,0,-1,-1,-1,0,1};//周りの座標

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>S.at(i).at(j);//初期座標入力
        }
    }

    vector<vector<char>> ans(H,vector<char>(W,0));//答えの配列
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(S[i][j]=='#'){//＃変えない
                cout<<'#';
                continue;
            }
            int count=0;
            for(int k=0;k<8;k++){//９×９
                int ni=i+dx[k];
                int nj=j+dy[k];
                
                if(ni<0 or ni>=H or nj<0 or nj>=W){//範囲外は無視
                    continue;
                }
                if(S[ni][nj]=='#'){//#を数える
                    count++;
                }
            }
            cout<<count; 
        }
        cout<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
from math import sqrt
def distance(a,b):
    return sqrt((a[0]-b[0])**2+(a[1]-b[1])**2)

N=int(input())
towns=[tuple(map(int,input().split())) for _ in range(N)]
ave=0
for i in range(N-1):
    for j in range(i,N):
        ave+=distance(towns[i],towns[j])
ave=ave/(N*(N-1)/2)
print(ave*(N-1))

Measured memory_bytes: 3064