akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <cmath>

#define BP 1000000007

using namespace std;

typedef unsigned long long ull;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned int ui;

typedef vector<ull> vull;
typedef vector<ll> vll;
typedef vector<ui> vui;
typedef vector<long> vl;
typedef vector<int> vi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;

typedef pair<ull, ull> pull;
typedef pair<ll, ll> pll;
typedef pair<ui, ui> pui;
typedef pair<long, long> pl;
typedef pair<int, int> pi;

typedef vector<pair<long, long> > vpl;
typedef vector<pair<int, int> > vpi;

typedef queue<long> ql;
typedef queue<int> qi;

template <class T>
void printv(vector<T> vc) {
    for (auto e: vc) cout << e << " ";
    cout << endl;
}

template <class T>
void printvv(vector<T> vvc) { 
    for (auto vc: vvc) {
        for (auto e: vc) cout << e << " ";
        cout << endl;
    }
}

template <class T>
void printvp(vector<pair<T, T> > vp) {
    for (auto pT: vp) cout << pT.first << " " << pT.second << endl;
}

int main() {
    ll n, k;
    cin >> n >> k;

    if (k == 0) {
        cout << n * n << endl;
        return 0;
    }

    ll ans = 0;
    for (ll b = k; b <= n; ++b) {
        /// 商を対象に計算する
        ll c = n / b;
        /// (c - 1) - (k - 1)より、c - k;
        ans += c * (b - k);

        /// 剰余を対象に計算する
        ll m = n % b;
        ans += max(m - k + 1, 0ll);
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (size_t i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static int MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int n, a, b, c;
vector<int> bamboo_length;

int get_sum(int l, int r) {
    int sum = 0;
    for (int i = l; i < r; ++i) {
        sum += bamboo_length[i];
    }

    return sum;
}

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

    cin >> n >> a >> b >> c;
    bamboo_length.resize(n);
    rep(i, n) cin >> bamboo_length[i];

    sort(all(bamboo_length));
    int ans = 1000000000;
    do {
        for (int i = 0; i < n; ++i) {  // used to create Kadomatsu A
            for (int j = i + 1; j < n; ++j) { // used to create Kadomatsu B
                for (int k = j + 1; k < n; ++k) {  // used to create Kadomatsu C
                    for (int l = k + 1; l <= n; ++l) {  // not be used
                        int len_a_created = 0, len_b_created = 0, len_c_created = 0, tmp_ans_created = 0, needed_point = 0;
                        len_a_created = get_sum(0, i + 1);
                        len_b_created = get_sum(i + 1, j + 1);
                        len_c_created = get_sum(j + 1, k + 1);
                        needed_point = abs(a - len_a_created) + abs(b - len_b_created) + abs(c - len_c_created) + 10 * (i + j - (i + 1) + k - (j + 1));
                        ans = min(ans, needed_point);
                    }
                }
            }
        }
    } while (next_permutation(all(bamboo_length)));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
#define dbg(x...) do { cout << "\033[32;1m" << #x <<" -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<class T, class... Ts> void err(const T& arg,const Ts&... args) { cout << arg << " "; err(args...); }
const int N = 100 + 5;
typedef double db;
const db eps = 1e-8;
int sgn(db x){
    if(fabs(x) < eps) return 0;
    if(x < 0) return -1;
    return 1;
}
struct Point{
    db x, y;
    Point(){}
    Point(db x, db y):x(x), y(y){}
    void input(){
        //如果为longdouble则需要改为Lf
        scanf("%lf%lf",&x, &y);
    }
    Point operator - (const Point &b)const{
        return Point(x - b.x, y - b.y);
    }
    db operator * (const Point &b)const{
        return x * b.x + y * b.y;
    }
    Point operator + (const Point &b)const{
        return Point(x + b.x, y + b.y);
    }
    bool operator < (Point b)const{
        return sgn(x-b.x) == 0 ? sgn(y - b.y) < 0 : x < b.x;
    }
    //叉积
    db operator ^ (const Point &b)const{
        return x * b.y - y * b.x;
    }
    db len(){
        return hypot(x, y);
    }
    Point trunc(db r){
        db l = len();
        if(!sgn(l)) return *this;
        r /= l;
        return Point(x*r, y*r);
    }
    //返回两点距离 
    db distance(Point p){
        return hypot(x - p.x, y - p.y);
    }
    Point operator * (const db &k) const {
        return Point(x * k,  y * k);
    }
    Point operator /(const db &k)const {
        return Point(x / k, y / k);
    }
    db len2(){
        return x * x + y * y;
    }
};
struct Line{
    Point s, e;
    Line(){}
    Line(Point s, Point e):s(s),e(e){}
    void input(){
        s.input();
        e.input();
    }
    Point lineprog(Point p){
        return s + ( ((e-s)*((e-s)*(p-s)))/((e-s).len2()) );
    }
    db length(){
        return s.distance(e);
    }
    db dispointtoline(Point p){
        return fabs((p-s) ^ (e-s)) / length();
    }
};
struct circle{
    Point p;
    db r;
    circle(){}
    circle(Point p, db r):p(p), r(r){}
    void input(){
        p.input();
        // 注意类型
        scanf("%lf", &r);
    }
    int relationline(Line v){
        db dst = v.dispointtoline(p);
        if(sgn(dst - r) < 0) return 2;
        else if(sgn(dst - r) == 0) return 1;
        return 0;
    }
    int pointcrossline(Line v, Point &p1, Point &p2){
        if(!(*this).relationline(v)) return 0;
        Point a = v.lineprog(p);
        db d = v.dispointtoline(p);
        d = sqrt(r * r - d * d);
        if(sgn(d) == 0){
            p1 = a;
            p2 = a;
            return 1;
        }
        p1 = a + (v.e - v.s).trunc(d);
        p2 = a - (v.e - v.s).trunc(d);
        return 2;
    }
};

int main(){
    circle c;
    c.input();
    int n;scanf("%d", &n);
    while(n--){
        Line l;
        l.input();
        Point p1, p2;
        c.pointcrossline(l, p1, p2);
        if(p2 < p1) swap(p1, p2);
        printf("%.8f %.8f %.8f %.8f\n", p1.x, p1.y, p2.x, p2.y);
    }

    return 0;
}


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

struct UnionFind
{
    std::vector<int> data;
    std::vector<ll> sum;
    std::vector<int> cnt;
    UnionFind(int size) : data(size, 0), sum(size, 0), cnt(size, 0){}
    void initialize(void){
        for(int i=0; i<(int)data.size(); i++){
            data[i] = i;
            sum[i] = 0;
            cnt[i] = 0;
        }
    }
    bool merge(int x, int y){
        x = find(x); y = find(y);
        if(x == y) return false;
        else{ data[x] = y; sum[y] += sum[x]; cnt[y] += cnt[x]; return true;}
    }
    ll get(int x){
        x = find(x);
        return sum[x];
    }
    void add(int x){
        cnt[find(x)]++;
    }
    int find(int x){ //根っこを見つける関数
        if(data[x] == x) return x;
        else return data[x] = find(data[x]); //経路圧縮
    }
    bool isSame(int x, int y){
        return find(x) == find(y);
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false); int N, M;
    cin >> N >> M;
    int X[N];
    for(int i=0; i<N; i++) cin >> X[i];
    int A[M], B[M], Y[M];
    for(int i=0; i<M; i++) cin >> A[i] >> B[i] >> Y[i];
    vector<pair<int, pair<int, int>>> edge;
    for(int i=0; i<M; i++){
        edge.push_back(make_pair(Y[i], make_pair(A[i]-1, B[i]-1)));
    }
    sort(edge.begin(), edge.end());
    UnionFind uf(N);
    uf.initialize();
    ll ret = 0;

    for(int i=0; i<N; i++){
        uf.sum[i] = X[i];
    }
    for(int i=0; i<M; i++){
        ll w = edge[i].first;
        int u = edge[i].second.first;
        int v = edge[i].second.second;
        uf.merge(u, v);
        uf.add(u);
        if(w <= uf.get(u)){
            int r = uf.find(u);
            ret += uf.cnt[r];
            uf.cnt[r] = 0;
        }
    }
    cout << M-ret << endl;
}


Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'A' && i < n - 2) {
            if (s[i + 1] == 'B' && s[i + 2] == 'C') {
                cnt++;
                i += 2;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

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

int main()
{
    int K, S;
    cin >> K >> S;

    int count = 0;
    for(int x = 0; x < K+1; x++)
    {
        for(int y = 0; y < K+1; y++)
        {
            int z = S - x - y;
            if (z >= 0 and z <= K)
            {
                count++;
            }
        }
        
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main(void){
  int p;
  int i;
  int pmin=2001,jmin=2001;
  for(i=0;i<3;i++){
    scanf("%d",&p);
    if(p<pmin){
      pmin=p;
    }
  }
  for(i=0;i<2;i++){
    scanf("%d",&p);
    if(p<jmin){
      jmin=p;
    }
  }
  printf("%d\n",pmin+jmin-50);
  return(0);
}

Measured memory_bytes: 1020
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
    var args = chunk.split(' ').map(Number);
    var a = args[0];
    var b = args[1];
    var operator;
    switch (true) {
        case a < b:
            operator = '<';
            break;
        case a > b:
            operator = '>';
            break;
        case a == b:
        default:
            operator = '==';
            break;
    }
    console.log('a %s b', operator);
});

Measured memory_bytes: 7644
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
typedef long long ll;
using namespace std;

int main(void){
  int h,w,k,i,j;
  char s[301][301];

  int ans[301][301];

  cin>>h>>w>>k;

  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      cin>>s[i][j];
    }
  }

  vector<int> t;
  int m,line;
  int I,J;
  t.clear();
  line=0;
  for(i=0;i<h;i++){
    m=0;
    for(j=0;j<w;j++){
      if(s[i][j]=='#'){
        t.push_back(j);
        m++;
      }
    }
    if(m==0){
      continue;
    }
    else if(m==k){
      int left=0;
      for(;k>1;k--){
        int c=t[m-k];
        for(I=line;I<h;I++){
          for(J=left;J<=c;J++){
            ans[I][J]=k;
          }
        }
        left=c+1;
      }
      for(I=line;I<h;I++){
        for(J=left;J<w;J++){
          ans[I][J]=1;
        }
      }
      break;
    }
    else{
      int left=0;
      for(int x=0;x<m-1;x++){
        int c=t[x];
        for(I=line;I<=i;I++){
          for(J=left;J<=c;J++){
            ans[I][J]=k;
          }
        }
        k--;
        left=c+1;
      }
      for(I=line;I<=i;I++){
        for(J=left;J<w;J++){
          ans[I][J]=k;
        }
      }
      k--;

      line=i+1;
      t.clear();
    }
  }

  for(i=0;i<h;i++){
    for(j=0;j<w-1;j++){
      cout<<ans[i][j]<<" ";
    }
    cout<<ans[i][w-1]<<endl;
  }

  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<ll, ll> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}



int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	// freopen("settling.in", "r", stdin);
	// freopen("settling.out", "w", stdout);

	ll d, t, s;
	cin >> d >> t >> s;

	if(d <= s * t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;


	return 0;
}


Measured memory_bytes: 3648
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m;
	cin>>n>>m;
	vvi in(n,vi(3));
	rep(i,n)rep(j,3)cin>>in[i][j];
	ll out=0;
	rep(i,8){
		vi t(n);
		rep(j,n)rep(k,3){
			if(i&1<<k)t[j]+=in[j][k];
			else t[j]-=in[j][k];
		}
		sort(all(t));
		ll sum=0;
		rep(j,m)sum+=t[n-j-1];
		out=max(out,sum);
	}
	cout<<out<<endl;
}










Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner scan=new Scanner(System.in);
		String s=scan.next(),p=scan.next();
		for(int i=0;i<s.length();i++) {
			if(s.indexOf(p)!=-1) {
				System.out.println("Yes");
				return;
			}
			char ch=s.charAt(s.length()-1);
			s=s.substring(0,s.length()-1);
			s=ch+s;
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 26140
#include <stdio.h>
int main(void){
    int n,i;
    float x1,y1,x2,y2,x3,y3,x4,y4;
    scanf("%d",&n);
    for(i=0;i<n;i++) {
        scanf("%f %f %f %f %f %f %f %f",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        if ((y2-y1)*(x4-x3)-(x2-x1)*(y4-y3)==0) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
bool che(ll t)
{
  for(ll i = 1;i*i<=t;i++)
  {
  	if(t%i==0 && t/i==i)
  	 return true;
  }
  return false;
}
int main()
{
  string a,b;
  cin>>a>>b;
  a+=b;
  cout<<(che(stoll(a))?"Yes":"No")<<"\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m;cin >> n>>m;
  vector<P> v(n);
  rep(i,n){
      ll a,b;cin >> a >> b;
      a--;
      v[i] = mp(a,b);
  }
  sort(all(v));
  priority_queue<ll> q;
  auto it = v.begin();
  ll ans = 0;
  rep(i,m){
      while((it->first)<=i && it!=v.end()){
          q.push(it->second);
          it++;
      }
      if(q.size()){
          ans += q.top();
          q.pop();
      }
  }
  cout << ans << endl;
}

Measured memory_bytes: 2936
#include <iostream>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;
 
int N, M, S1[100], S2[100];
 
int main(void) {
  while(cin >> N >> M, N && M) {
    int sum1 = 0, sum2 = 0;
    REP(i, 0, N) cin >> S1[i], sum1 += S1[i];
    REP(i, 0, M) cin >> S2[i], sum2 += S2[i];
 
    int p1 = 100000000, p2 = 100000000;
    REP(i, 0, N) REP(j, 0, M) {
      if(sum1 - S1[i] + S2[j] == sum2 + S1[i] - S2[j]) {
        if(p1 + p2 > S1[i] + S2[j]) {
          p1 = S1[i];
          p2 = S2[j];
        }
      }
    }
 
    if(p1 + p2 >= 100000000) {
      cout << -1 << endl;
    } else {
      cout << p1 << " " << p2 << endl;
    }
  }
 
  return 0;
}

Measured memory_bytes: 3040
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
long long N,K,tmp,ans;
cin>>N>>K;
tmp=(N+K)%K;
ans=min(tmp,K-tmp);
cout<<ans<<"\n";
return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
string S;

int dp[303][303][303];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S>>K;
	N=S.size();
	
	FOR(i,N) {
		dp[i][i][K]=1;
		if(i<N-1) {
			dp[i][i+1][K]=1+(S[i]==S[i+1]);
			if(K) dp[i][i+1][K-1]=2;
		}
	}
	
	
	
	for(i=1;i<=N;i++) {
		for(int L=0;L+i<=N;L++) {
			int R=L+i-1;
			for(k=0;k<=K;k++) {
				if(L) dp[L-1][R][k]=max(dp[L-1][R][k],dp[L][R][k]);
				if(R<N-1) dp[L][R+1][k]=max(dp[L][R+1][k],dp[L][R][k]);
				if(L&&R<N-1) {
					if(dp[L][R][k]==0) {
						dp[L-1][R+1][k]=max(dp[L-1][R+1][k],1+(S[L-1]==S[R+1]));
					}
					else {
						dp[L-1][R+1][k]=max(dp[L-1][R+1][k],dp[L][R][k]+2*(S[L-1]==S[R+1]));
					}
					if(k) dp[L-1][R+1][k-1]=max(dp[L-1][R+1][k-1],dp[L][R][k]+2);
				}
			}
		}
	}
	
	int ma=0;
	FOR(i,K+1) ma=max(ma,dp[0][N-1][i]);
	cout<<ma<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 108800
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<math.h>
using namespace std;

int main()
{
	
   int x,y;
   cin>>x>>y;
   
   if(y>=x*2&&y<=x*4&&y%2==0)
   {
   	
   	cout<<"Yes"<<endl;
   	
   }
   
   
   else 
   {
   	
   	cout<<"No"<<endl;
   	
   }
   	

	return 0;
	
	
}

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

typedef long long LL;

int n;

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

void work(){
}

void outo(){
  for (int i=1;i<=n;++i) printf("ACL");
  puts("");
}

int main(){
  into();
  work();
  outo();
  return 0;
}

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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

const int M = 1000000007;
map <pair <pair <ll, ll>, int>, int> mp;

ll power(int x, int y) {
	if (y == 0) return 1;
	ll temp = power(x, y >> 1);
	temp = (temp * temp) % M;
	if (y & 1) temp = (temp * x) % M;
	return temp;
}

pair <pair <ll, ll>, int> mak_pair(ll a, ll b, int sg) {
	if (a == 0 && b == 0) return {{0, 0}, 0};
	if (a < 0) sg = -sg, a = -a;
	if (b < 0) sg = -sg, b = -b;
	ll g = __gcd(a, b);
	a /= g; b /= g;
    if (a == 0) sg = 1;
    if (b == 0) sg = -1;
	return {{a, b}, sg};
}

pair <pair <ll, ll>, int> prep(pair <pair <ll, ll>, int> p) {
	return {{p.fi.se, p.fi.fi}, -p.se};
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	int cnt0 = 0;
	for (int i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		pair <pair <ll, ll>, int> p = mak_pair(b, a, 1);
		if (p.se == 0) cnt0++;
		else mp[p]++;
	}
	ll res = 1;
	while (mp.size()) {
		auto it = *mp.begin();
		int cnt1 = it.se;
		auto it2 = mp.find(prep(it.fi));
		int cnt2 = 0;
		if (it2 != mp.end()) {
			cnt2 = it2->se;
			mp.erase(it2);
		}
		mp.erase(it.fi);
		res *= (((power(2, cnt1) + power(2, cnt2)) % M) - 1 + M) % M;
		res %= M;
	}
	cout << (res + cnt0 - 1 + M) % M;
	return 0;
}
/*
10
3 2
3 2
-1 1
2 -1
-3 -9
-8 12
7 7
8 1
8 2
8 4
*/

//967
//479


Measured memory_bytes: 19128
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
#define inf 1000000000
#define pr1(a) cout << a << endl
#define pr2(a,b)cout << a <<  " " <<b<< endl
#define pr3(a,b,c) cout << a <<" " << b << " " << c << endl
 
const long double PI = acos(-1);

struct BIT{
  int N;
  vector<int> dat;
  void init(int n){
    N=n;
    dat.assign(N+1,0);
  }
  void add(int k,int x){
    for(k++;k<=N;k+=k&-k)dat[k]+=x;
  }
  int sum(int k){
    int ret=0;
    for(k++;k;k-=k&-k)ret+=dat[k];
    return ret;
  }
};

void solve(){
    int n,d,a;
    cin >> n >> d >> a;
    vector<pair<int,int>> v(n);
    vector<int> b(n);
    for(int i=0;i<n;i++){
      cin >> v[i].ff >> v[i].ss;
      b[i]=v[i].ff;
    }
    sort(all(v));
    sort(all(b));
    int ans = 0;
    BIT bit;
    bit.init(n+10);
    for(int i=0;i<n;i++){
      int val = bit.sum(i);
      // cout << val << endl;
      int cur = (v[i].ss+a-1)/a;
      if(val>=cur)continue;
      else {
        int req = cur-val;
        int nxt = upper_bound(all(b),v[i].ff+2*d) - b.begin();
        nxt--;
        // cout << nxt << endl;
        bit.add(i,req);
        bit.add(nxt+1,-req);
        ans+=req;
      }
    }
    cout << ans << endl;
}
 
signed main()
{  
    IOS;
    int t = 1;
    //cin >> t;
 
    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fastio() ios::sync_with_stdio(0);cin.tie(0);
#define nl "\n"
#define wi(x) cerr << #x << " is " << x << nl
const double eps = 1e-6;

void solve(){
	int n; cin >> n;
	vi v(n);
	rep(i,0,n-1) cin >> v[i];
	ll cur = 1000;
	rep(day,1,n-1){
		if(v[day] > v[day-1]){
			ll no = cur/v[day-1];
			cur += (no * (v[day] - v[day - 1]));
		}
	}
	cout << cur;
} 

int main(){
	fastio()
	
	int T=1;
	//int T; cin>>T;
	while(T--) solve();

	return 0;
}



Measured memory_bytes: 3652
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    b, c = [i for i in input().strip().split()]
    b = int(b)
    c = int(c.replace(".", ""))

    ans = (b * c) // 100

    return ans


if __name__ == "__main__":
    print(main())


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

int main(){
	int x,y;
	cin>>x>>y;
	while(x!=0&&y!=0){
		if(x>y) x=x%y;
		else y=y%x;
	}
	cout<<max(x,y)<<endl;
	return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

    string s;

    cin >> s;

    if(s[2] == s[3] && s[4] == s[5])
    {
        cout << "Yes";
    }

    else
    {
        cout << "No";
    }



}


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

typedef long long ll;
const int maxn = 4e5 + 3;
const ll ninf = std::numeric_limits<ll>::min();
int n, a[maxn];
std::map<int, ll> s[maxn];

void filter(int i) {
    static std::map<int, ll> t;
    t.clear();
    int r = (i + 1) / 2 + 5, l = r - 20;
    for(auto &&[u, v] : s[i]) {
        if(u < l || u > r)
            continue;
        t.emplace(u, v);
    }
    t.swap(s[i]);
}

int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; ++i) {
        scanf("%d", a + i);
    }
    s[0][0] = 0;
    s[1][0] = 0;
    s[1][1] = a[0];
    s[2][0] = 0;
    s[2][1] = a[1];
    for(int i = 3; i <= n; ++i) {
        auto &cs = s[i];
        for(int j = std::max(i - 4, 0); j <= i - 2; ++j) {
            for(auto &&[x, y] : s[j]) {
                if(cs.find(x + 1) == cs.end())
                    cs[x + 1] = y + a[i - 1];
                else
                    cs[x + 1] = std::max(cs[x + 1], y + a[i - 1]);
            }
        }
        filter(i);
    }
    ll ans = ninf;
    for(int i = 0; i <= n; ++i) {
        if(s[i].find(n / 2) != s[i].end()) {
            ans = std::max(ans, s[i][n / 2]);
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 223264
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
#define ar array
const int mxN=2e5;
const int MOD=1e9+7;
const int num=1e7+3;
ll a[num]={0};
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
int main()
{
    fastio;
    ll n;
    cin>>n;
    ll i,j;
    for(i=1;i<=n;i++)
    {
        for(j=i;j<=n;j+=i)
        {
            a[j]++;
        }

    }
    ll ans=0;
    for(i=1;i<=n;i++)
    {
        ans+=i*a[i];
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 81704
n = gets.to_i

class Array
  def sum
    inject :+
  end
end
arr = gets.split.map(&:to_i)
num = arr.count{|a| a < 0}

if num % 2 == 0
  puts arr.map(&:abs).sum
else
  abs = arr.map(&:abs)
  puts(abs.sum-abs.min*2)
end


Measured memory_bytes: 11396
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

int main() {
	int n, m;
	std::cin >> n >> m;


	std::vector<long long> imos0(m * 3 + 1);
	std::vector<long long> imos1(m * 3 + 1);

	// [l, r)
	auto add = [&](int l, int r, long long a, long long b) {
		imos0[l] += a;
		imos0[r] -= a;

		imos0[l] -= b * l;
		imos0[r] += b * l;

		imos1[l] += b;
		imos1[r] -= b;
	};

	auto f = [&](int k) {
		return imos0[k] + imos1[k] * k;
	};

	std::vector<int> a(n);
	for (int i = 0; i < n; i++) {
		std::cin >> a[i];
	}

	for (int i = 0; i + 1 < n; i++) {
		int d = a[i + 1] > a[i] ? a[i + 1] - a[i] : a[i + 1] + m - a[i];

		// x=a[i+1] -> 1
		// x=a[i+1]-1 -> 2
		// x=a[i+1]-2 -> 3
		// ... 
		// x=a[i+1]-(d-1) -> d
		// x=a[i+1]-d -> d

		add(a[i + 1] + m - (d - 1), a[i + 1] + m + 1, d, -1);
		add(a[i + 1] + 1, a[i + 1] + m - (d - 1), d, 0);
	}

	for (int i = 0; i < m * 3; i++) {
		imos0[i + 1] += imos0[i];
		imos1[i + 1] += imos1[i];
	}

	long long ans = 1e18;

	for (int i = 0; i < m; i++) {
		ans = std::min(ans, f(i) + f(i + m) + f(i + m * 2));
	}
	std::cout << ans << std::endl;
}


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

int main(){
  int A,B,count=0;
  cin >> A >> B;
  for(int i=A;i<B+1;i++){
    int C=i,C1,C2,C3,C4,C5;
    C1=C%10,C/=10;
    C2=C%10,C/=10;
    C3=C%10,C/=10;
    C4=C%10,C/=10;
    C5=C%10;
    if(C1==C5 && C2==C4){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 998244353
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
int modpow(int X,int Y){
  int sum=X,cnt=1;
  vi A;
  while(Y>=cnt){
    cnt*=2;
    A.pb(sum);
    sum*=sum;
    sum%=MOD;
  }
  int ret=1;
  int M=A.size();
  REP(i,1,M){
    if(Y>=(1ll<<M-i)){
      Y-=(1ll<<M-i);
      ret*=A[M-i];
      ret%=MOD;
    }
  }
  return ret;
}
int finv[500000],fac[500000];
void COMinit(){
  finv[0]=fac[0]=finv[1]=fac[1]=1;
  rep(i,2,500000){
    fac[i]=fac[i-1]*i%MOD;
    finv[i]=finv[i-1]*modpow(i,MOD-2)%MOD;
  }
}
int COM(int X,int Y){
  if(X<Y) return 0;
  if(X<0||Y<0) return 0;
  return fac[X]*finv[Y]%MOD*finv[X-Y]%MOD;
}
signed main(){
  COMinit();
  int N,A,B,K; cin>>N>>A>>B>>K;
  int ans=0;
  REP(i,0,N){
    int X=K-i*A;
    if(X%B==0){
      ans+=COM(N,i)*COM(N,X/B)%MOD;
      ans%=MOD;
    }
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 8064
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        int x,y,z,k,s,count=0;
        Scanner scan = new Scanner(System.in);
        k = scan.nextInt();
        s = scan.nextInt();
        if(s / k == 3){
            count++;
        }else{
            for(x = 0; x <= k; x++){
                for(y = 0;y<=k;y++){
                    if(s - x-y >=0 && s -x-y <=k) count++;
                }
             }
        }
        
        System.out.println(count);
    }
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

lint vc[MAX], dp[MAX];

int main(){
    int n; cin >> n;
    vector<P> vp, vq;
    rep(i, MAX) vc[i] = -1;
    rep(i, n){
        lint c; cin >> c; c--;
        if(vc[c] != -1 && vc[c] != i - 1){
            vp.push_back(P(vc[c], vp.size()));
            vq.push_back(P(i, vq.size()));
            vc[c] = i;
        }
        else vc[c] = i;
    }
    sort(all(vp));

    int m = vp.size(); int now = m - 1; lint tmp = 1, ans = 1;
    repr(i, m){
        int t = vq[i].fi;
        while(1){
            if(now < 0 || vp[now].fi < t) break;
            tmp += dp[vp[now].se]; tmp %= MOD;
            now--;
        }
        dp[vq[i].se] = tmp;
        ans += tmp; ans %= MOD;
    }
    out(ans);
}

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

int main() {
    int N;
    cin >> N;
    vector<int> num(N+1, 0);
    int count = 0;
    for(int i = 1; 6*i*i <= N; i++){
        for(int j = i; i*i + 2*j*j + i*j + 2*j <= N; j++){
            for(int k = j; i*i + j*j + k*k + i*j + j*k + k*i <= N; k++){
                int a = i*i + j*j + k*k + i*j + j*k + k*i;
                if(i == j && j == k) num.at(a)++;
                else if(i != j && j != k && k != i) num.at(a) += 6;
                else num.at(a) += 3;
            }
        }
    }
    for(int i = 1; i <= N; i++){
        cout << num.at(i) << endl;
    }
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)

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

    int k = 0;

    REP(i,n) {
        if((i+1) % 2 != 0) {
            k += 1;
        } 
    }

    cout << k*(n-k) << endl;
    return 0;
}



Measured memory_bytes: 256
n = int(input())

S = [input() for _ in range(n)]

buf = set()

target = S[0][0]
for s in S:
    if s in buf:
        print("No")
        exit()
    else:
        if s[0] != target:
            print("No")
            exit()

        buf.add(s)
        target = s[-1]

print("Yes")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin >> n >> k;
    vector<pair<ll,ll>> p;
    rep(i,n){
        int a,b;cin >> a >> b;
        p.push_back({a,b});
    }
    sort(p.begin(),p.end());
    rep(i,p.size()){
        if(p[i].second>=k){
            cout << p[i].first << endl;
            return 0;
        }
        k-=p[i].second;
    }
}

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

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> A(M);
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> A[i];
	}
	sort(A.begin(), A.end());
	int res = 0;
	for (int i = 0; i < M - 1; i++) {
		res += max(0, A[i] - N);
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)

int main() {
	int n, m, num[51] = {};
	long long a[51], b[51], c[51], d[51],minl,l;
	cin >> n >> m;
	rep(i, 0, n) {
		cin >> a[i] >> b[i];
		//cout << a[i]<<b[i] << endl;
	}
	rep(i, 0, m) {
		cin >> c[i] >> d[i];
		//cout << c[i] << d[i] << endl;
	}
	rep(i, 0, n) {
		minl = LONG_MAX;
		rep(j, 0, m) {
			l = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (minl > l) {
				minl = l;
				num[i] = j;
				//cout << minl << endl;
			}
		}
		cout << num[i]+1 << endl;
	}
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        var d = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var a = new int[n];
        int count = 0;
        for (int i = 0; i < n; i++) {
            a[i] = int.Parse(Console.ReadLine());
            for (int j = 1; j <= d[0] ; j += a[i]) {
                count++;
            }
        }
        Console.WriteLine(count + d[1]);
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <math.h>
#include <stdlib.h>
#include <numeric>
#include <functional>
int main(){
	int n, h[100000], ans = 0, now = 0;
	std::cin >> n;
	for(int i = 0; i < n; i++){
		std::cin >> h[i];
	}
	for(int i = n - 1; i > 0; i--){
		if(h[i] <= h[i - 1]){
			now++;
		}else{
			ans = std::max(ans, now);
			now = 0;
		}
	}
	ans = std::max(ans, now);
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 640
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}

	void run() throws FileNotFoundException {
		solver();
	}

	@SuppressWarnings("unchecked")
	void solver() throws FileNotFoundException {
		Scanner sc = new Scanner(System.in);
		int na = sc.nextInt();
		int nb = sc.nextInt();
		int w = sc.nextInt();
		int[][] p = new int[na + nb][3];
		for (int i = 0; i < na; ++i) {
			p[i][0] = 0;
			p[i][1] = sc.nextInt();// m
			p[i][2] = sc.nextInt();// c
		}
		for (int i = na; i < na + nb; ++i) {
			p[i][0] = 1;
			p[i][1] = sc.nextInt();// m
			p[i][2] = sc.nextInt();// c
		}

		Arrays.sort(p, new Comparator<int[]>() {
			@Override
			public int compare(int[] o1, int[] o2) {
				if (o1[2] != o2[2])
					return Integer.compare(o1[2], o2[2]);
				else
					return Integer.compare(o1[1], o2[1]);
			}
		});

		long[][] f = new long[2][w + 1];
		for (int i = 0; i < f.length; ++i) {
			for (int j = 0; j < f[i].length; ++j) {
				f[i][j] = -1;
			}
		}
		long ans = Long.MAX_VALUE / 16;
		int t = 0;
		for (int i = 0; i < na + nb; ++i) {
			t = Math.max(0, t - 2);
			if (p[i][1] > w)
				continue;
			for (int j = w - p[i][1]; j >= 1; --j) {
				f[p[i][0]][j + p[i][1]] = Math.max(f[p[i][0]][j + p[i][1]], f[p[i][0]][j]);
			}
			f[p[i][0]][p[i][1]] = p[i][2];
			while (t + 1 <= i && Math.max(g(f, p[t][2]), p[i][2] - p[t][2]) >= Math.max(g(f, p[t + 1][2]),
					p[i][2] - p[t + 1][2])) {
				++t;
			}
			ans = Math.min(ans, Math.max(g(f, p[t][2]), p[i][2] - p[t][2]));
		}
		System.out.println(ans);
	}

	long g(long[][] f, long lower) {
		long ret = Long.MAX_VALUE / 16;
		long las = Long.MAX_VALUE / 16;
		for (int i = 1; i < f[0].length; ++i) {
			if (f[1][i] >= lower)
				las = i;
			if (f[0][i] < lower)
				continue;
			ret = Math.min(ret, Math.abs(i - las));
		}
		las = -Long.MAX_VALUE / 16;
		for (int i = 1; i < f[1].length; ++i) {
			if (f[0][i] >= lower)
				las = i;
			if (f[1][i] < lower)
				continue;
			ret = Math.min(ret, Math.abs(i - las));
		}
		return ret;
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

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

class Solve {
private:
	using vd = std::vector<double>;
	using v2d = std::vector<vd>;
	using v3d = std::vector<v2d>;
	
	struct Edge {
		int to, limit;
		double distance;
	};
	using Edges = std::vector<std::vector<Edge>>;

	using i3 = std::array<int, 3>;
	using pdi3 = std::pair<double, i3>;

	Edges inputEdge(int n, int m)
	{
		Edges edge(n);
		for (int i{}; i < m; i++)
		{
			int x, y, c;
			double d;
			scanf("%d%d%lf%d", &x, &y, &d, &c);
			x--; y--;
			edge[x].push_back({y, c, d});
			edge[y].push_back({x, c, d});
		}
		return std::move(edge);
	}

	double& getReference(v3d& distance, const i3& index)
	{
		return distance[index[0]][index[1]][index[2]];
	}

public:
	bool is_last_query{};
	Solve()
	{
		int n, m;
		scanf("%d%d", &n, &m);
		if (n == 0 && m == 0)
		{
			is_last_query = true;
			return;
		}
		int s, g;
		scanf("%d%d", &s, &g);
		s--; g--;
		// edge[from][i] = {to, distance, limit}
		const Edges edge(inputEdge(n, m));

		// distance[頂点][来た速度][来た頂点] = 最短距離
		v3d distance(n, v2d(31, vd(n, 1e9)));
		std::fill(distance[s][0].begin(), distance[s][0].end(), 0);
		// {距離、{頂点、来た速度、来た頂点}
		std::priority_queue<pdi3, std::vector<pdi3>, std::greater<pdi3>> dij;
		dij.push({0, {s, 0, s}});
		while (!dij.empty())
		{
			const double now_dist{dij.top().first};
			const i3 now_vertex{dij.top().second};
			dij.pop();
			if (now_dist > getReference(distance, now_vertex))
				continue;

			for (const auto& road: edge[now_vertex[0]])
			{
				if (road.to == now_vertex[2]) continue;
				for (int add{-1}; add <= 1; add++)
				{
					// {to, velocity, from}
					const i3 next_vertex{road.to, now_vertex[1] + add, now_vertex[0]};
					if (next_vertex[1] <= 0 || road.limit < next_vertex[1]) continue;
		
					const double next_dist{now_dist + road.distance / next_vertex[1]};
					auto& table_dist{getReference(distance, next_vertex)};
					if (next_dist >= table_dist) continue;

					table_dist = next_dist;
					dij.push({next_dist, next_vertex});
				}
			}
		}
		const double min{*std::min_element(distance[g][1].begin(), distance[g][1].end())};
		if (min == 1e9) puts("unreachable");
		else printf("%.4lf\n", min);
	}

};

int main()
{
	while (!Solve().is_last_query);

	return 0;
}


Measured memory_bytes: 3884
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
ll N;
/*int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >>n;
    if(n==0){
        cout<<n<<"\n";
        return 0;
    }
    vector<char> v;
    int order;
   while(true){
       if(n==-1){
           while(order>2){
               order--;
               v.push_back('0');
           }
           v.push_back('1');
           v.push_back('1');
           break;
       }
       if(n<0){
            int i=2;
            int j=1;
           while(i<-n){
               i=i*4;
               j=j+2;
           }
           n=n+i;
           if(v.size()==0)
           v.push_back('1');
           else{
               for(int k=0;k<order-j-1;k++){
                   v.push_back('0');
               }
               if(n==0)break;
               v.push_back('1');
           }
           order=j;
       }
       else{
           int i=1;
            int j=0;
           while(i<n){
               i=i*4;
               j=j+2;
           }
           n=n-i;
           if(v.size()==0)
           v.push_back('1');
           else{
               for(int k=0;k<order-j-1;k++){
                   v.push_back('0');
               }
               if(n==0)break;
               v.push_back('1');
           }
           order=j;
       }
   }
    for(int i=0;i<v.size();i++){
        cout<<v[i];
    }
    cout<<"\n";
}*/
int main() {
    cin >> N;
  string str = "";
  while (N != 0) {
    int r = N % 2;
    if (r < 0) r += 2;
    N = (N - r) / (-2);
    str += (char)('0' + r);
  }
  reverse(str.begin(), str.end());
  if (str == "") str = "0";
  cout << str << endl;
}

Measured memory_bytes: 256
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use proconio::fastout;
use proconio::input;
//use proconio::marker::*;
//use std::collections::HashSet;
// use std::cmp::*;
//use std::collections::VecDeque;

fn main() {
    input! {
       X:i32
    }
    if X >= 30{println!("Yes");}else{
    println!("No");}
}


Measured memory_bytes: 2136
#include <stdio.h>
#include <stdlib.h>

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

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

	int a_dist, b_dist;

	a_dist = abs(x - a);
	b_dist = abs(x - b);

	if (a_dist < b_dist)
		printf("A\n");
	else
		printf("B\n");
}


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

int main(){
    int N; cin >> N;
    vector<int> b;
    while(N--){
        int type;
        cin >> type;
        switch(type){
            case 0:
                int tmp1;
                cin >> tmp1;
                b.push_back(tmp1);
                break;
            case 1:
                int tmp2; 
                cin >> tmp2;
                cout << b.at(tmp2) << endl; 
                break;
            case 2:
                b.pop_back();
                break;
            default:
                cout << "Error" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3920
(let* ((n (read-line))
       (a nil)
       (b nil))
  (if (oddp (length n))
      (progn (setf a (subseq n 0 (floor (/ (length n) 2)))) (setf b (subseq n (ceiling (/ (length n) 2)))))
      (progn (setf a (subseq n 0 (floor (/ (length n) 2)))) (setf b (subseq n (floor (/ (length n) 2))))))
  (setf b (reverse b))
  (princ (count nil (map 'list #'char= a b))))

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


int main() {
	int a, b, c;
  cin >> a >> b >> c;
  int sum = a * 100 + b * 10 + c;
  if (sum % 4) cout << "NO" << endl;
  else cout << "YES" << endl;
	return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    vector<bool> S(N), B(N);
    S[0] = false;
    B[0] = A[0] < A[1];
    S[N - 1] = true;
    B[N - 1] = false;
    for (int i = 1; i < N - 1; i++) {
        if (A[i - 1] <= A[i] && A[i] >= A[i + 1])
            S[i] = true;
        else if (A[i - 1] >= A[i] && A[i] <= A[i + 1])
            B[i] = true;
    }
    long long m = 1000, k = 0;
    for (int i = 0; i < N; i++) {
        if (S[i]) {
            m += A[i] * k;
            k = 0;
        } else if (B[i]) {
            k += m / A[i];
            m %= A[i];
        }
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 3576
import math
n, k = map(int, input().split())
A = list(map(int, input().split()))

max_len = max(A)
def f(x):
    ans = 0
    for a in A:
        cut_num = math.ceil(a / x) - 1
        #print(a, cut_num, a / x)
        ans += cut_num
    if ans <= k:
        return True
    else:
        return False

left = 0.001
right = max_len
while right - left > 1:
    mid = (right + left) // 2
    if f(mid):
        right = mid
    else:
        left = mid
else:
    print(int(right))

Measured memory_bytes: 104240