akhauriyash/Code-Regression huggingface dataset:
//hinagata.cpp
//作成日
//更新日
//目的
//手段
/*includes*/
#include <bits/stdc++.h>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPi(i,a,b) for(ll i=(a);i<(b);i++)
#define REPRi(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    ll X,Y;
    cin>>X>>Y;
    //inputend;
    int count=0;
    while(X<=Y){
        if(Y%2==1){
            Y-=1;
        }
        Y/=2;
        count+=1;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
	string s;
	cin>>s;
	long long k;
	cin>>k;
	int f=1;
	for(int i=0;i<k&&i<s.length();i++)
	{
		if(s[i]!='1')
		{
			f=s[i]-'0';
			break;
		}
	}
	cout<<f<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int( input() )
l = map( int, input().split() )

attendance_list = [0] * n
cnt = 1
for i in l:
  attendance_list[ i - 1 ] = cnt
  cnt += 1
alist = str( attendance_list[0] )
for a in attendance_list[1:]:
  alist += " " + str( a )
print( alist )

Measured memory_bytes: 13812
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<complex>

#define INF (long long)1000000000
#define MOD 1000000007
#define EPS 1e-8

#define REP(i, m) for(long long i = 0; i < m; ++i)
#define FOR(i, n, m) for(long long i = n; i < m; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

enum FACE{TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT};
class Dice {
public:
	Dice() {
		id[TOP] = 0; id[BOTTOM] = 1; id[FRONT] = 2;
		id[BACK] = 3; id[LEFT] = 4; id[RIGHT] = 5;
	}
	Dice(int top,int bottom, int front, int back, int left, int right) {
		id[TOP] = top; id[BOTTOM] = bottom; id[FRONT] = front;
		id[BACK] = back; id[LEFT] = left; id[RIGHT] = right;
	}
	int& operator[] (FACE f) { return id[f]; }
	void rotX(int c) {
		for(int i = 0; i < c; ++i) {
			int top = id[BACK], front = id[TOP], bottom = id[FRONT], back = id[BOTTOM];
			id[TOP] = top; id[FRONT] = front;
			id[BOTTOM] = bottom; id[BACK] = back;
		}
	}
	void rotY(int c) {
		for(int i = 0; i < c; ++i) {
			int top = id[LEFT], right = id[TOP], bottom = id[RIGHT], left = id[BOTTOM];
			id[TOP] = top; id[RIGHT] = right;
			id[BOTTOM] = bottom; id[LEFT] = left;
		}
	}
	void rotZ(int c) {
		for(int i = 0; i < c; ++i) {
			int front = id[RIGHT], left = id[FRONT], back = id[LEFT], right = id[BACK];
			id[FRONT] = front; id[LEFT] = left;
			id[BACK] = back; id[RIGHT] = right;
		}
	}
private:
	int id[6];
};

int main() {
	Dice d;
	int top,right,front,back,left,bottom;
	cin>>top>>right>>front>>back>>left>>bottom;
	d[TOP]=top;
	d[RIGHT]=right;
	d[FRONT]=front;
	d[BACK]=back;
	d[LEFT]=left;
	d[BOTTOM]=bottom;
	string s;
	cin>>s;
	REP(i,s.size()) {
		char c=s[i];
		if(c=='N'){ d.rotY(3); }
		if(c=='E'){ d.rotX(1); }
		if(c=='W'){ d.rotX(3); }
		if(c=='S'){ d.rotY(1); }
	}
	cout<<d[TOP]<<endl;
}

Measured memory_bytes: 3216
n, c = map(int, input().split())
xv = [list(map(int, input().split())) for i in range(n)]
dx = []
dy = []
for i in range(n):
    if i == 0:
        dx.append(xv[i][0])
        dy.append(c - xv[-i-1][0])
    else:
        dx.append(xv[i][0]-xv[i-1][0])
        dy.append(-xv[-i-1][0] + xv[-i][0])
right = [0]
left = [0]
for i in range(n):
    r = right[-1] + xv[i][1] - dx[i]
    l = left[-1] + xv[-i-1][1] - dy[i]
    right.append(r)
    left.append(l)
for i in range(1,n+1):
    right[i] = max(right[i-1], right[i])
    left[i] = max(left[i-1], left[i])

ans = 0
for i in range(1,n+1):
    a1 = right[i]
    a2 = right[i] - xv[i-1][0] + left[n-i]
    a3 = left[i]
    a4 = left[i] - (c - xv[-i][0]) + right[n-i]
    ans = max(ans,a1,a2,a3,a4)
print(ans)

Measured memory_bytes: 44480
#include<stdio.h>

/* 配列の要素を順番に出力 */
void trace(int A[], int N) {
    int i;
    for ( i = 0; i < N; i++) {
        if ( i > 0 ) printf(" "); //隣接する要素の間に１つの空白を出力
        printf("%d", A[i]);
    }
    printf("\n");
}

/* 挿入ソート（0オリジン配列）*/
void insertionSort(int A[], int N) {
    int j, i, v;
    for ( i = 1; i < N; i++ ) {
        v = A[i];
        j = i - 1;
        while ( j >= 0 && A[j] > v ) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        trace(A, N);
    }
}

int main() {
    int N, i, j;
    int A[100];

    scanf("%d", &N);
    for ( i = 0; i < N; i++ ) scanf("%d", &A[i]);

    trace(A, N);
    insertionSort(A, N);

    return 0;
}


Measured memory_bytes: 2104
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<iomanip>
#include<functional>
using namespace std;
typedef long long llong;
int main() {
	int n; cin >> n;
	while (n--) {
		string big, small;
		cin >> big >> small;
		if (small.size() > big.size())swap(big, small);
		reverse(big.begin(), big.end());
		reverse(small.begin(), small.end());
		//cout << "reverse" << endl << s1 << endl << s2 << endl;
		vector<int>vb(big.size()), vs(small.size());
		for (int i = 0; i < big.size(); i++)vb[i] = big[i] - '0';
		for (int i = 0; i < small.size(); i++)vs[i] = small[i] - '0';
		for (int i = 0; i < small.size(); i++) vb[i] += vs[i];
		for (int i = 0; i < big.size(); i++) {
			if (vb[i] >= 10) {
				vb[i] -= 10;
				if (i == big.size() - 1)vb.push_back(1);
				else vb[i + 1]++;
			}
		}
		if (vb.size() > 80)cout << "overflow" ;
		else for (int i = 0; i < vb.size(); i++) {
			cout << vb[vb.size() - 1 - i];
		}
		cout << endl;
	}
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = 3.141592653589793;
int n;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    while (n!=0) {
        int  s[105]={};
        rep(i,n) cin >> s[i];
        sort(s,s+n);
        int ans=0;
        rep2(i,1,n-1) ans+=s[i];
        cout << ans /(n-2) << endl;
        cin >> n;
    }
    return 0;
}

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

int main() {
  ll x;
  cin >> x;
  ll sum = 0;
  ll tm = 0;

  // 方針
  // 1,2,...,i を足す
  // xを超えたら、超えた分はx未満のはず
  // 最初からそれを除いていればOKと考える。

  for (ll i = 1; i <= x; i++) {
    sum += i;
    tm++;
    if (sum >= x) break;
  }

  cout << tm << endl;
  return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left

A, B, Q = map(int, input().split())
s, t, x = [], [], []
for i in range(A):
    s.append(int(input()))
for i in range(B):
    t.append(int(input()))
for i in range(Q):
    x.append(int(input()))


for x_i in x:
    s_r_index = bisect_left(s, x_i)
    if s_r_index >= len(s):
        s_r = 1e18
    else:
        s_r = s[s_r_index]

    if s_r_index > 0:
        s_l = s[s_r_index-1]
    else:
        s_l = -1e18

    t_r_index = bisect_left(t, x_i)
    if t_r_index >= len(t):
        t_r = 1e18
    else:
        t_r = t[t_r_index]

    if t_r_index > 0:
        t_l = t[t_r_index-1]
    else:
        t_l = -1e18

    move_length = [abs(x_i-s_l)+abs(s_l-t_l),
                   abs(x_i-s_l)+abs(s_l-t_r),
                   abs(x_i-s_r)+abs(s_r-t_l),
                   abs(x_i-s_r)+abs(s_r-t_r),
                   abs(x_i-t_l)+abs(t_l-s_l),
                   abs(x_i-t_l)+abs(t_l-s_r),
                   abs(x_i-t_r)+abs(t_r-s_l),
                   abs(x_i-t_r)+abs(t_r-s_r)]
    print(min(move_length))


Measured memory_bytes: 16152
s=input()
ls=["A",'C','G','T']
ans=0
u=0
i=0
while i < len(s):
  if s[i] in ls:
    cnt=1
    i+=1
    while i<len(s) and s[i] in ls:
      i+=1
      cnt+=1
    ans=max(cnt,ans)
  i+=1
print(ans)

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

const int MaxN = 100000 + 5;

int N, M;
int A[MaxN], dif[MaxN];

void init() {
  scanf("%d %d", &M, &N);
  for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
}

void solve() {
  if (M >= N) {
    puts("0");
    return;
  }
  sort(A + 1, A + 1 + N);

  int sum = A[N] - A[1];
  for (int i = 1; i < N; ++i)
    dif[i] = A[i + 1] - A[i];

  sort(dif + 1, dif + N, greater<int>());
  for (int i = 1; i < M; ++i) sum -= dif[i];
  cout << sum << endl;
}

int main() {
  init();
  solve();
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string.h>
#include <bits/stdc++.h>
#include<algorithm> 
using namespace std;
// main() is where program execution begins.



int main() {
    int A,B,C;
    cin>>A>>B>>C;  
    if (B/A > C)
    {
      cout <<C;
    }
    else{
      cout << B/A;
    }

   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int n,i,j;
  long long r=0,g=0,b=0,res;
  string s;
  cin >> n >> s;
  for(i=0;i<n;i++){
    if(s[i]=='R') r++;
    else if(s[i]=='G') g++;
    else b++;
  }
  res=r*g*b;
  for(i=0;i<n;i++)
    for(j=1;i+2*j<n;j++)
      if(s[i]!=s[i+j]&&s[i]!=s[i+2*j]&&s[i+j]!=s[i+2*j])
        res--;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(998244353)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
const int N = 100005;


int32_t main() {

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

    vector<int> v(5);
    rep(i,5)
    	cin >> v[i];
    int mn = inf;
    do {
    	int hr = 0;
    	rep(i,5) {
    		hr += (hr % 10) ? 10 - hr % 10 : 0;
    		hr += v[i];
    	}
    	mn = min(mn, hr);
    }while(next_permutation(all(v)));

    cout << mn << '\n';
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  int n;
  string s;
  int x=0;
  cin>>n;
  cin>>s;
  int max=0;
  for(int i=0;i<n;i++){
    if(s[i]=='I')x++;
    if(s[i]=='D')x--;
    if(max < x)max=x;
  }
  cout<<max<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

const ll mod = 1000000007;

template<int MOD> class Fp {
    ll val;
public:
    constexpr Fp(ll v = 0) noexcept : val(v % MOD) {
        if(val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator- () const noexcept { return val ? MOD - val : 0; }
    constexpr Fp operator+ (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator- (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator* (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator/ (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator+= (const Fp& r) noexcept {
        val += r.val;
        if(val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator-= (const Fp& r) noexcept {
        val -= r.val;
        if(val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator*= (const Fp& r) noexcept {
        (val *= r.val) %= MOD;
        return *this;
    }
    constexpr Fp& operator/= (const Fp& r) noexcept {
        ll a = r.val, b = MOD, u = 1, v = 0;
        while(b){
            ll t = a/b;
            a -= t*b; swap(a, b);
            u -= t*v; swap(u, v);
        }
        (val *= u) %= MOD;
        if(val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator== (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator!= (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    constexpr bool operator> (const Fp& r) const noexcept {
        return this->val > r.val;
    }
    constexpr bool operator< (const Fp& r) const noexcept {
        return this->val < r.val;
    }
    friend constexpr ostream& operator<< (ostream &os, const Fp<MOD>& x){
        ll tmp = x.val;
        os << tmp;
        return os;
    }
    friend constexpr istream& operator>> (istream &is, const Fp<MOD>& x){
        ll tmp;
        is >> tmp;
        x = Fp<MOD>(tmp);
        return is;
    }
    constexpr Fp<MOD> modpow(ll n) noexcept {
        if(n == 0) return 1;
        auto t = modpow(n>>1);
        t *= t;
        if(n & 1) t *= *this;
        return t;
    }
};
using mint = Fp<mod>;

const ll MAX = 2000005;
ll fact[MAX], ifact[MAX];

ll power(ll a, ll b){
    ll res = 1;
    while(b > 0){
        if(b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

ll comb(ll n, ll r){
    return (fact[n] * ifact[r]) % mod * ifact[n-r] % mod;
}

int main(){
    ll k; string s;
    cin >> k >> s;
    
    ll n = s.size();
    fact[0] = 1;
    rep(i, n+k) fact[i+1] = fact[i]*(i+1)%mod;
    ifact[n+k] = power(fact[n+k], mod-2);
    for(ll i = n+k-1; i >= 0; --i) ifact[i] = ifact[i+1]*(i+1)%mod;
    
    mint sum(0);
    for(ll i = 0; i <= k; ++i){
        mint tmp(0);
        tmp += mint(25).modpow(i);
        tmp *= comb(i + n-1, n-1);
        tmp *= mint(26).modpow(k-i);
        sum += tmp;
    }
    cout << sum << endl;
    return 0;
}

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

#define SZ(a) int((a).size())
#define FOR(var,a,b) for(__typeof(a) var=(a)-((a)<(b)?0:1);var!=(b)-((a)<(b)?0:1);var+=((a)<(b)?1:-1))
#define REP(var,n) FOR(var,0,n)
#define INT(n) int n;scanf("%d",&n)
#define VS(v,n) vector<string> v(n);REP(i,n){cin>>v[i];}

int main(){
  INT(h); INT(w); VS(as, h);
  vector<string> rs = as, bs = as;
  FOR(i, 1, w - 1){
    rs[0][i] = '#';
    bs[h - 1][i] = '#';
  }
  REP(i, h){
    rs[i][0] = '#';
    bs[i][w - 1] = '#';
    if (i % 2 == 0 && i < h - 1){
      FOR(j, 0, w - 1){
        rs[i][j] = '#';
      }
    }
    if (i % 2 == 1){
      FOR(j, 1, w){
        bs[i][j] = '#';
      }
    }
  }

  for(auto s: rs){cout << s << endl;}
  cout << endl;
  for(auto s: bs){cout << s << endl;}
  return 0;
}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long r, g, b; scan(r, g, b);
      long t = r * 100 + g * 10 + b;
      puts(t % 4 == 0 ? "YES" : "NO");
   }
};

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
int a[100010];
int b[100010];
int c[100010];

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    b[0]=a[0];
    for(int i=1;i<n;i++)
    {
        b[i]=__gcd(b[i-1],a[i]);
    }
    c[n-1]=a[n-1];
    for(int i=n-2;i>=0;i--)
    {
        c[i]=__gcd(c[i+1],a[i]);
    }
    int ans = max(c[1],b[n-2]);
    for(int i=1;i<n-1;i++)
    {
        ans = max(__gcd(b[i-1],c[i+1]),ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);
// priority_queue<ll, vector<ll>, greater<ll>> pq;

map<ll, ll> res;

// map<ll, ll> prime_factor(ll n){
void prime_factor(ll n){
    // map<ll, ll> res;
    for(ll i=2; i*i<=n; i++){
        while(n%i == 0){
            ++res[i];
            n /= i;
        }
    }
    // if(n != 1) res[n] = 1;
    if(n != 1) ++res[n];
}


int main(){
    ll n, ans = 1; cin >> n;
    Rep(i, 2, n+1) prime_factor(i);
    for(auto p: res){
        MUL(ans, p.second+1);
        // cout << p.first << ' ' << p.second << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
const double pi=acos(-1);
int main(){
  double r;
  cin >> r;
  cout << fixed << setprecision(10) << r*r*pi << " " << 2*r*pi << endl;
  return 0;
}



Measured memory_bytes: 3280
int main(void)
{
  char str[100000];
  char* p;
  int i;
  
  scanf("%s",str);
  
  p = str;
  
  while(*p >= 'a' && *p <= 'z')
  {
    printf("%c",*p);
    p+=2;
  }
  
  return 0;
}



Measured memory_bytes: 256
def sa(_a,_b):
    a = max(_a,_b)
    b = min(_a,_b)
    return a-b

n = int(input())
l = list(map(int,input().split()))
m = sum(l)
a = l[0]
b = m - a
ans = sa(a,b)
for i in range(1,len(l)-1):
    a += l[i]
    b -= l[i]
    ans = min(ans,sa(a,b))
print(ans)


Measured memory_bytes: 24812
#include<bits/stdc++.h>
#define ls (now*2)
#define rs (now*2+1)
#define ll long long
using namespace std;
const ll H=18;
const ll N=(1<<H)+5;
const ll mod=1e9+7;

ll read()
{
	ll s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(ll x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(ll x,char c='\n')
{
	write(x);
	putchar(c);
}
ll p[N],h,l,a[N],v[N],cnt,ans=0;
void dfs1(ll now,ll deep,ll mul)
{
	mul=mul*now%mod;
	if (deep==h)
	{
		ll i=now-l+1;
		now=l+p[i]-1;
		v[++cnt]=now;
		while (now)
		{
			mul=mul*now%mod;
			a[now]=(a[now]+mul)%mod;
			now/=2;
		}
		return;
	}
	dfs1(ls,deep+1,mul);
	dfs1(rs,deep+1,mul);
}
void dfs2(ll now,ll deep,ll mul)
{
	mul=mul*now%mod;
	if (deep==h)
	{
		ll i=now-l+1;
		now=l+p[i]-1;
		mul=mul*now%mod;
		while (now>1)
		{
			mul=mul*(now/2)%mod;
			ans=(ans+mul*a[now^1]%mod)%mod;
			now/=2;
		}
		return;
	}
	dfs2(ls,deep+1,mul);
	dfs2(rs,deep+1,mul);
}
void solve(ll now,ll deep)
{
	cnt=0;
	dfs1(ls,deep+1,now);
//	print(now);
//	for (int i=1;i<=7;i++) print(a[i],' ');
//	puts("");
	dfs2(rs,deep+1,1);
	for (ll i=1;i<=cnt;i++)
	{
		ll w=v[i];
		while (w)
		{
			a[w]=0;
			w/=2;
		}
	}
}
void dfs0(ll now,ll deep)
{
	if (deep==h) return;
	solve(now,deep);
	dfs0(ls,deep+1);
	dfs0(rs,deep+1);
}

int main()
{
	memset(a,0,sizeof(a));
	h=read();
	l=1<<(h-1);
	for (ll i=1;i<=l;i++) p[i]=read();
	dfs0(1,1);
	print(ans);

	return 0;
}

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

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))    
#define OUT(P) cout << (P) << endl    
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl    
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;    
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)    
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)    
typedef long long ll;    
const long DIVIDE = 1e9+7;

int sum_digits(int num);    
template <class T>    
vector<T> copy_vector(vector<T> vec);    
long gcd(long a, long b);    
long lcm(long a, long b);
vector<vector<long>> comb(long n, long r);
// ****** print functions ****** //
template <class T, class U>
void print_pairs(const vector<pair<T, U>> pairs);
template <class K, class V>
void print_map(const map<K, V> m);


int main() {    
    string str, s1, s2;
    cin >> s1 >> s2;
    str = s1 + s2;
    string str_r = s1 + s2;
    reverse(str_r.begin(), str_r.end());
    string ans = (str == str_r)? "YES" : "NO";
    cout << ans << endl;
    return 0;    
}    

/******************************/    
/***** DECRARED FUNCTIONS *****/    
/******************************/    

int sum_digits(int num) {    
    int rtn = 0;    
    while(num != 0) {    
        int tmp = num % 10;    
        rtn += tmp;    
        num /= 10;    
    }    
    return rtn;    
}    

// vectorのコピー    
template <class T>    
vector<T> copy_vector(vector<T> vec) {    
    vector<T> rtn;    
    rtn.reserve(vec.size());    
    copy(vec.begin(), vec.end(), back_inserter(rtn));    
    return rtn;    
}    

long gcd(long a, long b) {    
    if(b==0) return a;    
    else return gcd(b, a % b);    
}

long lcm(long a, long b) {
    long gcd_ = gcd(a, b);
    return (a * b) / gcd_;
}

vector<vector<long>> comb(long n, long r) {                                                                             
    vector<vector<long>> v(n+1, vector<long>(n+1, 0));    
    for(int i=0; i<v.size(); i++) {    
        v[i][0] = 1;    
        v[i][i] = 1;    
    }    
    for(int i=1; i<v.size(); i++) {    
        for(int j=1; j < i; j++) {    
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % DIVIDE;    
        }    
    }    
    return v;    
} 

template <class T, class U>
void print_pairs(const vector<pair<T, U>> &pairs) {
    for(int i=0; i<pairs.size(); i++) { 
        cout << "(" << pairs[i].first << ", " << pairs[i].second << ")" << " "; 
    } 
    cout << endl;
}

template <class K, class V>
void print_map(const map<K, V> &m) {
    for(auto it=m.cbegin(); it!=m.cend(); it++) {
        cout << it->first << ": " << it->second << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
//#include <random>
#include <map>
//#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <time.h>
//#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
//#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
double pi = 3.141592653589793;
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

//void solve1();
int score1();

int ti;
int D;
int sumC;
//int no = 26;
vector<int> c(26), t;
vector<vector<int>> s;

int main() {
	srand((unsigned)time(NULL));
	cin >> D;
	s.resize(D);

	rep(i, 26) {
		cin >> c[i];
		sumC += c[i];
	}
	rep(i, D) {
		s[i].resize(26);
		rep(j, 26) {
			cin >> s[i][j];
		}
	}
	t.resize(D);
	rep(i, D) {
		cin >> t[i];
		t[i]--;
	}
	score1();
	//cout << score1() << endl;

}

void solve1() {

	ti = clock();

	while (1) {
		double time = (double)(clock() - ti) / CLOCKS_PER_SEC;
		if (time > 9.9) {
			break;
		}

		
	}
}

int score1() {
	//最後にコンテストが行われた日
	vector<int> last(26, -1);
	int ans = 0;

	rep(i, D) {
		ans += s[i][t[i]];
		last[t[i]] = i;
		rep(j, 26) {
			ans -= c[j] * (i - last[j]);
		}
		cout << ans << endl;
	}
	return ans;
}


Measured memory_bytes: 3796
#include <cstdio>
#include <cmath>
#include <iostream>
using namespace std;

int main()
{
  int q;
  
  while (scanf("%d", &q), q != -1){
    double x = q / 2.0;
    while (!(fabs(x * x * x - q) < q * 1e-5)){
      x = x - (x * x * x - q) / (3.0 * x * x);
    }
    printf("%f\n", x);
  }

  return (0);
}

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

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

  if ((x == 1 or x == 3 or x == 5 or x == 7 or x == 8 or x == 10 or x == 2)
    && (y == 1 or y == 3 or y == 5 or y == 7 or y == 8 or y == 10 or y == 12)){
    cout << "Yes" << endl;
  }else  if ((x ==  4 or x == 6 or x == 9 or x == 11)
    && (y == 4 or y == 6 or y == 9 or y == 11)){
    cout << "Yes" << endl;
  }else if (x == 2 && y == 2){
    cout << "Yes" <<endl;
  }else{
    cout << "No" <<endl;
  }

}


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

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

typedef long long LL;
typedef unsigned long UL;

using namespace std;

int getGCM(int a, int b)
{
    int temp, r;

    if (a < b)
    {
        temp = a;
        a = b;
        b = temp;
    }

    r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

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

    int n, s;
    cin >> n >> s;

    vector<int> x(n);
    REP(i, n)
    {
        cin >> x[i];
        x[i] = abs(x[i] - s);
    }

    if (n == 1)
    {
        cout << x[0] << endl;
        return 0;
    }


    int ans = x.front();

    for (const auto& item : x)
    {
        ans = getGCM(item, ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(void){
	int a,b;
	char op;
	int i = 1;
	while(i){
		scanf("%d %c %d",&a,&op,&b);
		switch((int)op){
			case (int)'+':
				printf("%d\n",a+b);
				break;
			case (int)'-':
				printf("%d\n",a-b);
				break;
			case (int)'*':
				printf("%d\n",a*b);
				break;
			case (int)'/':
				printf("%d\n",a/b);
				break;
			case (int)'?':
				i = 0;
				break;
		}
	}
	
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>

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

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

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

  int res = 0;
  for (int i = 0; i < n; ++i){
    if (i+2 >= n) continue;
    if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') res += 1;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include <string.h>
#include<limits.h>
int main(void){
	int x, y, z, i;
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	scanf("%d%d", &x, &y);
	while (x != 0 && y != 0) {
		for (i = 0; i < x; i++) {
			for (z = 0; z < y; z++) {
				if ((z  + i )% 2 == 0 ) {
					printf("#");
				}
				else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
		scanf("%d%d", &x, &y);
	}
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 2032
N = int(input())
if N < 5002:
    if N % 2  == 0:
        sans = [6 * i  + 3 for i in range(N-2)]
        ans = sans + [2,4]
    if N % 2 == 1:
        sans = [6 * i  + 3 for i in range(N-3)]
        ans = sans + [2,4,6]
    if N == 3:
        ans = [2,3,25]
else:
    sans = [6 * i  + 3 for i in range(5000)]
    nis = [2 * i + 2 for i in range(N - 5000 )]
    if (len(nis) * (nis[0] + nis[-1]) //2) % 3 == 1:
        nis[-1] += 2
    elif    (len(nis) * (nis[0] + nis[-1]) //2) % 3 == 2:
        nis[-1] += 2
        nis[-2] += 2
    ans = sans + nis
ans = map(str,ans)
print(" ".join(ans)) 

Measured memory_bytes: 5236
#include <bits/stdc++.h>
#define ad(x) ((x - 1 ^ 1) + 1)

typedef long long ll;
const int N = 100054, M = N * 2;

int n, m, E = 0, L;
int to[M], first[N], next[M];
int p[N], dep[N], ssize[N]; // signed size
int cnt = 0, buf[N];

inline void addedge(int u, int v) {
	to[++E] = v, next[E] = first[u], first[u] = E;
	to[++E] = u, next[E] = first[v], first[v] = E;
}

void dfs(int x) {
	int i, y; ssize[x] = -(dep[x] & 1) | 1;
	for (i = first[x]; i; i = next[i])
		if (!~p[y = to[i]])
			p[y] = x, dep[y] = dep[x] + 1, dfs(y), ssize[x] += ssize[y];
		else if (dep[x] < dep[y])
			L = i;
//	fprintf(stderr, "ssize[%d] = %d\n", x, ssize[x]);
}

int main() {
	int i, u, v, incr; ll ans = 0;
	scanf("%d%d", &n, &m);
	for (i = 0; i < m; ++i) scanf("%d%d", &u, &v), addedge(u, v);
	memset(p, -1, sizeof p), p[1] = 0, dfs(1);
	if (m == n - 1) {
		if (ssize[1]) return puts("-1"), 0;
		for (i = 1; i <= n; ++i) ans += abs(ssize[i]);
		return printf("%lld\n", ans), 0;
	}
	u = to[ad(L)], v = to[L];
	assert(m == n && dep[u] < dep[v]);
	fprintf(stderr, "u = %d, v = %d\n", u, v);
	if ((dep[u] ^ dep[v]) & 1) {
		if (ssize[1]) return puts("-1"), 0;
		for (i = v; i != u; i = p[i]) buf[cnt++] = ssize[i];
		++cnt, std::nth_element(buf, buf + cnt / 2, buf + cnt);
		for (i=0;i<cnt;++i)
			fprintf(stderr, "buf[%d] = %d\n", i, buf[i]);
		for (i = 0; i < cnt; ++i) ans += abs(buf[i] - buf[cnt / 2]) - abs(buf[i]);
	} else {
		if (ssize[1] & 1) return puts("-1"), 0;
		incr = -ssize[1] / 2, ans = abs(incr);
		for (i = v; i != u; i = p[i]) ssize[i] += incr;
		for (; i; i = p[i]) ssize[i] += 2 * incr;
	}
	for (i = 1; i <= n; ++i) ans += abs(ssize[i]);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 8448
#include<cstdio>
using namespace std;

int main() {
  int r0, w0, c, r;
  while (1) {
    scanf("%d%d%d%d", &r0, &w0, &c, &r);
    if (r0 == 0) break;
    if (r0 >= w0 * c) printf("0\n");
    else printf("%d\n", (w0 * c - r0 + r - 1) / r);
  }
}



Measured memory_bytes: 2728
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,d,e=0,f=0,i,j,k,l;
    cin>>a>>b>>c>>d;
    for(i=0 ; ; i++)
    {
        c=c-b;
        a=a-d;
        if(c<=0 || a<=0) break;
    }
    if(c<=0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int n,m;
char a[30][30];
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
int bfs(int s){
	queue<int> q;
	q.push(s);
	vector<int> visited(n*m,-1);
	visited[s]=0;
	int ret=0;
	while(!q.empty()){
		int u=q.front();
		q.pop();
		ret=max(ret,visited[u]);
		int x=u/m,y=u%m;
		for(int i=0;i<4;i++){
			int nx=x+dx[i];
			int ny=y+dy[i];
			if(nx<0 || nx>=n || ny<0 || ny>=m) continue;
			if(visited[nx*m+ny]>=0 || a[nx][ny]=='#') continue;
			visited[nx*m+ny]=visited[u]+1;
			q.push(nx*m+ny);
		}
	}
	return ret;
}
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			cin>>a[i][j];
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++)
			if(a[i][j]!='#')
				ans=max(ans,bfs(i * m + j));
	}	
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main(){
    int N;
    int M;
    int result;

    cin >> N >> M;

    result = ((N + M) * (N + M - 1) / 2 ) - (N * M);

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))

counter = 0

import itertools
for v in itertools.combinations(l, 3):
  t = sorted(v, reverse=False)
  if (t[0]!=t[1])&(t[0]!=t[2])&(t[1]!=t[2])&((t[0]+t[1]) > t[2]):
    counter+=1

print(counter)

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

int main(){
  int n,m,x,y;
  cin>>n >>m >>x >>y;
  string ans = "War";
  
  for(int i=0,Xn;i<n;i++,x=max(x,Xn)){
    cin >> Xn;
  }
  for(int i=0,Ym;i<m;i++,y=min(y,Ym)){
    cin >> Ym;
  }
  
  if(x < y){
    ans = "No War";
  }
  cout<<ans<<endl;
}
    

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int i = 1;

    while (1)
    {
        int a;
        std::cin >> a;


        if (std::cin.eof()) {
            break;
        }

        if (a != 0) {
            std::cout << "Case " << i << ": " << a << std::endl;

            i += 1;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
 
bool study[10001];
 
signed main() {
  ios::sync_with_stdio(false);
  int N, M, T; cin >> N >> M >> T;
  memset(study, -1, sizeof(study));
  while(N--) {
    int t; cin >> t;
    for(int i = t - M; i <= t + M; ++i) {
      // assert(i >= 0);
      // assert(i <= T);
      if(i >= 0 && i <= T) {
        study[i] = false;
      }
    }
  }
  int ans = 0;
  REP(i, T) {
    if(study[i] || study[i + 1]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3216
import java.util.Scanner;

public class Main {
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int ans=0;
			int N = sc.nextInt();
			int A = sc.nextInt();
			int B = sc.nextInt();
			sc.close();

			for (int i = 1; i <= N; i++) {
				int sum = sum(i);
				if (A <= sum && sum <= B) {
					ans+=i;
				}
			}

			System.out.println(ans);
		}

		private static int sum(int i) {
			int sumDigits = 0;
			while( i != 0) {
				sumDigits += i % 10;
				i /= 10;
			}
			return sumDigits;
		}
}

Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>
#include <stack>

using namespace std;

int gcd(int a, int b, int c) {
	int v[3] = { a,b,c }, mini = 200;
	while (1) {
		v[1] %= v[0];
		v[2] %= v[0];
		mini = min(mini, min(v[1], v[2]));
		sort(v, v + 3);
		if (v[0] == 0 && v[1] == 0)break;
		if (v[0] == 0) {
			swap(v[0], v[1]);
			swap(v[1], v[2]);
		}
	}
	return v[2];
}

int main() {
	int k;
	cin >> k;
	int sum = 0;
	for (int i = 1; i <= k; i++) {
		for (int j = i; j <= k; j++) {
			for (int l = j; l <= k; l++) {
				if (i == j && j == l)sum += gcd(i, j, l);
				else if (i != j && j != l && l != i)sum += (gcd(i, j, l) * 6);
				else sum += (gcd(i, j, l) * 3);
			}
		}
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
#define INF 1e+18
using namespace std;

int n,m,s[100010];

int calc(int x){
	int ans = 0,L = 1;
	while(1){
		ans++;
		if(L + x > s[n - 1]) break;
		int ind = lower_bound(s,s + n,L) - s;
		if(L + x <= s[ind]){
			if(!ind) return INF;
			else L += max(1ll,x - abs(L - s[ind - 1]));
		}else{
			if(!ind || abs(L - s[ind - 1]) > abs(L - s[ind])) L += max(1ll,x - abs(L - s[ind]));
			else L += max(1ll,x - abs(L - s[ind - 1]));
		}
	}
	return ans;
}

signed main(){
	while(cin >> n >> m,n){
		for(int i = 0;i < n;i++) cin >> s[i];
		int low = 0,up = 1000010;
		while(up - low > 1){
			int mid = (up + low) / 2;
			if(calc(mid) >= m) low = mid;
			else up = mid;
		}
		if(!low || calc(low) == INF) cout << -1 << endl;
		else cout << low << endl;
	}
}


Measured memory_bytes: 3856
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	fsc := NewFastScanner()
	N, X := fsc.NextInt(), fsc.NextInt()
	M := []int{}
	res := 0
	for i := 0; i < N; i++ {
		M = append(M, fsc.NextInt())
		X -= M[i]
		res++
	}
	sort.Ints(M)
	res += X / M[0]
	fmt.Println(res)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}

func (s *FastScanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
#include<stdio.h>

int main()
{
	int a, b, c, i=3;

	scanf("%d %d %d", &a, &b, &c);

	if (a == b) {
		i--;
	}
	if (b == c) {
		i--;
	}
	if(c==a){
		i--;
	}

	if (a == b && a == c && b == c) {
		i++;
	}

	printf("%d\n", i);

	return 0;

}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll a,b,c,d;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	puts(llabs(a-c)<=d||(llabs(a-b)<=d&&llabs(b-c)<=d)?"Yes":"No");
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>

using namespace std;

int main()
{
  double a, b, x; cin >> a >> b >> x;
  double S = x / a;

  double rad;
  if(S > a * b / 2)
  {
    rad = atan(a * a / (2 * (a * b - S)));
  }
  else
  {
    rad = atan(2 * S / (b * b));
  }

  cout << fixed << std::setprecision(7) << 90.0 - rad * 180.0 / M_PI << endl;
}


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

int main(int, char**) {
        std::string s;
        std::cin >> s;
        while (true) {
                //std::cout << s << std::endl;
                int l = s.size();
                if (l==0) {
                        std::cout << "YES" << std::endl;
                        return 0;
                } else if (l >= 5 && (s.substr(l - 5) == "dream" || s.substr(l - 5) == "erase")) {
                        s.erase(l - 5);
                } else if (l >= 7 && s.substr(l - 7) == "dreamer") {
                        s.erase(l - 7);
                } else if (l >= 6 && s.substr(l - 6) == "eraser") {
                        s.erase(l - 6);
                } else {
                        std::cout << "NO" << std::endl;
                        return 0;
                }
        }
        return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
	char a[10];
	int lose=0;
	scanf("%s",a);
	for(int i=0;a[i]!='\0';i++)
	{
		if(a[i]=='A'&&a[i+1]=='C')
		{
			lose=1;
			break;
		}
	}
	if(lose)
		printf("Yes\n");
	else
		printf("No\n"); 
	
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>

using namespace std;

#define ll long long
#define rep(i, n) for (i = 0; i < n; i++)

int main()
{
  int M, N;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  int sum_of_elems = accumulate(A.begin(), A.end(), 0);
  if (A[M - 1] >= double(sum_of_elems) / double(4 * M))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fo(i,x,y) for(int i=x;i<=y;i++)
#define fd(i,x,y) for(int i=x;i>=y;i--)
using namespace std;

const int maxn=500007;

int n,L;
int SumV=0;

int hd,tl;
struct Water{
	int V;
	double T;
	Water(){}
	Water(int _V,double _T):V(_V),T(_T){}
	void operator +=(const Water &b){
		T=(T*V+b.T*b.V)/(V+b.V);
		V+=b.V;
	}
	void operator -=(const Water &b){
		if (V-b.V==0){
			T=0;
			V=0;
		}else{
			T=(T*V-b.T*b.V)/(V-b.V);
			V-=b.V;
		}
	}
	void operator -=(const int &b){
		SumV-=b;
	}
	double operator()(){
		return T/V;
	}
}b[maxn],SumT;

void Init(){
	scanf("%d%d",&n,&L);
}

void Solve(){
	hd=1,tl=0;
	fo(i,1,n){
		int T,V;
		scanf("%d%d",&T,&V);
		b[++tl]=Water(V,T);
		SumV+=V;
		SumT+=b[tl];
		while (SumV>L){
			int Temp=min(SumV-L,b[hd].V);
			SumT-=b[hd];
			b[hd].V-=Temp;
			SumV-=Temp;
			if (b[hd].V==0) hd++;
			else SumT+=b[hd];
		}
		while (hd<tl && b[tl].T<=b[tl-1].T){
			SumT-=b[tl];
			SumT-=b[tl-1];
			b[tl-1]+=b[tl];
			SumT+=b[tl-1];
			tl--;
		}
		printf("%.7lf\n",SumT.T);
	}
}

int main(){
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 16896
from sys import exit

S = input()
T = input()


def match(s, t):
    for i in range(len(t)):
        if s[i] != '?' and s[i] != t[i]:
            return False
    return True


for i in range(len(S) - len(T), -1, -1):
    if match(S[i: i + len(T)], T):
        print((S[:i] + T + S[i + len(T):]).replace('?', 'a'))
        exit()
print('UNRESTORABLE')


Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(1000000000)

N, M, K = map(int, input().split())

class Account:
    def __init__(self, val):
        self.val = val
        self.friends = []
        self.valid_blocks = 0
        self.graph = 0


def rec(index, past, graph):
    past.add(index)
    graph.add(index)
    account = accounts[index]
    account.graph = count
    for friend in account.friends:
        if friend in past:
            continue
        past, graph = rec(friend, past, graph)
    return past, graph


accounts = [Account(i - 1) for i in range(N)]

for _ in range(M):
    a, b = map(int, input().split())
    accounts[a-1].friends.append(b - 1)
    accounts[b-1].friends.append(a - 1)

past = set()
graphs = []
count = 0
for i in range(N):
    if i in past:
        continue
    past, graph = rec(i, past, set())
    graphs.append(graph)
    count += 1

for _ in range(K):
    c, d = map(int, input().split())
    C = accounts[c-1]
    D = accounts[d-1]
    if C.graph == D.graph:
        C.valid_blocks += 1
        D.valid_blocks += 1

answers = [0]*N
for i, account in enumerate(accounts):
    answers[i] = len(graphs[account.graph]) - len(account.friends) - 1 - account.valid_blocks

print(*answers)

Measured memory_bytes: 372816
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;



int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if (b-a==c-b){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256