akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
bool a[1300000]={0};
a[1]=1;
for(int i=2;i<650001;i++){
	if(a[i]==1) continue;
	int j=2*i;
	while(j<1300000){
		a[j]=1;
		j=j+i;
	}
}

int b[1400000]={0};
int q=1;
for(int i=0;i<1300000;i++){
	q++;
	while(a[q]==1) q++;	

	 b[i]=q;
	
}
//cout<<b[10]<<endl;
int n,p;
while(cin>>n>>p && n>-1){
	int k=0;
	while(b[k]<=n) k++;
	vector<int> v;
//	cout<<k<<endl;
	for(int ii=k;ii<k+500;ii++){
		for(int j=k;j<=ii;j++){
			v.push_back(b[ii]+b[j]);
	//		cout<<ii<<" "<<j<<endl;
			}	
	}
sort(v.begin(),v.end());
//for(int i=0;i<40;i++) cout<<v[i]<<endl;
	cout<<v[p-1]<<endl;
	
}



	return 0;
}

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

using namespace std;

int h, w;

pair<int, int> compute(int r, int c) {
    return {min(h - r - 1, r), min(w - c - 1, c)};
}

int main() {
    cin >> h >> w;
    map<pair<int, int>, int> cnt;
    map<char, int> freq;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cnt[compute(i, j)]++;
            char c;
            cin >> c;
            freq[c]++;
        }
    }
    vector<int> vals;
    for (auto i : freq) {
        vals.push_back(i.second);
    }
    int b[5] = {};
    for (auto i : cnt) {
        b[i.second]++;
    }
    for (int i = 4; i >= 0; i--) {
        for (int j = 0; j < b[i]; j++) {
            bool f = false;
            for (auto &&x: vals) {
                if (x >= i) {
                    x -= i;
                    f = true;
                    break;
                }
            }
            if(!f){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;


}


Measured memory_bytes: 384
#include <stdio.h>
int main(){
	int gohyaku,go,nokori,amari,kekka;
	
	scanf("%d", &nokori);
	gohyaku=nokori/500;
	amari = nokori % 500;
	go = amari / 5;
	kekka = gohyaku * 1000 + go * 5;
		printf("%d\n",kekka);
	
	return 0;
}

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

int main( int argc, char *argv[] )
{
int N;

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

	cin >> N;
	cout << N * 800 - ( N / 15 ) * 200 << endl;

	return 0;
}




Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<string>
using namespace std;
string str[1001],s,anss,lon;
int ans,num[1001],ma,i,a;
int main(){
    while(cin>>s){
        if(ma<s.size()){
            ma=s.size();
            lon=s;
        }
        str[i]=s;
        i++;
    }
    for(int j=0;j<i;j++){
        if(num[j]!=0)continue;
        a=0;
        for(int k=j+1;k<i;k++){
            if(str[j]==str[k]){
                a++;
                num[k]=1;
            }
            if(ans<a){
                ans=a;
                anss=str[k];
            }
        }
    }
    cout<<anss<<" "<<lon<<endl;
    return 0;
}

Measured memory_bytes: 1204
def simulate(nxt, pos, K):
    for _ in range(K):
        pos = nxt[pos]
    return pos


def main():
    N, K = [int(x) for x in input().split()]
    nxt = [int(x)-1 for x in input().split()]

    # Floyd's algorithm
    slow = 0
    fast = nxt[0]
    while fast != slow:
        fast = nxt[nxt[fast]]
        slow = nxt[slow]
    offset = 0
    slow = 0
    while fast != slow:
        fast = nxt[nxt[fast]]
        slow = nxt[slow]
        offset += 1
    loop_begin = slow
    slow = nxt[loop_begin]
    period = 1
    while slow != loop_begin:
        slow = nxt[slow]
        period += 1

    if K < offset:
        print(simulate(nxt, 0, K)+1)
    else:
        K -= offset
        K = K % period
        print(simulate(nxt, loop_begin, K)+1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 33416
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>
#include<bitset>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const double EPS = 0.000000000001;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================

	double N, M;
	cin >> N >> M;

	double percent = pow(0.5, M);
	cout << int(((N - M) * 100 + M * 1900) / percent);









}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int n, r;
    cin >> n >> r;
    if(n < 10){
        r += 100 * (10 - n);
    }
    cout << r << endl;
    return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3628
use itertools::{iproduct, Itertools};
use proconio::input;

fn main() {
    unsafe {
        input!(n: usize, k: usize, ijc: [(usize, usize, char); n]);
        let mut g = vec![vec![0; k + 1]; k + 1];
        let mut b_count = 0;
        let mut w_count = 0;
        for &(i, j, c) in &ijc {
            *g.get_unchecked_mut(i % k + 1).get_unchecked_mut(j % k + 1) +=
                if ((i / k + j / k) % 2 == 1) ^ (c == 'W') {
                    w_count += 1;
                    1
                } else {
                    b_count += 1;
                    -1
                };
        }
        for (i, j) in iproduct!(0..k, 0..k) {
            *g.get_unchecked_mut(i + 1).get_unchecked_mut(j + 1) +=
                g.get_unchecked(i + 1).get_unchecked(j) + g.get_unchecked(i).get_unchecked(j + 1)
                    - g.get_unchecked(i).get_unchecked(j);
        }

        let (min, max): (i32, i32) = iproduct!(0..k, 0..k)
            .map(|(i, j)| {
                g.get_unchecked(k).get_unchecked(k)
                    - g.get_unchecked(i).get_unchecked(k)
                    - g.get_unchecked(k).get_unchecked(j)
                    + 2 * g.get_unchecked(i).get_unchecked(j)
            })
            .minmax()
            .into_option()
            .unwrap();
        println!("{}", std::cmp::max(-min + w_count, max + b_count));
    }
}


Measured memory_bytes: 10196
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int pow(int x, int y){
  return (y==0?1:pow(x*x,y/2)*(y%2?x:1));
}

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

  int T, N;
  while(cin>>T>>N,T){
	int dig = log10(N);
	int ans = -1;
	map<int,int> mp;
	VI part;
	for(int bit=0;bit<(1<<dig);++bit){
	  VI tmp;
	  int num = N, sum = 0, prv = 0;
	  for(int i=0;i<dig;++i){
		if((bit>>i)&1){
		  int x = (num % pow(10,i+1)) / pow(10,prv);
		  sum += x;
		  prv = i+1;
		  num = num / pow(10,i+1) * pow(10,i+1);
		  tmp.PB(x);
		}
	  }
	  if(num > 0){
		sum += num / pow(10,prv);
		tmp.PB(num/pow(10,prv));
	  }

	  if(sum <= T && ans <= sum){
		  ans = sum, part = tmp;
		  mp[ans]++;
	  }
	}
	if(mp[ans] > 1) cout << "rejected" << endl;
	else if(ans == -1) cout << "error" << endl;
	else{
	  cout << ans;
	  for(int i=SZ(part)-1;i>=0;--i)
		cout << " " << part[i];
	  cout << endl;
	}
  }
  return 0;
}

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

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

  int ans = 0;
  rep(i, 1000) {
    string t;
    int x = i;
    rep(j, 3) {
      t.push_back('0' + x % 10);
      x /= 10;
    }
    int ti = 0;
    rep(j, n) {
      if (s[j] == t[ti]) {
        ti++;
        if (ti == 3) break;
      }
    }
    if (ti == 3) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
  int n,a,v;
  int ansa=1000,ansv=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a >> v;
    if(ansv<v){
      ansa = a;
      ansv = v;
    }
    else if(ansv==v&&ansa>a){
      ansa = a;
      ansv = v;
    }
  }
  cout << ansa << ' ' << ansv << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <vector>
#include <utility>
using Card = std::pair<char, int>;

int partition(std::vector<Card> &a, int p, int r){
    Card x = a[r];
    int i = p - 1;
    for(int j = p; j < r; ++j){
        if(a[j].second <= x.second) std::swap(a[++i], a[j]);
    }
    int m = i + 1;
    std::swap(a[m], a[r]);
    return m;
}

void qsort(std::vector<Card> &a, int p, int r){
    if(p >= r) return;
    int m = partition(a, p, r);
    qsort(a, p, m - 1);
    qsort(a, m + 1, r);
}

void msort(std::vector<Card> &a, std::vector<Card> &b, int p, int r){
    if(p >= r) return;
    int m = p + (r - p) / 2;
    msort(a, b, p, m);
    msort(a, b, m + 1, r);

    int i = p;
    int j = m + 1;
    for(int k = p; k <= r; ++k){
        if(i > m) b[k] = a[j++];
        else if(j > r) b[k] = a[i++];
        else if(a[i].second <= a[j].second) b[k] = a[i++];
        else if(a[i].second > a[j].second) b[k] = a[j++];
    }
    for(int k = p; k <= r; ++k){
        a[k] = b[k];
    }
}

int main(){
    int n;
    std::scanf("%d", &n);
    Card np = std::make_pair(0, 0);
    std::vector<Card> a(n, np);
    std::vector<Card> b(n, np);
    for(int i = 0; i < n; ++i){
        char tmp[2];
        std::scanf("%s", tmp);
        a[i].first = tmp[0];
        std::scanf("%d", &a[i].second);
        b[i] = a[i];
    }
    qsort(a, 0, n - 1);
    std::vector<Card> c(n, np);
    msort(b, c, 0, n - 1);
    bool isStable = true;
    for(int i = 0; i < n; ++i){
	if(b[i].first != a[i].first){
            isStable = false;
            break;
        }
    }
    if(isStable)  std::printf("Stable\n");
    else std::printf("Not stable\n");
    for(int i = 0; i < n; ++i){
        std::printf("%c %d\n", a[i].first, a[i].second);
    }
    return 0;
}


Measured memory_bytes: 4700
#include<iostream>
#include<utility>
#include<tuple>
#include<queue>
using namespace std;

// distance, y, x
typedef tuple<int,int,int> T;

const int WMAX = 70, HMAX = 70;
const int INF = 4e6;
const int DX[4] = {0, 1, 0, -1}, DY[4] = {1, 0, -1, 0};
bool maze[HMAX][WMAX];
int dist[HMAX][WMAX];
int W, H;

int main() {
  while (cin >> W >> H and W) {
    H = 2 * H - 1, W = 2 * W - 1;
    for (int y = 0; y < H; y++) {
      for (int x = 0; x < W; x++) {
        maze[y][x] = (x % 2 == 0 || y % 2 == 0);
        dist[y][x] = INF;
      }
    }
    for (int y = 0; y < H; y++) {
      for (int x = (y + 1) % 2; x < W; x += 2) {
        bool wall;
        cin >> wall;
        maze[y][x] = !wall;
      }
    }
    /*for (int y = 0; y < H; y++) {
      for (int x = 0; x < W; x++) {
        cout << maze[y][x];
      }
      cout << endl;
    }*/
    dist[0][0] = 1;
    priority_queue<T> que;
    que.push(T(0, 0, 0));
    while (!que.empty()) {
      T t = que.top(); que.pop();
      int d = get<0>(t), y = get<1>(t), x = get<2>(t);
      // cout << "(" << d << "," << y << "," << x << ")" << endl;
      if (d > dist[y][x]) continue;
      for (int i = 0; i < 4; i++) {
        int nx = x + DX[i], ny = y + DY[i];
        if (nx < 0 || W <= nx || ny < 0 || H <= ny) continue;
        if (!maze[ny][nx]) continue;
        if (dist[ny][nx] > dist[y][x] + 1) {
          dist[ny][nx] = dist[y][x] + 1;
          que.push(T(dist[ny][nx], ny, nx));
        }
      }
    }
    int ans = (1 + dist[H-1][W-1]) / 2;
    cout << (ans < INF / 3 ? ans : 0) << endl;
    /*for (int y = 0; y < H; y++) {
      for (int x = 0; x < W; x++) {
        cout << dist[y][x] << '\t';
      }
      cout << endl;
    }*/
  }
}

Measured memory_bytes: 1244
//赤(00) / 黄色(01) / 緑(10) / 青(11)と対応づける。
//□は| |と＝のandでできている。10は、1?と?0のandでできている. (?はそれぞれ任意のパターンにマッチする文字)
//「距離dのマス同士では、1ビット目が異なるようにしたい（2ビット目はどうでもよい)」だったら、|<-d->|ごとに0, 1, 0, 1…を割り振ればできる。
//2ビット目が～も同様。さて、この結果をa, bとおいたとき、2 * a + bの色で塗ったらどうなるでしょう。なんと、条件を満たせます。
//(c++ではa / b (a < 0, b > 0)の結果がfloor(a / b)と一致しないので面倒くさい)
#include <iostream>
#define rep(i, n) for (i = 0; i < n; i++)
using namespace std;

int h, w, d;
char *color = "RYGB";

int main() {
	int i, j;
	
	cin >> h >> w >> d;
	rep(i, h) {
		rep(j, w) {
			int a = ((i + j) / d) % 2;
			int b = ((i - j + w) / d) % 2;
			cout << color[2 * a + b];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD1 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int S;cin>>S;
  int v = 1e9;
  int x = (v - S%v)%v;
  cout<<0<<" "<<0<<" "<<v<<" "<<1<<" "<<(v - S%v)%v<<" "<<(S+x)/v<<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
char s[100001];
int main()
{
	int a,b;
	cin>>a>>b;
	for(int i=1;i<=a+b+1;i++) cin>>s[i];
	for(int i=1;i<=a+b+1;i++)
	{
		if(s[i]<48&&i!=a+1||s[i]>58&&i!=a+1)
		{
			cout<<"No"<<endl;
			return 0;
		}
		if(i==a+1&&s[i]!='-')
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  long square=0;
  long x=0,y=0 ;
  int tmpx,tmpy,I;
  bool flg=false;
  for(int i=0;i<N;i++){
    tmpx=a[i];
    for(int j=i+1;j<min(N,i+100);j++){
      if(tmpx==a[j]){
        I =i;
       x=a[j];
       flg=true;
       break;
     }
    }
    if(flg) break;
  }

//  cout << I << endl;
  flg=false;
  for(int k=I+2;k<N;k++){
    tmpy=a[k];
      //cout << tmpy << endl;
    for(int l=k+1;l<min(N,k+100);l++){
      if(tmpy==a[l]) {
        y=a[l];
        flg=true;
        break;
      }
    }
      if(flg) break;
  }

  square = x*y;
//  cout << x << endl;
//  cout << y << endl;
  cout << square << endl;


}


Measured memory_bytes: 640
#include <stdio.h>

int main(void){
    int a,b,c;
    int count = 0;
    scanf("%d %d %d",&a,&b,&c);
    while(a <= b){
        if(c % a == 0) count++;
        a++;
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 1028
import sys
lines = sys.stdin.readlines()

for line in lines:
    s = str(line)
    a,b,c,d,e,f = map(int, s.rstrip('\n').split())
    x = (e*c - b*f) / (a*e - b*d)
    if e*c - b*f == 0:
        x = 0
    x = round(x, 3)
    y = (a*f - c*d) / (a*e - b*d)
    if a*f - c*d == 0:
        y = 0
    y = round(y, 3)
    print(f'{x:.3f} {y:.3f}')


Measured memory_bytes: 5632
n=int(input())
t=[]
for i in range(n):
    t.append(int(input()))

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(a, b):
	return a * b // gcd (a, b)

p=t[0]
for k in range(1,n):
    p=lcm(p,t[k])

print(p)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  string a;
  cin >> a;
  
  if (a.at(0) == '1') a.at(0) = '9';
  else a.at(0) = '1';
  if (a.at(1) == '1') a.at(1) = '9';
  else a.at(1) = '1';
  if (a.at(2) == '1') a.at(2) = '9';
  else a.at(2) = '1';
  
  cout << a << endl;
}

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

int main() {
  int n, q;
  cin >> n >> q;
  dsu d(n);
  for(int i = 0; i < q; i++) {
    int t, u, v;
    cin >> t >> u >> v;
    if(t == 0) {
      d.merge(u, v);
    }
    else {
      if(d.same(u, v)) {
        cout << 1 << endl;
      }
      else {
        cout << 0 << endl;
      }
    }
  }
}

Measured memory_bytes: 4040
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int n, m;
    vector<int> x, y;
    cin >> n;
    x.resize(n);
    y.resize(n);
    for (int i=0; i<n; ++i){
        cin >> x[i];
        y[i] = x[i];
    }
    sort(y.begin(), y.end());
    m = y[n/2 - 1];
    for (int i=0; i<n; ++i){
        if(x[i] > m){
            cout << y[n/2 - 1] << endl;
        }
        else {
            cout << y[n/2] << endl;
        }
    }
}



Measured memory_bytes: 3712
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                        

using namespace std;
#define ll long long

struct pos{
  int x;
  int y;
};

int main(){
  int H, W, D;
  cin >> H >> W >> D;
  pos P[H*W];
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      int in;
      cin >> in;
      in--;
      pos p = {i, j};
      P[in] = p;
    }
  }

  int C[H*W]; // cost                                                                                          
  for(int i=0; i<H*W; i++){
    if(i < D){
      C[i] = 0;
    } else {
      C[i] = C[i-D] + abs(P[i-D].x - P[i].x) + abs(P[i-D].y - P[i].y);
    }
  }

  int Q;
  cin >> Q;
  for(int i=0; i<Q; i++){
    int l, r;
    cin >> l >> r;
    cout << C[r-1] - C[l-1] << endl;
  }

  return 0;
}



Measured memory_bytes: 2176
h,w,d = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
q = int(input())
lr = [list(map(int, input().split())) for i in range(q)]
spot = [0] * (h*w)
for ki,v in enumerate(a):
  for kj,i in enumerate(v):
    spot[i-1] = (ki,kj)
cumsum = [[0] for i in range(d)]
for start in range(d):
  for j in range(start,h*w-d,d):
    h1,w1 = spot[j]
    h2,w2 = spot[j+d]
    dist = abs(h1-h2) + abs(w1-w2)
    cumsum[start].append(dist+cumsum[start][-1])
for l,r in lr:
  l -= 1
  r -= 1
  mod = l % d
  L,R = l//d,r//d
  ans = cumsum[mod][R]-cumsum[mod][L]
  print(ans)

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

int main(){
    string s;
    cin >> s;
    rep(i, s.length()) {
        if ( i == 3 ) {
            cout << s[i] << " ";
        }
        else {
            cout << s[i];
        }
    }
    cout << endl;
    return 0;
}


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

int main(int argc, char const *argv[]){
  long N, S, temp;
  scanf("%ld", &N);
  temp = N;
  for(int i = 0; i <= 9; i++){
    S += ((int)(N/pow(10,i)))%10;
  }
  if(N%S==0)printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;

int main(){

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

  if((a<=0)||(b<=0)||(a>9)||(b>9)) {
    cout << "-1" << endl;
    return 0;
  }else{
    cout << (a*b) << endl;
  }
  return 0;
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<ll, ll>;
using iii = pair<ii, ll>;
#define vt vector
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
const ll MOD = 1e9 + 7;
const ll INF = 2e9;
const ll N = 1e2 + 5;

int n, ans;
int a[N], b[N];

void solve() {
    cin >> n;
    for(int i = 1; i < n; i++) {
        cin >> b[i];
    }
    a[1] = b[1];
    for(int i = 2; i <= n; i++) {
        a[i] = b[i - 1];
        if(b[i] < b[i - 1]) a[i] = b[i];
    }
    a[n] = b[n - 1];
    for(int i = 1; i <= n; i++) {
        ans += a[i];
    }
    cout << ans << "\n";
}

int main() {
    
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    solve();
    
}

Measured memory_bytes: 3612
#include <iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    int A[N+1],B[N+1],C[N];
    for(int i=0;i<N;i++) cin >> A[i];
    for(int i=0;i<N;i++) cin >> B[i];
    for(int i=0;i<N-1;i++) cin >> C[i];

    int total=0,a,b,c;
    for(int i=0;i<N;i++){
        a=A[i];
        if(A[i]+1==A[i+1]) total += C[a-1];
    }
    for(int i=0;i<N;i++) total += B[i];
    
    cout << total << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <cmath>
 
using namespace std;
 
// typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<string> vs;
 
// container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
// repetition
#define FOR(i,m,n) for (ll (i) = ((ll) m); (i) < ((ll) n); ++(i))
#define RFOR(i,m,n) for (ll (i) = ((ll) (m)-1); (i) >= ((ll) n); --(i))
#define REP(i,n) FOR(i,0,n)
 
// i/o
#define TFOUT(b,t,f) cout << ((b)? (t) : (f)) << endl
 
//constant
const double    EPS     = 1e-10;
const double    PI      = acos(-1.0);
const int       INFTY   = (1<<21);
const ll        INFTY_LL = (1LL<<60);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

void solve_helper(
    const vector< vector<ll> >& wf,
    vector< pair<int, bool> >& v,
    int current,
    ll score,
    ll& ret
) {
    int cnt = 0;
    REP(i, SZ(v)) {
        if (v[i].second) {
            cnt++;
            continue;
        }
        v[i].second = true;
        int next = v[i].first;
        solve_helper(wf, v,  next, score + wf[current][next], ret);
        v[i].second = false;
    }
    if (cnt == SZ(v) && score < ret) ret = score;
}

ll solve(const vector< vector<ll> >& wf, vector< pair<int, bool> >& v) {
    ll ret = INFTY_LL;
    REP(i, SZ(v)) {
        v[i].second = true;
        solve_helper(wf, v, v[i].first, 0, ret);
        v[i].second = false;
    }
    return ret;
}

int main() {
    int n, m, r; cin >> n >> m >> r;
    vector< pair<int, bool> > v;
    REP(i, r) {
        int e; cin >> e;
        e--;
        v.emplace_back(e, false);
    }
    vector< vector<ll> > wf(n, vector<ll>(n, INFTY_LL));
    REP(i, n) {
        wf[i][i] = 0;
    }
    REP(i, m) {
        int a, b; ll c; cin >> a >> b >> c;
        a--; b--;
        wf[a][b] = c;
        wf[b][a] = c;
    }
    REP(k, n) {
        REP(i, n) {
            REP(j, n) {
                ll x = wf[i][k] + wf[k][j];
                if (wf[i][j] > x) wf[i][j] = x;
            }
        }
    }
    cout << solve(wf, v) << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int h, w, base = 65;
    cin >> h >> w;
    rep(i, h)
    {
        rep(j, w)
        {
            string s;
            cin >> s;
            if (s == "snuke")
            {
                cout << (char)(base + j) << (i + 1) << endl;
                return 0;
            }
        }
    }
    // end

    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i).insert(0, 0).push(0)

t = 0
1.upto(n + 1) do |i|
  t += (a[i - 1] - a[i]).abs 
end

1.upto(n) do |i|
  puts t - (a[i - 1] - a[i]).abs - (a[i] - a[i + 1]).abs + (a[i - 1] - a[i + 1]).abs
end


Measured memory_bytes: 13572
#include<bits/stdc++.h>
#define maxn 300010
#define mod 998244353
#define ll long long
using namespace std;
int p[maxn], x[maxn], res[maxn], INV;
void fwt(int *a, int n, int opt)
{
	for (int l = 2; l <= n; l *= 2)
	{
		int m = l / 2;
		for (int *p = a; p != a + n; p += l)
			for (int i = 0; i <= m - 1; i++)
			{
				int x = p[i], y = p[i + m];
				p[i] = ((ll)x + y) * INV % mod;
				p[i + m] = ((ll)x - y + mod) % mod * INV % mod;
			}
	}
}
int calc(int a, int k)
{
	int ans = 1;
	while (k)
	{
		if (k % 2) ans = (ll)ans * a % mod;
		a = (ll)a * a % mod;
		k /= 2;
	}
	return ans;
}
int main()
{
	int n, full;
	scanf("%d", &n);
	INV = calc(2, mod - 2);
	full = 1 << n;
	int sum = 0;
	for (int i = 0; i <= full - 1; i++)
	{
		scanf("%d", &p[i]);
		sum = (sum + p[i]) % mod;
	}
	sum = calc(sum, mod - 2);
	for (int i = 0; i <= full - 1; i++)
		p[i] = (ll)p[i] * sum % mod;
	p[0] = (p[0] - 1 + mod) % mod;
	x[0] = full - 1;
	for (int i = 1; i <= full - 1; i++)
		x[i] = mod - 1;
	fwt(x, full, 1);
	fwt(p, full, 1);
	for (int i = 0; i <= full - 1; i++)
		res[i] = (ll)x[i] * calc(p[i], mod - 2) % mod;
	fwt(res, full, -1);
	for (int i = 0; i <= full - 1; i++)
		printf("%d\n", (res[i] - res[0] + mod) % mod);
	return 0;
}

Measured memory_bytes: 5888
using System;

namespace Kznner
{
	class Program
	{
		static void Main()
		{
			string[] inputABHM = Console.ReadLine().Split(' ');
			int A = int.Parse(inputABHM[0]);
			int B = int.Parse(inputABHM[1]);
			int H = int.Parse(inputABHM[2]);
			int M = int.Parse(inputABHM[3]);

			double Ax = Math.Sin(TimeToRadianA(H, M)) * A;
			double Ay = Math.Cos(TimeToRadianA(H, M)) * A;
			double Bx = Math.Sin(TimeToRadianB(H, M)) * B;
			double By = Math.Cos(TimeToRadianB(H, M)) * B;

			double deltaX = Ax - Bx;
			double deltaY = Ay - By;
			double distance = Math.Sqrt(deltaX * deltaX + deltaY * deltaY);

			Console.WriteLine(distance);
		}

		static double TimeToRadianA(int hour, int minutes)
		{
			double minutes_factor = 360.0 / 12 / 60;
			double hour_factor = 360.0 / 12;
			return Math.PI / 180 * (hour_factor * hour + minutes_factor * minutes);
		}

		static double TimeToRadianB(int hour, int minutes)
		{
			return Math.PI / 180.0 * ((double)minutes / 60 * 360);
		}
	}
}

Measured memory_bytes: 27980
#include<iostream>
using namespace std;
int main()
{
    int H,W,N,s;
    cin>>H>>W>>N;
    if(H>=W)
    {
        if(N%H!=0)
        {
            s=N/H+1;
        }
        else if(N%H==0)
            s=N/H;

    }
    else if(W>H)
    {
        if(N%W!=0)
        {
            s=N/W+1;

        }
        else if(N%W==0)
        s=N/W;


    }
    cout<<endl;
    cout<<s;


return 0;
}



Measured memory_bytes: 256
N,x =map(int,input().split())
a=list(map(int,input().split()))
cnt=0
for i in range(N-1):
    if a[i]+a[i+1]>x:
        #マイナスになるのを防ぐ
        if a[i+1]<(a[i]+a[i+1]-x):
            cnt+=a[i+1]
            a[i+1]=0
        else:
            cnt+=a[i]+a[i+1]-x
            a[i+1]-=a[i]+a[i+1]-x
#端はこの操作では実現できない可能性があるので別に
if a[0]+a[1]>x:
    cnt+=a[0]+a[1]-x
    a[0]-=a[0]+a[1]-x
if a[-1]+a[-2]>x:
    cnt+=a[-1]+a[-2]-x
    a[-1]-=a[-1]+a[-2]-x
print(cnt)

Measured memory_bytes: 14548
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

    vector<ll> s(n+1);
    rep(i,n) s[i+1] = s[i]+a[i];

    map<ll,ll> mp;
    rep_1(i,n) mp[s[i]]++;

    ll ans =0;
    for(auto x:mp){
        ll tmp = x.second;
        ans+=tmp*(tmp-1)/2;
    }
    cout<<ans<<endl;

}



Measured memory_bytes: 15872
m,n = map(int, input().split())

def my_pow(m,n):
    res = 1
    while n > 0:
        if n&1:
            res = res * m
        m = m * m
        n >>= 1
    return res

def my_pow_mod(m,n,M):
    res = 1
    while n > 0:
        if n&1:
            res = res * m % M
        m = m * m % M
        n >>= 1
    return res

print(my_pow_mod(m,n,1000000007))


Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <stack>
#include <map>
#include <iomanip>
using namespace std;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}

const int MAX = 510000;
const int MOD = 1000000007;

int64_t fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool sjudge(string &s, int b,int n){
    if (n == 5)
    {
        return (s.substr(b,5) == "dream" || s.substr(b,5) == "erase") ;
    }
    if (n == 6)
    {
        return (s.substr(b,6) == "eraser") ;
    }
    if (n == 7)
    {
        return (s.substr(b,7) == "dreamer") ;
    }
    
    
    /*
    bool go = (s.substr(b,5) == "dream" || s.substr(b,5) == "erase") ;
    bool ro = (s.substr(b,6) == "eraser") ;
    bool na = (s.substr(b,7) == "dreamer") ;
    return go||ro||na ;
    */
}

bool judge(string &s, int a, vector<bool> &table){
    bool ans ;
    if (a > 4)
    {
        ans = table.at(a-5) && sjudge(s,a-5,5) ;
    }
    if (a > 5)
    {
        ans = ans || (table.at(a-6) && sjudge(s,a-6,6)) ;
    }
    if (a > 6)
    {
        ans = ans || (table.at(a-7) && sjudge(s,a-7,7)) ;
    }
    
    return ans ;
}



int main(){
    string s ;
    cin >> s ;
    vector<bool> table(s.size()+1,0);
    table.at(0) = 1 ;
    for (size_t i = 5; i < s.size() + 1; i++)
    {
        table.at(i) = judge(s,i,table) ;
    }
    if (table.at(s.size()) == 1)
    {
        cout << "YES" ;
    }else
    {
        cout << "NO" ;
    }
    cout << endl ;
    
}

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

using namespace std;

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

  	int r = N % 10;
  	if(r == 3)
    {
      cout << "bon" << endl;
    }
  	else if(r == 0 || r == 1 || r == 6 || r == 8)
    {
      cout << "pon" << endl;
    }
  	else
    {
    	cout << "hon" << endl;
    }
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

ll mp[555555];

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

	string str;cin >> str;
	ll mi = 0;
	REP(i, str.size()){
		if(str[i] == '<')mp[i+1] = mp[i] + 1;
	}
	REV(i, str.size()){
		if(str[i] == '>')mp[i] = max(mp[i], mp[i+1] + 1);
	}


	ll ans = 0;
	REP(i, str.size() + 1)ans += mp[i];
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5020
#include <cstdio>

int main(){
  char str[16];
  int a,b;

  for(int i = 0 ; i < 9 ; i++){
    scanf("%s %d %d" ,str ,&a ,&b);
    printf("%s %d %d\n" ,str ,a + b , a*200+b*300);
  }

  return 0;
}

Measured memory_bytes: 1024
import itertools

n = int(input())
x = [list(map(int,input().split())) for i in range(n)]

all = list(itertools.permutations(x))
q=0
for i in range(len(all)):
    for j in range(n-1):
       q+= ((all[i][j][0]-all[i][j+1][0])**2+(all[i][j][1]-all[i][j+1][1])**2)**0.5

print(q/len(all))

Measured memory_bytes: 8180
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long int ll;




int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b + c || a + b == c || b == a + c || b + c == a || c == a + b || a + c == b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int t1=h1*60+m1,t2=h2*60+m2;
    int t=t2-t1,ans=t-k;
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
int main()
{
	int i,j,k,len,ty;
	int count = 0;
	
	
	scanf("%d",&len);
	int A[len];
	
	for(i=0;i<len;i++)
 	scanf("%d",&A[i]);
 		
 
 	  
 	//printf("\n");
	
	for(i=0;i<=len-1;i++){
	for(j=len-1;j>=i+1;j--){
	if (A[j]<A[j-1]){
		   ty = A[j];
                A[j] = A[j-1];
                A[j-1] = ty;
                count++;
	
}
	}
}
	for(i=0; i<=len-1; i++){
        printf("%d", A[i]);
        if(i!=len-1) printf(" ");
		  }
         
    printf("\n");
    printf("%d",count);
    printf("\n");
    return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int n;
vector<int> v[100010];
int dp[100010];
int main()
{
    cin >> n;
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    queue<P> que;
    // 1:white,2:balck
    map<int, int> ans;
    ans[1] = 1;
    ans[2] = 1;
    que.push(P(1, 1));
    que.push(P(n, 2));
    dp[1] = 1;
    dp[n] = 2;
    while (!que.empty())
    {
        P p = que.front();
        que.pop();
        for (auto i : v[p.first])
        {
            if (dp[i] == 0)
            {
                dp[i] = p.second;
                ans[p.second]++;
                que.push(P(i, p.second));
            }
        }
    }
    if (ans[1] > ans[2])
    {
        cout << "Fennec" << endl;
    }
    else
    {
        cout << "Snuke" << endl;
    }
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for (int i=0,_n=(int)(n); i < _n; i++)
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
 
typedef long long ll;

const int MAX_N = 100000 + 10;

int p[MAX_N];
vector<int> g[MAX_N];
int d[MAX_N];

void dfs(int v, int depth) {
  if (d[v] != -1) return;
  d[v] = depth;
  for (auto c : g[v]) dfs(c, depth + 1);
}

void dfs2(int cur, vector<pair<int,int>>&v, vector<int>&ivi) {
  if (v[ ivi[cur] ].first != -2) {
    v[ ivi[cur] ].first = -2;
    for (auto c : g[cur]) dfs2(c, v, ivi);
  }
}

int main2() {
  int N, K; cin >> N >> K;
  REP(i, N) {
    cin >> p[i];
    p[i]--;
  }
  int ans = 0;
  if (p[0] != 0) { p[0] = 0; ans++; }
  REP(i, N) g[i].clear();
  REP(i, N) {
    g[ p[i] ].push_back(i);
  }

  memset(d, -1, sizeof(d));
  dfs(0, 0);
  // REP(i, N) cout << d[i] << " "; cout << endl;

  vector<pair<int,int>> v; // depth, index
  REP(i, N) v.emplace_back(d[i], i);
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  vector<int> ivi(N);
  REP(i, N) {
    ivi[ v[i].second ] = i;
  }
  // REP(i, N) printf("(%d,%d)", v[i].first, v[i].second); cout << endl;
  // REP(i, N) cout << ivi[i] << " "; cout << endl;

  REP(i, N) if (v[i].first > K) {
    int cur = v[i].second;
    REP(k, K-1) cur = p[cur];
    ans++;
    // cout << "change:" << (cur+1) << endl;
    dfs2(cur, v, ivi);
    // REP(i, N) printf("(%d,%d)", v[i].first, v[i].second); cout << endl;
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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

const ll MRINF = 5000000000000000;

int main() {

  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int ans = 0;

  while(1){
    if(B>A)break;
    ans++;
    B *= 2;
  }
  while(1){
    if(C>B)break;
    ans++;
    C *= 2;
  }
  if(ans>K)cout << "No" << endl;
  else cout << "Yes" << endl;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3628
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class A
{
	public static void Main()
	{
		string S = Console.ReadLine();
		int ans = 0;
		for(int i = 0; i < 4; i++)
			ans += (S[i] == '+') ? 1 : -1;
		Console.WriteLine(ans);
	}
}





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

const int mod = 1000000007;

int now[3333][3333];
int pre[3333][3333];

signed main() {
	int n, q;
	cin >> n >> q;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		rep(j, n) {
			if(a[i] > a[j]) {
				now[i][j] = 1;
			}
			else {
				now[i][j] = 0;
			}
			pre[i][j] = -1;
		}
	}
	vector<int> kai(q + 10);
	int nw = 1;
	rep(i, q + 9) {
		kai[i + 1] = nw;
		nw = nw * 2 % mod;
	}
	rep(i, q) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		vector<pair<int, pair<int, int>>> q;
		rep(j, n) {
			if(j != x && j != y) {
				q.push_back(make_pair(now[j][x] * kai[i - pre[j][x]], make_pair(j, y)));
				q.push_back(make_pair(now[j][y] * kai[i - pre[j][y]], make_pair(j, x)));
				q.push_back(make_pair(now[x][j] * kai[i - pre[x][j]], make_pair(y, j)));
				q.push_back(make_pair(now[y][j] * kai[i - pre[y][j]], make_pair(x, j)));
			}
		}
		q.push_back(make_pair(now[x][x] * kai[i - pre[x][x]], make_pair(y, y)));
		q.push_back(make_pair(now[x][y] * kai[i - pre[x][y]], make_pair(y, x)));
		q.push_back(make_pair(now[y][x] * kai[i - pre[y][x]], make_pair(x, y)));
		q.push_back(make_pair(now[y][y] * kai[i - pre[y][y]], make_pair(x, x)));
		for(auto j: q) {
			now[j.second.first][j.second.second] = (now[j.second.first][j.second.second] * kai[i - pre[j.second.first][j.second.second]] + j.first) % mod;
			pre[j.second.first][j.second.second] = i;
		}
	}
	int ans = 0;
	rep(i, n) {
		for(int j = i + 1; j < n; j++) {
			ans = (ans + now[i][j] * kai[q - pre[i][j]]) % mod;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 160748
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
ll n,d,a;
cin>>n>>d>>a;
V<P> dd(n);
for(int i=0;i<n;i++){
    cin>>dd[i].fi>>dd[i].se;
}
ll ans=0,now=0;
sort(all(dd));
queue<P> q;
for(int i=0;i<n;i++){
   if(q.size()){
       while(!q.empty()){
           if(dd[i].fi>q.front().fi){
               now-=q.front().se;
               q.pop();
           }
           else break;
       }
   }
   if(dd[i].se-now<=0)continue;
   ans+=(dd[i].se-now+a-1)/a;
   q.push(P(dd[i].fi+2*d,(dd[i].se-now+a-1)/a*a));
   now+=(dd[i].se-now+a-1)/a*a;
}
cout<<ans<<endl;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ll S; cin >> S;
    ll res1, res2, res3;
    double tmp = sqrt(S);
    res3 = (ll)tmp;
    if(ll(tmp) < tmp) res3 = res3+1;
    res1 = 1;
    while(1){
        res2 = (res3*res3-S)/res1;
        if(res2 <= 1e09) break;
        res1++;
    }
    cout << 0 << " " << 0 << " " << res1 << " " << res3 << " " << res3 << " " << res2 << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

using namespace std;

#define MAXN 200005

vector<int> tree[MAXN];
long long int differences[MAXN] = { 0 };

void results(int node, int last) {
    for (int child : tree[node])
    {
        if (child != last) {
            differences[child] += differences[node];
            results(child, node);
        }
    }
}


int main() {
    int N, Q;
    cin >> N >> Q;
    
    int a, b;
    for (int i = 0; i < N - 1; i++)
    {
        cin >> a >> b;
        tree[a - 1].push_back(b - 1);
        tree[b - 1].push_back(a - 1);
    }

    for (int i = 0; i < Q; i++)
    {
        cin >> a >> b;
        differences[a - 1] += b;
    }
    
    results(0, -1);
    for (int i = 0; i < N; i++)
    {
        cout << differences[i] << " ";
    }
}


Measured memory_bytes: 24320
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		
		if(A + K - 1 < B - K + 1) {
			for(int i = A; i <= A + K - 1; i++) {
				System.out.println(i);
			}
			for(int i = B - K + 1; i <= B; i++) {
				System.out.println(i);
			}
		} else {
			for(int i = A; i <= B; i++) {
				System.out.println(i);
			}
		}
	}
}


Measured memory_bytes: 23124