akhauriyash/Code-Regression huggingface dataset:
n, k = map(int, input().split())
p = list(map(int, input().split()))
a = [0 for _ in range(n + 1)]
for i, pi in enumerate(p):
    a[i + 1] = a[i] + (1 + pi) / 2

ans = 0
for i in range(n - k + 1):
    ans = max(ans, a[i + k] - a[i])
print(ans)


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

int main(void) {
	int i, j;
	char t[101], c, st[101];
	while (1) {
		for (i = 0; ~scanf("%c", &c) && c != '\n'; i++) {
			t[i] = c;
		}
		t[i] = 0;
		if (t[0] == '.' && t[1] == 0) {
			return 0;
		} 
		memset(st, 0, sizeof st);
		for (i = 0, j = 0; i <= strlen(t); i++) {
			if (t[i] == '(' || t[i] == '[') {
				st[j++] = t[i];
			}
			if (t[i] == ')') {
				if (st[--j] != '(') {
					puts("no");
					break;
				}
			}
			if (t[i] == ']') {
				if (st[--j] != '[') {
					puts("no");
					break;
				}
			}
			if (t[i] == 0) {
				puts(j ? "no" : "yes");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 524
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
data = []
S = []
for i in range(M):
    s,c = [int(x) for x in stdin.readline().rstrip().split()]
    data.append((s,c))
    S.append(s)
ans = ["1"]+["0"]*(N-1)
 
for i,j in sorted(data)[::-1]:
    ans[i-1] = str(j)

if len(data) == len(set(data)) and len(data) != len(set(S)):
    print(-1)
else:
    if M == 0:
        if N == 1:
            print(0)
        elif N == 2:
            print(10)
        elif N == 3:
            print(100)
    else:
        if ans[0] == "0" and N != 1:
            print(-1)

        elif ans[0] == "0" and N == 1:
            print(0)

        else:
            print("".join(ans))

Measured memory_bytes: 3064
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;
type I = usize;
const MOD: usize = 1e9 as usize + 7;

fn main() {
    input!{
      n: usize,
      mut cs1: [usize; n],
    }
    let mut cs = vec![];
    for i in 1..n {
        if cs1[i] != cs1[i-1] {
            cs.push(cs1[i-1]);
        }
    }
    cs.push(cs1[n-1]);
    let n = cs.len();
    let mut ans = 1;
    let mut num = vec![0; 200001];
    for i in 0..n {
        if num[cs[i]] > 0 {
            ans += num[cs[i]];
            ans %= MOD;
        }
        num[cs[i]] = ans;
    }
    // debug!(num);
    println!("{}", ans);
}


Measured memory_bytes: 10620
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a[] = new int[3];
		a[0] = s.nextInt();
		a[1] = s.nextInt();
		a[2] = s.nextInt();
		Arrays.sort(a);
		System.out.println(a[0]+a[1]);
	}
}

Measured memory_bytes: 23636
import java.util.Scanner;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String str = scanner.next();
		String order,change;
		int Q = scanner.nextInt();
		int a,b;

		for(int loop = 0; loop < Q; loop++){
			order = scanner.next();

			if(order.equals("print")){

				a = scanner.nextInt();
				b = scanner.nextInt();

				print(str,a,b);

			}else if(order.equals("reverse")){

				a = scanner.nextInt();
				b = scanner.nextInt();

				str = reverse(str,a,b);

			}else{

				a = scanner.nextInt();
				b = scanner.nextInt();
				change = scanner.next();

				str = replaceStr(str,a,b,change);
			}
		}
	}

	private static void print(String str,int a,int b){
		String output = str.substring(a, b+1);
		System.out.println(output);
	}

	private static String reverse(String str,int a,int b){

		char work[] = str.toCharArray();

		int num = b-a+1;
		char tmp;

		for(int i = 0; i < num/2; i++){

			tmp = work[a+i];
			work[a+i] = work[b-i];
			work[b-i] = tmp;
		}

		return String.valueOf(work).substring(0, str.length());
	}

	private static String replaceStr(String str,int a,int b,String change){

		char ch[] = change.toCharArray();
		char work[] = str.toCharArray();

		for(int i = a; i <= b; i++){
			work[i] = ch[i-a];
		}

		return String.valueOf(work).substring(0,str.length());
	}
}


Measured memory_bytes: 29420
import java.util.Scanner;

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

        while (true) {
            int w = sc.nextInt();
            int h = sc.nextInt();
            if (w + h == 0) {
                break;
            }
            for (int i=0; i<w; ++i) {
                for (int j=0; j<h; ++j) {
                    System.out.print(((i+j)%2==1 ? "." : "#"));
                }
                System.out.println("");
            }
            System.out.println("");
        }
        sc.close();
    }
}


Measured memory_bytes: 35024
#include<cstdio>
#include<set>

using namespace std;

const int MAX_N = 1e5;
int par[MAX_N];
int ran[MAX_N];

void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        ran[i] = 0;
    }
}

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

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (ran[x] < ran[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (ran[x] == ran[y]) ran[x]++;
    }
}

int m, n;
set<int> s;

int main() {
    scanf("%d %d", &n, &m);
    init(n);
    for (int i = 0; i < m; i++) {
        int x, y, z;
        scanf("%d %d %d", &x, &y, &z);
        unite(x - 1, y - 1);
    }

    for (int i = 0; i < n; i++) {
        s.insert(find(i));
    }

    printf("%lu\n", s.size());
    return 0;
}       


Measured memory_bytes: 5760
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	lint N, a, b;
	cin >> N >> a >> b;
    
    if(b > a) swap(a, b);

	if ((a - b) % 2 == 0) {
		cout << (a - b) / 2 << "\n";
	}
	else {
		cout << min((a - b) / 2 + b, (a - b) / 2 + N - a + 1) << "\n";
	}

	return 0;
}


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

int main(void) {
	int n;
	int a[100000];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);

	ll sum = 0;
	for (int i = 0; i < n; i++)
		sum += a[i];
	ll evensuma = 0;
	for (int i = 1; i < n; i += 2)
		evensuma += a[i];


	ll rain[100000];
	rain[0] = sum - 2 * evensuma;

	for (int i = 1; i < n; i++)
		rain[i] = 2 * a[i - 1] - rain[i - 1];

	for (int i = 0; i < n; i++)
		printf("%lld ", rain[i]);
	return 0;
}

Measured memory_bytes: 2432
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long ll;

ll a = 2, b = 1;

int main(){
	int n; scanf( "%d", &n );
	for( int i = 1; i < n; ++i ){
		ll c = b;
		b = a + b;
		a = c;
	}
	printf( "%lld\n", b );
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
double sum1,sum2;
int n;
int a[15];
int b[20];
int c[15][15];
void sum(int a1,int b1)
{
	sum1+=sqrt((c[a1][1]-c[b1][1])*(c[a1][1]-c[b1][1])*1.0+(c[a1][2]-c[b1][2])*(c[a1][2]-c[b1][2])*1.0);
}
void dfs(int t)
{
	if(t==n+1)
	{
		for(int i=2;i<=n;i++)
		{
			sum(a[i-1],a[i]);
		}
		return;
	}
	for(int i=1;i<=n;i++)
	{
		if(b[i]==0)
		{
			a[t]=i;
			b[i]=1;
			dfs(t+1);
			b[i]=0;
		}
	}
}
long long h=1;
void jie()
{
	for(int i=1;i<=n;i++)
	h*=i;
}
int main()
{
	cin>>n;
	jie();
	for(int i=1;i<=n;i++)
	cin>>c[i][1]>>c[i][2];
	dfs(1);
	sum2=sum1/h;
	printf("%0.10f",sum2);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n,h;
  cin >> h >> n;
  vector<int> a(n),b(n);
  vector<vector<ll>> dp(n+1,vector<ll>(h+1,INF));
  dp[0][0]=0;
  rep(i,n){
    cin >> a[i] >> b[i];
  }
  rep(i,n){
    for(int j=0; j<=h; j++){
      //dp[i+1][j]=min(dp[i][j],dp[i+1][j-a[i]]+b[i]);

      chmin(dp[i+1][j], dp[i][j]);
      chmin(dp[i+1][min(j+a[i], h)], dp[i+1][j] + b[i]);

    }
  }

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

  return 0;
}


Measured memory_bytes: 81656
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define debug(var) cout << #var << ": " << var << endl
using namespace std;
using Int = int64_t;
using Double = double;
using Uint = uint64_t;
constexpr Uint mod = 1e9 + 7;
constexpr Int INF = INT_MAX;
template<typename T>
using Grid = vector<vector<T>>; // 二次元配列。[y][x]
template<typename T, typename U>
using Umap = unordered_map<T, U>;
template<typename T>
using Uset = unordered_set<T>;
template<typename T>
using P = pair<T, T>;

int main() {

	Umap<string, Int> map;
	Int N; cin >> N;
	rep(i, N) {
		string S; cin >> S;
		map[S]++;
	}
	Int maximum = -1;
	vector<string> v;
	for (const auto m : map)maximum = max(maximum, m.second);
	for (const auto m : map) {
		if (m.second == maximum)v.push_back(m.first);
	}
	sort(v.begin(), v.end());
	for (const auto e : v)cout << e << endl;

}

Measured memory_bytes: 26692
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end() 

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


int main() {
  ll mod=1000000007;
  ll n,a,b;
  cin>>n>>a>>b;
  
  ll A=1;
  ll B=1;
  for(ll i=0;i<a;i++) {
A*=(n-i);
  A%=mod;
  }
  for(ll i=0;i<b;i++) {
B*=(n-i);
    B%=mod;
  }
  
  
  for(ll i=2;i<=a;i++) {
A*=mod_pow(i,mod-2,mod);
    A%=mod;
  }
  for(ll i=2;i<=b;i++) {
B*=mod_pow(i,mod-2,mod);
    B%=mod;
  }
  ll ans=mod_pow(2,n,mod);
  ans--;
  ans-=(A+B);
  
  if(ans<0) {
    while(ans<0) {
      
ans+=mod;
  }
  }
  
  cout<<ans<<endl;
}

  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  

  


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define maxn 5000010
struct node
{
    int l,r,no;
}c[maxn];
int n,m;
int tree[maxn],front[maxn],last[maxn];
int ans[maxn];
bool cmp(node x,node y)
{
    return x.r<y.r;
}
int lowbit(int i)
{
    return i&(-i);
}
void update(int i,int x)
{
    while(i<=maxn)
    {
        tree[i]+=x;
        i+=lowbit(i);
    }
}
int query(int i)
{
    int sum=0;
    while(i>0)
    {
        sum+=tree[i];
        i-=lowbit(i);
    }
    return sum;
}
int main()
{   
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        int temp;
        scanf("%d",&temp);
        front[i]=last[temp]+1;//front数组为i位置上的数上一次出现的位置+1
        last[temp]=i;//last数组为i位置上的数到目前为止最后一次出现的位置
    }
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&c[i].l,&c[i].r);
        c[i].no=i;//每次查询的序号
    }
    sort(c+1,c+1+m,cmp);//按右端点排序
    int k=1;//k初值为1
    for(int i=1;i<=m;i++)
    {
        while(k<=c[i].r)
        {
            k++;
            update(front[k-1],1);
            update(k,-1);
        }
        ans[c[i].no]=query(c[i].l);//查询左端点
    }
    for(int i=1;i<=m;i++)
    printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 17456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x,k,d,c;
int main()
{
    scanf("%lld%lld%lld",&x,&k,&d);
    if(x<0)x=-x;
    c=x/d;
    if(k<=c)
    {
        x=x-k*d;
    }
    else
    {
        c=c-k;
        x=x%d;
        if(c&1)x=d-x;
    }
    printf("%lld",x);
    return 0;
}


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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int gcd(int a, int b){ return b?gcd(b, a % b):a; }

int main(){
  int n, cd, a, b, c;
  scanf("%d", &n);
  if(n == 2){
    scanf("%d%d", &a, &b);
    cd = gcd(a, b);
  }else{
    scanf("%d%d%d", &a, &b, &c);
    cd = gcd(a, gcd(b, c));
  }

  for(int i = 1; i <= cd / 2; i++){
    if(cd%i) continue;
    printf("%d\n", i);
  }
  printf("%d\n", cd);
  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
using namespace std;
int main(){
    int a,b,big;
    cin>>a>>b;
    int add=a+b;
    int mul=a*b;
    int sub=a-(b);
    if (add>mul&&add>sub)
    {big=add;}
    else if (mul>sub&&mul>add)
    {big=mul;}
    else if (sub>add&&sub>mul)
    {big=sub;}
    cout<<big;
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;
list<long long int> Prime(int M) {
	list<long long int>P;
	P.push_back(2);
	P.push_back(3);
	for (int i = 5; i <= M; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	return P;
}


long long int N;
long long int ans;
long long int H, W;
long long int K;
list<long long int>ret;

int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	while (N) {
		vector<int>num(N);
		ans = 0;
		for (int i = 0; i < N; i++)cin >> num[i];
		sort(num.begin(), num.end());
		for (auto i : num)ans += i;
		ans -= num[0];
		ans -= num[N - 1];
		ret.push_back(ans / (N-2));
		cin >> N;
	}
	for (auto i : ret)cout << i << endl;
	return 0;
}

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

int main() {
  int n;cin>>n;
  vector<int> t(n);
  rep(i,n)cin>>t[i];
  int m;cin>>m;
  rep(i,m){
    int p,x;cin>>p>>x;
    int cnt=0;
    rep(j,n){
      if(j+1==p)cnt+=x;
      else cnt+=t[j];
    }
    cout<<cnt<<endl;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    for (int i = 111; ; i+=111) {
        if (i < n) continue;
        else {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  if(N<10)
    cout<<N<<endl;
  else if(N>=10 && N<100)
    cout<<9<<endl;
  else if(N>=100 && N<1000)
    cout<<N-90<<endl;
  else if(N>=1000 && N<10000)
    cout<<909<<endl;
  else if(N>=10000 && N<100000)
    cout<<N-9090<<endl;
  else
    cout<<90909<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long LL;
 
LL mod = 1000000007;
const LL maxn = 100004;

int main()
{
	LL g[maxn];

	for (LL i = 0; i < maxn; ++i) {
		g[i] = 1;
	}

	g[0] = g[1] = 0;
	for (LL i = 2; i*i <= maxn; ++i) {
		if (g[i]) {
			for (LL j = i*i; j < maxn; j += i) {
				g[j] = 0;
			}
		}
	}

	LL x;
	cin >>x;
	LL f;

	for (LL i = x; i < maxn; ++i) {
		if (g[i]) {
			f = i;
			break;
		}
	}

	cout << f << endl;



}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll a[214514],b[214514];
int main(){
	ll n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i]>>b[i];
	sort(a,a+n);
	sort(b,b+n);
	if(n%2)cout<<b[n/2]-a[n/2]+1<<endl;
	else cout<<b[n/2]+b[n/2-1]-(a[n/2]+a[n/2-1])+1<<endl;	
	return 0;
}

Measured memory_bytes: 6736
#include<iostream>
#include<string>

using namespace std;

int main() {
	int A,B,K;

	cin >> A >> B >> K;

	if (2*K > B-A+1) {
		for (int i = A; i <= B; ++i)
		{
			cout << i << endl;
		}
	} else {
		for (int i = A; i < A+K ; ++i)
		{
			cout << i << endl;
		}
		for (int i = B-K+1; i <=B ; ++i)
		{
			cout << i <<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
import sys


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    H, W = map(int, input().split())
    Grid = [list(input()) for _ in range(H)]

    uf = UnionFind(H * W)
    direction = [(1, 0), (-1, 0), (0, 1), (0, -1)]

    for i in range(H):
        for j in range(W):
            if Grid[i][j] == '#':
                for dx, dy in direction:
                    nx, ny = i + dx, j + dy
                    if 0 <= nx <= H - 1 and 0 <= ny <= W - 1:
                        if Grid[nx][ny] == '#':
                            uf.union(i * W + j, nx * W + ny)
    ans = True

    for k, v in uf.all_group_members().items():
        i, j = k // W, k % W
        if Grid[i][j] == '#' and len(v) == 1:
            ans = False
            break

    if ans:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


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

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

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

#define INF 1e16
#define mod 1000000007

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

  ll N,M;
  cin>>N>>M;
  ll H=(N-1)/2;
  vector<P> ps;
  ll l=0,r=H-1;
  repl(d,1,H+1){
    if(d%2==1){
      ps.push_back(P(l,(l-d+N)%N));
      l++;
    }else{
      ps.push_back(P(r,(r+d)%N));
      r--;
    }
  }
  rep(i,M){
    cout<<ps[i].fi+1<<" "<<ps[i].se+1<<endl;
  }

  return 0;
}


Measured memory_bytes: 5300
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<bool>ryoukinzyo(N+1, false);
    for (int i=0; i<M; i++) {
        int x;
        cin >> x;
        ryoukinzyo[x] = true;
    }

    int cost = 0;
    int n = X;
    while (n < N) {
        n = n + 1;
        if (ryoukinzyo[n]) {
            cost += 1;
        }
    }

    int sita_cost = 0;
    int l = X;
    while (l > 0) {
        l = l - 1;
        if (ryoukinzyo[l]) {
            sita_cost +=1;
        }
    }

    cout << min(cost, sita_cost) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
    int n,t;
    int money = 0, counts = 0;
    cin >> n >> t;
    int a[100001], b[100001];
    for(int i = 0; i< n; ++i)
        cin  >> a[i];
    for(int i = 0; i < n - 1; ++i)
        b[i] = a[i + 1] - a[i];
    int maxium[100001];
    maxium[0] = b[0];
    money = maxium[0];
    counts = 1;
    for(int i = 1; i < n - 1; ++i)
    {
        if(maxium[i - 1] > 0)
            maxium[i] = maxium[i - 1] + b[i];
        else
            maxium[i] = b[i];
        if(maxium[i]  > money)
        {
            money = maxium[i];
            counts = 1;
        }
        else if(maxium[i] == money)
            ++counts;
    }
    cout << counts << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdarg>
#include <set>
#include <limits>
#include <iomanip>

using namespace std;
#define INF 2e9 + 9
#define MOD 1000000007
#define ALL(v) v.begin() , v.end()
#define Int int64_t
#define pll pair<Int,Int>
template<class T> using pql = priority_queue<T, vector<T>>;
template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
#define ll(n) Int n; cin >> n;
#define LL(...) Int __VA_ARGS___; cin >> __VA_ARGS___;
#define OUT(...) cout << __VA_ARGS___;
#define RP(n, i, s) for(Int i = s ;i < n ;i++)
#define REP(n, i) for (Int i = 0; i < n; i++)
#define REPe(n, i) for (Int i = 1; i <= n; i++)
#define RPe(n, i, s) for (Int i = s; i <= n; i++)
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;
#define upd_min(miner, updater) if (miner > updater) miner = updater;

void ansYes(bool flag) {
    if (flag) cout << "Yes" << endl; else cout << "No" << endl;
}

void ansYES(bool flag) {
    if (flag) cout << "YES" << endl; else cout << "NO" << endl;
}

struct node {
    Int to;
    Int length;
};


vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return (ret);
}

/*
vector<vector<int>> to;
vector<int> flag;
vector<int> c;


Int dfs(int from, int mae) {
    flag[from] = 1;
    Int mini = 0;
    for (auto next : to[from]) {
        if (next == mae) continue;
        if (flag[next] == 1) {
            return -1;
        } else {
            mini = min(mini, dfs(next, from));
        }
    }
    return mini;
}*/

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

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

struct datas {
    Int max;
    Int size;
};

class ContainChecker {
protected:
    Int minx, miny, maxx, maxy;
public:
    ContainChecker(Int minx, Int miny, Int maxx, Int maxy) : minx(minx), miny(miny), maxx(maxx), maxy(maxy) {};

    bool in(Int x, Int y) {
        return (minx <= x && miny <= y && x <= maxx && y <= maxy);
    }
};

Int n;
vector<string> que;
void dfs(string s,char k) {
   // cout << s << endl;
    if (s.size() == n) {
        que.push_back(s);
        return;
    }
    for (int i = 0; i <= k;i++){
        dfs(s + (char)('a'+i),i+1);
    }
}
int main(void) {
    Int h,w;
    cin >> h >> w;
    Int n;
    cin >> n;
    queue<Int> s;
    REP(n,i){
        Int a;
        cin >> a;
        REP(a,z){
            s.push(i+1);
        }
    }
    Int mp[h][w];
    Int x = 0, y = 0;
    int muki = 1;
    while(!s.empty()){
        auto z = s.front();
        s.pop();
        mp[y][x] = z;
        x += muki;
        if (x == w) {
            x--;
            y++;
            muki = -1;
        }
        if (x == -1){
            x++;
            y++;
            muki = 1;
        }
    }
    REP(h,i){
        REP(w,k){
            cout << mp[i][k] << " ";
        }
        cout << endl;
    }
}




Measured memory_bytes: 512
/*
[abc127] C - Prison
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_M = 1e5;

int N, M;
int l[MAX_M], r[MAX_M];

ll solve() {
    int lr = *max_element(l, l + M);
    int rl = *min_element(r, r + M);
    return (rl >= lr) ? (rl - lr + 1) : 0;
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> l[i] >> r[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 1024
import scala.io.Source

object Main {
  def main(args: Array[String]) = {
    val lines = Source.stdin.getLines.toStream
    val input = lines.drop(1).head.split(' ').map(_.toLong)
    val memo = Array.ofDim[Long](input.length + 1, input.length + 1, 2)

    (1 to input.length).foreach { n =>
      memo(n-1)(n)(0) = input(n-1)
      memo(n-1)(n)(1) = 0
    }

    (2 to input.length).foreach { right =>
      (2 to right).foreach { range =>
        var locMin = Long.MaxValue
        var cost = 0L
        ((right - range + 1) to (right - 1)).reverse.foreach { split =>
          var cand = memo(right - range)(split)(1) + memo(split)(right)(1)
          if (cand <= locMin) {
            locMin = cand
            cost = memo(right - range)(split)(0) + memo(split)(right)(0)
          }
        }
        memo(right - range)(right)(0) = cost
        memo(right - range)(right)(1) = locMin + cost
      }
    }

    println(memo(0)(input.length)(1))
  }
}


Measured memory_bytes: 45676
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

signed main(){
  string s;
  cin>>s;
  int n=s.size();
  string a="keyence";
  for(int l=0;l<n;l++){
    for(int r=0;r<n-l;r++){
      string x=s;
      r(k,r)x.erase(x.begin()+l);
      if(x==a){
        cout<<"YES"<<endl;
        return 0;
      }
    }
  }
  cout<<"NO"<<endl;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
  char a[1000000];
  int i,ichi=0,zero=0;
  for(i=0;;i++){
    scanf("%c",&a[i]);
    if(a[i]=='1'){
      ichi++;
    }else if(a[i]=='0'){
      zero++;
    }else{
      break;
    }
  }
  if(ichi<zero){
    printf("%d",ichi*2);
  }else{
    printf("%d",zero*2);
  }
  return 0;
}


Measured memory_bytes: 256
int main()
{
  char a[100],b[100];
  int n;
  
  scanf("%s", a);
  scanf("%s", b);
  
  n = strlen(a);
  
  if(strncmp(a,b,n)==0 && strlen(b)==n+1)
  {
    printf("Yes");
  }else
  {
   printf("No"); 
  }
  return 0; 
}

Measured memory_bytes: 1776
/*
Author : N_o_o_B
Created : April 12 2020 17:36:18 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 0;
    vl cnt(3);
    fori(i,n){
        if(s[i]=='R') cnt[0]++;
        else if(s[i]=='G') cnt[1]++;
        else cnt[2]++;
    }
    ans = cnt[1]*cnt[2]*cnt[0];
    fori(i,n){
        for(int j=1;i-j>=0 and i+j < n;j++){
            if(s[i-j] != s[i+j] and s[i-j] != s[i] and s[i+j] != s[i]){
                ans--;
            }
        }
    }
    cout << ans << endl;

    time_taken();
    return 0;
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define mod 1000000007
bool compare(int a, int b) {
    return a > b;
}
int main() {
    fio;
    string s;
    cin >> s;
    int x = s.length();
    if (s[x - 1] == 's') {
        s.append("es");
        cout << s << endl;
    }
    else {
        s.append("s");
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mx 1000000009
int main() {
	ll n, W;
	cin >> n >> W;
	ll v[n + 1], w[n + 1];
  ll sum = 0;
	for (ll i = 1; i <= n; i++) {
		cin >> w[i] >> v[i];
	}
	for (ll i = 1; i <= n; i++)
		sum += v[i];
	ll dp[sum + 1];
	// memset(dp, ll_MAX, sizeof(dp));

	for (ll i = 1; i <= sum; i++)
		dp[i] = mx;
	dp[0] = 0;
	for (ll i = 1; i <= n; i++) {
		for (ll j = sum; j >= v[i]; j--) {
			dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
		}
	}
	for (ll i = sum; i >= 0; i--) {
		if (dp[i] <= W) {
			cout << i; break;
		}
	}
}

Measured memory_bytes: 4316
#include <iostream>
#include <vector>

struct Prime {
    int max_n;
    std::vector<int> primes;
    std::vector<bool> isp;

    explicit Prime(int max_n)
        : max_n(max_n), isp(max_n + 1, true) {
        isp[0] = isp[1] = false;
        for (int i = 2; i * i <= max_n; ++i) {
            if (isp[i]) {
                for (int j = i; i * j <= max_n; ++j) {
                    isp[i * j] = false;
                }
            }
        }

        for (int p = 2; p <= max_n; ++p) {
            if (isp[p]) primes.push_back(p);
        }
    }

    template <class T>
    bool isprime(T n) const {
        if (n <= max_n) return isp[n];
        for (T p : primes) {
            if (p * p > n) break;
            if (n % p == 0) return false;
        }
        return true;
    }

    template <class T>
    std::vector<std::pair<T, int>> factorize(T n) const {
        std::vector<std::pair<T, int>> facts;
        for (T p : primes) {
            if (p * p > n) break;
            if (n % p != 0) continue;
            int exp = 0;
            while (n % p == 0) {
                n /= p;
                ++exp;
            }
            facts.emplace_back(p, exp);
        }
        if (n > 1) {
            facts.emplace_back(n, 1);
        }
        return facts;
    }

    template <class T>
    static std::vector<T> divisors(T n) {
        std::vector<T> ret;
        for (T p = 1; p * p <= n; ++p) {
            if (n % p != 0) continue;
            ret.push_back(p);
            if (n / p == p) continue;
            ret.push_back(n / p);
        }
        return ret;
    }
};

Prime P(1000000);

using lint = long long;

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

    auto ps = P.factorize(n);

    lint ans = 0;
    for (auto [p, e] : ps) {
        for (int i = 1; e >= i; ++i) {
            ++ans;
            e -= i;
        }
    }

    std::cout << ans << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3884
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second

signed main(){
	int n;
	cin>>n;
	r(i,100000){
		double x=i;
		x = (x*1.08);
		x=(int)(x);
		if((int)x == n){
			//cout<<i*1.08<<endl;
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<":("<<endl;
}


Measured memory_bytes: 256
N=gets.to_i
H=gets.split.map(&:to_i)
n=0
loop do
  l=r=H.index(H.max)
  break if H[l].zero?
  n+=1
  l-=1 until l.zero? || H[l-1].zero?
  r+=1 until r==N-1 || H[r+1].zero?
  l.upto(r) do |i|
    H[i]-=1
  end
end
p n

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<double> VL;
typedef vector<string> VS;
typedef vector<PLL> VP;
typedef vector<ll> VLL;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; } //charを整数に
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];

int main()
{
    int N;
    cin >> N;
    VI p(N),judge(N);
    rep(i,N){
        cin >> p.at(i);
    }
    int count=0;
    rep(i,N){
        if(p[i]==i+1){
            judge[i]=1;
        }
        if(judge[i]==1){
            swap(p[i],p[i+1]);
            judge[i]=0;
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;
const int MAX_N = 110;
const int MAX_V = 100100;

// DPテーブル
long long dp[MAX_N][MAX_V];

int main()
{
    int N;
    long long W;
    cin >> N >> W;

    long long weight[MAX_N], value[MAX_N];
    for (int i = 0; i < N; ++i)
        cin >> weight[i] >> value[i];

    // 初期化
    for (int i = 0; i < MAX_N; ++i)
        for (int j = 0; j < MAX_V; ++j)
            dp[i][j] = INF;

    // 初期条件
    dp[0][0] = 0;

    // DPループ
    for (int i = 0; i < N; ++i)
    {
        for (int sum_v = 0; sum_v < MAX_V; ++sum_v)
        {

            // i 番目の品物を選ぶ場合
            if (sum_v - value[i] >= 0)
                chmin(dp[i + 1][sum_v], dp[i][sum_v - value[i]] + weight[i]);

            // i 番目の品物を選ばない場合
            chmin(dp[i + 1][sum_v], dp[i][sum_v]);
        }
    }

    // 最適値の出力
    long long res = 0;
    for (int sum_v = 0; sum_v < MAX_V; ++sum_v)
    {
        if (dp[N][sum_v] <= W)
            res = sum_v;
    }
    cout << res << endl;
}


Measured memory_bytes: 86272
/*input
5 4 1
1000000000 1000000000 1000000000 1000000000 1000000000
1000000000 1000000000 1000000000 1000000000
*/

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

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n+1), b(m+1);
    for (int i = 1; i <= n; i++) {
        int t;
        cin >> t;
        a[i] = a[i-1]+t;
    }
    for (int i = 1; i <= m; i++) {
        int t;
        cin >> t;
        b[i] = b[i-1]+t;
    }
    int ub = upper_bound(a.begin(), a.end(), k)-a.begin()-1;
    int ans = ub;
    for (int i = ub; i >= 0; i--) {
        int t = upper_bound(b.begin(), b.end(), k-a[i])-b.begin()-1;
        ans = max(ans, i+t);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6416
#include<stdio.h>
int c[100002];
void merge(int i,int j,int *s){
  if(i!=j){
    merge(i,(i+j)/2,s);
    merge((i+j)/2+1,j,s);
    int a=i,b=(i+j)/2+1;
    int d;
    for(d=i;d<=j;d++){
      if((i+j)/2<a){
        c[d]=s[b];
        b++;
      }
      else if(j<b){
        c[d]=s[a];
        a++;
      }
      else if(s[a]>s[b]){
        c[d]=s[a];
        a++;
      }
      else{
        c[d]=s[b];
        b++;
      }
    }
    for(d=i;d<=j;d++)
      s[d]=c[d];
  }
}
int main(){
  int n,h,i;
  scanf("%d%d",&n,&h);
  int a,amax=0,b[n+1];
  for(i=0;i<n;i++){
    scanf("%d%d",&a,&b[i]);
    if(amax<a)
      amax=a;
  }
  merge(0,n-1,b);
  int count=0;
  i=0;
  while(h>0){
    if(amax<b[i] && i<n){
      h-=b[i];
      i++;
      count++;
    }
    else{
      if(h%amax==0)
        count+=h/amax;
      else
        count+=h/amax+1;
      break;
    }
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>

using namespace std;

int main (){
  int N;
  cin >> N;
  int res = 0;
  for (int i = 0; i < N; i++) {
    string str;
    cin >> str;
    if (str == "A") res++;
    else res--;
    if (res < 0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  if (res == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3168
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var X = long.Parse(Console.ReadLine());
            var ureshisa = 0;
            while (true)
            {
                if (X >= 500)
                {
                    ureshisa += 1000;
                    X -= 500;
                }
                else if (X >= 5)
                {
                    ureshisa += 5;
                    X -= 5;
                }
                else
                {
                    break;
                }
            }

            Console.WriteLine(ureshisa);
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<algorithm>

int msbc_(int x) { return 31 - __builtin_clz(x); }
int lsbc_(int x) { return __builtin_ctz(x); }

struct edge {
  int fr, to, cost;
  edge(int in_f=0, int in_t=0, int in_c=0):
    fr(in_f), to(in_t), cost(in_c) {}
  friend std::ostream& operator << (std::ostream& o, edge const& e) {
    o << e.fr << " " << e.to << " " << e.cost;
    return o;
  }
};

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int L; std::cin >> L;
  std::vector<edge> ans;
  ans.reserve(60);
  int m = msbc_(L), k = 1;
  for(int i = 0; i < m; ++i) {
    ans.emplace_back(i+1, i+2, 0);
    ans.emplace_back(i+1, i+2, k);
    k *= 2;
  }

  while(L > k) {
    int l = lsbc_(L - k);
    ans.emplace_back(l+1, m+1, k);
    k += 1<<l;
  }
  std::cout << (m+1) << " " << ans.size() << "\n";
  for(auto const& e: ans) std::cout << e << "\n";
  return 0;
}


Measured memory_bytes: 256
import re
str_in_org = input()
KEYENCE = 'keyence'
flag = False
for n in range(1,7):
    str_in = str_in_org
    len_in = len(str_in)
    len_tail = len_in - (7 - n)
    str_div1 = str_in[:n]
    str_div2 = str_in[len_tail:]
    key_div1 = KEYENCE[:n]    
    key_div2 = KEYENCE[n:]
    
    if( str_div1 == key_div1 and str_div2 == key_div2 ):
        if( str_div1 + str_div2 == KEYENCE ):
            flag = True
if flag == True :
    print ('YES')
else:
    print ('NO')


Measured memory_bytes: 3188
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class LargestSquare {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            long n = in.nextInt();
            long s = 1l;
            while (true) {
                s++;
                if (s * s > n) {
                    --s;
                    break;
                }
            }
            out.println(s * s);
        }

    }

    static class FastReader {
        BufferedReader reader;
        StringTokenizer st;

        public FastReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String line = reader.readLine();
                    if (line == null) {
                        return null;
                    }
                    st = new StringTokenizer(line);
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 21460
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;

int cross(int[] r1, int[] r2) {
	return r1[0]*r2[1]-r1[1]*r2[0];
}

void main() {
	int n = to!int(readln().strip());
	int c;
	while(n) {
		int[] p0 = array(map!(to!int)(readln().strip().split()));
		int[][] p;
		foreach(i; 1..n) {
			auto pi = map!(to!int)(readln().strip().split());
			p ~= [pi[0]-p0[0], pi[1]-p0[1]];
		}
		int s;
		foreach(i; 1..n-1) {
			s += cross(p[i], p[i-1]);
		}
		writefln("%d %.1f", ++c, abs(s/2.0));

		readln();
		n = to!int(readln().strip());
	}
}

Measured memory_bytes: 1172
import sys
import os


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


    a = int(sys.stdin.readline().rstrip())
    print(a // 2 if a % 2 == 0 else a // 2 + 1)


if __name__ == '__main__':
    main()


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

int main(){
  string S;
  cin >> S;
  long long ans = 0;
  long long c = 0;
  for(size_t i = 0; i < S.length(); ++i){
    if(S[i] == 'B') ++c;
    else ans += c;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 5e6+10;
bool vis[maxn];
ll prime[maxn],cnt;
ll ans = 0;
void init()
{
	for(int i=2;i<maxn;i++)
	{
		if(!vis[i])
		{
			prime[cnt++]=i;
		}
		for(int j=0;j<cnt&&i*prime[j]<maxn;j++)
		{
			vis[i*prime[j]]=1;
			if(i%prime[j]==0)break;
		}
	}
} 
void solve(ll x,ll y)
{
	for(int i=0;i<cnt;i++)
	{
		if(x%prime[i]==0&&y%prime[i]==0)ans++;
		while(x%prime[i]==0)x/=prime[i];
		while(y%prime[i]==0)y/=prime[i];
	}
	if(x==y&&x!=1)ans++;
}
int main()
{
	ll a,b;
	init();
	cin>>a>>b;	
	solve(a,b);
	cout<<ans+1<<endl;
}

Measured memory_bytes: 9472
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    char Array[5];
    int i,mind=0;
    cin>>Array;
    for(i=0;i<4;i++)
    {
        if(Array[i]=='+')
        {
            mind=mind+1;
        }
        else if(Array[i]=='-')
        {
            mind=mind-1;
        }
    }
    cout<<mind<<endl;
    return 0;
}


Measured memory_bytes: 256