akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
int min(int a, int b)
{
    if (a < b)
        return a;
    else
        return b;
}
int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    int x[100005];
    int i;
    for (i = 0; i < n; i++)
        scanf("%d", &x[i]);
    if (k == 1)
    {
        printf("%d\n", abs(x[0]));
        return 0;
    }
    int ans = 999999999;
    int t;
    for (i = 0; i <= n - k; i++)
    {
        t = min(abs(x[i]), abs(x[i + k - 1]));
        t += x[i + k - 1] - x[i];
        ans = min(ans, t);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{

int a,b;
scanf("%d %d", &a, &b);
if(a < b){
  printf("a < b\n");
} else if(a > b){
  printf("a > b\n");
} else{
  printf("a == b\n");
}
   return 0;
}  

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

int main(){
  int W, H, N;
  cin >> W >> H >> N;
  int A[W][H];
  for(int i=0; i<W; i++){
    for(int j=0; j<H; j++) A[i][j]=0;
  }
  for(int i=0; i<N; i++){
    int x, y, a;
    cin >> x >> y >> a;
    if(a==1){
      for(int j=0; j<x; j++){
        for(int k=0; k<H; k++) A[j][k]++;
      }
    }
    if(a==2){
      for(int j=x; j<W; j++){
        for(int k=0; k<H; k++) A[j][k]++;
      }
    }
    if(a==3){
      for(int j=0; j<W; j++){
        for(int k=0; k<y; k++) A[j][k]++;
      }
    }
    if(a==4){
      for(int j=0; j<W; j++){
        for(int k=y; k<H; k++) A[j][k]++;
      }
    }
  }
  int ans=0;
  for(int i=0; i<W; i++){
    for(int j=0; j<H; j++) if(A[i][j]==0) ans++;
  }
  cout << ans << endl;
}

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


int main(void) {
	int n;
	double v, y, t;
	int floor;
	
	while( scanf("%lf", &v) != EOF) {
		t = v / 9.8;
		y = 4.9 * t*t;
		for ( floor = 1; 5 * floor -5 < y; floor++);
		printf("%d\n", floor);
	}
	
	return 0;
}

Measured memory_bytes: 628
#include <iostream>
#include <map>

using namespace std;
typedef long long ll;

ll h;

map<ll, ll> dp;

ll score(ll x) {
  auto iter = dp.find(x);
  if (iter != dp.end()) {
    return iter->second;
  }
  if (x <= 1) {
    return dp[x] = x;
  }
  return dp[x] = score(x / 2) * 2 + 1;
}

void solve() {
  cout << score(h) << endl;
}

int main() {
  cin >> h;
  solve();
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {

	var (
		n int
		s string
	)

	var (
		rCnt int
		bCnt int
	)

	fmt.Scan(&n)
	fmt.Scan(&s)

	for i := 0; i < n; i++ {
		if s[i] == 'R' {
			rCnt++
		} else {
			bCnt++
		}
	}

	if rCnt > bCnt {
		fmt.Print("Yes")
	} else {
		fmt.Print("No")
	}

}


Measured memory_bytes: 512
import sys
read=sys.stdin.buffer.readline

class BIT:
    def __init__(self,N):
        self.N=N
        self.bit=[0]*N
    def add(self,a,w):
        x=a
        while(x<self.N):
            self.bit[x]+=w
            x|=x+1
    def get(self,a):
        ret,x=0,a-1
        while(x>=0):
            ret+=self.bit[x]
            x=(x&(x+1))-1
        return ret
    def cum(self,l,r):
        return self.get(r)-self.get(l)

def update(x,i):
    if good[x]==-1:
        good[x]=i
        bit.add(i,1)
    else:
        bit.add(good[x],-1)
        good[x]=i
        bit.add(good[x],1)
    return
    
N,Q=map(int,read().split())
c=tuple(map(int,read().split()))
Query=[]
for i in range(Q):
    l,r=map(lambda x:int(x)-1,read().split())
    Query.append((l,r,i))
Query.sort(key=lambda x:x[1])
ans=[-1]*Q
good=[-1]*(N+1)
bit=BIT(N)

i=0
for L,R,w in Query:
    while(i<=R):
        update(c[i],i)
        i+=1
    ans[w]=bit.cum(L,R+1)

print(*ans,sep='\n')

Measured memory_bytes: 231808
using System;
using System.Text;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int sx = sc.NextInt();
        int sy = sc.NextInt();
        int tx = sc.NextInt();
        int ty = sc.NextInt();

        StringBuilder sb = new StringBuilder();
        sb.Append('R', tx - sx);
        sb.Append('U', ty - sy);
        sb.Append('L', tx - sx);
        sb.Append('D', ty - sy + 1);
        sb.Append('R', tx - sx + 1);
        sb.Append('U', ty - sy + 1);
        sb.Append('L');
        sb.Append('U');
        sb.Append('L', tx - sx + 1);
        sb.Append('D', ty - sy + 1);
        sb.Append('R');
        Console.WriteLine(sb);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11164
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;


 
signed main(){
	int N;
	cin >> N;
	vector<string>s(N);
	REP(i,N){
		cin >> s[i];
	}
	vector<pair<int,int>>ok;
	vector<pair<int,int>>v;
	REP(i,N){
		int cnt = 0,mi = 0;
		for(auto e:s[i]){
			if(e == '(')++cnt;
			else --cnt;
			CHMIN(mi,cnt);
		}
		if(cnt >= 0)ok.emplace_back(mi,cnt);
		else v.emplace_back(mi,cnt);
	}
	sort(ALL(ok),[](pair<int,int>a,pair<int,int>b){
		return a.first > b.first;
	});
	int sum = 0;
	for(auto[a,b]:ok){
		if(sum + a < 0){
			out("No");
			return 0;
		}
		sum += b;
	}
	sort(ALL(v),[](pair<int,int>a,pair<int,int>b){
		return a.first - a.second < b.first - b.second;
	});
	for(auto[a,b]:v){
		if(sum + a < 0){
			out("No");
			return 0;
		}
		sum += b;
	}
	if(sum)out("No");
	else out("Yes");
}

Measured memory_bytes: 50296
import java.util.*;

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

        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i=0; i<N; i++) {
            a[i] = sc.nextInt();
        }

        int res = 0;

        for (int i=0; i<N; i++) {

            while (i+1 < N && a[i] == a[i+1]) {
                i++;
            }

            if (i+1 < N && a[i] < a[i+1]) {
                while (i+1 < N && a[i] <= a[i+1]) {
                    i++;
                }
            } else if(i+1 < N && a[i] > a[i+1]) {
                while (i+1 < N && a[i] >= a[i+1]) {
                    i++;
                }
            }
            res++;
        }
        System.out.println(res);
    }
}



Measured memory_bytes: 48860
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

const double EPS = 1e-4;

double calc(double ra, double rb, double s){
    double lb = abs(ra - rb);
    double ub = ra + rb;
    REP(_, 64) {
        double d = (lb + ub) / 2;
        double tha = acos((ra * ra + d * d - rb * rb) / (2.0 * d * ra));
        double thb = acos((rb * rb + d * d - ra * ra) / (2.0 * d * rb));
        double sum = ra * ra * tha + rb * rb * thb - ra * d * sin(tha);
        if(sum > s){
            lb = d;
        }else{
            ub = d;
        }
    }
    return ub;
}

inline double sq(double x){
    return x * x;
}

inline bool judge(double x, double y, double r, double W, double H){
    return x - r > -EPS && x + r < W + EPS && y - r > -EPS && y + r < H + EPS;
}

bool solve(double W, double H, double sa, double sb, double sc, bool reversed){
    double ra = sqrt(sa / M_PI);
    double rb = sqrt(sb / M_PI);

    if(2.0 * ra > min(W, H) + EPS) return false;
    if(2.0 * rb > min(W, H) + EPS) return false;

    double D = calc(ra, rb, sc);
    double xa = ra;
    double ya = ra;

    for(double xb : {ra, rb, W - rb}){
        double dy = sqrt(sq(D) - sq(xa - xb));

        for(int sign = -1; sign <= 1; sign += 2){
            double yb = ya + sign * dy;
            if(judge(xb, yb, rb, W, H)){
                if(not reversed) {
                    printf("%.9f %.9f %.9f %.9f %.9f %.9f\n", xa, ya, ra, xb, yb, rb);
                } else {
                    printf("%.9f %.9f %.9f %.9f %.9f %.9f\n", xb, yb, rb, xa, ya, ra);
                }
                return true;
            }
        }

    }

    for(double yb : {ra, rb, H - rb}){
        double dx = sqrt(sq(D) - sq(ya - yb));

        for(int sign = -1; sign <= 1; sign += 2){
            double xb = xa + sign * dx;
            if(judge(xb, yb, rb, W, H)){
                if(not reversed) {
                    printf("%.9f %.9f %.9f %.9f %.9f %.9f\n", xa, ya, ra, xb, yb, rb);
                } else {
                    printf("%.9f %.9f %.9f %.9f %.9f %.9f\n", xb, yb, rb, xa, ya, ra);
                }
                return true;
            }
        }

    }

    return false;
}

int main(){
    double W, H, sa, sb, sc;
    while(cin >> W >> H >> sa >> sb >> sc && W > 0){
        if(solve(W, H, sa, sb, sc, false)) continue;
        if(solve(W, H, sb, sa, sc, true)) continue;
        cout << "impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 1368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using pii = pair<int,int>;
using pll = pair<long,long>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back

int main() {
  int n; cin>>n;
  int cnt=0;
  int d1,d2;
  bool can=false;
  rep(i,n) {
    cin>>d1>>d2;
    if(d1!=d2) cnt=0;
    else cnt++;
    if(cnt==3) can=true;
  }
  if(can) cout<<"Yes\n";
  else cout<<"No\n";
}


Measured memory_bytes: 3624
#include<iostream>

int main()
{
	int n, d;
	
	std::cin >> n >> d;
	
	int result;
	
	result = n / (2 * d + 1);
	
	if (n % (2 * d + 1) != 0)
	{
		++result;
	}
	
	std::cout << result << std::endl;
	
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
#pragma endregion

void solve() {
  int N;
  cin >> N;
  vi64 A(N);
  cin >> A;
  i64 xor_sum = 0;
  {
    rep(i, N) xor_sum ^= A[i];
    rep(i, N) A[i] &= ~xor_sum;
  }
  int p = 0;
  rrep(i, 60) {
    bool f = false;
    repi(j, p, N) if ((A[j] >> i) & 1) {
      swap(A[p], A[j]);
      f = true;
      break;
    }
    if (!f) {
      continue;
    }
    rep(j, N) {
      if (j == p) continue;
      if ((A[j] >> i) & 1) A[j] ^= A[p];
    }
    p++;
  }
  A.resize(60);
  i64 acc = 0;
  rep(i, 60) acc ^= A[i];
  i64 ans = acc * 2 + xor_sum;
  cout << ans << endl;
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;

ll l,r;
int main(){
  cin >> l >> r;
  ll ans = 2020;
  r = min(r, l+2019);
  for(ll i = l; i <= min(r, l+2019); i++){
    for(ll j = i+1; j <= min(r, l+2019); j++){
      ll tmp = (i%2019)*(j%2019)%2019;
      ans = min(ans, tmp);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<ll> v(n);
  map<char,ll> mp;
  Rep(i,n+1){
    string tmp=to_string(i);
    if(tmp[tmp.size()-1]!='0' && tmp[0]==tmp[tmp.size()-1]) mp[tmp[0]]++;
  }
  ll ans=0;
  for(auto c:mp) ans+=(c.second)*(c.second);
  map<ll,ll> mp2;
  Rep(i,n+1) mp2[i]=0;
  Rep(i,n+1){
    string tmp=to_string(i);
    if(tmp[tmp.size()-1]==0 || tmp[0]==tmp[tmp.size()-1]) continue;
    ll cur=(tmp[0]-'0')*10+(tmp[tmp.size()-1]-'0');
    mp2[cur]++;
  }
  Rep(i,10){
    Rep(j,10){
      if(i==j) continue;
      ans+=mp2[i*10+j]*mp2[j*10+i];
    }
  }
  cout<<ans<<endl;
}

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

int main() {
  vector<int> antena(5);
  for (int i=0; i<5; i++) cin >> antena[i];
  int k; cin >> k;
  string msg = "Yay!";
  for (int i=0; i<5; i++) {
    for (int j=i+1; j<5; j++) {
      if (antena[j] - antena[i] > k) {
        msg = ":(";
        break;
      }
    }
  }
  cout << msg << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;
int main(){
    int N, K = 0; cin >> N;
    vector<pair<int, int>> P(N);
    vector<vector<int>> V(N+1); //map(N+1, vector<int>(N+1)), 
    int init;
    map<pair<int, int>, int> I;
    for(int i = 0; i < N-1; i++){
        int a, b; cin >> a >> b;
        V[a].push_back(b);
        V[b].push_back(a);
        P[i] = make_pair(a, b);
        if(i == 0) init = a;
    }

    for(int i = 0; i < N; i++) K = max(K, (int)V[i].size());
    int c = 1;

    vector<int> cs(N+1, 0);
    queue<int> Q; Q.push(1);
    while(!Q.empty()){
        int v = Q.front(); Q.pop();
        int c = cs[v];

        for(int i = 0; i < V[v].size(); i++){
            int u = V[v][i];
            
            if(v < u){
                //cout << " " << v << " " << u << " " << c << endl;
                Q.push(u);
                c++;
                if(c > K) c = 1;
                cs[u] = c;
                I[make_pair(v, u)] = c;
                //map[v][u] = c;
                //map[u][v] = c;
                //cout << " " << v << " " << u << " " << c << endl;
                
                
                //cout << u << " " << v << " color " << c << endl;
            }
        }
    }
    cout << K << endl;
    for(int i = 0; i < N-1; i++){
        cout << I[P[i]] << endl;
    }
}


Measured memory_bytes: 13440
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		while (true) {
			String str = br.readLine();

			String[] num = getElement(str);

			int h = Integer.parseInt(num[0]);
			int w = Integer.parseInt(num[1]);

			if (h == 0 && w == 0) {
				break;
			}
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					System.out.print("#");
//					if (j == w - 1) {
//						System.out.print(" ");
//					}
				}
				System.out.print("\r\n");
			}
			System.out.print("\r\n");
		}

	}

	//??????????????????????????????????????????
	public static String[] getElement(String element) {
		return (element.split(" "));
	}
}

Measured memory_bytes: 36628
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let n = read!(usize);
    let a: Vec<i64> = read![[i64]];
    let b: Vec<i64> = read![[i64]];

    let mut b_sub_a = 0; // 肩代わり可能な数
    let mut a_sub_b = 0; // 肩代わりされなければならない数
    for i in 0..n {
        if b[i] >= a[i] {
            b_sub_a += (b[i] - a[i]) / 2;
        } else {
            a_sub_b += a[i] - b[i];
        }
    }

    println!("{}", if b_sub_a >= a_sub_b { "Yes" } else { "No" });
}


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

#define INF 1234567890
#define ll long long

int N, P = 1;
vector<string> v;
int go[1010101][26], cnt[1010101][26];
// cnt[n][c] : n 아래에 문자 c가 존재하는 문자열이 몇 개인가?
int C[26]; // Insert 함수 전용

void Insert(int n, int p, string &s) // suffix 삽입
{
	if (p == -1) return;

	for(int i=0; i<26; i++)
		if (C[i])
			cnt[n][i]++;
	C[s[p]-'a']--;

	int next = go[n][s[p]-'a'];
	if (next == 0) go[n][s[p]-'a'] = next = ++P;
	//cout << n << " -> " << next << " : " << s[p] << "\n";
	Insert(next, p-1, s);
}

int Find(int n, int p, string &s)
{
	if (p == 0) return cnt[n][s[0]-'a'];

	int next = go[n][s[p]-'a'];
	if (next == 0) return 0;
	return Find(next, p-1, s);
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	for(int i=0; i<N; i++)
	{
		string s;
		cin >> s;
		v.push_back(s);
	}
	sort(v.begin(), v.end(), [&](string &a, string &b){return a.size() > b.size(); }); // 길이가 긴 순으로 삽입

	ll res = 0;
	vector<int> upd;
	for(int i=0; i<N; i++)
	{
		upd.push_back(i);

		int val = Find(1, (int)v[i].size()-1, v[i]);
		//cout << v[i] << " " << val << "\n";
		res += val;
		
		// 몰아서 업데이트
		if (i+1 != N && v[i].size() != v[i+1].size())
		{
			for(int idx : upd)
			{
				memset(C, 0, sizeof(C));
				for(char c : v[idx])
					C[c-'a']++;
				Insert(1, (int)v[idx].size()-1, v[idx]);
			}
			upd.clear();
		}
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 207232
use smallvec::alloc::collections::VecDeque;
use text_io::*;

fn main() {
    let n: usize = read!();
    let m: usize = read!();
    let mut vec = vec![vec![]; n];
    for _ in 0..m {
        let a: usize = read!();
        let b: usize = read!();
        vec[a - 1].push(b - 1);
        vec[b - 1].push(a - 1);
    }
    
    let mut queue = VecDeque::new();
    queue.push_back(0);
    let mut ans: Vec<isize> = vec![-1; n];
    
    while !queue.is_empty() {
        let q = queue.pop_front().unwrap();
        vec[q].iter().for_each(|&i| {
            if ans[i] == -1 {
                ans[i] = q as isize;
                queue.push_back(i);
            }
        })
    }
    
    println!("Yes");
    ans.iter().skip(1).for_each(|i|
        println!("{}", i + 1));
}


Measured memory_bytes: 11948
//#include "gap.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stdlib.h>
#include <cmath>
#include <math.h>
#include <fstream>
#include <bitset>
#include <time.h>
#include <queue>
#define int long long
using namespace std;
int32_t main(){
    int n, z, w;
    cin >> n >> z >> w;
    vector<int> data(n);
    for (int i=0; i < n; i++) cin >> data[i];
    int dp[n][2];
    for (int i=n-1; i >= 0; i--){
        int old;
        if (i != 0) old = data[i-1];
        else old = w;
        int res = abs(old - data[n-1]);
        for (int j=i+1; j < n; j++){
            res = max(res, dp[j][1]);
        }
        dp[i][0] = res;
        if (i != 0) old = data[i-1];
        else old = z;
        res = abs(old - data[n-1]);
        for (int j=i+1; j < n; j++){
            res = min(res, dp[j][0]);
        }
        dp[i][1] = res;
    }
    cout << dp[0][0] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int h = Integer.parseInt(sc.next()); 
            int w = Integer.parseInt(sc.next());
            if (h == 0 && w == 0) {
                break;
            } else {
                for (int j = 0; j < h; j++) {
                    for (int i = 0; i < w; i++)
                        if ((j != 0 && j != h-1) && (i != 0 && i != w-1))
                            System.out.print(".");
                        else
                            System.out.print("#");
                    System.out.println();
                }
                System.out.println();
            }
        }
    }
}


Measured memory_bytes: 36404
#include<iostream>
using namespace std;
const int MAX = 105;
char map[MAX][MAX];
bool visit[MAX][MAX];
int h, w;
int dx[4] = { 0,0,1,-1 };
int dy[4] = { 1,-1,0,0 };
void bfs(int x, int y)
{
	visit[x][y] = true;
	int xx, yy;
	for (int i = 0; i < 4; i++)
	{
		xx = x + dx[i];
		yy = y + dy[i];
		if (xx >= 0 && xx < h&&yy >= 0 && yy < w)
		{
			if (map[x][y] == map[xx][yy] && !visit[xx][yy])
			{
				bfs(xx, yy);
			}
		}
	}
}
int main()
{
	int i, j;
	while (cin >> h >> w)
	{
		if (h == 0 && w == 0)
		{
			break;
		}
		for (i = 0; i < h; i++)
		{
			for (j = 0; j < w; j++)
			{
				cin >> map[i][j];
				visit[i][j] = false;
			}
		}
		int sum = 0;
		for (i = 0; i < h; i++)
		{
			for (j = 0; j < w; j++)
			{
				if (!visit[i][j])
				{
					bfs(i, j);
					sum++;
				}
			}
		}
		cout << sum << endl;
	}
	return 0;
}


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

int main(){
    long long n,k,q,a;
    cin >> n >> k >> q;
    vector<long long> count(n,k);
    for (int i=0;i<q;++i){
        cin >> a;
        count.at(a-1)+=1;    
    }
    for(int j=0;j<n;++j){
            count.at(j)-=1*q;
        }
    for(int i=0;i<n;++i){
        if(count.at(i)<=0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}

Measured memory_bytes: 1408
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

S=list(str(input()))
r_sum=0


def dec2bin(target):
	amari=[]
	while(target!=0):
		amari.append(target%2)
		target=target//2
	amari.reverse()
	return amari

    
for i in range(2**(len(S)-1)):
	add_list=dec2bin(i)
	tmp=[0]*(len(S)-1-len(add_list))
	add_list=tmp+add_list
	c=0
	for j in range(len(S)):
		r_sum += int(S[-j-1]) *(10**c)
		c += 1
		if(j<(len(S)-1)):
			if(add_list[-j-1]==1):
				c=0
print(r_sum)
	

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

int main() {
	int h, n;
	scanf("%d%d", &h, &n);
	for(int i=0;i<n;i++) {
		int x;
		scanf("%d", &x);
		if(h>0) h-=x;
	}
	puts(h>0?"No":"Yes");
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[51];
int main()
{
	int n,k,tot=0;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=n;i>n-k;i--)
		tot+=a[i];
	printf("%d",tot);
}

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

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

    int a, b;
    cin >> a >> b;

    string m = (a <= 8 and b <= 8 ? "Yay!" : ":(");
    cout << m << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second

int n, a[100005], ans;
pair<int, int> pr[100005];
bool b[100005];

int main() {
	scanf("%d", &n);
	for ( int i = 1; i <= n; i++ ) {
		scanf("%d", &a[i]);
		pr[i].x = a[i];
		pr[i].y = i;
	}
	sort(pr + 1, pr + n + 1);
	for ( int i = 1; i <= n; i += 2 ) {
		b[pr[i].y] = true;
	}
	for ( int i = 1; i <= n; i += 2 ) {
		if ( !b[i] ) ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 5080
#include<stdio.h>
int main()
{
    int h,w;
    int i,j;
    while(1){
        scanf("%d %d", &h, &w);
        if(h==0&&w==0)break;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                if((i%2==0&&j%2==0)||(i%2==1&&j%2==1)){
                printf("#");
                }
                else{
                printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2616
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}


int main(){
    int N, M;
    cin >> N >> M;

    int s[10],c[10];
    rep(i,M)cin >> s[i] >> c[i];

    rep(i,1000){
        int keta=0,d[5];
        if(i <= 9){
            keta = 1;
            d[1] = i; 
        }

        else if(10 <= i && i<=99){
            keta =2;
            d[2] = i%10; d[1] = i/10;
        }

        else {
            keta = 3;
            d[3] = i%10; d[2] = (i/10)%10; d[1] = i/100;
        }

        if(N != keta)continue;

        bool can = true;
        rep(j,M){
            if(d[s[j]] != c[j]){
                can = false;
            }
        }

        if(can){
            cout << i << endl;
            return 0;
        }
        
    }
    cout <<"-1" << endl;



}

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

const int MAX_N = 5e5+10, MAX_Q = 5e5+10;
int N, Q;
int c[MAX_N];
int l,r;
vector<int> qry[MAX_N];
vector<int> qid[MAX_N];
int lst[MAX_N];
int dat[MAX_N];
int ans[MAX_Q];

void add(int i, int v)
{
	while(i<MAX_N){
		dat[i]+=v;
		i+=i&-i;
	}
}

int sum(int i)
{
	int res = 0;
	while(i>0){
		res+=dat[i];
		i-=i&-i;
	}
	return res;
}

int rangesum(int i, int j)
{
	return sum(j)-sum(i-1);
}

void solve()
{
	for(int i=1;i<=N;++i){
		if(lst[c[i]]>0) add(lst[c[i]], -1);
		add(i,1);
		lst[c[i]]=i;
		for(int j=0;j<qry[i].size();++j){
			ans[qid[i][j]]=rangesum(qry[i][j],i);
		}
	}
	for(int i=0;i<Q;++i)cout<<ans[i]<<'\n';
}

int main()
{
	cin >> N >> Q;
	for(int i=1;i<=N;++i) cin >> c[i];
	for(int i=0;i<Q;++i){
		cin >> l >> r;
		qry[r].push_back(l);
		qid[r].push_back(i);
	}
	solve();
	return 0;
}

Measured memory_bytes: 52948
/*
????????????????????????????????¨??¢?´¢??????????????§?????????
?????¢?´¢????????¶???????????????????£???????????????????????????????????????????????????????
*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
using namespace std;

int num = 0;


string hds;
int hdi;
int hdfs(){
	vector<int> vt;
  //cout<<"v"<<num<<endl;
	int ret=0;
	if(isdigit(hds[hdi])){
		int a=0;
		while(isdigit(hds[hdi]))	a=10*a+(hds[hdi++]-'0');
		vt.push_back(a/2+1);
	}else	{
		while(hds[hdi++]=='[')	{
      num++;
		vt.push_back(hdfs());
		if(hds[hdi + 1]!=']') hdi++;
		}
	}

	sort(vt.begin(),vt.end());
	REP(j,0,(int)vt.size()/2+1)	ret+=vt[j];
	//p(ret);
  num--;
	return ret;
}

int main(){
	int n;
	cin>>n;
	REP(i,0,n)	{
		hdi=0;
		cin>>hds;
		p(hdfs());
	}
	return 0;
}

Measured memory_bytes: 3180
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  ll r, D, x;
  cin >> r >> D >> x;
  FOR(i, 10) {
    x = x * r - D;
    print(x);
  }
  return 0;
}

Measured memory_bytes: 256
#define alphanso                  \
	ios_base::sync_with_stdio(0); \
	cin.tie(NULL)
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
int main()
{
	alphanso;
	int n, x, i;
	cin >> n;
	map<int, int> m;
	for (i = 1; i <= n; i++)
	{
		cin >> x;
		m[x] = i;
	}
	for (auto it = m.begin(); it != m.end(); it++)
		cout << it->second << " ";
	return 0;
}

Measured memory_bytes: 8284
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>

using namespace std;
typedef int INT;
typedef unsigned int UINT;
typedef long long LLONG;
typedef unsigned long long ULLONG;

//#define LengthOf()

int main()
{
	INT x, y, z;
	cin >> x >> y >> z;

	cout << z << " " << x << " " << y;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	static Scanner in = new Scanner(System.in);
	
	public static void main(String[] args) {
		while (in.hasNext()) {
			String s = in.nextLine();
			while (true) {
				if (s.contains("this") ||
					s.contains("the") ||
					s.contains("that")) {
					System.out.println(s);
					break;
				} else {
					s = shift(s);
					//System.out.println(s);
				}
			}
		}
	}
	
	public static String shift(String s) {
		StringBuffer input = new StringBuffer(s);
		StringBuffer output = new StringBuffer();
		for (int i = 0; i < input.length(); i++) {
			char c = input.charAt(i);
			if (c >= 97 && c <= 122) {
				output.append((char)(((((c-97)+1)%26)+97)));
			} else {
				output.append(String.valueOf(c));
			}
		}
		return output.toString();
	}
}

Measured memory_bytes: 17200
A, B, M = map(int, input().split())
*a, = map(int, input().split())
*b, = map(int, input().split())
ans = 10**20

for _ in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x-1]+b[y-1]-c)

a.sort()
b.sort()

ans = min(ans, a[0]+b[0])
print(ans)


Measured memory_bytes: 24752
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <climits>
#include <functional>

#define REP(i,n) for(int i = 0;i < n;i++)
#define pyfor(j,s,n,i) for(int j = s;j < n;j += i)

using namespace std;
typedef long long ll;
const int INF = INT_MAX;

const int max_n = 1e3;

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

  int N;
  cin >> N;

  int a[N];
  REP(i, N) {
    cin >> a[i];
  }

  ll cnt = a[0]-1;
  int min = 2;

  for(int i = 1;i < N;i++){
    if (a[i] == min) {
      min++;
    } else {
      cnt += (a[i]-1)/min;
    }
  }

  cout << cnt << "\n";
  return 0;
}


Measured memory_bytes: 768
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>

using namespace std;

long long N, M, X, U[2000], V[2000], W[2000];

pair<int, pair<int, int> > edge[2000];
long long parent[1000];
long long weight;
long long S[3];
long long ans;

int par(int a) {
	if (parent[a] == -1) { return a; }
	parent[a] = par(parent[a]);
	return parent[a];
}

int main() {
	scanf("%lld %lld", &N, &M);
	scanf("%lld", &X);
	for (int i = 0; i < M; i++) {
		scanf("%lld %lld %lld", &U[i], &V[i], &W[i]);
		edge[i] = make_pair(W[i], make_pair(U[i]-1, V[i]-1));
	}
	sort(edge, edge + M);

	/*各辺について、その辺を含むような大域木のうち重み最小のものを求める*/

	S[0] = 0;
	S[1] = 0;
	S[2] = 0;

	for (int i = 0; i < M; i++) {
		weight = edge[i].first;
		for (int i = 0; i < N; i++) {
			parent[i] = -1;
		}
		parent[edge[i].second.second] = edge[i].second.first;
		for (int j = 0; j < M; j++) {
			if (i == j) { continue; }
			if (par(edge[j].second.first) != par(edge[j].second.second)) {
				parent[par(edge[j].second.second)] = par(edge[j].second.first);
				weight = weight + edge[j].first;
			}
		}
		if (weight < X) { S[0]++; }
		else if (weight == X) { S[1]++; }
		else { S[2]++; }
	}

	
	if (N < 3) { printf("0\n"); return 0; }
	if (S[0] == 0) {
		if (S[1] == 0) { printf("0\n"); return 0; }
		/*(2^S[1] - 2)* 2^S[2]*/
		ans = 1;
		for (int i = 0; i < S[1]; i++) {
			ans = (ans * 2) % 1000000007;
		}
		ans = (ans - 2 + 1000000007) % 1000000007;
		for (int i = 0; i < S[2]; i++) {
			ans = (ans * 2) % 1000000007;
		}
		printf("%lld\n", ans); return 0;
	}
	if (S[1] == 0) { printf("0\n"); return 0; }
	/*2 * (2^S[1] - 1)* 2^S[2]*/
	ans = 2;
	for (int i = 0; i < S[1]; i++) {
		ans = (ans * 2) % 1000000007;
	}
	ans = (ans - 2 + 1000000007) % 1000000007;
	for (int i = 0; i < S[2]; i++) {
		ans = (ans * 2) % 1000000007;
	}
	printf("%lld\n", ans); return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<ll> x(n);
	rep(i, n) cin >> x[i];
	ll ans = 1e18;
	for (int i = k - 1; i < n; ++i) {
		ll tmp = x[i] - x[i - k + 1];
		if (x[i] <= 0) {
			tmp += abs(x[i]);
		}
		else if (x[i - k + 1] >= 0) {
			tmp += abs(x[i - k + 1]);
		}
		else {
			tmp += min(abs(x[i]), abs(x[i - k + 1]));
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
//
//  CPlibrary
//
//  Created by Tanmay Singh on 3/03/2020.
// INDIAN INSTITUTE OF TECHNOLOGY (BHU) , VARANASI
//  Copyright © 2020 Tanmay Singh. All rights reserved.
//#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
 
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <climits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
 
#define FAST(); ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define mod 1000000007
typedef long long int  bigint ;
typedef std::vector< int > vi;
typedef std::vector< long long int > vll;
typedef std::vector< vi > vvi;
 
using namespace std;

int main(){
    FAST() ;
    string a , b ; cin >> a >> b ;
    string c = a + b ;
    int N = stoi(c) ;
    if( sqrt((double)N) - (int)(sqrt(N)) == 0 )
        cout << "Yes" << endl ;
    else
        cout << "No" << endl ;
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  int e; cin >> e;
  while (e!=0) {
    int m = INF;
    for (int z = 0; z*z*z <= e; z++) {
      for (int y = 0; z*z*z+y*y <= e; y++) {
        m = min(m, e+y+z-y*y-z*z*z);
      }
    }
    cout << m << endl;
    cin >> e;
  }
}



Measured memory_bytes: 2984
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  ll ans=1;
  ll mn=v[0];
  rep(i,n-1){
    mn=min(v[i],mn);
    if(mn>v[i+1]) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1920
// D - Redistribution
#include <bits/stdc++.h>
using namespace std;

int main(){
	int S; cin>>S;
	int b3 = 1, b2 = 0, now = 0; // now == b1
	while(S-- > 2){ // S-2>0 -> S>2
		int b1 = now;
		now = (b1 + b3) % 1'000'000'007;
		b3 = b2; b2 = b1;
	}
	cout<< now <<endl;
}


Measured memory_bytes: 3624
// depends on: -

/*
usage:

tools::pow2(5) => 32
*/

#include <type_traits>
#include <cstddef>

namespace tools {
  template <typename T, typename std::enable_if<std::is_unsigned<T>::value, std::nullptr_t>::type = nullptr> constexpr T pow2(const T x) {
    return static_cast<T>(1) << x;
  }
  template <typename T, typename std::enable_if<std::is_signed<T>::value, std::nullptr_t>::type = nullptr> constexpr T pow2(const T x) {
    return static_cast<T>(static_cast<typename std::make_unsigned<T>::type>(1) << static_cast<typename std::make_unsigned<T>::type>(x));
  }
}
#include <iostream>
#include <cstdint>
#include <string>
#include <vector>
#include <iterator>
#include <algorithm>

int main() {
  std::string s;
  std::cin >> s;
  std::vector<std::int_fast64_t> digits;
  std::transform(s.begin(), s.end(), std::back_inserter(digits), [](const char c) {
    return std::stoi(std::string({c}));
  });

  std::int_fast64_t result = 0;
  for (std::uint_fast64_t bit_flags = 0; bit_flags < tools::pow2<std::uint_fast64_t>(digits.size() - 1); ++bit_flags) {
    std::int_fast64_t buffer = 0;
    for (std::int_fast64_t i = 0; i < static_cast<std::int_fast64_t>(digits.size()) - 1; ++i) {
      buffer = 10 * buffer + digits[i];
      if ((bit_flags & tools::pow2<std::uint_fast64_t>(i)) != 0) {
        result += buffer;
        buffer = 0;
      }
    }
    buffer = 10 * buffer + digits.back();
    result += buffer;
  }

  std::cout << result << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int ans=0;
    for(int i=0;i<s.size()/2;i++){
        if(s[i]!=s[s.size()-i-1])
        ans++;

    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]

for x, y, h in xyh:
    if h!= 0:
        x0, y0, h0 = (x, y, h)
        break

for i in range(101):
    for j in range(101):
        res = 1
        for x, y, h in xyh:
            if h == max(h0+abs(x0-i)+abs(y0-j)-abs(x-i)-abs(y-j), 0):
                res *= 1
            else:
                res *= 0
        if res:
            print(i, j, h0 + abs(x0-i) + abs(y0-j))
            exit()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int d,t,s;
	cin>>d>>t>>s;
	if(d<=t*s){
		cout<<"Yes";
	} 
	else{
		cout<<"No";
	}
	re 0;
}

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

int main() {
  int n, i;
  cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n-1);
  for (i=0;i<n;i++) {
    cin>>a[i];
  }
  for (i=0;i<n;i++) {
    cin>>b[i];
  }
  for (i=0;i<n-1;i++) {
    cin>>c[i];
  }
  int sum = 0;
  for (i=0;i<n;i++) {
    sum += b[a[i]-1];
    if (i != 0) {
      if (a[i] == a[i-1]+1) {
        sum += c[a[i-1]-1];
      }
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256