akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

template <long long Mod> struct ModInt { /* {{{ */
  long long v;
  constexpr ModInt(const long long x = 0) {
    v = x % Mod;
    if (v < 0) {
      v += Mod;
    }
  }
  constexpr ModInt operator+(const ModInt rhs) const { return ModInt(*this) += rhs; }
  constexpr ModInt operator-(const ModInt rhs) const { return ModInt(*this) -= rhs; }
  constexpr ModInt operator*(const ModInt rhs) const { return ModInt(*this) *= rhs; }
  constexpr ModInt operator/(const ModInt rhs) const { return ModInt(*this) /= rhs; }
  const ModInt &operator+=(const ModInt rhs) {
    v += rhs.v;
    if (v >= Mod) {
      v -= Mod;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) {
    if (v < rhs.v) {
      v += Mod;
    }
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) {
    v = v * rhs.v % Mod;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  friend ostream &operator<<(ostream &s, ModInt<Mod> m) {
    s << m.v;
    return s;
  }
  friend istream &operator>>(istream &s, ModInt<Mod> m) {
    s >> m.v;
    return s;
  }
}; /* }}} */

const int mod = 1e9 + 7;
using modint = ModInt<mod>;

modint nCk(int n, int k) {
  modint v = 1;
  for (int i = 0; i < k; i++) {
    v *= (n - i);
    v /= (i + 1);
  }
  return v;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;

  modint ans = 1;
  modint a = 2;
  int exp = N;
  while (exp) {
    if (exp & 1) ans *= a;
    a *= a;
    exp /= 2;
  }
  ans -= nCk(N, A) + nCk(N, B) + 1;
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


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

int main()
{
	int n;
	cin >> n;
	vector<int> L(n);
	for (int i = 0; i < n; i++) {
		cin >> L[i];
	}

	sort(L.begin(), L.end());

	int cnt = 0;
	
	for (int a = 0; a < n; a++) {
		for (int b = a + 1; b < n; b++) {
			int r = lower_bound(L.begin(), L.end(), L[a] + L[b]) - L.begin();
			int l = b + 1;
			cnt += max(0, r - l);
		}
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

/*
 * |n-m|>1 なら0.
 * |n-m|=0 ならn! * m! * 2
 * |n-m|=1 ならn! * m!
 */
const ll MOD = 1000000007;
int main() {
  ll n, m; cin >> n >> m;
  ll d = abs(n-m);
  if (d > 1) {
    cout << 0 << endl;
    return 0;
  }
  
  ll nBan = 1;
  loop(i,1,n+1) {
    nBan *= i;
    nBan %= MOD;
  }
  
  ll mBan = 1;
  loop(i,1,m+1) {
    mBan *= i;
    mBan %= MOD;
  }
  
  ll ans = (nBan * mBan) % MOD;
  if (d == 0) {
    ans = (ans * 2) % MOD;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

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

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

    long sum = accumulate(a.begin(), a.end(), 0L);
    long snuke = 0;
    long ans = LONG_MAX;
    for (int i = 0; i < n-1; i++) {
        snuke += a[i];
        ans = min(ans, abs(snuke - (sum - snuke)));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys
import numpy as np

input = sys.stdin.readline


def ST():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


N, P = MI()
S = ST()

ans = 0
if P == 2:
    for i, s in enumerate(S, 1):
        if int(s) % 2 == 0:
            ans += i
elif P == 5:
    for i, s in enumerate(S, 1):
        if int(s) % 5 == 0:
            ans += i
else:
    cnt = np.zeros(P)
    cnt[0] = 1
    res = 0
    tmp = 1
    for s in S[::-1]:
        res += int(s) * tmp
        res %= P
        cnt[res] += 1
        tmp *= 10
        tmp %= P

    for c in cnt[cnt >= 2]:
        ans += c * (c - 1) // 2

print(int(ans))


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

#define int ll
#define rep(i,a,b) for(ll i=(a);i<=(b);i++)
#define END(x) do{cout<<(x)<<endl;exit(0);}while(0)
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: x)cerr<<e<<" ";cerr<<"\n";}while(0)
#define exp2(x)  (1LL<<(x))

using namespace std;
using ll=long long;

signed main() {
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
  int N, K; cin >> N >> K;
  int V[N];rep(i,0,N-1) cin >> V[i];

  int ans=0;
  rep(i, 0, K) rep(j, 0, K-i) {
      debug(i); debug(j);
      if(i>N or j>N) continue;
      if(i+j>N) continue;
      int rem = K-i-j;
      vector<int> v; int t=0;
      rep(l,0,i-1) {t+= V[l]; v.push_back(V[l]);}
      rep(r,0,j-1) {t+= V[N-1-r]; v.push_back(V[N-1-r]);}
      //debugv(v);
      sort(v.begin(), v.end());
      rep(ii,0,min(rem,int(v.size()))-1) {
          if (v[ii]<0) t -= v[ii]; else break;
      }

      ans=max(ans,t);
  }
  END(ans);
}


Measured memory_bytes: 256
import math
from functools import reduce
from sys import setrecursionlimit
setrecursionlimit(10**6)

def gcd(*numbers):
  return reduce(math.gcd, numbers)

n,x = map(int,input().split())
xl = list(map(int,input().split()))
xl = list(map(lambda y: abs(y-x), xl))

ans = -1
if len(xl) == 1:
    ans = xl[0]
else:
    ans = gcd(*xl)

print(ans)

Measured memory_bytes: 20540
/**
 *    author:  tourist
 *    created: 17.08.2019 15:29:06       
**/
#include <bits/stdc++.h>

using namespace std;

class matching {
 public:
  vector<vector<int>> g;
  vector<int> pa;
  vector<int> pb;
  vector<int> was;
  int n, m;
  int res;
  int iter;

  matching(int _n, int _m) : n(_n), m(_m) {
    assert(0 <= n && 0 <= m);
    pa = vector<int>(n, -1);
    pb = vector<int>(m, -1);
    was = vector<int>(n, 0);
    g.resize(n);
    res = 0;
    iter = 0;
  }

  void add(int from, int to) {
    assert(0 <= from && from < n && 0 <= to && to < m);
    g[from].push_back(to);
  }

  bool dfs(int v) {
    was[v] = iter;
    for (int u : g[v]) {
      if (pb[u] == -1) {
        pa[v] = u;
        pb[u] = v;
        return true;
      }
    }
    for (int u : g[v]) {
      if (was[pb[u]] != iter && dfs(pb[u])) {
        pa[v] = u;
        pb[u] = v;
        return true;
      }
    }
    return false;
  }

  int solve() {
    while (true) {
      iter++;
      int add = 0;
      for (int i = 0; i < n; i++) {
        if (pa[i] == -1 && dfs(i)) {
          add++;
        }
      }
      if (add == 0) {
        break;
      }
      res += add;
    }
    return res;
  }

  int run_one(int v) {
    if (pa[v] != -1) {
      return 0;
    }
    iter++;
    return (int) dfs(v);
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
      --a[i][j];
    }
  }
  vector<int> used(h * w, 0);
  vector<vector<int>> b(h, vector<int>(w));
  vector<vector<int>> c(h, vector<int>(w));
  for (int col = 0; col < w; col++) {
    matching mat(h, h);
    vector<vector<int>> go(h, vector<int>(h, -1));
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (!used[a[i][j]]) {
          mat.add(i, a[i][j] / w);
          go[i][a[i][j] / w] = a[i][j];
        }
      }
    }
    assert(mat.solve() == h);
    for (int i = 0; i < h; i++) {
      b[i][col] = go[i][mat.pa[i]];
      used[b[i][col]] = 1;
    }
  }
  for (int j = 0; j < w; j++) {
    vector<int> x(h);
    for (int i = 0; i < h; i++) {
      x[i] = b[i][j];
    }
    sort(x.begin(), x.end());
    for (int i = 0; i < h; i++) {
      c[i][j] = x[i];
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (j > 0) {
        cout << " ";
      }
      cout << b[i][j] + 1;
    }
    cout << '\n';
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (j > 0) {
        cout << " ";
      }
      cout << c[i][j] + 1;
    }
    cout << '\n';
  }
  return 0;
}


Measured memory_bytes: 640
using System;
using System.Text.RegularExpressions;

namespace Small_Large_orEqual{
	class class1{
		static void Main(string[] args){
			string input = Console.ReadLine();
			Match m = Regex.Match(input,@"(?<a>-?\d+) (?<b>-?\d+)$");
			int a = int.Parse(m.Groups["a"].Value),b=int.Parse(m.Groups["b"].Value);
			if(a < b){
				Console.Write("a < b\n");
			}
			else if(a > b){
				Console.Write("a > b\n");
			}
			else{
				Console.Write("a == b\n");
			}
			
		}
	}
}

Measured memory_bytes: 11592
#include <cstdio>

using namespace std;

typedef double db;

const int N = 305;

db dp[N][N][N];
int bio[N][N][N], n, cn[N];

db f(int x,int y,int z){
    if(x < 0 || y < 0 || z < 0) return 0;
    if(!x && !y && !z) return 0;
    if(bio[x][y][z]) return dp[x][y][z];
    dp[x][y][z] = (db)x / (x + y + z) * f(x - 1, y , z) + (db)y / (x + y + z) * f(x + 1, y - 1, z) + (db)z / (x + y + z) * f(x, y + 1, z - 1) + (x + y + z != n ? (db)n / (x + y + z) : 1);
    bio[x][y][z] = 1;
    return dp[x][y][z];
}

int main(){
    scanf("%d", &n);
    for(int i = 0;i<n;i++){
        int x;scanf("%d", &x);
        cn[x]++;
    }
    printf("%.10lf\n", f(cn[1], cn[2], cn[3]));
}


Measured memory_bytes: 329984
/*
[dp] M - Candies
*/

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

const int MAX_N = 100;
const int MAX_K = 1e5;
const ll MOD = 1e9 + 7;

int N, K;
int a[MAX_N];
ll dp[MAX_N + 1][MAX_K + 2];

ll solve() {
    dp[0][0] = 1;
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= K; j++) {
            (dp[i][j] += dp[i - 1][j]) %= MOD;
            (dp[i][min(K + 1, j + a[i - 1] + 1)] += MOD - dp[i - 1][j]) %= MOD;
        }
        for (int j = 0; j <= K; j++) {
            (dp[i][j + 1] += dp[i][j]) %= MOD;
        }
    }

    return dp[N][K];
}

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char X;
  cin >> X;
  if ( X == 'A' ) {
    cout << 'T' << endl;
  }
  if ( X == 'T' ) {
    cout << 'A' << endl;
  }
  if ( X == 'C' ) {
    cout << 'G' << endl;
  }
  if ( X == 'G' ) {
    cout << 'C' << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<set>
#include<cmath>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll INF =  1LL << 60;
const int inf = 1 << 30;
int n, m, x, y, q, d; ll z, w = 0, sum = 0; int ans = 0;
const int MAX = 510000;
const int MOD = 1000000007;
int main(void) {
	int a[5];
	rep(i, 5) {
		cin >> a[i];
		if (a[i] % 10 == 0) {
			sum += a[i];
			a[i] = 0;
		}
	}
	rep(i, 5) {
		if (a[i] != 0) {
			sum += 10 - (a[i] % 10);
			ans = max(ans, 10 - (a[i] % 10));
			sum += a[i];
		}
	}cout << sum -ans << endl;
}

Measured memory_bytes: 3608
import java.util.*;
import java.util.function.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int u = sc.nextInt();
    int v = sc.nextInt();
    int[] A = new int[N];
    int[] B = new int[N];
    for (int i = 1; i < N; i++) {
      A[i] = sc.nextInt();
      B[i] = sc.nextInt();
    }
    sc.close();

    List<Integer>[] tree = new List[N + 1];
    for (int i = 1; i < tree.length; i++) tree[i] = new ArrayList<>();
    for (int i = 1; i < N; i++) {
      tree[A[i]].add(B[i]);
      tree[B[i]].add(A[i]);
    }
/*
    IntFunction<int[]> dist = r -> {
      int[] ds = new int[N + 1];
      Deque<Integer> stack = new ArrayDeque<>();
      stack.push(r);
      while (0 < stack.size()) {
        int i = stack.pop();
        for (int t : tree[i])
          if (ds[t] == 0 && t != r) {
            ds[t] = ds[i] + 1;
            stack.push(t);
          }
      }
      return ds;
    };
    int[] dist_u = dist.apply(u);
    int[] dist_v = dist.apply(v);
*/
    int[] dist_u = new int[N + 1];
    Arrays.fill(dist_u, -1);
    dist_u[u] = 0;
    dist(dist_u, u, tree);
    
    int[] dist_v = new int[N + 1];
    Arrays.fill(dist_v, -1);
    dist_v[v] = 0;
    dist(dist_v, v, tree);

    int d = 0;
    for (int i = 1; i < N + 1; i++)
      if (dist_u[i] < dist_v[i] && dist_v[d] < dist_v[i]) d = i;

    long ans = dist_v[d] - 1;
    System.out.println(ans);
  }

  private static void dist(int[] ds, int r, List<Integer>[] tree) {
    for (Integer tr : tree[r]) {
      int t = tr.intValue();
      if (ds[t] < 0) {
        ds[t] = ds[r] + 1;
        dist(ds, t, tree);
      }
    }
  }
}

Measured memory_bytes: 105320
H,W = map(int,input().split(" "))
a = [ ]
for i in range(H):
    ai = input()
    a.append(ai)

md = 1e9 + 7
dp = [ [0]*W for _ in range(H) ]
dp[0][0] = 1
for h in range(H):
    for w in range(W):
        if a[h][w] == '.':
            if w > 0:
                dp[h][w] += dp[h][w-1]
            if h > 0:
                dp[h][w] += dp[h-1][w]
        dp[h][w] %= md

print(int(dp[H-1][W-1]))

Measured memory_bytes: 78556
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long a = scan.nextLong();
    long b = scan.nextLong();
    long c = scan.nextLong();
    long d = scan.nextLong();
    if (c<d){
      long g = c;
      c = d;
      d = g;
    }
    long gg = divisor(c,d);
    long e = c*d/gg;
    long f = find(a,b,c);
    long f1 = find(a,b,d);
    long f2 = find(a,b,e);
    System.out.println(b-a+1-f-f1+f2);
  }

  static long find(long a, long b, long c){
    long sum = 0;
    if (a%c == 0){
      sum += 1;
    }

    long aa = (long) a/c;
    long bb = (long) b/c;
    sum += (bb-aa);
    return sum;
  }

  static long divisor(long a, long b){
    if (b == 0){
      return a;
    }

    long remain = (long) a%b;
    a = b;
    b = remain;
    long result = divisor(a,b);
    return result;
  }
}


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

using namespace std;
using ii = pair<int, int>;

pair<int, vector<ii>> solve(int N, int K)
{
    set<ii> es;

    for (int u = 1; u <= N; ++u)
        for (int v = u + 1; v <= N; ++v)
            es.insert(ii(u, v));

    int u = 1, v = 2;

    while (K)
    {
        if (v == N)
        {
            ++u;
            v = u + 1;
        }

        if (u >= N - 1)
            break;

        es.erase(ii(u, v));
        ++v;
        --K;
    }

    vector<ii> ans(es.begin(), es.end());

    int M = K > 0 ? -1 : (int) ans.size();

    return make_pair(M, ans);
}

int main()
{
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;

    auto ans = solve(N, K);
    auto M = ans.first;
    auto xs = ans.second;

    cout << M << endl;

    if (M > -1)
        for (auto x : xs)
            cout << x.first << ' ' << x.second << '\n';

    return 0;
}


Measured memory_bytes: 3904
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    string S, T;
    cin >> S >> T;
    int N = S.length();
    string F;
    for (int i = 0; i < N; ++i) {
        F += T[i];
    }
    if (S == F) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3596
#include<stdio.h>
int main()
{
	int n,k,i=0,m=1,t,w;
	scanf("%d%d",&n,&k);
	while(i!=n)
	{
		t=m*2;
		w=m+k;
		if(t>w)
		{
			m=m+k;
			i++;
		}
		else
		{
			m=m*2;
			i++;
		}
	}
	printf("%d\n",m);
	return 0;
}



Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
    char S[5];

    scanf("%s", S);

    for (int i = 0; i < 3; i++)
    {
        if (S[i] == S[i + 1])
        {
            printf("Bad");
            return 0;
        }
        
    }
    
    printf("Good");

    return 0;
}

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

int main()
{
	int n;
	string s;

	cin >> n;
	cin >> s;

	if (n % 2 == 0)
	{
		int len = n;
		int halfLen = len / 2;

		string s1 = s.substr(0, halfLen);
		string s2 = s.substr(halfLen, len);


		if (s1 == s2)
		{

			cout << "Yes" << endl;
			return 0;
		}

	}

	cout << "No" << endl;

	return 0;
}

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

int A[100005], n;

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
  }
  int q, k, sum = 0;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    cin >> k;
    if (*lower_bound(A, A+n, k) == k) sum++;
  }
  cout << sum << endl;
  return 0;
}



Measured memory_bytes: 3384
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

S = input()
n = len(S)
s = [0]
for i, x in enumerate(S):
	s.append(int(S[i])*pow(10, n-i-1, 2019)%2019)

tmp = 0
t = []
for x in s:
	tmp = (tmp+x)%2019
	t.append(tmp)

ans = 0
for v in Counter(t).values():
	ans += v*(v-1)//2
print(ans)

Measured memory_bytes: 24928
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/05/02 21:22:19 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

using namespace std;

#define	int	long long
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

typedef long long 			ll;
typedef vector<int>			VI;
typedef vector<vector<int>>	VVI;
typedef pair<int, int>		PII;

// TOP
void	Main()
{
	int	x;
	cin >> x;
	int	n;
	n = 100;
	int cnt;
	cnt = 0;
	while (n < x)
	{
		n += n / 100;
		cnt++;
	}
	cout << cnt << endl;
}
// END

int32_t	main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
const int NMAX=100666; //LOL
using namespace std;
const int INF=1000000007;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef vector<int> VI;

string s;

void solve()
{
    cin>>s;
    bool q=0;
    bool l=0;

    for(int i=0; i<s.size(); ++i)
    {
        if(i<= s.size() -5 && s[i]=='e' && s[i+1] =='r' && s[i+2]=='a' && s[i+3]=='s' && s[i+4]=='e')
        {
            i+=4;
            l=0;
            q=1;

           continue; 
        }
        if(i<= s.size() -5 && s[i]=='d' && s[i+1] =='r' && s[i+2]=='e' && s[i+3]=='a' && s[i+4]=='m')
        {
            q=0;
            l=1;
            i+=4;
           continue; 
        }
             
        if(q && s[i]=='r')
        {
            q=0;
            continue;
        }
        if(l && i<=s.size()-2 && s[i]=='e' && s[i+1]=='r')
        {
            l=0;
            i++;
           continue; 
        }

        cout<<"NO";
        return;
    }
    cout<<"YES";
}

int main()
{
    // Tic
    clock_t t=clock();
   
    solve();
    cout<<"\n";
 
    //Toc
    t=clock()-t;
    //printf("It took me %d clicks (%f seconds).\n",(int)t,((float)t)/CLOCKS_PER_SEC);
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);


int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif
  int a;
  scanf("%d", &a);
  printf("%d\n", a + a * a + a * a * a);



#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

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

using ll = long long;

int n, m;
ll k, tmp;
const ll sz = 2e6 + 10;
ll a[sz], b[sz];
using namespace std;

int main()
{
    scanf("%d%d%lld", &n, &m, &k);
    ll prev = 0;
    for (int i=0; i<n; ++i) {
        scanf("%lld", &tmp);
        prev += tmp;
        a[i] = prev;
    }
    prev = 0;
    for (int i=0; i<m; ++i) {
        scanf("%lld", &tmp);
        prev += tmp;
        b[i] = prev;
    }
    ll mx = 0;
    for(ll i = 0; i < n; i++) {
        if(a[i] > k) break; 
        ll cnt = 0;
        auto it = lower_bound(b, b+m, k-a[i]) - b;
        if(it == m || b[it] > k-a[i]) it--;
        cnt += it  + 1;
        cnt += (i + 1);
        mx = max(mx, cnt);
    }
    ll mxb = 0;
    for(ll i = 0; i < m; i++) {
        if(b[i] > k) break;
        auto it = lower_bound(a, a+n, k-b[i]) - a;
        ll cnt = 0;
        if(it == n || b[it] > k-b[i]) it--;
        cnt += (i + 1);
        mxb = max(mxb, cnt);
    }
    
    printf("%d", max(mx, mxb));
}


Measured memory_bytes: 6920
class queClass:

	def __init__(self, qtime, valuelist):
		self.qtime = qtime
		self.valuelist = valuelist
		self.stime = 0

	def run(self):
		time = self.qtime
		if time < self.valuelist[0][1]:  # クオンタム内に処理できなかった場合
			self.valuelist.append([self.valuelist[0][0], self.valuelist[0][1] - time])
			self.valuelist.remove(self.valuelist[0])
			self.stime = self.stime + self.qtime
		else:  # クオンタム内に処理できた場合
			self.stime = self.stime + self.valuelist[0][1]
			print('{0} {1}'.format(self.valuelist[0][0], self.stime))
			self.valuelist.remove(self.valuelist[0])
			if len(self.valuelist) == 0:
				exit(0)
		return


n, q = map(int, input().split())
inplist = []
for i in range(0, n):
	a, b = input().split()
	inplist.append([a, int(b)])
# print(inplist)
que = queClass(q, inplist)
while True:
	que.run()



Measured memory_bytes: 13008
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
int n,m;
vector<vi> graph;
vi col,parity;
const int inf = 1e9;
priority_queue<ii,vector<ii> > pq;
vi vis;
int main()
{
	int x,y,i;
	scanf("%d",&n);
	graph.assign(n+1,vi());
	for(i=1;i<n;i++)
	{
		scanf("%d %d",&x,&y);
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	col.assign(n+1,inf);
	scanf("%d",&m);
	for(i=0;i<m;i++)
	{
		scanf("%d %d",&x,&y);
		col[x] = y;
		pq.push(ii(y,x));
	}
	parity.assign(n+1,-1);
	parity[x] = col[x] % 2;
	queue<int> q;
	q.push(x);
	while(!q.empty())
	{
		x = q.front();q.pop();
		for(auto i : graph[x])
		{
			if(parity[i]==-1)
			{
				parity[i] = 1 - parity[x];
			}
			else
			{
				if(parity[i]==parity[x])
				{
					printf("No");
					return 0;
				}
			}
		}
	}
	vis.assign(n+1,0);
	while(!pq.empty())
	{
		ii p = pq.top();pq.pop();
		int c = p.first;
		int v = p.second;
		if(vis[v]==0 && c == col[v])
		{
			vis[v] = 1;
			for(auto i : graph[v])
			{
				if(col[i]==inf)
				{
					col[i] = col[v] - 1;
					pq.push(ii(col[i],i));	
				}
			}
		}
	}
	
	q.push(1);
	vis.assign(n+1,0);
	while(!q.empty())
	{
		x = q.front();q.pop();
		vis[x] = 1;
		for(auto i : graph[x])
		{
			if(vis[i]==0)	
			{
				q.push(i);
				if(abs(col[i]-col[x])!=1)
				{
					printf("No");
					return 0;
				}
			}
		}
	}
	printf("Yes\n");for(i=1;i<=n;i++)		printf("%d\n",col[i]);
}


Measured memory_bytes: 11360
import itertools
from collections import Counter
h = int(input())
if h == 1:
	print(1)
	exit()
a = list(map(int,input().split()))
t = Counter(a)
b = []
for i, j in t.most_common():
	if j == 1:
		b.append(i)
bset = set(a)

def sieve(n):
	ret = []
	divlis = [-1]*(n+1)  # 何で割ったかのリスト(初期値は-1)
	flag = [True]*(n+1)
	flag[0] = False
	flag[1] = False
	ind = 2
	while ind <= n:
		if flag[ind]:
			ret.append(ind)
			ind2 = ind**2
			while ind2 <= n:
				flag[ind2] = False
				divlis[ind2] = ind
				ind2 += ind
		ind += 1
	#何で割ったかのリストを取得したいとき, divlisも出力する
	return ret

k = sieve(1000)

def pfact(m):
	pf = {}
	cnt = 0
	i = k[cnt]
	st = len(k)
	while m > 1 and cnt < st:
		i = k[cnt]
		while m%i == 0:
			pf[i] = pf.get(i,0) + 1
			m //= i
		cnt += 1
	if m>1 : pf[m]=1
	return pf

def makediv(n):
	s = pfact(n)
	k = [range(i+1) for i in s.values()]
	ansl = []
	for i in itertools.product(*k):
		ans = 1
		for n, j in enumerate(s.keys()):
			ans *= (j**i[n])
		ansl.append(ans)
	ansl.sort()
	return ansl

ans = 0
for i in b:
	t=makediv(i)
	t.remove(i)
	mode = 1
	for l in t:
		if l in bset:
			mode = 0
			break
	if mode:
		ans += 1
print(ans)

Measured memory_bytes: 154464
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $k = <STDIN>);
my @que;
my $cnt;
for my $i (1..9) {
  push @que, $i;
  $cnt++;
  if ($cnt == $k) {
    say $i;
    exit;
  }
}
while (@que) {
  my $i = shift @que;
  if ($i % 10 == 0) {
    $cnt++;
    if ($cnt == $k) {
      say $i * 10;
      exit;
    }
    push @que, $i * 10;
    $cnt++;
    if ($cnt == $k) {
      say $i * 10 + 1;
      exit;
    }
    push @que, $i * 10 + 1;
  } elsif ($i % 10 != 0 && $i % 10 != 9) {
    $cnt++;
    if ($cnt == $k) {
      say $i.($i % 10 - 1);
      exit;
    }
    push @que, $i * 10 + $i % 10 - 1;
    $cnt++;
    if ($cnt == $k) {
      say $i * 10 + $i % 10;
      exit;
    }
    push @que, $i * 10 + $i % 10;
    $cnt++;
    if ($cnt == $k) {
      say $i * 10 + $i % 10 + 1;
      exit;
    }
    push @que, $i * 10 + $i % 10 + 1;
  } else {
    $cnt++;
    if ($cnt == $k) {
      say $i * 10 + 8;
      exit;
    }
    push @que, $i * 10 + 8;
    $cnt++;
    if ($cnt == $k) {
      say $i * 10 + 9;
      exit;
    }
    push @que, $i * 10 + 9;
  }
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;

ll llmax(ll x, ll y){
	if (x > y) return x;
	return y;
}

ll llmin(ll x, ll y){
	if (x > y) return y;
	return x;
}

bool is_prime(int x){
	for (int i = 2; i*i <= x; i++){
		if (!(x%i)) return false;
	}
	return true;
}


int main(){
	int x;
	cin >> x;
	for (int i = x; ; i++){
		if (is_prime(i)){
			cout << i << endl;
			break;
		}
	}
	return 0;
}


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

int main() {
  string F, A;
  cin >> F;
  cin >> A;
  int n;
  for(int i=0; i<3; i++) {
    if(F[i] == A[i]) {
      n++;
    }
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

template<typename T>
struct BinaryIndexedTree {
private:
    int n;
    vector<T> bit;
    
public:
    BinaryIndexedTree(int _n) : n(_n + 1), bit(n + 1, 0){}
    
    T sum(int idx) {
        T s(0);
        for(int x = idx + 1; x > 0; x -= (x & -x)) s += bit[x];
        return s;
    }
    
    void add(int idx, T a) {
        for(int x = idx + 1; x <= n; x += (x & -x)) bit[x] += a;
    }
    
    T query(int l, int r) {
        return sum(r - 1) - sum(l - 1);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, q;
    cin >> n >> q;
    BinaryIndexedTree<ll> ft(n);
    rep(i, n) {
        ll a;
        cin >> a;
        ft.add(i, a);
    }
    rep(i, q) {
        ll t, a, b;
        cin >> t >> a >> b;
        if (t == 0) {
            ft.add(a, b);
        }
        else {
            cout << ft.query(a, b) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 8256
#include<stdio.h>

int main(){

    int a,b,c;
    int d;//??????????????????
    int e;//c+60
    int i,j=0;
    scanf("%d %d %d",&a,&b,&c);

    if(a<0 || b<0 || c<0) return 0;
    if(a>60 || b>60 || c>60) return 0;
    i=0;
    while(j<100){
        i=i+a;
        if(c<=i){
            printf("%d\n",c);
            return 0;
        }
        i=i+b;
        if(c<=i){
            c=c+60;
        }
        j++;
    }
    printf("-1\n");
    
    return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan= new Scanner(System.in);
        int x=scan.nextInt();
        int a=scan.nextInt();
        int b=scan.nextInt();
        if (a>=b){
            System.out.println("delicious");
        }else if (b-a<=x){
            System.out.println("safe");
        }else {
            System.out.println("dangerous");
        }
    }
}


Measured memory_bytes: 23508
n = int(input())
a = [int(i) for i in input().split()]
sw = 0
for i in range(n):
    minj = i
    for j in range(i+1,n):
        if a[j] < a[minj]: minj = j
    if i != minj:
        a[i],a[minj] = a[minj],a[i]
        sw += 1
print(" ".join(map(str,a)))
print(sw)


Measured memory_bytes: 5604
#include<bits/stdc++.h> 
using namespace std;
int n,k,mm[3030][3030],m;
long long f[3030][3030][4];
int main() {
int r,v,c;
	scanf("%d%d%d",&n,&m,&k);
	for (int i = 1;i <= k; i++) {
		scanf("%d%d%d",&r,&c,&v);
		mm[r][c] = v;
	}
	for (int i = 1;i <= n; i++)
		for (int j = 1;j <= m; j++) {
		
				f[i][j][0] = max(f[i][j-1][0],f[i-1][j][3]);
				f[i][j][1] = f[i][j][0];
				f[i][j][1] = max(f[i][j][1],f[i][j][0]+mm[i][j]);
				f[i][j][1] = max(f[i][j][1],f[i][j-1][1]);
				f[i][j][2] = f[i][j][1];
				f[i][j][2] = max(f[i][j][2],f[i][j-1][1]+mm[i][j]);
				f[i][j][2] = max(f[i][j][2],f[i][j-1][2]);
				f[i][j][3] = f[i][j][2];
				f[i][j][3] = max(f[i][j][3],f[i][j-1][2]+mm[i][j]);
				f[i][j][3] = max(f[i][j][3],f[i][j-1][3]);
		}
		
	printf("%lld\n",f[n][m][3]);
	return 0;
}

Measured memory_bytes: 323396
from itertools import accumulate

n, c = map(int, input().split())
xs, vs = zip(*(map(int, input().split()) for _ in range(n)))

xs = (0,) + xs + (c,)
ds = [j - i for i, j in zip(xs, xs[1:])]

clockwise = [0] + [v - d for v, d in zip(accumulate(vs), accumulate(ds))]
clockwise_maxs = list(accumulate(clockwise, func=max))
clock_max = clockwise_maxs[-1]

anticlockwise = [0] + [v - d for v, d in zip(accumulate(vs[::-1]), accumulate(ds[::-1]))]
anticlockwise_maxs = list(accumulate(anticlockwise, func=max))
anticlock_max = anticlockwise_maxs[-1]

clockwise2 = [0] + [v - d*2 for v, d in zip(accumulate(vs), accumulate(ds))]
clock_anticlock = [x + y for x, y in zip(clockwise2, reversed(anticlockwise_maxs))]
c_ac_max = max(clock_anticlock)

anticlockwise2 = [0] + [v - d*2 for v, d in zip(accumulate(vs[::-1]), accumulate(ds[::-1]))]
anticlock_clock = [x + y for x, y in zip(anticlockwise2, reversed(clockwise_maxs))]
ac_c_max = max(anticlock_clock)

print(max(clock_max, anticlock_max, c_ac_max, ac_c_max))

Measured memory_bytes: 59224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int n;
vl a;

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> n;
	a.resize(n);
	bool isValid = true;
	rep(i,0,n) {
		cin >> a[i];
		if(i>0 && a[i-1] > a[i]) {
			isValid = false;
		}
	}
	if(isValid) {
		cout << 0 << '\n';
		return 0;
	}
	int idx = 0;
	rep(i,0,n) {
		if(abs(a[idx]) < abs(a[i])) {
			idx = i;
		}
	}
	vector<pair<int, int> > ret;
	rep(i,0,n) {
		a[i] += a[idx];
		ret.pb(mp(idx,i));
	}
	bool flag = (a[idx] > 0);
	if(flag) {
		rep(i,0,n-1) {
			if(a[i] > a[i+1]) {
				a[i+1] += a[i];
				ret.pb(mp(i,i+1));
			}
		}
	} else {
		per(i,0,n-1) {
			if(a[i] > a[i+1]) {
				a[i] += a[i+1];
				ret.pb(mp(i+1,i));
			}
		}
	}
	cout << sz(ret) << '\n';
	rep(i,0,sz(ret)) {
		cout << ret[i].F+1 << ' ' << ret[i].S+1 << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main() {
    int a[3], b[3];
    rep(i, 3) cin >> a[i] >> b[i];
    int count1 = 0, count2 = 0, count3 = 0, count4 = 0;
    rep(i, 3) {
        if (a[i] == 1 || b[i] == 1) count1++;
        if (a[i] == 2 || b[i] == 2) count2++;
        if (a[i] == 3 || b[i] == 3) count3++;
        if (a[i] == 4 || b[i] == 4) count4++;
    }
    if (count1 <= 2 && count2 <= 2 && count3 <= 2 && count4 <= 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
line = gets.chomp.chars.map(&:to_i)
first, second, third = 0, 0, 0

(1..7).each do |bit|
	first = (bit>>2 & 1 == 1 ? [1,"+"] : [-1,"-"] )
	second = (bit>>1 & 1 == 1 ? [1,"+"] : [-1,"-"] )
	third = (bit & 1 == 1 ? [1,"+"] : [-1,"-"] )

	if line[0] + line[1]*first[0] + line[2]*second[0] + line[3]*third[0] == 7
		print line[0], first[1], line[1], second[1], line[2], third[1], line[3], "=7"
		exit
	end
end



Measured memory_bytes: 1788
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    long long int a,b;
    char c;
    cin>>a>>c>>b;
    if(c=='+')
    {
        cout<<(a+b);
    }
    else
    cout<<(a-b);
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
int main() {
	int n;
	std::cin >> n;
	long long int sum = 0;
	for (auto i = 0; i < n; ++i) {
		int a;
		std::cin >> a;
		sum += a;
	}
	std::cout << sum / n << std::endl;
	return 0;
}

Measured memory_bytes: 3012
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
#include <istream>
#include <algorithm>

int main()
{
    int x, a, b,c;

    std::cin >> a;
    std::cin >> b;
    std::cin >> c;
    std::cin >> x;

    int count = 0;
    for (int i = 0; i <= a; i++)
        for (int j = 0; j <= b; j++)
            for (int k = 0; k <= c; k++)
                if (500 * i + 100 * j + 50 * k == x)
                    count++;
    std::cout << count << std::endl;

    getchar();
    getchar();

    return 0;
}


Measured memory_bytes: 384
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
ll arr[3005];
ll dp[3005][3005][2];

ll rec(int beg, int end, int ctr) {
	if(beg > end) {
		return 0;
	}
	ll &ans = dp[beg][end][ctr];
	if(ans != -1) {
		return ans;
	}
	if(ctr == 0) {
		ans = max(arr[beg] + rec(beg + 1, end, 1), arr[end] + rec(beg, end - 1, 1));
	}
	else {
		ans = min(-arr[beg] + rec(beg + 1, end, 0), -arr[end] + rec(beg, end - 1, 0));
	}
	return ans;
}


int main() {
	scanf("%lld", &N);
	// cout << N <<  " " << -N;
	for(int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
	}
	memset(dp, -1, sizeof(dp));
	cout << rec(0, N - 1, 0);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 141568
# C - Sentou

N, T = map(int, input().split())
t = list(map(int, input().split()))

ans = 0
for idx in range(N-1):
    if t[idx+1] - t[idx] < T:
        ans += t[idx+1] - t[idx]
    else:
        ans += T
        
print(ans+T)

Measured memory_bytes: 25200
import std.algorithm;
import std.range;
import std.stdio;
import std.math;
import std.array;
import std.string;
import std.conv;

/// 数列の読み込み
auto readNums(T = int)() {
	return readln().chomp.split.map!(to!T).array;
}

auto minElement(R)(R r) {
    return r.reduce!((a, b) => min(a, b));
}


void main() {
	auto nums = readNums();
	immutable a = nums[0];
	immutable b = nums[1];
	immutable q = nums[2];
	auto ss = assumeSorted(iota(0, a).map!((i) => readNums!long()[0]).array);
	auto ts = assumeSorted(iota(0, b).map!((i) => readNums!long()[0]).array);
	auto xs = iota(0, q).map!((i) => readNums!long()[0]).array;
	foreach(x; xs) {
		long distSW = -1;
		long distSE = -1;
		auto foundS = ss.trisect(x);
		if(!foundS[1].empty) {
			distSW = 0;
			distSE = 0;
		} else {
			if(!foundS[0].empty) {
				distSW = abs(foundS[0][$ - 1] - x);
			}
			if(!foundS[2].empty) {
				distSE = foundS[2][0] - x;
			}
		}
		
		long distTW = -1;
		long distTE = -1;
		auto foundT = ts.trisect(x);
		if(!foundT[1].empty) {
			distTW = 0;
			distTE = 0;
		} else {
			if(!foundT[0].empty) {
				distTW = abs(foundT[0][$ - 1] - x);
			}
			if(!foundT[2].empty) {
				distTE = foundT[2][0] - x;
			}
		}
		
		ulong minDist = long.max;
		if(distSW >= 0 && distTW >= 0) {
			minDist = min(minDist, max(distSW, distTW));
		}
		if(distSE >= 0 && distTE >= 0) {
			minDist = min(minDist, max(distSE, distTE));
		}
		if(distSW >= 0 && distTE >= 0) {
			minDist = min(minDist, distSW * 2 + distTE);
			minDist = min(minDist, distTE * 2 + distSW);
		}
		if(distSE >= 0 && distTW >= 0) {
			minDist = min(minDist, distSE * 2 + distTW);
			minDist = min(minDist, distTW * 2 + distSE);
		}
		writefln("%s", minDist);
	}
}

Measured memory_bytes: 6268
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;

#define ll long long

ll A, B, C, X, Y,ans[10],ANS;

int main()
{
	cin >> A >> B >> C >> X >> Y;
	
	ans[0] = A * X + B * Y;
	ans[1] = min(X, Y) * 2 * C + (X - min(X, Y))*A + (Y - min(X, Y))*B;
	ans[2] = C * max(X, Y)*2;
	

	ANS = min(ans[0],min( ans[1], ans[2]));

	cout << ANS;
	//system("pause");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int s;
  cin >> s ;
  int s_1 = s / 100;
  int s_2 = s / 10 - 10 * s_1 ;
  int s_3 = s - 100 * s_1 - 10 * s_2 ;
  cout << s_1 + s_2 + s_3  << endl;
}

Measured memory_bytes: 3560
//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 N, K, T, U, V, L;

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

  cin >> N >> K >> T >> U >> V >> L;
  VI D(N); REP(i,N) cin >> D[i];
  
  int prv = 0, num = 0;
  double ans = 0;
  for(int i=0;i<N;++i){
	if(num > 0){
	  if(prv + T * V < D[i]){
		ans += T;
		prv += T*V;
		--num, --i;
	  }
	  else{
		--num;
		int to = prv + T * V;
		for(;i<N;++i){
		  if(to < D[i]){
			--i;
			ans += T;
			prv = to;
			break;
		  }
		  if(++num > K){
			ans += (D[i] - prv)*1. / V;
			prv = D[i];
			break;
		  }
		}
		if(i == N){
		  if(prv + T*V < L){
			ans += T;
			prv = to;
		  }
		  else{
			ans += (L - prv)*1. / V;
			prv = L;
		  }
		}
	  }
	}
	else{
	  ans += (D[i] - prv)*1. / U;
	  prv = D[i];
	  ++num;
	}
  }
  if(prv != L){
	while(num > 0){
	  if(prv + T*V < L){
		ans += T;
		prv += T*V;
	  }
	  else{
		ans += (L - prv)*1. / V;
		prv = L;
		num = 0;
	  }
	  --num;
	}
	ans += (L - prv)*1. / U;
  }

  cout << fixed << setprecision(9) << ans << endl;
  
  return 0;
}

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

long long int answ(long long int x){
  if(x==1) return 1;
  if(x>1) return 2*answ(x/2)+1;
}
 
int main() {
  long long int n,a,b;
  cin>>n>>a>>b;
  if(a==0) cout<<"0"<<endl;
  else{
  long long int x=n/(a+b);
  long long int ans=x*a;
  if(n%(a+b)>0){
  if(n%(a+b)>=a) ans+=a;
    else ans+=n%(a+b);
  }
  cout<<ans<<endl;
}}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x;
    cin>>x;
    if(x>=400 && x<=599)
        cout<<"8"<<endl;
    else if(x>=600 && x<=799)
        cout<<"7"<<endl;
    else if(x>=800 && x<=999)
        cout<<"6"<<endl;
     else if(x>=1000 && x<=1199)
        cout<<"5"<<endl;
    else if(x>=1200 && x<=1399)
        cout<<"4"<<endl;
        else if(x>=1400 && x<=1599)
        cout<<"3"<<endl;
    else if(x>=1600 && x<=1799)
        cout<<"2"<<endl;
        else if(x>=1800 && x<=1999)
        cout<<"1"<<endl;

}


Measured memory_bytes: 3604
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

n=I()
m=n.bit_length()
x=LI()
L=I()
q=I()

r=[0]*n


for i in range(n):
    r[i]=bisect.bisect(x,x[i]+L)-1
    
nb=[r]
nx=[0]*n

for k in range(m):
    nx=[0]*n
    for i in range(n):
        nx[i]=r[r[i]]
    nb.append(nx)
    r=nx

for _ in range(q):
    a,b=LI_()
    if a>b:
        a,b=b,a
    
    t=0
    for p in range(m,-1,-1):
        if nb[p][a]<b:
            t+=1<<p
            a=nb[p][a]
    
    print(t+1)


Measured memory_bytes: 81148
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> P(N);
    vector<string> S(N),C(N);
    vector<int> Q(N),R(N);
    for(int i = 0; i < N; i++){
        cin >> S[i] >> P[i];
        C[i] = S[i];
        Q[i] = R[i] = 0;
    }
  
    sort(C.begin(),C.end());
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(C[i] == S[j] && Q[i] <= P[j]){
                    Q[i] = P[j];
                    R[i] = j + 1;
            }
        }
            S[R[i]-1] = "ZZZZZ";
            P[R[i]-1] = 0;
    }
    for(int i = 0; i < N; i++){
        cout << R[i] << endl;
    }
}

Measured memory_bytes: 384