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

class Main
{
    public static void main(String[] args) throws java.io.IOException
    {
        Scanner in = new Scanner(System.in);
        int H = in.nextInt();
        int W = in.nextInt();
        in.nextLine();

        char[][] S = new char[H][W];

        for (int i = 0; i < H; i++) {
            S[i] = in.nextLine().toCharArray();
        }

        int[] ns = {-1, 0, 1};
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (S[i][j] == '#') continue;
                int sum = 0;
                for (int k : ns) {
                    if (i + k < 0 || i + k >= H) continue;
                    for (int l : ns) {
                        if (j + l < 0 || j + l >= W) continue;
                        if (S[i + k][j + l] == '#') sum++;
                    }
                }
                S[i][j] = (char) ('0' + sum);
            }
        }

        for (int i = 0; i < H; i++)
            System.out.println(S[i]);
    }
}

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

using namespace std;

#define si(x) scanf("%d",&x);
#define SZ 109

int grid[SZ][SZ] = {0};
int R, C, N, A;
int I = 0, J = 0;

void put(int color, int cnt)
{
    while(cnt--)
    {
        grid[I][J] = color;
        if(I % 2) J--;
        else J++;
        if(J < 0) J++, I++;
        else if(J >= C) J--, I++;
    }
}

int main()
{
    cin >> R >> C >> N;
    for(int i = 0; i < N; i++)
    {
        si(A);
        put(i + 1, A);
    }
    for(int i = 0; i < R; i ++)
    {
        for(int j = 0; j < C; j++)
        {
            printf("%d ", grid[i][j]);
        }
        printf("\n");
    }
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main()
{
	char str[200];
	scanf("%s", &str);
	str[strlen(str) - 1] = '\0';

	do {
		if (strlen(str) % 2 == 1) {
			str[strlen(str) - 1] = '\0';
		}
		else {
			for (int i = 0; i < strlen(str) / 2; i++) {
				if (str[i] == str[(strlen(str) / 2)+i]) {
					if (i == strlen(str) / 2 - 1) {
						printf("%d",strlen(str));
						return 0;
					}
				}
				else {
					break;
				}
			}
			str[strlen(str) - 1] = '\0';
		}

	} while (1);

}

Measured memory_bytes: 128
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;

int main(void){
	char c;
	scanf(" %c",&c);
	c++;
	printf("%c\n",c);
	
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main(void) {
	int n;
	cin >> n;
	vector<int> p(n), q(n), a(n);
	for (int i = 0; i < n; ++i) cin >> p[i];
	for (int i = 0; i < n; ++i) cin >> q[i];
	iota(a.begin(), a.end(), 1);

	int cnt = 0, P = 0, Q = 0;
	do {
		if (a == p) P = cnt;
		if (a == q) Q = cnt;
		++cnt;
	} while (next_permutation(a.begin(), a.end()));
	cout << abs(P - Q);
	return 0;
}

Measured memory_bytes: 256
import Data.Bits
import qualified Data.ByteString.Char8 as C
import qualified Data.Vector.Unboxed as U

main = C.interact $ put . sol . get

get = U.unfoldr (C.readInt . C.dropWhile (<'0'))

put = C.unwords . fmap (C.pack . show) . U.toList

sol v = U.map (xor p) u
  where
  u = U.tail v
  p = U.foldl1' xor u

Measured memory_bytes: 39108
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def calc(bits, P, C, G):
    total = 0
    cnt = 0
    p = P[:]
    i = 0
    while bits > 0:
        if bits % 2:
            total += p[i] * (i + 1) * 100 + C[i]
            cnt += p[i]
            p[i] = 0
        bits >>= 1
        i += 1
    if total >= G:
        return cnt

    for i in range(len(p)-1, -1, -1):
        if p[i] != 0: break
    need = math.ceil((G - total) / ((i + 1) * 100))
    if need <= p[i]:
        return cnt + need
    return float("inf")



def main():
    D, G = MI()
    P = [None] * D
    C = [None] * D
    for i in range(D):
        P[i], C[i] = MI()

    ans = sum(P)
    for bits in range(2 << (D-1)):
        ans = min(ans, calc(bits, P, C, G))
    return ans



if __name__ == "__main__":
    print(main())


Measured memory_bytes: 6276
import functools
import math

n, x_init = map(int, input().split())
x = list(map(int, input().split()))
x.append(x_init)
x.sort()

dist_next = []
for i in range(n):
    dist_next.append(x[i + 1] - x[i])

ans = functools.reduce(math.gcd, dist_next)
print(ans)


Measured memory_bytes: 20556
#include <cstdio>
using namespace std;

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

    long long int ofs = 0;
    for(int i=N-1; i>=0; i--) {
        A[i] += ofs;
        if(A[i] <= B[i]) ofs += (B[i] - A[i]) % B[i];
        else {
            long long int mo = A[i] % B[i];
            ofs += (B[i] - mo) % B[i];
        }
    }
    printf("%lld\n", ofs);
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=200010,INF=2000000000;
ll a[N];
ll dp[N][2];
ll n;
template<class T>
T mx(T a,T b){
	if(a>b) return a;
	return b;
}
int main()
{
	//freopen("in.txt","r",stdin);
	scanf("%lld",&n);
	for(ll i=1;i<=n;++i) scanf("%lld",&a[i]);
	for(ll i=0;i<=n;++i){
		for(ll j=0;j<3;++j){
			dp[i][j]=-(ll)INF*INF;
		}
	}
	if(n&1){
		dp[1][0]=a[1];
		for(ll i=3;i<=n;i+=2) dp[i][0]=dp[i-2][0]+a[i];
		dp[2][1]=a[2];
		for(ll i=4;i<=n;i+=2) dp[i][1]=mx(dp[i-2][1],dp[i-3][0])+a[i];
		dp[3][2]=a[3];
		for(ll i=5;i<=n;i+=2) dp[i][2]=mx(mx(dp[i-2][2],dp[i-3][1]),dp[i-4][0])+a[i];
		printf("%lld",mx(mx(dp[n][2],dp[n-1][1]),dp[n-2][0]));
	}
	else{
		dp[1][0]=a[1];
		for(ll i=3;i<=n;i+=2) dp[i][0]=dp[i-2][0]+a[i];
		dp[2][1]=a[2];
		for(ll i=4;i<=n;i+=2) dp[i][1]=mx(dp[i-2][1],dp[i-3][0])+a[i];
		printf("%lld",mx(dp[n][1],dp[n-1][0]));
	}
}

Measured memory_bytes: 8528
use proconio::input;

fn main() {
    input! {
        n: u32,
        m: u32
    }
    input! {
        a: [u32; m]
    }
    let total: u32 = a.iter().sum();
    if total > n {
        println!("-1");
        return;
    }
    println!("{}", n - total);
}


Measured memory_bytes: 2208
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;

int main(void) {
    int N,M;cin>>N>>M;
    set<int> ship1_terminal,ship2_start;
    for (int i = 0; i < M; i++) {
        int a,b;cin>>a>>b;
        if (a > 1 && b < N) continue;
        if (a == 1 && b < N) ship1_terminal.insert(b);
        else if (a > 1 && b == N) ship2_start.insert(a);
    }
    set<int> result;
    set_intersection(ship1_terminal.begin(), ship1_terminal.end(),
    ship2_start.begin(), ship2_start.end(), inserter(result, result.end()));

    if (result.size() > 0) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

int main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int a[4]; memset(a, -1, sizeof a);
	int n, m; cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int s, c; cin >> s >> c;
		if(a[s] != c && a[s] != -1) {
			cout << -1 << '\n';
			return 0;
		}

		a[s] = c;
	}

	if(n != 1 && a[1] == 0) {
		cout << -1 << '\n';
		return 0;
	}

	for(int i = 1; i <= n; i++) {
		if(a[i] == -1)
			a[i] = ((n > 1 && i == 1) ? 1 : 0);
		cout << a[i];
	}
	cout << '\n';

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			int n = sc.nextInt();
			int m = sc.nextInt();

			if ((n | m) == 0) {
				break;
			}

			int y[] = new int[n];
			for (int i = 0; i < n; i++) {
				y[i] = sc.nextInt();
			}
			Arrays.sort(y);

			int ans = 0;
			for (int i = 0; i < n; i++) {
				if ((i + 1) % m != 0) {
					ans += y[y.length - 1 - i];
				}
			}
			System.out.println(ans);
			
		}

	}

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define ll long long int
#define inv(name,Type,size) vector<Type> name(size);for(int index=0;index<n;index++) cin>>name[index];
#define F(a,n,i) for(int i=a;i<n;i++)
#define pb push_back
#define endl "\n"
#define mod 10000000007
#define modpro 99824435
using namespace std;

void solve(){
	int n;
	cin>>n;
	vector<pair<int,int>> v(n);
	F(0,n,i){
		cin>>v[i].first;
		v[i].second=i+1;
	}
	sort(v.begin(),v.end());
	F(0,n,i){
		cout<<v[i].second<<" ";
	}
}
int main()
{
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
  //int t;cin>>t;while(t--) solve(),cout<<endl;
  solve();
}



Measured memory_bytes: 3952
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	ll stps = x / d;
	if(stps >= k) {
		cout << x - d * k << '\n';
	} else {
		x %= d;
		k -= stps;
		debug(x, k);
		if(k & 1) x = (d - x);
		cout << x << '\n';
	}
}



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

int main() {
	string s;
	cin >> s;
	if(s == "Sunny") cout << "Cloudy"; 
	
	if(s == "Cloudy") cout << "Rainy";

	if(s == "Rainy") cout << "Sunny";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}

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

  string ans = "Three";
  for (int i = 0; i < N; i++)
  {
    char S;
    cin >> S;
    if (S == 'Y')
    {
      ans = "Four";
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		ArrayList<ArrayDeque<Integer>> lists = new ArrayList<>();
		for (int i = 0; i < n; i++) {
		    lists.add(new ArrayDeque<>());
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < m; i++) {
		    int type = sc.nextInt();
		    if (type == 0) {
		        lists.get(sc.nextInt()).add(sc.nextInt());
		    } else if (type == 1) {
		        int idx = sc.nextInt();
		        if (lists.get(idx).size() > 0) {
		            sb.append(lists.get(idx).peek()).append("\n");
		        }
		    } else {
		        int idx = sc.nextInt();
		        if (lists.get(idx).size() > 0) {
		            lists.get(idx).poll();
		        }
		    }
		}
		System.out.print(sb);
	}
}



Measured memory_bytes: 170000
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
//const long long mod = 998244353;


int main() {
	int A, B;
	scanf("%d %d", &A, &B);
	if ((A + B) % 2) {
		printf("IMPOSSIBLE");
	}
	else {
		printf("%d", (A + B) / 2);
	}
	return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

//    String nyuA=sc.nextLine();
 
      String[] t=sc.nextLine().split(" ");

//int n=Integer.parseInt(nyu);

int K=Integer.parseInt(t[0]);
int S=Integer.parseInt(t[1]);


//long H=Long.parseLong(t[0]);
//long W=Long.parseLong(t[1]);
//long C=Long.parseLong(t[2]);

//boolean[][] data=new boolean[H][W];

int count=0;
br:
for(int i=0;i<=K;i++){
for(int j=0;j<=K;j++){
int k=S-i-j;
if(0<=k && k<=K){
count++;
}
}
}


System.out.println(count);

	}
}

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

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())

ans = 0
for i in range(K):
    tmp = 1
    for j in range(i+K, N, K):
        if T[j] == T[j-K]:
            tmp += 1
        else:
            tmp = -(-tmp // 2)
            if T[j-K] == "r":
                tmp *= P
            elif T[j-K] == "s":
                tmp *= R
            else:
                tmp *= S
            ans += tmp
            tmp = 1

        if j + K >= N:
            tmp = -(-tmp // 2)
            if T[j] == "r":
                tmp *= P
            elif T[j] == "s":
                tmp *= R
            else:
                tmp *= S
            ans += tmp
    if i + K >= N:
        if T[i] == "r":
            tmp *= P
        elif T[i] == "s":
            tmp *= R
        else:
            tmp *= S
        ans += tmp

print(ans)


Measured memory_bytes: 4084
import sys
import bisect

def main():
    input = sys.stdin.buffer.readline
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    B = list(map(int, input().split()))
    B.sort()
    C = list(map(int, input().split()))
    C.sort()
    ans = 0
    for i in B:
        a = bisect.bisect_left(A, i)
        c = bisect.bisect_right(C, i)
        ans += a*(N-c)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 27624
#include <stdio.h>

int main()
{
	int N;
	float A[100];
	float gyaku = 0;
	scanf("%d", &N);
	for (int i = 0; i <= N-1; i++) {
		scanf("%f", &A[i]);
		gyaku = gyaku + 1 / A[i];
	}
	printf("%6f", 1 / gyaku);
}


Measured memory_bytes: 128
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int N, M, cant, a, b; bool ok = true; vector<bool> vis; vector<vector<int> > G;
bool dfs(int pos) {
	if (pos == a || pos == b) return true;
	vis[pos] = true;
	for (int i : G[pos]) {
		if (i != cant && !vis[i] && dfs(i)) {
			return true;
		}
	}
	return false;
}
int main() {
	cin >> N >> M;
	G.resize(N);
	for (int i = 0; i < M; ++i) {
		cin >> a >> b; --a, --b;
		if (a != 0 && b != 0) {
			G[a].push_back(b);
			G[b].push_back(a);
			bool ok = true;
			for (int j = 1; j < N; ++j) {
				vis = vector<bool>(N, false);
				cant = j;
				if (!dfs(0)) {
					ok = false;
				}
			}
			cout << (ok ? "Yes" : "No") << endl;
		}
		else {
			if (a > b) swap(a, b);
			vis = vector<bool>(N, false);
			a = -1; cant = -1;
			cout << (dfs(0) ? "Yes" : "No") << endl;
			G[0].push_back(b);
			G[b].push_back(0);
		}
	}
	return 0;
}


Measured memory_bytes: 3240
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18, MAX_N = 200000;

lint N, arr[100000], sum = 0;
priority_queue<lint> mns, pls, zero;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	REP(i, N) {
		cin >> arr[i];
		if (arr[i] > 0) pls.push(-arr[i]);
		else if (arr[i] < 0) mns.push(arr[i]);
		else zero.push(0);
		sum += abs(arr[i]);
	}
	if (SZ(pls) == N) {
		lint minv = -pls.top(); pls.pop();
		cout << sum - 2 * minv << endl;
		lint tmp = minv;
		REP(i, N - 2) {
			cout << tmp << " ";
			pls.pop();
			cout << -pls.top() << endl;
			tmp += pls.top();
		}
		cout << minv << " " << tmp << endl;
	}
	else if (SZ(mns) == N) {
		cout << sum + 2 * mns.top() << endl;
		lint tmp = mns.top();
		REP(i, N - 1) {
			cout << tmp << " ";
			mns.pop();
			cout << mns.top() << endl;
			tmp -= mns.top();
		}
	}
	else {

		if (SZ(pls) == 0 && SZ(mns) == 0) {
			REP(i, SZ(zero) - 1) pls.push(0);
			mns.push(0);
		}
		else if (SZ(pls) == 0) {
			REP(i, SZ(zero)) pls.push(0);
		}
		else {
			REP(i, SZ(zero)) mns.push(0);
		}
		cout << sum << endl;
		lint ld = -pls.top();
		lint tmp = mns.top();
		REP(i, SZ(pls) - 1) {
			cout << tmp << " ";
			pls.pop();
			cout << -pls.top() << endl;
			tmp -= -pls.top();
		}
		cout << ld << " " << tmp << endl;
		ld -= tmp;
		tmp = ld;
		REP(i, SZ(mns) - 1) {
			cout << tmp << " ";
			mns.pop();
			cout << mns.top() << endl;
			tmp -= mns.top();
		}
	}
}


Measured memory_bytes: 4724
#include <stdio.h>

int main(void) {

	int h,w,i,j;
	while(1){
		scanf("%d%d",&h,&w);
		if(h==0 && w==0){
			break;
		}
		i=h;
		j=w;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
	string s;
	while (cin >> s) {
		vector<int> d(10, 0);
		for (int i = 0; i < s.size(); i++) {
			d[s[i]-'0']++;
		}
		/*for (int i = 0; i < 10; i++) {
			cout << i << ' ' << d[i] << endl;
		}*/
		vector<int> v;
		for (int i = 1; i < 10; i++) {
			if (d[i] < 4) {
				vector<int> e = d;
				e[i]++;
				/*for (int j = 1; j < 10; j++) {
					cout << j << ' ' << e[j] << endl;
				}*/
				for (int j = 1; j < 10; j++) {
					if (e[j] > 1) {
						bool h = true;
						vector<int> f = e;
						f[j] -= 2;
						//cout << i << ' ' << j << ' ';
						//cout << f[1] << ' ';
						for (int k = 1; k < 10; k++) {
							if (f[k] >= 3) {
								f[k] -= 3;
								k--;
							} else if (f[k] == 0) {
							} else if (k < 8) {
								if (f[k] == 1 && f[k+1] >= 1 && f[k+2] >= 1) {
									f[k]--;
									f[k+1]--;
									f[k+2]--;
								} else if (f[k] == 2 && f[k+1] >= 2 && f[k+2] >= 2) {
									f[k] -= 2;
									f[k+1] -= 2;
									f[k+2] -= 2;
								} else {
									//cout << k << endl;
									h = false;
									break;
								}
							} else {
								//cout << k << endl;
								h = false;
								break;
							}
						}
						if (h) {
							v.push_back(i);
							break;
						}
					}
				}
			}
		}
		if (v.size() == 0) {
			cout << 0 << endl;
		} else {
			cout << v[0];
			for (int i = 1; i < v.size(); i++) {
				cout << ' ' << v[i];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int InN, L, total;
  string stN, stDig; 
  cin >> InN;
  stN = to_string(InN);
  L = stN.size();

  vector<int>indig(L);            
  for(int i = 0;i < L;i++){     
  stDig = stN.at(i);
  indig.at(i) = atoi(stDig.c_str()); 
  total = total + indig.at(i);
  }
  
  if(InN % total == 0){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
}

Measured memory_bytes: 256
def main():
    INF = 1 << 30

    N, K = map(int, input().split())
    *A, = (int(x) - 1 for x in input().split())

    dist = [INF] * N
    dist[0] = 0

    cur = A[0]
    d = 1
    while dist[cur] == INF:
        dist[cur] = d
        d += 1
        cur = A[cur]

    if K <= d - 1:
        for i, x in enumerate(dist, start=1):
            if x == K:
                print(i)
                return

    if K == d:
        print(cur + 1)
        return

    K -= d
    loop_range = d - dist[cur]
    K %= loop_range
    for _ in range(K):
        cur = A[cur]
    print(cur + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 32408
ntlist = list(map(int, input().split()))
n,t = ntlist[0], ntlist[1]

c = 10**10
for i in range(n):
    inputlist = list(map(int, input().split()))
    if inputlist[1] <= t:
        if inputlist[0] <= c:
            c = inputlist[0]
print(c) if c != 10**10 else print('TLE')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A; int B; cin>>A>>B;
  if(A==2){
    if(B==2)
      cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  else if(A==4||A==6||A==9||A==11){
    if(B==4||B==6||B==9||B==11)
      cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  else{
    if(B==1||B==3||B==5||B==7||B==8||B==10||B==12)
      cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3636
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a,b,gyo0=0,gyo1=0,re0=0,re1=0,h,w,count;
    string s;
    cin>>a;
    cout<<800*a-a/15*200;
    return(0);
}


Measured memory_bytes: 256
//Swapping Two Numbers
#include <iostream>
using namespace std;

int main(){

int x, y;

while (1){
        cin >> x >> y;
        if (x == 0 && y ==0 ) break;
        if (x > y) cout << y << " " << x << endl;
        else       cout << x << " " << y << endl;
        }
}

Measured memory_bytes: 1160
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

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

    vector<ll> a(n,0);
    rep(i,n)cin>>a[i];

    rep(ii,k){
        vector<ll> b(n,0);
        rep(i,n){
            ll m1 = max(0ll,i-a[i]);
            ll m2 = min(n-1,i+a[i]);
            b[m1]++;
            if(m2+1<n)b[m2+1]--;
        }
//        rep(i,n){
//            cout<<b[i]<<" ";
//        }

        ll sum = b[0];

        for(int i=1;i<n;i++){
            b[i]+=b[i-1];
            sum+=b[i];
        }

      
        if(sum==n*n){
            rep(i,n){
                cout<<n<<" ";
            }
            cout<<endl;
            return 0;
        }
        a=b;
    }

    rep(i,n){
        cout<<a[i]<<" ";
    }
    cout<<endl;



return 0;
}


Measured memory_bytes: 6400
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

ants = [a, b, c, d, e]
txt = 'Yay!'

for i in range(len(ants)):
    for j in range(len(ants)):
        if i != j and abs(ants[i] - ants[j]) > k:
            txt = ':('

print(txt)

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


int main(){
    int M = 998244353;
    int N;
    cin >> N;

    long long D[N];
    map<int, int> m;
    for (int i = 0; i < N; i++) {
        cin >> D[i];
        m[D[i]]++;
    }
    long long res = 0;
    if (m[0] != 1) {
        res = 0;
    }else{
        res = 1;
        for (int i = 1; i < N; i++) {
            res *= m[D[i] - 1];
            res %= M;
        }
    }
 
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
const int maxn=2e5+7;

int main()
{
    ll n,x,y;
    cin>>n>>x>>y;
    ll t1=x,t2=y;
    for(int i=1;i<n;i++){
        ll a,b;
        cin>>a>>b;
        ll tmp1=t1/a,tmp2=t2/b;
        if(t1%a!=0) tmp1++;
        if(t2%b!=0) tmp2++;
        ll t;
        t=max(tmp1,tmp2);
        t1=a*t,t2=b*t;
    }
    cout<<t1+t2<<endl;
    return 0;
}


Measured memory_bytes: 256
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
a,b=map(int,input().split())
c=b-a
print((c*(1+c))//2-b)

Measured memory_bytes: 72940
#include <iostream>


using namespace std;

int main()
{
	long long a, b, c, d;
	
	long long sum = 0;
	
	cin>>a>>b>>c>>d;
	
    if (a <= d){
		sum +=a;
	}else {
		sum +=d;
		cout<<sum;
		return 0;
	}	
	
	d = d-a;
	
	if (d == 0){
		cout<<sum;
		return 0;
	}
	
	if (d <= b){
		cout<<sum;
		return 0;
	}
	
	d = d - b;
	
	if (d <= c){
		sum -=d;
	}
	cout<<sum;
	
	return 0;
}


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

signed main(){
	int N,Y; cin>>N>>Y;
	int j=-1,k=-1;
	for(j=0;j<=N;j++){
		if((Y-1000*N-4000*j)%9000==0 && (Y-1000*N-4000*j)>=0 && N-j-(Y-1000*N-4000*j)/9000>=0){
			k=(Y-1000*N-4000*j)/9000;
			break;
		}
	}
	cout<<k<<' '<<(k!=-1? j : -1)<<' '<<(k!=-1 ? N-j-k : -1)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
const int maxn=(int)1e4+10;
const int maxd=100+10;
const int mod=(int)1e9+7;
char s[maxn];
long long dp[maxn][maxd];
long long dp2[maxn][maxd];
int n,d;
  
long long modu(long long a, long long b, long long m){ return (a+b+10*m)%m; }

int main()
{
	scanf("%s",s+1);
	scanf("%d",&d);
	n=strlen(s+1);
	reverse(s+1,s+n+1);
	dp[0][0]=1;
	for(long long i=1;i<=n;i++)
		for(long long j=0;j<d;j++)
			for(long long k=0;k<=9;k++)
				dp[i][j]=modu(dp[i][j],dp[i-1][modu(j,-k,d)],mod);
	dp2[0][0]=1;
	for(long long i=1;i<=n;i++)
	{
		for(long long j=0;j<d;j++)
		{
			for(long long k=0;k<(s[i]-'0');k++)
				dp2[i][j]=modu(dp2[i][j],dp[i-1][modu(j,-k,d)],mod);
			dp2[i][j]=modu(dp2[i][j],dp2[i-1][modu(j,-(long long)(s[i]-'0'),d)],mod);
		}
	}
	printf("%lld",modu(dp2[n][0],mod-1,mod));
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
#define BIGINF (int) 4e18 + 7
#define MOD7 1000000007
#define MOD9 1e9 + 9
#define INF  (int)2e9 + 7
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
typedef long long ll;
typedef long double ld;
typedef string str;
typedef double d;
typedef unsigned u;
typedef unsigned long long ull;

const int N = 1005;



int main () {
    //freopen("inputf.txt", "r", stdin);
    //freopen("outputf.txt", "w", stdout);
    int h, w;
    char mat[N][N];
    SCD(h);
    SCD(w);
    getchar();
    for (int i = 0; i < h; i++) {
    	for (int j = 0; j < w; j++) {
    		SCC(mat[i][j]);
    	}
    	getchar();
    }
    long long dp[N][N];
 	memset(dp, 1, sizeof(dp));
 	bool show = false; 
 	for (int i = 0; i < h; i++) {
 		if (mat[i][0] == '#' || show) {
 			dp[i][0] = 0;
 			show = true;
 		}
 		else  dp[i][0] = 1;
 	}
 	show = false;
 	for (int i = 0; i < w; i++) {
 		if (mat[0][i] == '#' || show) {
 			dp[0][i] = 0;
 			show = true;
 		}
 		else  dp[0][i] = 1;
 	}

 	for (int i = 1; i < h; i++) {
 		for (int j = 1; j < w; j++) {
 			dp[i][j] = 0;
 			if (mat[i][j] == '.') {
 				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD7;
 			}
 			else {
 				dp[i][j] = 0;
 			}
 		}
 	}
 	printf("%lld", dp[h - 1][w - 1]);


    return 0;
}



Measured memory_bytes: 9216
N,M=map(int,input().split())
X=list(map(int,input().split()))
X.sort(key=int)
p=[0]*M
for i in range(1,M): p[i]=X[i]-X[i-1]
p.sort(key=int)
for i in range(min(N-1,M)): p.pop(-1)
print(sum(p))

Measured memory_bytes: 13960
import math

n=int(input())
 
def diffs(n):
  total=0
  for k in range(1,n):
    for l in range(k+1,n):
      total+=math.gcd(n,math.gcd(k,l))*6
  for k in range(1,n):
    total+=math.gcd(n,k)*6
  total += n
  return total

sum=0
for i in range(1,n+1):
  sum += diffs(i)

print(sum)

Measured memory_bytes: 9200
from math import log2
n = int(input())
x,y,f,ans,c = [0]*30,[0]*30,1,0,1
for i in range(n):
    a = int(input())
    y[int(log2(a&(-a)))],s = 1,bin(a)[2:][::-1]
    for j in range(len(s)): x[j]+=int(s[j])
for i in range(29,-1,-1):
    if (f and x[i]%2) or (1-f and 1-x[i]%2):
        if y[i]: f,ans = 1-f,ans+1
        else: c = 0
if c: print(ans)
else: print(-1)

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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define REP64(i, s,  n) for(int64 i = s;i < (n);i++)
#define INF 999999999
#define MOD 1000000007
using namespace std;

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

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

int64 N,P;

map<int64, int64> A;	// 特定の数　→　何乗か
						// 例：　A[2] = 3　→　２の３乗が含まれる
void calc(int64 x) {
	// ２　から　変数の２乗が元数以下の間、繰り返す
	int64 w = x;
	for(int64 i = 2; i * i <= x;  i++) {
		while(w % i == 0) {
			A[i]++;
			w /= i;
		}
	}
	// 最後に残った数も含める
	A[w]++;
}

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

	cin >> N >> P;
	
	calc(P);
	
	int64 ans = 1;
	int64 w;
	for(auto a : A) {
		w = a.second / N;
		while(w > 0) {
			ans *= a.first;
			w--;
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define N 200000

int main() {
	static char s[N + 1];
	int n, i, j, i_, j_, max, min;

	scanf("%s", s);
	n = strlen(s);
	min = 1000000;
	i_ = -1;
	for (i = 0; i < n; i++)
		if (s[i] == 'A' && min > i)
			min = i_ = i;
	max = 0;
	j_ = -1;
	for (j = n - 1; j >= i_ + 1; j--)
		if (s[j] == 'Z' && max < j)
			max = j_ = j;
	printf("%d\n", j_ - i_ + 1);
	return 0;
}


Measured memory_bytes: 384
a = list(map(int,input().split()))
b = [1,3,5,7,8,10,12]
c = [4,6,9,11]
d = [2]
e = 0

if a[0] in b and a[1] in b:
  e += 1
elif a[0] in c and a[1] in c:
  e += 1

if e == 1:
  print("Yes")
else:
  print("No")

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

int main(){
    int a,b,sum=0;
    cin>>a>>b;
    if(a<b){
        sum+=b;
        b--;
    }else{
        sum+=a;
        a--;
    }
    sum+=max(a,b);
    cout<<sum;
    
}

Measured memory_bytes: 256
fun main() {
    val input = readLine()!!.split(" ").map { it.toInt() }
    val n = input[0]
    val m = input[1]

    val resultMap = HashMap<Int, Int>()
    for (i in (1..n)) {
        resultMap[i] = 0
    }

    for (i in 0 until m) {
        val ab = readLine()!!.split(" ").map { it.toInt() }
        resultMap[ab[0]] = resultMap[ab[0]]!! + 1
        resultMap[ab[1]] = resultMap[ab[1]]!! + 1
    }

    for (x in resultMap) {
        println(x.value)
    }
}

Measured memory_bytes: 36516
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

int n;
int a[2005];
bitset <4000005> bs;

int main() {
	scanf("%d", &n);
	rep(i, n) scanf("%d", &a[i]);
	bs.set(0);
	int sm = 0;
	rep(i, n) bs |= bs << a[i], sm += a[i];
	int ans = (sm + 1) >> 1;
	while (!bs.test(ans)) ++ ans;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1664
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 998244353
def POW(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x
    elif y % 2 == 0:
        return POW(x, y // 2) ** 2 % MOD
    else:
        return POW(x, y // 2) ** 2 * x % MOD
def mod_factorial(x, y): return x * POW(y, MOD - 2) % MOD
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import Counter

def main():
    N = II()
    H = LI()
    ma = 0
    ans = 0
    for h in H:
        if ma <= h:
            ans += 1
            ma = h

    return ans

print(main())

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	int N; cin >> N;
	if(N == 1) cout << "Hello World" << endl;
	else{
		int a, b; cin >> a >> b;
		cout << a+b << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 1005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        char ch;
        int y, m, d;
        cin >> y >> ch >> m >> ch >> d;
        if (y > 2019) cout << "TBD\n";
        else if (y == 2019 && m > 4) cout << "TBD\n";
        else if (y == 2019 && m == 4 && d > 30) cout << "TBD\n";
        else cout << "Heisei\n";
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int w = Integer.parseInt(sc.next());
		for(int i = 0; i < s.length(); i+=w) {
		System.out.print(s.charAt(i));
		}
	}
}

Measured memory_bytes: 36012
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    s = input().strip()
    slen = len(s)

    ans1 = 0
    for i in range(slen):
        if s[i] != str(i%2):
            ans1 += 1
    ans2 = 0

    for i in range(slen):
        if s[i] != str((i+1)%2):
            ans2 += 1
    
    print(min(ans1, ans2))

solve()


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

int main(){ 
    long long a,b,k; cin>>a>>b>>k;
    if(k<=a){
        cout<<a-k<<' '<<b<<endl;
    }else if(k<=a+b){
        cout<<0<<' '<<a+b-k<<endl;
    }else cout<<0<<' '<<0<<endl;
    return 0;
    }

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#define SIZE 200005
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll inv[SIZE],fac[SIZE],finv[SIZE];
void make()
{
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<SIZE;i++)
	{
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		fac[i]=fac[i-1]*(ll) i%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}
ll C(int a,int b)
{
	if(a<b) return 0;
	return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}
ll mpow(ll x,ll t)
{
	if(t==0) return 1;
	ll ret=mpow(x,t/2);
	ret=ret*ret%MOD;
	if(t%2==1) ret=ret*x%MOD;
	return ret;
}
int main()
{
	make();
	int n,A,B,DC;
	scanf("%d %d %d %d",&n,&A,&B,&DC);
	ll pa=(ll) A*inv[A+B]%MOD,pb=(ll) B*inv[A+B]%MOD;
	ll ret=0;
	for(int k=0;k<n;k++)
	{
		ret+=C(k+n-1,k)*mpow(pb,k)%MOD*mpow(pa,n)%MOD*(ll) (k+n)%MOD;
		ret+=C(k+n-1,k)*mpow(pa,k)%MOD*mpow(pb,n)%MOD*(ll) (k+n)%MOD;
		ret%=MOD;
	}
	//printf("%lld\n",ret);
	ret=ret*inv[A+B]%MOD*100LL%MOD;
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;


int N, K;

string S;



int main()
{
	int ans = 0;

	cin >> N;
	cin >> K;

	cin >> S;

	vector<int>B = vector<int>();

	int b = - K;
	if (S.at(0) == '0') { b++; }

	for (int i = 0;i<N; i++) {
		if (i>0 && S.at(i - 1) == '1' && S.at(i) == '0') {
			if (b >= 0) {
				B.at(b) = i - B.at(b);
			}
			b++;
		}
		else if (i == 0 || S.at(i - 1) == '0' && S.at(i) == '1') {
			B.push_back(i);
		}

	}

	b = max(b,0);
	while (b<(int)B.size()) {
		B.at(b) = N - B.at(b);
		b++;
	}

	for (int i = 0; i < (int)B.size(); i++) {
		ans = max(ans, B.at(i));
	}

	cout << ans << endl;

	return 0;
}


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

int main(){
	int n, rst;
	char k;
	cin>>rst;
	while(1){
		cin>>k;
		if(k=='=') break;
		cin>>n;
		switch(k){
			case '+':
				rst+=n;
				break;
			case '-':
				rst-=n;
				break;
			case '*':
				rst*=n;
				break;
			case '/':
				rst/=n;
				break;
		}
	}
	cout<<rst<<endl;
	return 0;
}


Measured memory_bytes: 3068
import java.util.Scanner;






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

}



Measured memory_bytes: 26184
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
int top,s[1000];
int pop(){
	top--;
	return s[top+1];
}
int push(int a){
	s[++top]=a;
}
int main(){
	int b,a;
	top=0;
	char c[3];
	while(cin>>c){
		if(c[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}
		else if(c[0]=='-'){
			a=pop();
			b=pop();
			push(b-a);
		}
		else if(c[0]=='*'){
			a=pop();
			b=pop();
			push(a*b);
		}
		else{
			push(atoi(c));
		}
	}
	cout<<pop()<<endl;
	return 0;
}



Measured memory_bytes: 3100
import sys
import math
import itertools


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, K = map(int, input().split())

    ans =0
    for i in range(1,N+1):
        if i>K:
            ans += (N-i+1)/N
            break
        else:
            s =math.ceil(math.log2(K/i))
        ans +=(0.5 **s ) /N

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 65216
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  double R1,R2;
  cin >> R1 >> R2;
  double S1 = 1/R1;
  double S2 = 1/R2;
  double S3 = S1 + S2;
  double R3 = 1/S3;
  cout << R3 << endl;
  return 0;
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(200005);
int main(){
    ll n,m,k;
    cin >> n >> m >> k;
    mint p = comb(n*m -2 ,k -2);
    mint sum = 0;
    for(int k = 1; k < m; k++){
        sum += k*(m-k)*n*n;
    }
    for(int k = 1; k < n; k++){
        sum += k*(n-k)*m*m;
    }

    sum *= p;

    cout << sum << endl;

}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <map>
#include <set>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;

const int MAX_H = 200000;
int H, W;
vector<int> A(MAX_H), B(MAX_H);

int main() {
  cin >> H >> W;
  rep(i, H) {
   cin >> A[i] >> B[i];
  }
  
  // map[現在位置] = 開始位置
  map<int, int> mp;
  rep(i, W) mp[i] = i;
  // (現在位置-開始位置）を保持
  multiset<int> st;
  rep(i, W) st.insert(0);
  
  rep(i, H) {
    int l = A[i];
    l--;
    int r = B[i];
    auto it = mp.lower_bound(l);
    int mr = -1;
    while (it != mp.end() && it->first <= r) {
      mr = max(mr, it->second);
      // 下にいけないルートは消す
      int x = it->first - it->second;
      st.erase(st.find(x));
      mp.erase(it++);
    }
    if (mr != -1 && r < W) {
      st.insert(r - mr);
      mp[r] = mr;
    }
    
    // 最短
    int ans = -1;
    if (st.size() > 0) {
      ans = *st.begin() + (i + 1);
    }
    cout << ans << endl;
  }
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
	string s;
	cin >> s;

	s[3] = '8';

	cout << s << endl;
	return (0);
}


Measured memory_bytes: 3548
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#include <math.h>
#include <iomanip>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int n,h;
   	cin>>n>>h;
   	int memo=0;
   	int ans=INT_MAX;
   	int a[n],b[n];
   	vector<int> bt;
   	int am=0;
   	int tmp;
	vector<int> nage;
   	for(int i=0;i<n;++i){
   		cin>>a[i]>>b[i];
   		am=max(am,a[i]);
   	}
	for(int i=0;i<n;++i){
   		if(b[i]>am){bt.push_back(b[i]);}
	}
	sort(bt.begin(),bt.end(),greater<int>());
	for(int i=0;i<bt.end()-bt.begin();++i){
		h-=bt[i];
		if(h<=0){cout<<i+1<<endl;goto end;}
	}
   	if(h%am==0){cout<<h/am+bt.end()-bt.begin()<<endl;}else{cout<<h/am+1+bt.end()-bt.begin()<<endl;}
   end:
	return 0;
}

Measured memory_bytes: 1660
#include<iostream>
#include<utility>
#include<vector>
#include<climits>

using namespace std;

typedef pair<int, int> Pii;

class BIT {
    public:
    int n;
    int bit[1000001];
    
    BIT(int n){
        this->n = n;
        fill(bit, bit+n, 0);
    }

    void add(int idx, int x){
        for(int i=idx;i<=this->n;i+=i&-i) bit[i] += x;
    }

    //bit[1]からbit[end]までの和 (閉区間)
    int sum(int end){
        int ret = 0;
        for(int i=end;i>=1;i-=i&-i) ret += bit[i];
        return ret;
    }
};


int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;

    int mp[2][n+1];
    char c;
    int num;
    for(int i=1;i<=2*n;++i){
        cin >> c >> num;
        mp[(c=='W'?0:1)][num] = i;
    }

    vector< vector<int> > dp(n+1, vector<int>(n+1, INT_MAX));
    dp[0][0] = 0;
    BIT tree = BIT(2*n+1);

    for(int i=0;i<=n;++i){
        if(i) tree.add(mp[0][i], 1);

        for(int j=0;j<=n;++j){
            if(j) tree.add(mp[1][j], 1);
            if(i != n) dp[i+1][j] = min(dp[i+1][j], dp[i][j] + (i+j-tree.sum(mp[0][i+1])));
            if(j != n) dp[i][j+1] = min(dp[i][j+1], dp[i][j] + (i+j-tree.sum(mp[1][j+1])));
        }

        for(int j=1;j<=n;++j) tree.add(mp[1][j], -1);
    }

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

Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
template <typename T>
bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;}
const ll MOD = 1e9+7;
long long Comb(int n, int i){long long ans = 1; if(i>n || i < 0) return 0; if(i == 0 || i == n) return 1; else {for(int j = 1; j <= i; ++j){
      ans *=(n+1-j);
      ans /= j;
      ans %= MOD;} }return ans;}




void solve(){
    int n, k; cin >> n >> k;
    vector<int> snake;
    for(int i = 0; i < n; ++i) {
        int tmp; cin >> tmp;
        snake.push_back(tmp);
    }
    sort(snake.rbegin(), snake.rend());
    int ans = 0;
    for(int i = 0; i < k; ++i){
        ans += snake[i];
    }
    cout << ans << endl;
}

int main(void){
    solve();
    return 0;
}


Measured memory_bytes: 3604