akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
     int n, k;
    cin >> n >> k;
    vector<ll> a(n), res;
    rep(i,n) cin >> a[i];
    for(int i = 0; i+k < n; ++i) {
        if(a[i] >= a[i+k]) cout << "No" << endl;
        else cout << "Yes" << endl;
       
    }
    return 0;
}

Measured memory_bytes: 4832
//                   * In The Name of Allah *
// Writer: arianBASS
//#include "stdafx.h"
#include <bits/stdc++.h>
#define Turbo std::ios::sync_with_stdio(false)
#define int long long
#define pb push_back
#define ever ( ; ; )

using namespace std;

int32_t main() {
	Turbo;
	int n;
	cin >> n;
	for (int i = (int)(sqrt(n)); i > 0; i--) {
		int b = (int)(n / i);
		if (b * i == n) {
			cout << (b + i - 2) << '\n';
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	
	vector<int> p(n), q(n), v(n);
	
	for (int i = 0; i < n; ++i){
		v[i] = i + 1;
		cin >> p[i];
	}
	for (int i = 0; i < n; ++i){
		cin >> q[i];
	}
	
	int a, b, i = 0;
	
	do{
		if (p == v)
			a = i;
		if (q == v)
			b = i;
		++i;
	}while (next_permutation(v.begin(), v.end()));
	
	cout << abs(a - b);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		int i = 0; //いったん保持する箱
		int j = 0; //いったん保持する箱

		i = x; //xをいれる i 1 x 1
		j = y; //zをいれる　j2
		x = y; // x 2 y2 223
		y = i; // x2 y1 z3 213　AB
		x = z; // x 3 y1 z3
		z = j; // x 3 y1 z1
		System.out.println(x);
		System.out.println(y);
		System.out.println(z);
		sc.close();
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <fstream>
#include <bitset>
#include <map>
#include <queue>
#include <complex>
#include <assert.h>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <stack>
#include <numeric>

typedef long long ll;
typedef long double ld;

#define pb push_back
#define mp make_pair

using namespace std;

vector<pair<int, int> > pts;

int ct(int x1, int x2, int y1, int y2){
	int c = 0;
	for(const pair<int, int> &p : pts){
		int x = p.first, y = p.second;
		if(x1 <= x && x <= x2 && y1 <= y && y <= y2) c++;
	}
	return c;
}

ll minarea = -1;

void update(int x1, int x2, int y1, int y2){
	ll area = (x2 - x1) * 1ll * (y2 - y1);
	if(minarea == -1) minarea = area;
	else minarea = min(minarea, area);
}

int main(){
	int z, n;
	cin >> n >> z;
	
	set<int> xp, yp;
	for(int i=0; i<n; i++){
		int x, y;
		cin >> x >>y;
		pts.pb({x, y});
		xp.insert(x);
		yp.insert(y);
	}
	vector<int> xxp, yyp;
	for(int u : xp) xxp.pb(u);
	for(int u : yp) yyp.pb(u);

	
	for(int i = 0; i < xxp.size(); i++){
		for(int j = i; j < xxp.size(); j++){
			for(int k = 0; k< yyp.size(); k++){
					int most = ct(xxp[i], xxp[j], yyp[k], yyp.back());
					if(most < z) continue;
					int lo = k, hi = yyp.size() - 1;
					while(lo <= hi){
						int mid = (lo + hi)/2;
						int c = ct(xxp[i], xxp[j], yyp[k], yyp[mid]);
						if(c >= z){
							update(xxp[i], xxp[j], yyp[k], yyp[mid]);
							hi = mid - 1;
						}
						else{
							lo = mid + 1;
						}
					}
			}
		}
	}
	cout << minarea << endl;

	return 0;
}



Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(a * b, c) << endl;
  return 0;
}
//templete by private_yusuke


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 200010;
#define lowbit(x) ((x) & (-(x)))
int v[N],a[N],n,k,ans;
void add(int pos,int val) {
  for (; pos <= n+1 ; pos += lowbit(pos))
    v[pos] += val;
}
int query(int pos) {
  int res = 0;
  for (; pos ; pos -= lowbit(pos))
    res += v[pos];
  return res;
}
vector<int> tmp;
signed main() {
  scanf("%lld%lld",&n,&k);
  tmp.push_back(0);
  for (int i = 1 ; i <= n ; ++ i) {
    scanf("%lld",&a[i]);
    a[i] -= k;
    a[i] += a[i-1];
    tmp.push_back(a[i]);
  }
  sort(tmp.begin(),tmp.end());
  tmp.erase(unique(tmp.begin(),tmp.end()),tmp.end());
  for (int i = 0 ; i <= n ; ++ i)
    a[i] = lower_bound(tmp.begin(),tmp.end(),a[i]) - tmp.begin() + 1;
  for (int i = n ; i >= 0 ; -- i) {
    ans += query(n+1) - query(a[i]-1);
    add(a[i],1);
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 5104
#include <stdio.h>
#include <stdbool.h>

static bool search(int A[], int n, int key)
{
    int i = 0;
    A[n] = key;

    while (A[i] != key) {
        i++;
    }

    return i != n;
}

int main()
{
    int n;
    int A[10001];

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

    int q;
    int sum = 0;
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        int key;
        scanf("%d", &key);
        if (search(A, n, key))
            sum++;
    }
    printf("%d\n", sum);
    return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<long> v(n);
  for(int i=0;i<n;i++) cin>>v[i];
  long cnt=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int k=j+1;k<n;k++){
        if(v[i]!=v[j]&&v[j]!=v[k]&&v[k]!=v[i]){
          long M=max(v[i],max(v[j],v[k]));
          if(v[i]+v[j]+v[k]>2*M) cnt++;
        }
      }
    }
  }
  cout<<cnt;
}


Measured memory_bytes: 3624
package main

import (
	"fmt"
	"math"
)

func main() {
	var N int
	var x, y []float64
	fmt.Scanf("%d", &N)
	for i := 0; i < N; i++ {
		var a, b float64
		fmt.Scanf("%f %f", &a, &b)
		x = append(x, a)
		y = append(y, b)
	}
	var ans float64
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			ans += math.Sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]))
		}
	}
	ans *= 2.0
	ans /= float64(N)
	fmt.Println(ans)

}


Measured memory_bytes: 512
def draw_rect(H,W):
    for i in range(H):
        for j in range(W):
            if i==0 or i==H-1:
                print("#",end="")
            elif j==0 or j==W-1:
                print("#",end="")
            else:
                print(".",end="")
        print("")


def read_data():
    ls=[]
    while True:
        s,t=tuple(input().split())
        
        H=int(s)
        W=int(t)
        
        if H==0 and W==0:
            break
        
        ls.append((H,W))
        
    return ls


def draw_all_rect(ls):
    for W,H in ls:
        draw_rect(W,H)
        print("")

ls=read_data()
draw_all_rect(ls)


Measured memory_bytes: 7012
#include <bits/stdc++.h>
using namespace std;
const int N = 402;
const long long INF = 1000000009000000009;

int n;
int a[N];
long long p[N];

long long dp[N][N];
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    for (int i = 1; i <= n; ++i)
        p[i] = p[i - 1] + a[i];
    for (int d = 2; d <= n; ++d)
    {
        for (int l = 1; l <= n - d + 1; ++l)
        {
            int r = l + d - 1;
            dp[l][r] = INF;
            for (int i = l; i < r; ++i)
            {
                dp[l][r] = min(dp[l][r], dp[l][i] + dp[i + 1][r] + p[r] - p[l - 1]);
            }
        }
    }
    cout << dp[1][n] << endl;
    return 0;
}


Measured memory_bytes: 1536
import heapq

distance = (
            (0,1,2,3,1,2,3,4,2,3,4,5,3,4,5,6),
            (1,0,1,2,2,1,2,3,3,2,3,4,4,3,4,5),
            (2,1,0,1,3,2,1,2,4,3,2,3,5,4,3,4),
            (3,2,1,0,4,3,2,1,5,4,3,2,6,5,4,3),
            (1,2,3,4,0,1,2,3,1,2,3,4,2,3,4,5),
            (2,1,2,3,1,0,1,2,2,1,2,3,3,2,3,4),
            (3,2,1,2,2,1,0,1,3,2,1,2,4,3,2,3),
            (4,3,2,1,3,2,1,0,4,3,2,1,5,4,3,2),
            (2,3,4,5,1,2,3,4,0,1,2,3,1,2,3,4),
            (3,2,3,4,2,1,2,3,1,0,1,2,2,1,2,3),
            (4,3,2,3,3,2,1,2,2,1,0,1,3,2,1,2),
            (5,4,3,2,4,3,2,1,3,2,1,0,4,3,2,1),
            (3,4,5,6,2,3,4,5,1,2,3,4,0,1,2,3),
            (4,3,4,5,3,2,3,4,2,1,2,3,1,0,1,2),
            (5,4,3,4,4,3,2,3,3,2,1,2,2,1,0,1),
            (6,5,4,3,5,4,3,2,4,3,2,1,3,2,1,0),
           )

def d_manhattan(node_list):
    s = 0
    for i in range(16):
        j = node_list[i] - 1
        if j == -1: continue
        s += distance[i][j]
    return s

def moveNode(node_list, space, direction):
    node_tmp = node_list[:]
    node_tmp[space], node_tmp[space + direction] = node_tmp[space + direction], node_tmp[space]
    return node_tmp

class board:
    def __init__(self, node_list, move):
        self.node = node_list
        self.space = node_list.index(0)
        self.move = move
        self.h = d_manhattan(node_list)
        self.f = self.move + self.h

    def makeBoard(self, node_close):
        node_now = self.node
        space = self.space
        move = self.move
        x_s = space%4
        y_s = space//4
        if x_s < 3:
            node_tmp = moveNode(node_now, space, 1)
            if tuple(node_tmp) not in node_close:
                yield board(node_tmp, move + 1)
        if x_s > 0:
            node_tmp = moveNode(node_now, space, -1)
            if tuple(node_tmp) not in node_close:
                yield board(node_tmp, move + 1)
        if y_s < 3:
            node_tmp = moveNode(node_now, space, 4)
            if tuple(node_tmp) not in node_close:
                yield board(node_tmp, move + 1)
        if y_s > 0:
            node_tmp = moveNode(node_now, space, -4)
            if tuple(node_tmp) not in node_close:
                yield board(node_tmp, move + 1)

b_open = []
n_close =set()
n_goal = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0]
n_start = []

for i in range(4):
    inp = list(map(int, input().split()))
    n_start.extend(inp)

b_start = board(n_start, 0)
heapq.heappush(b_open, (b_start.f, b_start.h, 0, b_start))

i = 0
while b_open:
    _, _, _, b_now = heapq.heappop(b_open)
    if b_now.node == n_goal:
        b_goal = b_now
        break
    n_close.add(tuple(b_now.node))
    for b_new in b_now.makeBoard(n_close):
        heapq.heappush(b_open, (b_new.f, b_new.h, i, b_new))
        i += 1

print(b_goal.move)

Measured memory_bytes: 247824
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n) - 1; i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

template<typename T>
inline void setmax(T& a, T b) {
    if (a < b) a = b;
}

template<typename T>
inline void setmin(T& a, T b) {
    if (a > b) a = b;
}

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

const int N = 111;
ll dp[N][N * N];
ll pw[N * N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); 
    srand((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
    int n0, k;
    cin >> n0 >> k;
    pw[0] = 1;
    forn(i, 1, N * N)
        pw[i] = pw[i - 1] * (k + 1) % MOD;
    fore(n, 1, n0)
        forn(m, 0, N * N) {
            fore(i, 0, k){
                if (i > n) {
                    dp[n][m] += dp[n - 1][m];
                    dp[n][m] %= MOD;
                    continue;
                }
                int waves = m + (i + m) / n;
                if (waves >= N * N)
                    continue;
                dp[n][m] += dp[n - 1][waves];
                dp[n][m] += pw[n - 1] * ((i + m) / n);
                dp[n][m] %= MOD;
            }
        }
    ll All = pw[n0] * k % MOD * (MOD + 1) / 2 % MOD * n0 % MOD;
    cout << (All + MOD - dp[n0][0]) % MOD << '\n';
}


Measured memory_bytes: 10368
import sys

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

    ans = 0
    for i in range(1, N+1):
        if i >= K:
            ans += 1 / N
        else:
            cnt = 1
            while i * 2**cnt < K:
                cnt += 1

            ans += 1 / N * (0.5)**cnt

    return ans


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


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

using namespace std;
typedef long long int ll;


int main()
{
	int n,k;
	cin>>n>>k;
	vector<ll> A(n);
	rep(i,n) cin>>A[i];
	for(int i = 0; i < n-k; i++){
		if(A[i] < A[i+k]){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4464
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	int n;
	cin >> n;
	int ac(0), wa(0), tle(0), re(0);
	rep(i, n) {
		string buf;
		cin >> buf;
		if (buf == "AC") {
			ac++;
		}
		else if(buf=="WA"){
			wa++;
		}
		else if (buf == "TLE") {
			tle += 1;
		}
		else {
			re++;
		}
	}
	cout << "AC" << " x " << ac << endl;
	cout << "WA" << " x " << wa << endl;
	cout << "TLE" << " x " << tle << endl;
	cout << "RE" << " x " << re << endl;
	return 0;
}

Measured memory_bytes: 3532
#include <cstdio>
#include <algorithm>
#define maxn 200010
#define LL long long
using namespace std;
int a[maxn],l[maxn];
int main(){
	int n,i;
	LL ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	for(i=1;i<=n;i++)l[i]=max(a[i],l[i-1]);
	for(i=1;i<=n;i++)ans+=l[i]-a[i];
	printf("%lld\n",ans);
	return 0;
}

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

		int N = sc.nextInt();
		int K = sc.nextInt();
		int Q = sc.nextInt();
		int[] point = new int[N+1];
		for( int i=0; i<Q; i++ ){
			point[sc.nextInt()]++;
		}
		for( int i=1; i<=N; i++ ){
			if( point[i]>Q-K ){
				System.out.println("Yes");              
            }else{
				System.out.println("No");              
            }              
		}
	}
}


Measured memory_bytes: 56072
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	string S, T;
	cin >> S >> T;

	vector<string> list;
	for (auto i = 0; i <= (int)S.size() - (int)T.size(); ++i)
	{
		auto isValid = true;

		for (auto j = 0; j < T.size(); ++j)
		{
			if (S[i + j] != '?' && S[i + j] != T[j])
			{
				isValid = false;
				break;
			}
		}

		if (isValid)
		{
			string temp = "";
			if (i > 0)
			{
				temp = S.substr(0, i);
			}
			temp += T;
			if (i + T.size() < S.size())
			{
				temp += S.substr(i + T.size());
			}

			replace(temp.begin(), temp.end(), '?', 'a');
			list.push_back(temp);
		}
	}

	if (list.size() <= 0)
	{
		cout << "UNRESTORABLE" << endl;
	}
	else
	{
		sort(list.begin(), list.end());
		cout << list[0] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する



int main() {
    unsigned int N,M;
    cin >> N >> M;
    vector<int> v(N+1,0);
    v[1] = 1;
//    vector<vector<int> > V(N+1,vector<int>(N+1,0));
//    vector<pair<int,int>> e;
    vector<int> w;


    REP(i,0,M){
        int a,b;
        cin >> a >> b;
        if(a == 1){
            v[b] = 1;
        }
        if(b == 1){
            v[a] = 1;
        }
        if(a == N){
            w.push_back(b);
        }
        if(b == N){
            w.push_back(a);
        }
    }

    bool flag = false;
    REP(i,0,w.size()) {
        if(v[w[i]] == 1){
            flag = true;
        }
    }



//    REP(a,0,2){
//        vector<int> check;
//        REP(i,0,N){
//            if(v[i] == 1){
//                check.push_back(i);
//            }
//        }

//        REP(i,0,check.size()){
//            REP(j,1,N+1){
//                if(v[check[i]] == 1 && V[check[i]][j] == 1){
//                    v[j] = 1;
//                }
//            }
//        }

//        REP(i,0,check.size()){
//            REP(j,0,e.size()){
//                int from = e[j].first;
//                int to = e[j].second;
//                if(from == check[i]){
//                    v[to] = 1;
//                }
//            }
//        }

//    }

    if(flag){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }


    return 0;

}


Measured memory_bytes: 1660
N = int(input())
W = list(map(int, input().split()))

sum1 = 0
sum2 = sum(W)
ans = 1000000000
for t in range(N):
    sum1 += W[t]
    sum2 -= W[t]
    if abs(sum1 - sum2) <= ans:
        ans = abs(sum1 - sum2)
print(ans)


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

void solve(int n, string &s, int i = 0, char m = 'a')
{
	if (i == n)
	{
		cout << s << endl;
		return;
	}

	for (char c = 'a'; c <= m; c++)
	{
		s.push_back(c);
		solve(n, s, i + 1, m);
		s.pop_back();
	}

	if (0 < i && m != 'z')
	{
		s.push_back(m + 1);
		solve(n, s, i + 1, m + 1);
		s.pop_back();
	}
}

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

	string s = "";

	solve(n, s);

	return 0;
}

Measured memory_bytes: 1536
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;


int main() {
    int N, K;
    string S;
    cin >> N >> K >> S;

    vector<int> state;

    for (int s = true, c = 0, n = 0; n <= N; n++) {
        if (n == N) {
            state.push_back(c);
        } else if (s && S[n] == '0') {
            state.push_back(c);
            s = false;
            c = 1;
        } else if (!s && S[n] == '1') {
            state.push_back(c);
            s = true;
            c = 1;
        } else {
            c++;
        }
    }

    vector<int> sum;
    sum.push_back(0);
    for (int i = 0; i < state.size(); i++) sum.push_back(sum[i] + state[i]);

    int res = 0;
    for (int i = 1; i < sum.size(); i++) {
        int imax;
        if (i % 2 == 1) {
            imax = min((int)sum.size() - 1, i + 2 * K);
        } else {
            imax = min((int)sum.size() - 1, i + 2 * (K - 1));
        }
        int tmp = sum[imax] - sum[i - 1];
        if (tmp > res) res = tmp;
    }

    cout << res << endl;

    return 0;
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int reds = 0;
    rep(i,n){
        if(s[i] == 'R'){
            reds++;
        }
    }
    int ans = 0;
    rep(i, reds) {
        if (s[i] == 'W') ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3752
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int x[10], y[10];
double dist(int i, int j) {
  double dx = x[i] - x[j];
  double dy = y[i] - y[j];
  return pow(dx * dx + dy * dy, 0.5);
}

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

  cin >> n;
  FOR(i, 1, n + 1) {
    cin >> x[i] >> y[i];
  }

  double sum = 0.0;
  vector<int> v(n);
  REP(i, n) v[i] = i + 1;
  do {
    FOR(i, 0, n - 1) sum += dist(v[i], v[i + 1]);
  } while(next_permutation(v.begin(), v.end()));
  int fac = 1;
  FOR(i, 2, n + 1) fac *= i;
  cout << fixed << setprecision(10) << (sum / fac) << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
 
int main(){
  char S[3];
  
  scanf("%c%c%c",&S[0],&S[1],&S[2]);
  
  if(S[0]=='R'){
    if(S[1]=='R'){
      if(S[2]=='R'){
        printf("3\n");
      }else{
        printf("2\n");
      }
    }else{
      printf("1\n");
    }
  }else{
    if(S[1]=='R'){
      if(S[2]=='R'){
        printf("2\n");
      }else{
        printf("1\n");
      }
    }else{
      if(S[2]=='R'){
        printf("1\n");
      }else{
        printf("0\n");
      }
    }
  }
  return 0;
}

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

int main(){
    char A[6];
    int i_A,i_B,ans;
    cin >> i_A >> i_B;
    for(i_A ; i_A <= i_B;i_A++){
        sprintf(A,"%d",i_A);
        if((A[0] == A[4]) && (A[1] == A[3])){
            ans = ans + 1;
        } 
    }

    cout << ans;
    
}

Measured memory_bytes: 256
#include <iostream>
#define ll long long
using namespace std;

int main()
{
    ll n,m;
    cin>>n>>m;
    ll ans = 0;
    if(n*2<=m){
        ans=n;
        m=m-n*2;
        ans+=m/4;
    }
    else{
        ans = m/2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"
import "sort"

type Prefecture int

type City struct {
    Prefecture Prefecture
    CityIndex int
    Year int
    ID string
}

type Cities []City

func (c Cities) Len() int {
    return len(c)
}

func (c Cities) Swap(i, j int) {
    c[i], c[j] = c[j], c[i]
}

func (c Cities) Less(i, j int) bool{
    return c[i].Year < c[j].Year
}

type ByCityIndex struct {
    Cities
}
func (b ByCityIndex) Less(i, j int) bool{
    return b.Cities[i].CityIndex < b.Cities[j].CityIndex
}

func main(){
    tmp := scanNums(2)
    _, m := tmp[0], tmp[1] //県の数と市の数
    preMap := make(map[Prefecture]Cities)
    //市の情報を取得
    for cityIndex :=0; cityIndex < m; cityIndex++{
        tmp = scanNums(2)
        p, y := Prefecture(tmp[0]), tmp[1] //県と市ができた年
        city := City{
            Prefecture: p,
            CityIndex : cityIndex,
            Year: y,
        }
        var cities Cities
        var ok bool
        if cities, ok = preMap[p]; !ok{
            cities = make(Cities, 0)
        }
        cities = append(cities, city)
        preMap[p] = cities
    }
    //県ごとに市のIDをつける
    allCities := make(Cities, 0)
    for prefecture, cities := range preMap {
        sort.Sort(cities)
        for idx, c := range cities{
            c.ID = fmt.Sprintf("%06d", prefecture) + fmt.Sprintf("%06d", (idx+1))
            allCities = append(allCities, c)
        }
    }

    //表示するため市のindexで並び替える
    sort.Sort(ByCityIndex{allCities})
    for i:=0; i<len(allCities); i++{
        fmt.Printf("%s\n", allCities[i].ID)
    }
}


/**
 * １行に空白区切りで数字を読み込み
 */
func scanNums(len int) (nums []int) {
	nums = make([]int, len)
	for i := 0; i < len; i++ {
		fmt.Scan(&nums[i])
	}
	return
}


Measured memory_bytes: 36224
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int p, q, r; cin >> p >> q >> r;
    cout << min({p + q, r + q, q + r, p + r, r + p, q + p});
}


Measured memory_bytes: 256
#include<cstdio>
int a[30];
int main()
{
	char c=getchar();
	while(c<='z'&&c>='a')
	{
		a[c-'a'+1]++;
		c=getchar();
	}
	for(int i=1;i<=26;i++)
	if(!a[i])
	{
		printf("%c\n",i+'a'-1);
		return 0;
	}
	printf("None\n");
	return 0;
}

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


int main() {
	//code
	//cout<<"ashish"<<endl;
	long long int n;
	cin>>n;
	long long int a[n];
	long long int x=0;
	for(long long int i=0;i<n;i++){
        cin>>a[i];
         x=x^a[i];}
         long long int k=0;
    for(long long int i=0;i<n;i++){
    k=x^a[i];
    cout<<k<<" ";}
   // cout<<x<<endl;
	return 0;
}


Measured memory_bytes: 5148
#include <stdio.h>

int main(){
    
    int a[3];
    int b,i;
    
    scanf("%d",&a[0]);
    scanf("%d",&a[1]);
    scanf("%d",&a[2]);
    
    
    if(a[0] > a[1]){
        if(a[1] > a[2]){
            printf("%d %d %d\n",
                a[2],a[1],a[0]);
                return 0;
        }
    }
    
    if(a[0] > a[1]){
        b = a[0];
        a[0] = a[1];
        a[1] = b;
    }
    
    if(a[1] > a[2]){
        if(a[0] > a[2]){
            b = a[0];
            a[0] = a[2];
            a[2] = a[0];
            
        }else
         if(a[1] > a[2]){
            b = a[1];
            a[1] = a[2];
            a[2] = b;
        }
    }
    
    for(i = 0; i < 2;i++)
        printf("%d ",a[i]);
        
        printf("%d\n",a[2]);
        
     return 0;
}

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

using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const int MX = 3005;
ll d[MX][MX];
ll a[MX];

int main(){
  int n; scanf("%d", &n);
  for(int i=1;i<=n;i++){
    scanf("%lld", a+i);
  }

  for(int i=1;i<=n;i++){
    for(int j=1;j<=n-i+1;j++){
      if( (n-i)%2 == 0){
        d[i][j] = max(a[j]+d[i-1][j+1], a[j+i-1]+d[i-1][j]);
      }
      else{
        d[i][j] = min(-a[j]+d[i-1][j+1], -a[j+i-1]+d[i-1][j]);
      }
    }
  }
  cout << d[n][1];
  return 0;
}


Measured memory_bytes: 70016
#include <iostream>
#include <vector>
using namespace std;
#define int long long
const int ma = 405;
const int inf = 1e15;
int dp[ma][ma];
main()
{
    int n;
    cin >> n;
    vector< int> a(n);
    for( int i = 0;i < n; i++ ) cin >> a[i];
    vector< int > s(n+1);
    for( int i = 0; i < n ;i++ )s[i +1] = a[i] + s[i];
    for( int i = 0; i < n; i++ )for( int j = 0; j < n; j++ ) dp[i][j] = inf;
    for( int l = n - 1; l >= 0; l-- )
    {
        for( int r  = l; r < n; r++ )
        {
            if( l == r ) dp[l][r] = 0;
            else 
            {
                for( int k = l; k < r; k++ )
                {
                    dp[l][r] = min( dp[l][r], dp[l][k] + dp[k + 1][r] + ( s[r + 1] - s[l] ) ) ;
                }
            }
        }
    }
    cout << dp[0][n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1536
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn solve(a: Vec<char>) -> usize {
    let mut count = 0;
    let mut b = a[0];
    for i in 1..a.len() {
        if b != a[i] {
            count += 1;
        }
        b = a[i];
    }
    count
}



fn main() {
    input! {
    a: chars,
    };

    println!("{}", solve(a));
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(void){
	int A, B, C, c = 0;

	do{
		scanf("%d %d", &A, &B);
	}while(A < 1 || A > 3 || B < 1 || B > 3);

	for (C = 0; C <= 3; C++){
		if (A * B * C % 2)	c++;
	}

	if (c != 0)	printf("Yes\n");
	else	printf("No");

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int n,a,x,y;
	scanf("%d %d",&n,&a);
	x=n%500;
	y=x-a;
	if(0>=y){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define gc() getchar()
using namespace std;
const int maxn=200010,maxm=400010;
int n,m,cnt,head[maxn];
struct edge{
    int from,to,next;
}edges[maxm];
char c[maxn];
bool sz[maxn];
inline bool check(int p){
    char hd;
    if(head[p]<0) return false;
    register int j;
    for(j=head[p];sz[edges[j].to];j=edges[j].next);
    if(j>=0) hd=c[edges[j].to];
    for(;j>=0;j=edges[j].next) if(!sz[edges[j].to]){
        if(c[edges[j].to]!=hd) return true;
    }
    return false;
}
inline void dfs(int p){
    sz[p]=true;
    for(register int j=head[p];j>=0;j=edges[j].next) if((!sz[edges[j].to])&&(!check(edges[j].to))) dfs(edges[j].to);
}
inline void gi (int &x){
    char c;
    for(c=gc();c<'0'||c>'9';c=gc());
    for(x=0;c<='9'&&c>='0';c=gc()) x=x*10+(c&15);
}
int main(){
    scanf("%d%d",&n,&m);getchar();
    scanf("%s",c+1);int xx,yy;memset(head,-1,sizeof(head));
    for(register int i=1;i<=m;i++){
        gi(xx);gi(yy);
        edges[cnt]=(edge){xx,yy,head[xx]};
        head[xx]=cnt++;
        edges[cnt]=(edge){yy,xx,head[yy]};
        head[yy]=cnt++;
    }
    bool flag;//memset(sz,1,sizeof(sz));
    while(true){
        flag=true;
        for(register int i=1;i<=n;i++) if((!sz[i])&&(!check(i))){
            flag=false;dfs(i);
        }
        if(flag) break;
    }
    for(register int i=1;i<=n;i++) if(!sz[i]){
        printf("Yes\n");return 0;
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"	
	typedef long long LL;
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define mod2 998244353
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)	
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define read(a) ll a; cin >> a;
	#define reads(s) string s; cin >> s;
	#define readb(a, b) ll a, b; cin >> a >> b;
	#define readc(a, b, c) ll a, b, c; cin >> a >> b >> c;
	#define readarr(a, n) int a[(n) + 1] = {}; forab(i, 0, (n-1)) {cin >> a[i];}
	#define readmat(a, n, m) int a[n + 1][m + 1] = {}; forab(i, 1, n) {forab(j, 1, m) cin >> a[i][j];}
	#define readv(A,n) vll A(n,0); forn(i,n) cin>>A[i]; 
	#define print(a) cout << a << endl;
	#define printarr(a, n) forab (i, 1, n) cout << a[i] << " "; cout << endl;
	#define printv(v) for (int i: v) cout << i << " "; cout << endl;
	#define printmat(a, n, m) forab(i, 1, n) {forab (j, 1, m) cout << a[i][j] << " "; cout << endl;}
	 
	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	int fpow(int base, int power, int MOD) {
    int result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 
	int modinv(int x) {return fpow(x, mod - 2, mod);}
	void solve()
	{
		ll n,w;
		cin>>n>>w;
		ll A[n][2];
		ll dp[n+1][w+1];
		mem(dp,0);
		forn(i,n)
		{
			cin>>A[i][0]>>A[i][1];
		}

		forab(i,0,n)
		{
			forab(j,0,w)
			{
				if(i==0||j==0)
					dp[i][j]=0;
				else if(A[i-1][0]<=j)
				{
					dp[i][j]=max(A[i-1][1]+dp[i-1][j-A[i-1][0]],dp[i-1][j]);
				}
				else
					dp[i][j]=dp[i-1][j];
			}
		}
		cout<<dp[n][w]<<endl;


	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
	//	cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		return 0;
	}

	
	

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};
vector<int> v(300001,0),v2(300001,0);
ll s = 0;
void solve(ll n){
  cout << n << ":";
  REP(i,1,s){
    if(n % v2[i] == 0){
      cout << " " << v2[i];
    }
  }
  cout << endl;
}
template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  rep(i,300001){
    if(i % 7 == 1 || i % 7 == 6){
      v[i] = i;
    }
  }
  Unique(v);
  REP(i,1,v.size()){
    bool f = false;
    REP(j,2,i){
      if(v[j] * v[j] > v[i]) break;
      if(v[i] % v[j] == 0){
        f = true;
        break;
      }
    }
    if(!f){
      v2[s] = v[i];
      ++s;
    }
  }
  while(cin >> n){
    if(n == 1) break;
    solve(n);
  }
  return 0;
}

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

using namespace std;

int main() {
    int n;
    vector<int> num;
    cin >> n;
    vector<pair<int,int>> a(n);
    for (int i = 0; i < n; i++) {
        num.push_back(i);
        cin >> a[i].first >> a[i].second;
    }

    double x,y;
    double sum = 0.0;
    int c = 0;
    do {
        for (int i = 0; i < n-1; i++) {
            x = a[num[i]].first - a[num[i+1]].first;
            y = a[num[i]].second - a[num[i+1]].second;
            sum += pow(x * x + y * y,0.5);
        }
        c++;
    } while (next_permutation(num.begin(), num.end()));
    cout << fixed << setprecision(10) << sum / c << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String f = sc.nextLine();
		if(f.substring(f.length() - 1, f.length()).equals("s")){
			System.out.println(f + "es");
		}else{
			System.out.println(f + "s");
		}
		
		
		
	}
}

Measured memory_bytes: 38560
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	int n, l;
	cin >> n >> l;

	int sum = 0;
	for(int i=1; i<=n; i++){
		sum += l + i - 1;
	}

	int mn = INT_MAX;
	int ans = 0;
	for(int i=1; i<=n; i++){
		int katki = l + i - 1;
		if(abs(katki) < mn){
			mn = abs(katki);
			ans = sum - katki;
		}
	}

	cout << ans;

	return 0;
}

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

int main(){
  int n,W;
  cin>>n>>W;
  
  vector<int> dp(W+1,0);
  rep(i,n){
    int v,w;
    cin>>v>>w;
    rep(j,W){
      int nj = j+w;
      if(nj <= W)
      dp[nj]=max(dp[nj],dp[j]+v);
    }
  }

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


Measured memory_bytes: 3132
n,m = gets.split(" ").map{|v|
	v.to_i
}

pic = []
n.times do
	pic << gets.chomp
end

template = []
m.times do
	template << gets.chomp
end

fl =0
for i in 0..n-m
	for j in 0..n-m
		# picの[i,j]成分を左上隅とした部分が、templateと一致するか
		fl = 0
		for k in 0 .. m-1
			if pic[i+k][j..j+m-1] != template[k]
				fl = 1
				break
			end
		end
		if fl == 0 then
			puts "Yes"
			
			exit
		end
	end
end
puts "No"




Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 5000010
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d ", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 1000000007
#define mod 998244353
#define PI acos(-1.0)
#define eps 1e-9
#define mem(a, b) memset(a, b, sizeof(a))
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

inline int Set(int N, int pos){return N=N | (1<<pos);}
inline int Reset(int N, int pos){return N=N & ~(1<<pos);}
inline bool Check(ll N, ll pos){return (bool)(N & (1LL<<pos));}

inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modInverse(ll a) { return modPow(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll fast_exp(ll x, ll n, ll m)
{
    ll res = 1;
    while(n>0)
    {
        if(n%2==1)
            res = (res * x) % m;
        x = (x * x) % m;
        n/=2;
    }
    return res%m;
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

clock_t t_Start;
void Start()
{
    t_Start = clock();
}
void End()
{
    double Time = (double)(clock()-t_Start)/CLOCKS_PER_SEC;
    error(Time);
}

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet;
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet1;

set<ll>num;

void solve(ll x, int i)
{
    if(x > 3234566667) return;
    if(num.size() > 1e5) return;
    num.insert(x);
    ll xx = (10LL * x) + i;
    solve(xx, i);
    if(i < 9)
    {
        xx = (10LL * x) + (i + 1);
        solve(xx, i + 1);
    }
    if(i > 0)
    {
        xx = (10LL * x) + (i - 1);
        solve(xx, i - 1);
    }
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Start();

    FASTIO;
    for(int i = 1; i <= 9; i++)
        solve((ll)i, i);
    vector<ll>ans;
    for(auto x : num)
        ans.push_back(x);
    int n;
    cin>>n;
    cout<<ans[n-1]<<endl;

    //End();
    return 0;
}


Measured memory_bytes: 6140
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    int h,w,cnt = 0;
    cin >> h >> w;
    for(int i = 0;i < h;i++){
        string s;
        cin >> s;
        for(auto c:s) if(c == '#') cnt++;
    }
    if(cnt == w+h-1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <queue>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#define ll long long
using namespace std;
const ll maxn=1e5+111;
char a[maxn][12]={0};
int main(){
	for(ll i=1;i<=9;++i) a[i][0]=i+'0';
	for(ll i=10;i<=100000;++i){
		strcpy(a[i],a[i-1]); 
		ll k=0;
		while(a[i][k]!='\0'&&((a[i][k+1]!='\0'&&a[i][k]>a[i][k+1])||a[i][k]=='9')) ++k;
		if(a[i][k]=='\0'){
			a[i][k]='1';
			for(k=k-1;k>=0;--k) a[i][k]='0';
		}
		else{
			a[i][k]+=1;
			for(k=k-1;k>=0;--k) a[i][k]=max(char(a[i][k+1]-1),'0');
		}
	}
    ll k;
	scanf("%lld",&k);
	ll len=strlen(a[k]);
	for(ll i=len-1;i>=0;--i) printf("%c",a[k][i]);
	printf("\n");
    return 0;
}

Measured memory_bytes: 1408
// : (Colon)
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
typedef long double ld;

ld a, b, h, m;
const ld pi=3.14159265358979323846264338327950288;

int main(){
    cin >> a >> b >> h >> m;

    ld ar=2*pi*(h*60+m)/720;
    ld br=2*pi*m/60;
    ld r=abs(ar-br);
    if(r>pi){ r=2*pi-r;}
    ld cr=cos(r);
    ld ans;
    ans=a*a+b*b-2*a*b*cr;
    ans=sqrt(ans);
    cout << fixed << setprecision(15) << ans << endl;
    //cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4164
#include "bits/stdc++.h"
using namespace std;
const int N = 1111;
int n;
int a[N];
set < int > d;
int main()
{
            ios_base::sync_with_stdio(false);
            cin.tie(0);
            cout.tie(0);
            cin >> n;
            for(int i = 0 ; i < n ; i++){
                    cin >> a[i];
            }

            sort(a , a + n);
            cout << a[n - 1] - a[0] << endl;
            return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
s = int(input())
if s <= 10**9:
    print(s, 0, 0, 0, 0, 1)
else:
    print(10**9, 1*(s<10**18), 10**9 - int(str(s)[-9:]), s // 10**9 + 1*(s<10**18),0,0)


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

const double pi=3.14159265359265358979;

int main(void){
	long double ah,bm;
	long double h,m;
	long double hd,md;
	cin>>ah>>bm>>h>>m;
	hd=0.5*m+30.0*h;
	md=6.0*m;
	long double dig=abs(hd-md);
	long double rad=(pi/180.0)*dig;
	long double ans=sqrt((ah*ah)+(bm*bm)-(2.0*ah*bm*cos(rad)));
	printf("%.12llf",ans);

	return 0;
}	

Measured memory_bytes: 4168
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Queue;

public class Main implements Runnable{

	public static void main(String[] args) {
		new Thread(null,new Main(), "" ,Runtime.getRuntime().maxMemory()).start();
	}
	
	int gcd(int a,int b) {
		return a==0?b:gcd(b%a,a);
	}
	
	public void run() {
		FastScanner sc=new FastScanner();
		int[] cnt=new int[26];
		char[] cs=sc.next().toCharArray();
		for(char c:cs)cnt[(int)(c-'a')]++;
		System.out.println(Arrays.stream(cnt).filter(v->v>1).sum()==0?"yes":"no");
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 28628
#include<bits/stdc++.h>
using namespace std;
int main() {
  int64_t a,b,c,i;
  cin>>a>>b;
  if(a>b) swap(a,b);
  c=b%a;
  while(c>0){
    b=a;
    a=c;
    c=b%a;
  }
  int64_t ans=1;
  for(i=2;i*i<=a;i++){
    if(a%i==0){
      ans++;
      while(a%i==0) a/=i;
      if(a==1) break;
    }
  }
  if(a>1) ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
if H == 1 or W == 1:
	print(1)
elif H % 2 == 1 and W % 2 == 1:
    print((H//2+1)*(W//2+1)+(H//2)*(W//2))
elif H % 2 == 1 and W % 2 == 0:
    print((H//2+1)*W//2+(H//2)*(W//2))
elif H % 2 == 0 and W % 2== 1:
    print((H//2)*(W//2+1)+(H//2)*(W//2))    	 
else:
    print(2*(H//2)*(W//2))   

Measured memory_bytes: 3064