akhauriyash/Code-Regression huggingface dataset:
#pragma region include
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 4e18;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion

int main() {
    int N; input(N);
    vector<int> A(N + 1),B(N); input(A,B);
    ll ans = 0;
    REP(i, N) {
        if (i > 0 && B[i-1] > 0) {
            if (A[i] >= B[i - 1]) {
                A[i] -= B[i - 1];
                ans += B[i - 1];
                B[i - 1] = 0;
            }
            else {
                ans += A[i];
                A[i] = 0;
                continue;
            }
        }
        if (A[i] > B[i]) {
            A[i] -= B[i];
            ans += B[i];
            B[i] = 0;
        }
        else {
            B[i] -= A[i];
            ans += A[i];
            A[i] = 0;
        }
    }
    if (B[N - 1] > A[N]) {
        ans += A[N];
    }
    else {
        ans += B[N - 1];
    }
    cout << ans << endl;
    getchar(); getchar();
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e4;

char arr[N][N];
char arr1[N][N];
int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    int x=n/500;
    int y=n%500;
    if(m>=y){
        printf("Yes\n");
        return 0;
    }
    puts("No");
}


Measured memory_bytes: 256
#include<iostream>
typedef long long ll;
using namespace std;
const int N=100000;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n,i,j,a[N],b[N],c[N],k;
	cin>>n;
	cin>>a[0]>>b[0]>>c[0];
	for(i=1;i<n;++i){
		cin>>a[i]>>b[i]>>c[i];
		a[i]+=max(b[i-1],c[i-1]);
		b[i]+=max(a[i-1],c[i-1]);
		c[i]+=max(a[i-1],b[i-1]);
	}
	cout<<max(a[n-1],max(b[n-1],c[n-1]));
}

Measured memory_bytes: 2560
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	a := ReadInts(N)
	v := 0
	for _, ai := range a {
		if ai == v+1 {
			v++
		}
	}
	if v == 0 {
		fmt.Println(-1)
	} else {
		fmt.Println(N - v)
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int cnt = 0;
    int now = 0;
    while (true) {
        cnt++;
        now += k;

        if (now >= n) break;
        else now--;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

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

		int inputTime = Integer.parseInt(input);
		int hour = 0;
		int minute = 0;

		while(inputTime >= 3600) {
			if ((inputTime -= 3600) >= 0) {
				hour++;
			}
		}

		while(inputTime >= 60) {
			if ((inputTime -= 60) >= 0) {
				minute++;
			}
		}
		System.out.println(hour + ":" + minute + ":" + inputTime);

	}
}



Measured memory_bytes: 26268
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {
  i64 N, i;
  cin >> N;

  map<pi, i64> mp;
  REP(1, N+1, i) {
    i64 d_last = i % 10;
    i64 d_first = i;
    while(d_first >= 10) {
      d_first /= 10;
    }
    pi k(d_first, d_last);
    if(mp.find(k) == mp.end())
      mp[k] = 1;
    else
      mp[k]++;
  }

  i64 ans = 0;
  for(auto p: mp) {
    pi k = p.first;
    i64 c = p.second;
    if(k.first == k.second) {
      ans += c + c * (c - 1);
    }
    else {
      pi k2(k.second, k.first);
      if(mp.find(k2) != mp.end()) {
	ans += c * mp[k2];
      }
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int main() {
	int N[3];
	for (int i = 0; i < 3; i++) scanf("%d", &N[i]);

	sort(N, N + 3);
	if (N[0] == 5 && N[1] == 5 && N[2] == 7) return !printf("YES\n");
	return !printf("NO\n");
}

Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
	using u64 = std::int_fast64_t;
public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
#pragma endregion

int main() {
	cin >> N >> K;
	cout << (ll)(log(N) / log(K) + 1);
}



Measured memory_bytes: 512
/*
    Code written by Talant I.D.
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);

inline bool isvowel(char ch){
    ch = tolower(ch);
    return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u');
}

inline bool isprime(int n){
    if(n < 2 || (n%2 == 0 && n != 2)) return false;
    for(int i = 3; i*i <= n; i += 2)
        if(n%i == 0) return false;
    return true;
}

int main(){
    do_not_disturb

    int s, w;
    cin >> s >> w;
    if(w >= s){
        cout << "unsafe";
    }
    else{
        cout << "safe";

    }

    return 0;
}


Measured memory_bytes: 3608
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let k: u64 = sc.cin();
    let xs: Vec<usize> = sc.vec(n);

    let mut memo = vec![None; n];
    memo[0] = Some(0);

    {
        let mut cur = 0;
        let mut t = 0;
        while t < k {
            t += 1;
            cur = xs[cur] - 1;
            // trace!(t, cur);
            if let Some(s) = memo[cur] {
                let du = t - s;
                t += (k - t) / du * du;
            } else {
                memo[cur] = Some(t);
            }
        }
        put!(cur + 1);
    }
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


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

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

  int ans = 0;
  ans += (n / 500) * 1000;
  n %= 500;
  ans += (n / 5) * 5;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define TR(i,v)       for(__typeof((v).begin())i=(v).begin();i!=(v).end();++i)
#define DEBUG(x)      cout<<#x<<" = "<<x<<endl
#define SIZE(p)       (int)(p).size()
#define MP(a,b)       make_pair((a),(b))
#define ALL(p)        (p).begin(),(p).end()
#define rep(i,n)      for(int i=0;i<(int)(n);++i)
#define REP(i,a,n)    for(int i=(a);i<(int)(n); ++i)
#define FOR(i,a,b)    for(int i=(int)(a);i<=(int)(b);++i)
#define FORD(i,b,a)   for(int i=(int)(b);i>=(int)(a);--i)
#define CLR(x,y)      memset((x),(y),sizeof((x)))
typedef long long LL;
typedef pair<int,int> pii;
struct Point{
  int x,y;
  void read(){
    scanf("%d %d",&x,&y);
  }
};
bool operator<(const Point &a, const Point &b) {
  return a.x-b.x<0 || ((a.x-b.x)==0 && (a.y-b.y)<0);
}
int main(){
  int N,K;scanf("%d%d",&N,&K);
  std::vector<Point> P(N);
  rep(i,N)P[i].read();
  vector<int> X,Y;
  rep(i,N)X.push_back(P[i].x),Y.push_back(P[i].y);
  sort(ALL(X)),sort(ALL(Y));
  sort(ALL(P));
  LL res=-1;
  rep(j,N)
  rep(i,j)
  rep(jj,N)
  rep(ii,jj){
    int c=0;
    LL xl=X[i],xr=X[j];
    LL yl=Y[ii],yr=Y[jj];
    rep(k,N){
      c+=P[k].x>=xl && P[k].x<=xr && P[k].y>=yl && P[k].y<=yr;
    }
    // DEBUG(c);
    if(c>=K){
      LL t=(LL)(xr-xl)*(yr-yl);
      if(res==-1 || res>t)res=t;
    }      
  }
  printf("%lld\n",res);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>

using namespace std;

struct Card
{
    char pic;
    unsigned int val;
    int order;
};

void quick_sort(Card *, int, int);

int partition(Card *cards, int l, int r)
{
    Card pivot = cards[r];
    int i = l - 1;

    for (int j = l; j < r; j++) {
        if (cards[j].val <= pivot.val)
            swap(cards[++i], cards[j]);
    }

    swap(cards[++i], cards[r]);
    
    return i;
}

void quick_sort(Card *cards, int l, int r)
{
    if (l < r) {
        int p = partition(cards, l, r);
        quick_sort(cards, l, p - 1);
        quick_sort(cards, p + 1, r);
    }
}

void print_cards(Card *cards, int n)
{
    for (int i = 0; i < n; i++) {
        cout << cards[i].pic << " " << cards[i].val << endl;
    }

}

bool is_stable(Card *cards, int n)
{
    for (int i = 1; i < n; i++) {
        if (cards[i-1].val == cards[i].val && cards[i-1].order > cards[i].order)
            return false;
    }
    return true;
}

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

    int n;
    Card cards[100000];

    cin >> n;
    for (int i = 0; i < n; i++) {
        char pic;
        unsigned int val;
        cin >> pic >> val;
        cards[i] = Card{pic, val, i};
    }

    quick_sort(cards, 0, n-1);
    cout << (is_stable(cards, n) ? "Stable" : "Not stable") << endl;
    print_cards(cards, n);
    
    return 0;
}

Measured memory_bytes: 2368
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		double pi = Math.PI;
		double area = r * r * pi;
		double length = r * 2 * pi;
		System.out.printf("%f %f", area, length);
	}
}


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

bool graph[10][10];
bool visited[10], all_visited;


int dfs(int v,int n) {
	visited[1] = true;
	all_visited = true;
	for (int i = 1; i <= n; ++i) {
		if (visited[i] == false) {
			all_visited = false;
		}
	}
	if (all_visited)return 1;
	int sum = 0;
	for (int i = 1; i <= n; ++i) {
		if (graph[v][i] == false)continue;
		if (visited[i])continue;
		visited[i] =true;
		sum+=dfs(i, n);
		visited[i] = false;
	}
	return sum;
}

int main() {
	int n, m,a,b;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> a>>b;
		graph[a][b] = true;
		graph[b][a] = true;
	}
	cout << dfs(1,n) << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()
len_s = len(s)
r_counts = [0] * len_s
r_counts[0] = 1
for i in range(1, len_s):
    if s[i] == 'R':
        r_counts[i] = r_counts[i-1] + 1

l_counts = [0] * len_s
l_counts[len_s - 1] = 1
for i in reversed(range(0, len_s - 1)):
    if s[i] == 'L':
        l_counts[i] = l_counts[i+1] + 1

ans = ['0'] * len_s
for i in range(len_s - 1):
    if s[i] != 'R' or s[i+1] != 'L':
        continue
    r_r = r_counts[i] // 2
    r_l = r_counts[i] - r_r
    l_l = l_counts[i+1] // 2
    l_r = l_counts[i+1] - l_l
    ans[i] = str(r_l + l_l)
    ans[i+1] = str(r_r + l_r)
print(' '.join(ans))


Measured memory_bytes: 11636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

template<class T> inline bool chmin(T& a, T b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}
vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int get_digit(ll n){
    int digit = 0;
    if(n == 0){
        return 1;
    }
    while(n != 0){
        digit++;
        n /= 10;
    }
    return digit;
}
bool is_junretu(ll n){
    int digit = get_digit(n);
    string s;
    s = to_string(n);
    bool flg= true;
    for(int i = 1; i <= digit; i++){
        if(s.find(i) == string::npos){
            flg = false;
            break;
        }
    }
    return flg;
}

bool is_prime(ll n){

    if(n == 2) return true;
    if(n == 3) return true;
    if(n % 2 == 0) return false;
    if(n % 3 == 0) return false;

    for(int i = 5; i * i <= n; i += 6){
        if(n % i == 0) return false;
        if(n % (i+2) == 0) return false;
    }
    return true;
}
int main(){

    ll x;
    cin >> x;
    while(!is_prime(x)){
        x++;
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int P[100001];
int Find(int A) {
	if (P[A] < 0) return A;
	return P[A] = Find(P[A]);
}

bool Unite(int A, int B) {
	int a = Find(A);
	int b = Find(B);
	if (a == b) return false;
	if (P[a] > P[b]) swap(a, b);
	P[a] += P[b];
	P[b] = a;
	return true;
}

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


	int N = getint(), M = getint();
	int ip[100001];
	rep1(i, N) ip[getint()] = i;

	rep1(i, N) P[i] = -1;
	rep(i, M) Unite(getint(), getint());

	int kotae = 0;
	rep1(i, N) kotae += Find(i) == Find(ip[i]);

	co(kotae);

	Would you please return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;


int main(){
  int a,b,k;
  cin >> a >> b >> k;
  int ans = 0;
  for(int i=min(a,b);i>=1;i--){
    if(a%i==0 && b%i==0){
      ans = i;
      k--;
    }
    if(k==0)break;
  }
  cout << ans << endl;
}


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

const int maxn = 300005;
const long long mod = 998244353;

long long n, a, b, k, ans;
long long fact[maxn];

long long add_mod (long long x, long long y) {
	return (x + y) % mod;
}

long long mul_mod (long long x, long long y) {
	return (x * y) % mod;
}

long long pow_mod (long long x, long long y) {
	long long res = 1, t = x;
	while (y) {
		if (y & 1)
			res = mul_mod(res, t);
		t = mul_mod(t, t);
		y >>= 1;
	}
	return res;
}

long long div_mod (long long x, long long y) {
	return mul_mod(x, pow_mod(y, mod - 2));
}

long long ncr_mod (long long x, long long y) {
	return div_mod(fact[x], mul_mod(fact[x - y], fact[y]));
}

void precalc () {
	fact[0] = 1;
	for (long long i = 1; i < maxn; ++i)
		fact[i] = mul_mod(i, fact[i - 1]);
}

signed main () {
	precalc();
	scanf("%lld %lld %lld %lld", &n, &a, &b, &k);
	for (long long i = 0; i <= n; ++i) {
		if ((k - i * a) >= 0 && (k - i * a) % b == 0 && 0 <= (k - i * a) / b && (k - i * a) / b <= n) 
			ans = add_mod(ans, mul_mod(ncr_mod(n, i), ncr_mod(n, (k - i * a) / b)));
	}
	printf("%lld\n", ans);
}


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

int main(){
  int N; cin >>N;
  int h[N]; for(int i=0;i<N;i++){cin >>h[i];}
  
  int r=0;
  for(int i=0;i<N;i++){
    bool flag = true;
    for(int j=0;j<i;j++){
      if(h[j]>h[i]){
        flag = false;
        break;
      }
    }
    r += flag;
  }
  cout << r << endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		while(true){
			int n = stdIn.nextInt();
			if(n==0){
				return;
			}
			int c = n/4;
			int s = 0;
			for(int i=0;i<c;i++){
				s += stdIn.nextInt();
			}
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 12000
//In The Name Of God
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<double, double> dd;
typedef pair<dd, double> ddd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<dd> vdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ii> vii;
typedef vector<vii> vvii;

mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define forn(i, n) for (ll i = 0; i < n; i++)
#define forr(i, n) for (int i = n; i >= 0; i--)
#define forne(i, x, n) for (ll i = x; i < n; i++)
#define forre(i, x, n) for (int i = n; i >= x; i--)
#define all(a) (a).begin(), (a).end()
#define eps 1e-9

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vi al(n);
    forn(j, n) cin >> al[j];
    bool ok = true;
    vi ans;
    while (ok && al.size()) {
        ok = false;
        forr(i, al.size() - 1) {
            if (al[i] - 1 == i) {
                ans.push_back(al[i]);
                ok = true;
                al.erase(al.begin() + i);
                break;
            }
        }
    }
    if (ans.size() < n) {
        cout << -1 << endl;
        return 0;
    }
    forr(i, n - 1) cout << ans[i] << endl;
    return 0;
}

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

using namespace std;

int main() {
    int T, k;
    while(~scanf("%d%d", &T, &k)) {
        int a;
        int maxn = 0;
        for(int i = 0; i < k; i++) {
            scanf("%d", &a);
            maxn = max(a, maxn);
        }
        if((maxn * 2 <= T && (T % 2 == 0)) || (maxn * 2 <= (T + 1) && (T % 2 == 1))) printf("0\n");
        else printf("%d\n", maxn * 2 - T - 1);
    }
    return 0;
}


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


int main(void)
{
    int n;
    cin >> n;
    vector<string> w(n);
    set<string> s;
    for (int i = 0;i < n;i++)
    {
        cin >> w[i];
        s.insert(w[i]);
    }
    bool ok = true;
    char back_ward;
    for (int i = 0;i < n-1;i++)
    {
        back_ward = w[i][w[i].size()-1];
        if (w[i+1][0] != back_ward) ok = false;
    }

    if (s.size() != w.size()) ok = false;

    cout << (ok? "Yes":"No") << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 300100;
int uf[maxn], xp[maxn];
int find(int x){
	if(x == uf[x]) return x;
	return uf[x] = find(uf[x]);
}
int main(){
	iota(uf, uf + maxn, 0);
	int n, h, w;
	cin >> n >> h >> w;
	vector<tuple<int, int, int> > eds;
	for(int i = 0; i < n; i++){
		int x, y, z;
		cin >> x >> y >> z;
		x--;
		y--;
		eds.push_back(make_tuple(-z, n + x, n + h + y));
	}
	sort(eds.begin(), eds.end());
	long long ans = 0;
	for(int i = 0; i < eds.size(); i++){
		int x, y, z;
		tie(z, x, y) = eds[i];
		x = find(x);
		y = find(y);
		if(x == y){
			if(xp[x] == 0){
				xp[x] = 1;
				ans -= z;
			}
		} else if(xp[x] + xp[y] <= 1){
			uf[y] = x;
			xp[x] += xp[y];
			ans -= z;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3700
#include <iostream>
 #include <vector>
 #include <map>
 #include <string>
 #include <algorithm>
 using namespace std;

 typedef long long ll;



 int main()
 {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> buff(n);
    for(int i = 0;i < n; i++)
    {
        int y;
        cin >> y;
        buff.at(i) = a.at(i) = y;
    }

    sort(buff.begin(), buff.end());
    int f = buff.at(n-1);
    int s = buff.at(n-2);

    vector<int> ans(n);

    for(int i = 0; i < n; i++)
    {
        if(a.at(i) == f) ans.at(i) = s;
        else ans.at(i) = f;
    }
    
    for(int i = 0; i < n; i++)
    {
        cout << ans.at(i) << endl;
    }

     return 0;
 }

Measured memory_bytes: 3968
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

int main(){
    int N, M, P;
    while(std::cin >> N >> M >> P, N){
        int cn = 0;
        int X[101];

        FOR(i, 1, N+1){
            std::cin >> X[i];
            cn += X[i];
        }

        if(X[M] == 0){puts("0");}
        else{
            printf("%d\n", cn * (100 - P) / X[M]);
        }
    }
}

Measured memory_bytes: 1148
class Node:
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.rank = 0


class DisjointSet:
    def __init__(self, nodes):
        self.nodes = nodes

    def find_set(self, key):
        pivot = self.nodes[key]
        while pivot.key != pivot.parent.key:
            pivot = pivot.parent
        self.nodes[key].parent = pivot
        return pivot.key

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

    def unite(self, x, y):
        y_root = self.find_set(y)
        x_root = self.find_set(x)
        if self.nodes[x].rank > self.nodes[y].rank:
            self.nodes[y_root].parent = self.nodes[x_root]
        elif self.nodes[x].rank < self.nodes[y].rank:
            self.nodes[x_root].parent = self.nodes[y_root]
        else:
            self.nodes[x_root].parent = self.nodes[y_root]
            self.nodes[y_root].rank = self.nodes[y_root].rank + 1


N, M = [int(i) for i in input().split()]
nodes = [Node(i) for i in range(N)]
for node in nodes:
    node.parent = node
ds = DisjointSet(nodes)

for _ in range(M):
    x, y, z = [int(i) for i in input().split()]
    x -= 1
    y -= 1
    if ds.same(x, y):
        pass
    else:
        ds.unite(x, y)
ans = len(set([ds.find_set(i) for i in range(N)]))
print(ans)


Measured memory_bytes: 74016
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
  int a;
  string s;
  cin>>a>>s;
  if(a==3200){
   // cout<<a<<endl;
    cout<<s;
  }
  else if(a>3200)
    cout<<s;
  else 
    cout<<"red";
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    ArrayList<Integer> lists = new ArrayList<Integer>();
    for (int i = 0; i < N; i++) {
      lists.add(sc.nextInt());
    }
    int cnt = 0;
    for (int i = 1; i < N - 1; i++) {
      if ((lists.get(i) > lists.get(i - 1) && lists.get(i) < lists.get(i + 1))
          || (lists.get(i) < lists.get(i - 1) && lists.get(i) > lists.get(i + 1))) {
        cnt++;
      }
    }
    System.out.println(cnt);
  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

vector<int>E[100];
int s[100], g[100];
bool used[100];
int t;

void dfs(int u) {
	used[u] = true;
	s[u] = ++t;
	for (int v : E[u]) {
		if (!used[v])dfs(v);
	}
	g[u] = ++t;
}
int main() {
	int n; scanf("%d", &n);
	rep(i, n) {
		int u, k; scanf("%d%d", &u, &k); u--;
		rep(j, k) {
			int v; scanf("%d", &v); v--;
			E[u].push_back(v);
		}
	}
	rep(i, n) {
		if (!used[i])dfs(i);
	}
	rep(i, n) {
		printf("%d %d %d\n", i + 1, s[i], g[i]);
	}
}

Measured memory_bytes: 3256
#071_D
n = int(input())
s = [input() for _ in range(2)]
mod = 10 ** 9 + 7

dp = [0 for _ in range(n)]
tate = [s[0][i] == s[1][i] for i in range(n)]

if tate[0]:
    dp[0] = 3
    x = 1
else:
    dp[0] = dp[1] = 6
    x = 2

while x < n:
    if tate[x-1] and tate[x]:
        dp[x] = (dp[x-1] * 2) % mod
    elif tate[x-1]:
        dp[x] = (dp[x-1] * 2) % mod
        dp[x+1] = dp[x]
        x += 1
    elif tate[x-1] == False and tate[x]:
        dp[x] = dp[x-1]
    else:
        dp[x] = (dp[x-1] * 3) % mod
        dp[x+1] = dp[x]
        x += 1
    x += 1
    
print(dp[n-1])

Measured memory_bytes: 3064
# C - Rally
def main():
    N, *X = map(int, open(0).read().split())
    calc = lambda x, p: (x - p) ** 2
    left, right = min(X), max(X)
    ans = min(sum(calc(x, p) for x in X) for p in range(left, right + 1))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,x,ans=1e9,sum;
bool dp[880][880];
main(){
	cin>>n;
	dp[0][0]=1;
	r(i,n){
		cin>>x;
		sum+=x;
		for(int j=879;j>=0;j--)
		  for(int k=879;k>=0;k--)
		    if(dp[j][k]){
		    	if(j+x<810)dp[j+x][k]=1;
		    	if(k+x<810)dp[j][k+x]=1;
		    }
	}
	r(i,880)r(j,880)if(dp[i][j])ans=min(ans,max({i,j,sum-i-j}));
	cout<<ans<<endl;
}

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

int main() {
	vector <vector<int>> A(3, vector<int> (3));
	for (int i=0; i<3; i++){
	    for (int j=0; j<3; j++){
	        cin >> A.at(i).at(j);
	    }
	}
	int N;
	cin >> N;
	for (int i=0; i<N; i++){
	    int B;
	    cin >> B;
	    for (int j=0; j<3; j++){
	        for (int k=0; k<3; k++){
	            if (A.at(j).at(k)==B) A.at(j).at(k)=0;
	        }
	    }
	}
	bool bingo=false;
	for (int i=0; i<3;i++) {
	    if(!A.at(i).at(0)&&!A.at(i).at(1)&&!A.at(i).at(2)){
	    bingo=true;
	    }
	}
	for (int i=0; i<3; i++){
	    if (!A.at(0).at(i) && !A.at(1).at(i) && !A.at(2).at(i)) bingo=true;
	}
	if (!A.at(0).at(0)&&!A.at(1).at(1)&&!A.at(2).at(2)) bingo=true;
	if (!A.at(2).at(0)&&!A.at(1).at(1)&&!A.at(0).at(2)) bingo=true;
	if (bingo) cout << "Yes" << endl;
	else cout << "No" << endl;

}

Measured memory_bytes: 256
h,w = map(int,input().split())
mp = [input() for i in range(h)]
mp2 = []
for i in range(h):
    if mp[i]!='.'*w:
        mp2.append(mp[i])
space = []
for i in range(w):
    flag = True
    for j in range(len(mp2)):
        flag &= (mp2[j][i]=='.')
    if flag:
        space.append(i)
for i in range(len(mp2)):
    for j in range(w):
        if j in space:
            continue
        print(mp2[i][j],end='')
    print("")


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

int main(){
 int N;
 cin>>N;
 int h[101],m[101];
 for(int i=0;i<N;i++){
	cin>>h[i]>>m[i];
 }
 h[N]=24;m[N]=0;

 int M;
 cin>>M;

 int k[101],g[101];
 for(int j=0;j<M;j++){
	cin>>k[j]>>g[j];
 }
 k[M]=24;g[M]=0;

 for(int i=0,j=0;i<N||j<M;){
	if(h[i]==k[j]&&m[i]==g[j]){
		cout<<h[i]<<':'<<m[i]/10<<m[i]%10;
		i++;j++;
	}
	else if(h[i]<k[j]||(h[i]==k[j]&&m[i]<g[j])){
		cout<<h[i]<<':'<<m[i]/10<<m[i]%10;
		i++;
	}
	else{
		cout<<k[j]<<':'<<g[j]/10<<g[j]%10;
		j++;
	}
	if(i==N&&j==M){
		cout<<endl;
	}
	else {
		cout<<' ';
	}
 }
return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  ll h;
  cin >> h;

  ll a = 1;
  ll ans = 0;

  REP(i,45){
    if(h >= a){
      ans += a;
    }
    else break;
    a *= 2;
    if(a > 1e12) break;
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
#define repi(i, a, b)    for(int i = a; i < b; i++)
#define repd(i, a, b)    for(int i = b-1; i >= a; i--)   
#define rep(i, n)        for(int i = 0; i < n; ++i)
#define ll               long long int
#define I                iterator
#define lf               long double
#define pb               push_back
#define pq               priority_queue
#define all(c)           (c).begin(), (c).end()




int main(){
    int r, d, x;
    cin >> r >> d >> x;
    rep(i, 10){
        int ans = r*x - d;
        cout << ans << endl;
        x = ans;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  static const double pi = 3.141592653589793;
  int A,B,H,M;  cin >> A >> B >> H >> M;
  double degree,ans;
  degree = min(abs(30*H - 5.5*M),360-abs(30*H - 5.5*M));
  ans = sqrt(A*A+B*B-2*A*B*cos((double)pi*degree/180));
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 4228
#include <cstdio>
int n, a, mx, c[200005];
int main() {
	scanf("%d", &n);
	for(int i=0; i<n; i++) {
		scanf("%d", &a);
		c[a] = c[a-1] + 1;
		if(c[a]>mx) mx = c[a];
	}
	printf("%d", n-mx);
	return 0;
}

Measured memory_bytes: 896
n = int(input())
h = list(map(int, input().split()))

INF = 1000000000
#最小値(コスト)を求める問題のため、DP配列を無限大に初期化
dp = [INF] * (n + 1)
#0番目の地点はコスト0
dp[0] = 0

for i in range(1, n):
  dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
  if i > 1:
    dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[n - 1])




Measured memory_bytes: 13976
n,k = list(map(int,input().split())); arr = list(map(int,input().split())); arr.sort(reverse=True)
absarr = [[abs(i), 1 if i>0 else -1 if i<0 else 0] for i in arr]; absarr.sort(reverse=True, key=lambda x: x[0])
mod = 10**9+7

zeroflag = True if absarr[-1][0] == 0 else False
from collections import Counter
posnegarr = Counter([i[1] for i in absarr[:k]])
pos = posnegarr[1]; neg = posnegarr[-1]

if absarr[k-1] == 0:
    ans = 0
elif neg % 2 == 0 or n == k:
    ans = 1
    for i in absarr[:k]:
        ans *= i[0]; ans %= mod
    if n == k and neg % 2 == 1:
        ans = -ans % mod
else:
    ans = 1
    for i in absarr[:k]:
        ans *= i[0]; ans %= mod
    if pos > 0:
        if absarr[k][0] == 0:
            ans = 0
        nextpos = nextneg = 0
        tmp = k
        while tmp < n and (nextpos == 0 or nextneg == 0):
            num = absarr[tmp]
            if num[0] == 0:
                break
            elif num[1] > 0 and nextpos == 0:
                nextpos = num[0]
            elif num[1] < 0 and nextneg == 0:
                nextneg = num[0]
            tmp += 1
        backpos = backneg = 0
        tmp = k-1
        while backpos == 0 or backneg == 0:
            num = absarr[tmp]
            if num[1] > 0 and backpos == 0:
                backpos = num[0]
            elif num[1] < 0 and backneg == 0:
                backneg = num[0]
            tmp -= 1
        if ans == 0:
            pass
        elif nextpos*backpos > nextneg*backneg:
            ans *= nextpos*pow(backneg,-1,mod); ans %= mod
        else:
            ans *= nextneg*pow(backpos,-1,mod); ans %= mod
    else:
        nextpos = 0
        tmp = k
        while tmp < n and nextpos == 0:
            num = absarr[tmp]
            if num[1] > 0:
                nextpos = num[0]
            tmp += 1
        backneg = absarr[k-1][0]
        if nextpos != 0:
            ans *= nextpos * pow(backneg,-1,mod); ans %= mod
        elif zeroflag:
            ans = 0
        else:
            ans = 1
            for i in arr[:k]:
                ans *= i; ans %= mod
        
print(ans)

Measured memory_bytes: 44696
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)
#define repd(i,x,y) for(int i=x; i>=y; --i)

using namespace std;
const int N=500005;
typedef long long LL;
int n,dis[N],a[N],x;
LL mex[N];

int getint()
{
	char ch;
	while(!isdigit(ch=getchar()));
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

void solve()
{
	x=getint();
	if(dis[x-1]>=mex[x+1]) puts("YES");
	else puts("NO");
}

int main()
{
	n=getint(),dis[0]=getint();
	rep(i,1,n) a[i]=getint();
	rep(i,1,n) dis[i]=min(dis[i-1],abs(dis[i-1]-a[i]));
	mex[n+1]=1;
	repd(i,n,1) mex[i]=a[i]>=mex[i+1]*2?mex[i+1]:mex[i+1]+a[i];
	for(int T=getint(); T--; solve());
	return 0;
}

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

int main(void) {
  int K, X;
  cin >> K >> X;
  
  int _min = X - K + 1;
  int _max = X + K - 1;
  int __min = max(_min, -1000000);
  int __max = min(_max, 1000000);
  
  for(int i = __min; i <= __max; i++) {
    cout << i << " "; 
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
bool rev(long long int a,long long int b)
{
    if(a>b)return true;
    else return false;
}
bool compa(pair<string,pair<int,int>>a,pair<string,pair<int,int>>b)
{
    if(a.first==b.first)
    {
        if(a.second.first>b.second.first)
        return true;
        else
        return false;
    }
    if(a.first<b.first)
    return true;
    else 
    return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    long long int n;
    cin>>n;
    n=3*n;
    long long int a[n];
    for(long long int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n,rev);
    long long int ans=0;
    for(long long int i=1;i<=2*n/3;i+=2)
    {
        ans+=a[i];
    }
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 5928
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Xml.Schema;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public ulong NextUlong()
        {
            return ulong.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {

        private void Scan()
        {
            // var sc = new Scanner();

        }

        public void Solve()
        {
            Scan();
            int N = int.Parse(Console.ReadLine());
            if (N == 1)
            {
                Console.WriteLine("Hello World");
            }
            else
            {
                Console.WriteLine(int.Parse(Console.ReadLine()) + int.Parse(Console.ReadLine()));
            }
        }

        static void Main() => new Program().Solve();
    }
}

Measured memory_bytes: 11220
/*input
5 2
1 0 0 1 0
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#define ll long long 
#define ld long double
#define pii pair<int,int>
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define MP make_pair
const ll INF64=4e12;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1){
            res=(res*a)%MOD;
        }
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
int arr[maxn];
int arr2[maxn];
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n,k;
    cin>>n>>k;
    REP(i,n){
        cin>>arr[i];
    }
    while(k--){
        bool d=1;
        REP(i,n){
            if(arr[i]!=n) d=0;
        }
        if(d){
            break;
        }
        vector<pii> v;
        int sum=0;
        int cur=0;
        REP(i,n){
            v.pb({max(i-arr[i],0),1});
            v.pb({min(i+arr[i]+1,n+1),-1});
        }
        sort(ALL(v));
        REP(i,n){
            while(cur<sz(v) and v[cur].f==i) sum+=v[cur].s,++cur;
            arr[i]=sum;
        }
    }
    REP(i,n) cout<<arr[i]<<' ';
}

Measured memory_bytes: 11108
import java.util.Scanner;

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

  public static void main(String[] args) {
    int H = sc.nextInt();
    int W = sc.nextInt();
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (sc.next().equals("snuke")) {
          System.out.println("" + (char)(j + 'A') + (i + 1));
        }
      }
    }
  }

}


Measured memory_bytes: 10704
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

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

  sort(a, a + n);

  deque< ll > b;
  for(int i = 0; i < n / 2; i++){
    if(i % 2 == 0){
      b.push_front(a[i]);
      b.push_back(a[n - 1 - i]);
    }
    else{
      b.push_back(a[i]);
      b.push_front(a[n - 1 - i]);
    }
  }
  if(n % 2 == 1){
    if(abs(a[n / 2] - b.front()) > abs(a[n / 2] - b.back())){
      b.push_front(a[n / 2]);
    }
    else{
      b.push_back(a[n / 2]);
    }
  }

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

  cout << sum << endl;

  return 0;
}


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

int main() {
  int H, W; cin >> H >> W;
  char s[H+2][W+2];
  for (int i = 0; i < H+2; i++) {
    s[i][0] = '.';
    s[i][W+1] = '.';
  }
  for (int i = 0; i < W+2; i++) {
    s[0][i] = '.';
    s[H+1][i] = '.';
  }
  for (int i = 1; i < H+1; i++) {
    for (int j = 1; j < W+1; j++)
      cin >> s[i][j];
  }
  for (int i = 1; i < H+1; i++) {
    for (int j = 1; j < W+1; j++) {
      if (s[i][j] == '#') {
        if (s[i-1][j] == '.' && s[i][j-1] == '.' && s[i][j+1] == '.' && s[i+1][j] == '.') {
          cout << "No" << endl;
          return 0;
        }
      }      
    }
  }
  cout << "Yes" << endl;
}


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

int main(){
  int N;
  cin >> N;
  string data;
  int counter = 0;
  int counter_1 = 0;
  int counter_2 = 0;
  int counter_3 = 0;

  for(int i = 0;i < N;i++){
    cin >> data;
    for(int j = 0;j < data.size();j++){
      if(data.substr(j,2) == "AB")counter++;
    }
    if(data.substr(data.size() - 1,1) == "A")counter_3++;
    if(data.substr(0,1) == "B")counter_2++;
    if(data.substr(data.size() - 1,1) == "A" && data.substr(0,1) == "B")counter_1++;
  }

  counter_3 -= counter_1;
  counter_2 -= counter_1;

  if(counter_1 == 0){
    counter += min(counter_2,counter_3);
  }else{
    if(counter_2 + counter_3 > 0){
      counter += counter_1 + min(counter_2,counter_3);
    }else{
      counter += counter_1 - 1;
    }
  }
  cout << counter << endl;
}


Measured memory_bytes: 256
x,y=map(int,input().split())
count=abs(abs(x)-abs(y))
if x==-y:
    print(1)
elif x*y<0:
    print(count+1)
elif x<y:
    print(count)
elif x*y:
    print(count+2)
else:
    print(count+1)


Measured memory_bytes: 2940
# coding: utf-8
# Your code here!
a=input().split()
x=int(a[0])
y=int(a[1])
z=[]
c=[]
d=[[1,0],[0,-1],[-1,0],[0,1]]
ans=1
for i in range(x):
    a_list=[]
    for j in range(y):
        a_list.append(0)
    z.append(a_list)
for i in range(x):
    b=list(input())
    c.append(b)

for i in range(x):
    for j in range(y):
        if c[i][j]=="#":
            s=i
            t=j
            count=0
            for k in range(4):
                s=i+d[k][0]
                t=j+d[k][1]
                
                if (s>=0 and s<x) and (t>=0 and t<y):
                    
                    if c[s][t]=="#":
                        count+=1
                     
            if count==0:
                ans=0
                
if ans==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064