akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int a, b, c, k;
    cin >> a >> b >> c >> k;
    for(int i = 0; i <= k; ++i){
        int B = b;
        for(int j = 0; j < i; ++j){
            B *= 2;
        }
        for(int j = 0; i + j <= k; ++j){
            int C = c;
            for(int x = 0; x < j; ++x){
                C *= 2;
            }
            if(a < B && B < C){
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
}

Measured memory_bytes: 3648
#include <cstdio>

using namespace std;
typedef long long llong;

#define MAX 81
const llong mod = 1000000000 + 7;

int main()
{
  int N, A[MAX];
  llong money = 1000, kabu = 0;
  scanf("%d", &N);
  for (int i = 0; i < N; i++)
  {
    scanf("%d", &A[i]);
  }

  for (int i = 0; i < N; i++)
  {
    if (i == N - 1)
    {
      money += kabu * A[i];
      kabu = 0;
      break;
    }
    if (A[i] < A[i + 1])
    {
      llong div = money / A[i];
      kabu += div;
      money -= div * A[i];
    }
    else
    {
      money += kabu * A[i];
      kabu = 0;
    }
  }

  printf("%lld", money);

  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl;
#define pno cout << "no" << endl;
#define pYe cout << "Yes" << endl;
#define pNo cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;
#define end return 0;
#define prin(num) cout << num << endl;
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 100000000000
#define MOD 1000000007LL
#define MAX 200005
#define NIL -1
#define WHITE 0
#define BLACK 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

int main(void) {
    ll x, y;
    cin >> x >> y;
    ll ans=INF;
    if(x<=y)
        ans=min(ans, y-x);
    if(-x<=y)
        ans=min(ans, y+x+1);
    if(x<=-y)
        ans=min(ans, -y-x+1);
    if(-x<=-y)
        ans=min(ans, -y+x+2);
    cout << ans << endl;
}


Measured memory_bytes: 256
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g PROGRAM -o OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
    if (!y)
        return x;
    return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;


inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

vector<string> split(char d,string s)
{
    stringstream ss(s);
    string t;
    vector<string> words;
    while(getline(ss,t,d))
    {
        words.pb(t);
    }

    return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
    auto start = chrono::high_resolution_clock::now();
#endif
    
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int x;
    cin >> x;
    cout << ((x >= 30) ? "Yes" : "No");

#ifdef LOCAL
    auto end = chrono::high_resolution_clock::now();
    double time_taken =
        chrono::duration_cast<chrono::nanoseconds>(end - start).count();

    time_taken *= 1e-9;

    cerr << "\nTime taken by program is : " << fixed
         << time_taken << setprecision(9);
    cerr << " sec" << endl;
#endif
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int k, a, b;
    cin >> k;
    cin >> a >> b;

    int num = a / k;
    int c = (num + 1) * k;
    if (c <= b || a % k == 0)
        cout << "OK" << endl;
    else
    {
        cout << "NG" << endl;
    }
}

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

//template
#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 ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end



int main(){
    int n; scanf("%d",&n);
    vector<int> x(n),y(n);
    rep(i,0,n)scanf("%d%d",&x[i],&y[i]);
    vector<int> ord(n); iota(ALL(ord),0);
    double ans=0;
    do
    {
        double sub=0;
        rep(i,0,n-1){
            int pre=ord[i],to=ord[i+1];
            sub+=sqrt((x[pre]-x[to])*(x[pre]-x[to])+(y[pre]-y[to])*(y[pre]-y[to]));
        }
        ans+=sub;
    } while (next_permutation(ALL(ord)));
    rep(i,1,n+1)ans*=1.0/i;
    printf("%.12f\n",ans);
    return 0;
}

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

int main(){
    ll a, b;
    cin >> a >> b;
    ll s = (a*b+1)/2;
    if(a == 1 || b == 1){
        cout << 1 << endl;
        return 0;
    }
    cout << s << endl;
}


Measured memory_bytes: 256
n = (int)(input())  # num of station
cost = []  # list of costed timeto next
s = []  # list of init train time
freq = []  # list of freq of train departure
for i in range(n-1):
  a, b, c = (list)(map(int, input().split()))
  cost.append(a)
  s.append(b)
  freq.append(c)


def t(num):  # return time will cost to go from (num)station to end
  time = 0
  for j in range(num, n-1):
    if time < s[j]:  # if init train has not departed
      time = s[j]
    elif time % freq[j]:  # if next train has not arrived
      time = wait_next(time, freq[j])
    time += cost[j]  # add time to next station
  return time


def wait_next(now, freq):  # calc time we will wait to get next train
  while(1 and False):
    if not now % freq:
      break
    now += 1
#  return now
  return (now//freq+1)*freq


for i in range(n):
  print(t(i))


Measured memory_bytes: 3188
#include <cstdio>
#include <queue>
#include <algorithm>

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

using namespace std;

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

const ll inf = 2e10;
const int nb = 400;

struct E{
	int t, c;
};

int n, m, q;
vector<E> g[(int)1e5];
ll sd[(int)1e5];
ll gd[(int)1e5];
vector<pair<ll, ll>> sv;
vector<vector<ll>> gv;

void dijkstra(int i, ll* d){
	fill(d, d + n, inf);
	priority_queue<P, vector<P>, greater<P>> q;
	d[i] = 0;
	q.push({0, i});
	while(!q.empty()){
		P v = q.top();
		q.pop();
		if(v.first > d[v.second]){
			continue;
		}
		for(auto& x: g[v.second]){
			if(d[x.t] > d[v.second] + x.c){
				d[x.t] = d[v.second] + x.c;
				q.push({d[x.t], x.t});
			}
		}
	}
}

int query(ll fs, ll fg){
	int a = upper_bound(sv.begin(), sv.end(), make_pair(fs, inf)) - sv.begin();
	int r = 0;
	rep(i, a / nb){
		r += (gv[i].end() - lower_bound(gv[i].begin(), gv[i].end(), fg));
	}
	for(int i = a / nb * nb; i < a; ++i){
		if(sv[i].second >= fg){
			++r;
		}
	}
	return r;
}

int main(){
	scanf("%d%d", &n, &m);
	rep(i, m){
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		g[a].push_back({b, c});
		g[b].push_back({a, c});
	}

	dijkstra(0, sd);
	dijkstra(n - 1, gd);

	rep(i, n){
		sv.push_back({sd[i], gd[i]});
	}
	sort(sv.begin(), sv.end());

	for(int i = 0; i < n; i += nb){
		vector<ll> v;
		for(int j = i; j < min(i + nb, n); ++j){
			v.push_back(sv[j].second);
		}
		sort(v.begin(), v.end());
		gv.push_back(v);
	}

	scanf("%d", &q);
	rep(i, q){
		ll fs, fg;
		scanf("%lld%lld", &fs, &fg);
		printf("%d\n", query(fs, fg));
	}
	return 0;
}

Measured memory_bytes: 12296
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};


ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}
 ll modd = 1e9+ 7;
ll wa (ll n,ll mi, ll ma){
    ll ans  = n * (mi+ma) /2;
    return ans;
}
ll kw(ll k,ll n){
    
    ll ans  =0;
    ll mi,ma;
    mi= wa(k,0,k-1);
    
    ma = wa(k,n-k+1,n);
    
    return (ma-mi +1)%modd;
}

int main(){
    string s,t;
    cin >> s >> t;
    int si = s.size(),ti = t.size();
    int ans = ti;
    int cnt = 0;
    REP(i,si-ti+1){
        
             cnt = 0;
            REP(k,ti){
                if(s[i+k] == t[k]){
                    cnt ++;
                }
            }
            ans = min(ans, ti-cnt);
        
    }
    cout << ans <<endl;
}





Measured memory_bytes: 3584
#include <stdio.h>

int main(void){
  char s[35];
  char x, y, z, w;
  fgets(s, 35, stdin);
  int c = 0;
  int f = 0;
  while(f != 2){
    if(s[c] == ' ' && f == 1) {
      z = s[c - 1];
      w = s[c + 1];
      f++;
    }
    if(s[c] == ' ' && f == 0) {
      x = s[c - 1];
      y = s[c + 1];
      f++;
    }
    c++;
  }
  if(x == y && z == w) printf("YES\n");
  else printf("NO\n");
  return 0;
}

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

int main()
{
    int n; cin>>n;
    vector<int> a(n);
    int i=0;
    for(auto& e: a) { cin>>e; e-=++i; }
    sort(begin(a), end(a));

    long res=0;
    for(auto& e: a) res+=abs(e-a[n/2]);
    cout<<res<<endl;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication23
{
    //ITP1_10-D
 
    class Distance
    {
        int v;
        int[] x, y;
 
        public Distance(int[] i,int[] j,int k)
        {
            x = i;
            y = j;
            v = k;
        }
 
        public double Dis(int a)
        {
            double sum = 0;
            for (int i = 0; i < v; ++i)
            {
                sum += Math.Pow(Math.Abs(x[i] - y[i]),a);
            }
            return sum;
        }
    }
 
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
 
            string[] x = Console.ReadLine().Split(' ');
            int[] xArray = Array.ConvertAll(x, int.Parse);
 
            string[] y = Console.ReadLine().Split(' ');
            int[] yArray = Array.ConvertAll(y, int.Parse);
 
 
            Distance p = new Distance(xArray,yArray,n);         //????????????????????????????????????
 
            double p1, p2, p3;
 
            p1 = p.Dis(1);                      //????????????????????????
            p2 = Math.Pow(p.Dis(2), 1.0 / 2.0);
            p3 = Math.Pow(p.Dis(3), 1.0 / 3.0);
 
 
            double max = Math.Abs(xArray[0] - yArray[0]);       //p = ?????????¨???
            for (int i = 1; i < n; ++i)
            {
                max = Math.Max((Math.Abs(xArray[i] - yArray[i])), max);
            }
 
            Console.WriteLine("{0:f8}", p1);
            Console.WriteLine("{0:f8}", p2);
            Console.WriteLine("{0:f8}", p3);
            Console.WriteLine("{0:f8}", max);
        }
    }
}

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

using ll = long long;

signed main(){
	ll d,n;
	cin >> d >> n;

	vector<ll>v(n+5);

	for(ll i=0;i<n;i++){
		cin >> v[i];
	}
	v[n] = v[0]+d;

	ll ans = (-1);

	for(ll i=1;i<=n;i++){
		ans = max(ans,(v[i]-v[i-1]));
	}

	cout << (d-ans) << "\n";

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#include <utility>
#include <numeric>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	ll sum = 0;
	REP(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	sum /= 2;
	ll sum1 = 0;
	ll m = 100000000000;
	int k = 0;
	REP(i, n) {
		sum1 += a[i];
		if (i == n - 1) {
			break;
		}
		if (abs(sum1 - sum) < m) {
			m = abs(sum1 - sum);
			k = i;
		}
	}
	ll snuke = 0;
	ll arai = 0;
	REP(i, n) {
		if (i <= k) {
			snuke += a[i];
		}
		else {
			arai += a[i];
		}
	}
	cout << abs(snuke - arai) << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int N=2e5+5;
typedef long long LL;
LL a[N];

int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	LL l=2,r=4e18,mmax=-1,mmin=4e18;
	while(l<=r){
		LL mid=(l+r)/2;
		LL num=mid;
		for(int i=1;i<=n;i++){
			num=num/a[i]*a[i];
		}
		if(num>=2){
			mmin=mid;
			r=mid-1;
		}		
		else
			l=mid+1;
	}
	l=2,r=4e18;
	while(l<=r){
		LL mid=(l+r)/2;
		LL num=mid;
		for(int i=1;i<=n;i++){
			num=num/a[i]*a[i];
		}
		if(num<=2){
			mmax=mid;
			l=mid+1;		
		}		
		else
			r=mid-1;
	}
	if(mmin<=mmax)
		printf("%lld %lld\n",mmin,mmax);
	else
		puts("-1");
	return 0;
}



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

using namespace std;

typedef long long ll;

const int N = 1e5 + 5;

int x, y, a, b, c;
ll A[N], B[N], C[N], D[N * 2];

int main() {
	ios::sync_with_stdio(false);
	cin >> x >> y >> a >> b >> c;
	for (int i = 1; i <= a; i++) cin >> A[i];
	for (int i = 1; i <= b; i++) cin >> B[i];
	for (int i = 1; i <= c; i++) cin >> C[i];
	sort(A + 1, A + 1 + a, [](int x, int y) {
		return x > y; 
	});
	sort(B + 1, B + 1 + b, [](int x, int y) {
		return x > y; 
	});
	sort(C + 1, C + 1 + c, [](int x, int y) {
		return x > y; 
	});
	int tot = 0;
	for (int i = 1; i <= x; i++) D[++tot] = A[i];
	for (int i = 1; i <= y; i++) D[++tot] = B[i];
	for (int i = 1; i <= c; i++) D[++tot] = C[i];
	sort(D + 1, D + 1 + tot, [](int x, int y) {
		return x > y; 
	});
	ll ans = 0;
	for (int i = 1; i <= x + y; i++) ans += D[i];
	cout << ans << '\n';
	return 0; 
}

Measured memory_bytes: 4224
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int n, m;
  cin >> n >> m;
  vector<string> a;
  vector<string> b;
  for(int i = 0; i < n; i++){
    string s;
    cin >> s;
    a.pb(s);
  }
  for(int i = 0; i < m; i++){
    string s;
    cin >> s;
    b.pb(s);
  }
  for(int i = 0; i + m <= n; i++){
    for(int j = 0; j + m <= n; j++){
      bool flag = true;
      for(int k = 0; k < m; k++){
        if(b[k] != a[i+k].substr(j, m)){
          flag = false;
          break;
        }
      }
      if(flag){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
ll mypow(ll x, ll n, ll m) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		return mypow(x*x%m, n / 2, m);
	}
	else {
		return x * mypow(x, n - 1, m) % m;
	}
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
///////////////////////////////////////
int a, b;
int main() {
	cin >> a >> b;
	int l = 0;
	int r = INF;
	int ans = INF;
	for (int i = 0; i <= 1100; ++i) {
		if ((i * 8) / 100 == a&&i * 10 / 100==b) {
			ans = min(ans, i);
		}
	}
	if (ans == INF)cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)
A = [0] * N

step_R  = [0] * N
count_R = 1
step_L  = [0] * N
count_L = 1

for i in range(1, N):
    if S[i-1] == 'R':
        if S[i] == 'L':
            for j in range(count_R):
                step_R[i-1-j] = j+1
            count_R  = 1
        else:
            count_R += 1

for i in range(1, N)[::-1]:
    if S[i] == 'L':
        if S[i-1] == 'R':
            for j in range(count_L):
                step_L[i+j] = j+1
            count_L  = 1
        else:
            count_L += 1

steps = [max(step_R[i], step_L[i]) for i in range(N)]

for i in range(N):
    step = steps[i]
    if S[i] == 'R':
        if step % 2 == 0:
            A[i+step]   += 1
        else:
            A[i+step-1] += 1
    else:
        if step % 2 == 0:
            A[i-step]   += 1
        else:
            A[i-step+1] += 1

print(' '.join([str(a) for a in A]))


Measured memory_bytes: 16076
import copy
N,A,B,C,D = map(int,input().split())
S = input()

for i in range(A,max(C,D)-1):
    if S[i:i+2] == "##":
        print("No")
        exit(0)

if C > D:
    flag = False
    for i in range(B-1,D):
        if S[i-1:i + 2] == "...":
            flag = True
            break

    if flag == False:
        print("No")
        exit(0)

print("Yes")

Measured memory_bytes: 4084
#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;

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

	int c = 0;
	int d = 0;

	vector< vector<int> > vv(2);

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'F') {
			c++;
		}
		else {
			vv[d].push_back(c);
			c = 0;
			d++;
			d %= 2;
		}
	}

	vv[d].push_back(c);

	set<long long int> stx;
	set<long long int> sty;

	if (vv[0].size() > 0) {
		stx.insert(vv[0][0]);
	}
	for (int i = 1; i < vv[0].size(); i++) {
		set<long long int> st;
		for (set<long long int>::iterator ite = stx.begin(); ite != stx.end(); ite++) {
			st.insert(*(ite)+vv[0][i]);
			st.insert(*(ite)-vv[0][i]);
		}
		stx = st;
	}

	sty.insert(0);
	for (int i = 0; i < vv[1].size(); i++) {
		set<long long int> st;
		for (set<long long int>::iterator ite = sty.begin(); ite != sty.end(); ite++) {
			st.insert(*(ite)+vv[1][i]);
			st.insert(*(ite)-vv[1][i]);
		}
		sty = st;
	}

	if (stx.find(x) != stx.end() && sty.find(y) != sty.end()) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 768
#include <iostream>

int main()
{
    int a, b, x;
    std::cin >> x >> a >> b;
    if (b <= a) std::cout << "delicious" << std::endl;
    else if (b > (a + x)) std::cout << "dangerous" << std::endl;
    else std::cout << "safe" << std::endl;
    return 0;
}


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

const long long INF = -1 * 1e18;

struct edge{  
  int to;
  int cost;
  edge(int &to, int &cost){  
    this-> to = to;
    this-> cost = cost;
  }
};

int V, E;

//if G has negative cycle d[start] = INF
vector<long long> BellmanFord(int start, vector<vector<edge>> G){  
  vector<long long> d(V, INF);
  long long N = 0;
  d[start] = 0;
  for(int i = 0; i <= 10 * V; i++){  
    if(i == V){  
      N = d[V-1]; 
    }
    if(i == 10 * V){  
      if(N == d[V-1]) cout << d[V-1] <<endl;  
      else cout << "inf" <<endl;
      return d;
    }
    for(int j = 0; j < V; j++){  
      for(auto e: G[j]){  
        if(d[j] == INF) continue;
        else if(d[e.to] < d[j] + e.cost){  
          d[e.to] = d[j] + e.cost; 
        } 
      } 
    }
  }
  return d;
}


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  cin >> V >> E;
  vector<vector<edge>> G(V);
  for(int i = 0; i < E; i++){  
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    G[a].push_back(edge(b, c));
  }
  BellmanFord(0, G);;
}


Measured memory_bytes: 3716
#include <iostream>

using namespace std;

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

    switch( x ){
    case 1: case 3: case 5: case 7: case 8: case 10: case 12: x = 0; break;
    case 2: x = 2; break;
    default: x = 1;
    }

    switch( y ){
    case 1: case 3: case 5: case 7: case 8: case 10: case 12: y = 0; break;
    case 2: y = 2; break;
    default: y = 1;
    }

    if( x == y ) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int m[] = new int[N];
		int min = 1000;
		for (int i = 0; i < N; i++) {
			m[i] = sc.nextInt();
			if (m[i] < min)
				min = m[i];
		}
		int count = 0;
		for (int i = 0; i < N; i++) {
			X -= m[i];
			count++;
		}
		count += X / min;
		System.out.println(count);
	}
}

Measured memory_bytes: 22228
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>
#include <queue>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
//using ull = unsigned long long;
using ull = int;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

ull gcd(ull x, ull y) {
  return y ? gcd(y, x % y) : x;
}

int main() {
  //std::cout << std::fixed << std::setprecision(10);
  int n;
  cin >> n;

  vector<int> a(n);
  each(i, n) {
    cin >> a[i];
  }

  if (n == 2) {
    cout << max_value(a) << endl;
    return 0;
  }

  vector<ull> l = {a[0]};
  for (ull i=0; i < (n-1); i++) {
    auto prev = l[l.size() - 1];
    ull res = gcd(prev, a[i+1]);
    l.push(res);
  }

  vector<ull> r = {a[n-1]};
  for (ull i=(n-2); i >= 0; i--) {
    auto prev = r[r.size() - 1];
    ull res = gcd(prev, a[i]);
    r.push(res);
  }
  reverse(r.begin(), r.end());

  //dump(l);
  //dump(r);

  ull result = 0;
  each(i, n) {
    if (i == 0) {
      //cout << "i:[" << i << "]   " << result << " : " << r[1] << endl;
      result = max({result, r[1]});
    } else if (i == (n-1)) {
      //cout << "i:[" << i << "]   " << result << " : " << l[l.size()-2] << endl;
      result = max({result, l[l.size() - 2]});
    } else {
      //cout << "i:[" << i << "]   " << result << " : " << l[i-1] << " - " << r[i+1] << endl;
      result = max({result, gcd(l[i-1], r[i+1])});
    }
  }

  cout << result << endl;

  return 0;
}


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

int main(){
  int N,K;
  cin >> N >> K;
  
  vector<int> h(N);
  for (int i = 0 ; i < N ; i++){
    cin >> h.at(i);
  }
  sort(h.begin(),h.end(),greater<int>());
  
  int min_h = h.at(0);
  for ( int i = 0 ; i < N-K+1 ; i++ ){
    min_h = min( min_h , h.at(i) - h.at(i+K-1));
  }
  
  cout << min_h << endl;
}

Measured memory_bytes: 640
from itertools import product

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

C = []
A = []
for i in range(N):
    t = list(map(int, input().split()))
    C.append(t[0])
    A.append(t[1:])

result = -1
for p in product([True, False], repeat = N):
    t = [0] * M
    c = 0
    for j in range(N):
        if not p[j]:
            continue
        c += C[j]
        for k in range(M):
            t[k] += A[j][k]
    if all(x >= X for x in t):
        if result == -1:
            result = c
        else:
            result = min(result, c)
print(result)


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

int main() {
  int N;
  cin >> N;
  int sum{0};
  for (int i = N; i > 0; i /= 10) {
    sum += i % 10;
  }
  cout << (N % sum == 0 ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define inline __inline__ __attribute__((always_inline))
const int N = 1e6 + 5, INF = 0x3f3f3f3f, M = N << 1;
const ll LNF = 0x3f3f3f3f3f3f3f3f;

vector<int> p1, p2;
set<ll> s;
map<ll, int> mp;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ll a, b;
  cin >> a >> b;
  for (ll i = 2; i * i <= a; i++) {
    if (a % i == 0) {
      p1.emplace_back(i);
      while (a % i == 0) a /= i;
    }
  }
  if (a > 1) p1.emplace_back(a);
  for (ll i = 2; i * i <= b; i++) {
    if (b % i == 0) {
      p2.emplace_back(i);
      while (b % i == 0) b /= i;
    }
  }
  if (b > 1) p2.emplace_back(b);
  for (ll x : p1) mp[x]++;
  for (ll x : p2) mp[x]++;
  for (pii x : mp) if (x.second >= 2) s.insert(x.first);
  s.insert(1);
  cout << s.size() << '\n';

  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <math.h>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <queue>

#define MAX 21
#define ll long long int
using namespace std;

int main(void)
{
	vector<int> a;

	int n;
	int i;
	int temp;
	deque<int>b;

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> temp;
		a.push_back(temp);
	}

	if (n % 2 == 0) {
		for (i = 0; i < n; i++) {
			if (i % 2 == 0) {
				b.push_back(a[i]);
			}
			else {
				b.push_front(a[i]);
			}
		}
	}
	else {

		for (i = 0; i < n; i++) {
			if (i % 2 == 0) {
				b.push_front(a[i]);
			}
			else {
				b.push_back(a[i]);
			}
		}

	}

	for (i = 0; i < n; i++) {
		cout << b.at(i) << " ";
	
	}

	cout << endl;

	return (0);
}

Measured memory_bytes: 3828
def main():
    from itertools import zip_longest
    N = int(input())
    ans = 1 << 60
    for i in range(1, N//2+1):
        cur = 0
        for c, d in zip_longest(str(i), str(N-i), fillvalue=0):
            cur += int(c) + int(d)
        ans = min(ans, cur)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41196
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		double numerator = 1;
		double denominator = 0;
		double ans;
		for(int i=0;i<N;i++) {
			A[i] = sc.nextInt();
			numerator *=(double) A[i];
		}
		for(int i=0;i<N;i++) {
			denominator += (double) numerator/A[i];
		}
		ans = numerator/denominator;
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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() {
    ll n;
    string s;
    cin >> n >> s;
    vector<ll> west(n+1,0);
    vector<ll> east(n+1,0);
    repp(i,1,n+1){
        west[i] = west[i-1];
        if(s[i-1] == 'W')west[i]++;
    }
    repp(i,1,n+1){
        east[i] = east[i-1];
        if(s[i-1] == 'E')east[i]++;
    }
    ll res = LONG_LONG_MAX;
    rep(i,n){
        res = min(res, west[i] + (east[n] - east[i+1]));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5380
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<int> H(N);
    cin >> H;

    vector<int> dp(N + 1);
    dp[2] = abs(H[1] - H[0]);
    FOR(i, 2, N) {
        dp[i + 1] = min(dp[i] + abs(H[i] - H[i - 1]), dp[i - 1] + abs(H[i] - H[i - 2]));
    }

    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;
  bool judge=true;
  for(long long i=1;i<=t;i*=2){
    if((v-w)*i>=fabs(b-a)){
      judge=false;
      break;
    }
  }
  if(judge){
    if((v-w)*t>=fabs(b-a)){
      judge=false;
    }
  }
  if(judge){
    cout << "NO" << endl;
  }
  else{
    cout << "YES" << endl;
  }
}

Measured memory_bytes: 3636
from sys import stdin
n = int(stdin.readline().rstrip())
A = list(map(int,stdin.readline().rstrip().split()))
B = list(map(int,stdin.readline().rstrip().split()))
point = 0
fa = min(A[0],B[0])
fb = min(A[1],B[0]-fa)
point += fb
point += fa
for i in range(1,n):
    fc = min(A[i]-fb,B[i])
    point += fc
    fb = min(A[i+1],B[i]-fc)
    point += fb
print(point)

Measured memory_bytes: 18476
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include<map>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;

int main() {
	int i, j;
	int H;
	int N;
	int sum = 0;
	int A[200000];
	cin >> H >> N;
	for (i = 0; i < N; ++i) {
		cin >> A[i];
	}
	for (i = 0; i < N; ++i) {
		sum += A[i];
	}
	if (sum >= H) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


}

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

int main(void)
{
    int64_t n, k;
    cin >> n >> k;
    if(abs(n-k) >= n){
        cout << n << endl;
    }
    else if(k == 1){
        cout << 0 << endl;
    }
    else{
        int64_t rem = n % k;
        if(abs(rem - k) < rem)
            cout << abs(rem - k) << endl;
        else
            cout << rem << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int Min(int a,int b){
    if(a<b) return a;
    return b;
}



int main(void){
    int N,zero=0,one=0;
    char s[100000];

    scanf("%s",s);

    for(int i=0;i<100000;i++){
        if(s[i]=='0') zero++;
        else if(s[i]=='1') one++;
        else break;
    }

    printf("%d",Min(zero,one)*2);
    
    
    

    return 0;
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

X = {}
N = int(input())


for i in make_divisors(N-1):
    X[i] = 1

for i in make_divisors(N):
    hoge = N
    if i == 1:
        continue
    while hoge % i == 0:
        hoge //= i
    if hoge % i == 1:
        X[i] = 1
    else:
        X[i] = 0

"""
for k,i in X.items():
    if i >= 1:
        print(k)
"""
print(sum(X.values())-1)

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

long ears(long t, long i){
    if(i==0 || i==4) return t;
    if(i==2){
        if(t%2==1) return 0;
        else return 1;
    }
    if(i==1 || i==3){
        if(t==0) return 2;
        else if(t%2==0) return 0;
        else return 1;
    }
}

int main(){
    long L,t;
    cin >> L;
    long A[L][5];

    cin >> t;

    for(int i=0; i<5; ++i){
        A[0][i]=ears(t,i);
    }

    for(int i=1; i<L; ++i){
        cin >> t;
        A[i][0]=A[i-1][0]+ears(t,0);
        long min1=min(A[i-1][0],A[i-1][1]);

        A[i][1]=min1+ears(t,1);
        long min2=min(min1,A[i-1][2]);

        A[i][2]=min2+ears(t,2);
        long min3=min(min2,A[i-1][3]);

        A[i][3]=min3+ears(t,3);
        long min4=min(min3,A[i-1][4]);

        A[i][4]=min4+ears(t,4);
    }

    long MIN=A[L-1][0];
    for(int i=0; i<4; ++i){
        if(MIN>A[L-1][i+1]) MIN=A[L-1][i+1];
    }

    cout << MIN << endl;
    return 0;
}

Measured memory_bytes: 8064
n=int(input())
T=0;
p=input().rstrip().split(' ')
q=input().rstrip().split(' ')
for i in range(0,len(q)):
    A=int(q[i])
    B=int(p[i])
    C=int(p[i+1])
    if A>=B:
        T+=B;
        A=A-B;
        if(A>=C):
            T+=C;
            p[i+1]=0;
        else:
            p[i+1]=int(p[i+1])-A;
            T+=A;
    else:
        T+=A;
print(T)


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

int main() {
    int ans = 0;
    int N, A, B;
    cin >> N >> A >> B;
    vector<int> X(3, 0);
    rep(i, N) {
        int p;
        cin >> p;
        if(p <= A)
            X[0]++;
        else if(p <= B)
            X[1]++;
        else
            X[2]++;
    }
    ans = *min_element(X.begin(), X.end());
    cout << ans << endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int main(void)
{
    int N, M;
    cin >> N >> M;
    int a[200010] = {0};
    int b[200010] = {0};
    rep(i,M){
        cin >> a[i] >> b[i];
    }
    bool A[200010] = {false};
    bool B[200010] = {false};
    rep(i,200001){
        if(a[i] == 1) A[b[i]] = true;
        if(b[i] == N) B[a[i]] = true;
    }
    rep(i,200001){
        if( A[i] == true && B[i] == true ){
            cout << "POSSIBLE";
            return 0;
        }
    }
    cout << "IMPOSSIBLE";
    return 0;
}

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

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

  if(n>=1 && n<=9){
      cout << n << endl;
      return 0;
  }
  else if(n>=10 && n<=99){
      cout << 9 << endl;
      return 0;

  }
  else if(n>=100 && n<=999){
      cout << 9 + (n-99)  << endl;
      return 0;
  }
  else if(n>=1000 && n<=9999){
      cout << 909 << endl;
      return 0;
  }
  else if(n>=10000 && n<=99999){
      cout << 909 + (n-9999) << endl;
      return 0;
  }
  else {
      cout << 90909 << endl;
  }
}

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

bool judge(int num)
{
	int i;
	int ret = 0;
	for (i = 1; i <= num; i++) {
		if (num % i == 0)
			ret++;
		if (ret > 8)
			break;
	}

	return ret == 8;
}

int main(int argc, char *argv[])
{
	int n, i;
	int result = 0;
	cin >> n;

	for (i = 1; i <= n; i += 2) {
		if (judge(i))
			result++;
	}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
int a[51],b[51],c[51],d[51];
pair<int,int> diff[51];
int main(){ _;
  int n,m;cin>>n>>m;
  REP(i,n) cin>>a[i]>>b[i];
  REP(i,m) cin>>c[i]>>d[i];
  REP(i,n){
    REP(j,m){
      diff[j].first=abs(a[i]-c[j])+abs(b[i]-d[j]);
      diff[j].second=j+1;
    }
    sort(diff,diff+m);
    cout<<diff[0].second<<endl;
  }
}


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

count = {k:0 for k in range(1, n)}
for i in range(1, n+1):
    for j in range(1, i):
        k = min(abs(i-j), abs(x-i) + 1 + abs(j-y),abs(y-i) + 1 + abs(x-j))
        count[k] += 1
for i in count.values():
    print(i)

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <iomanip>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main()
{
	int n;
	while (cin >> n && n ){
		vector<vector<int> > b (n, vector <int> (n, 0 ) );
		int row = n/2+1, col = n/2;
		int cnt = 1;
		b[row][col] = cnt++;
		
		while (cnt <= n*n ){
			row = (row + 1) % n;
			col = (col + 1) % n;
			if (b[row][col] == 0 ){
				b[row][col] = cnt;
			}else{
				int nr = (row+1) % n;
				int nc = (n + col - 1 ) % n;
				while (b[nr][nc] != 0 ){
					nr = (row+1) % n;
					nc = (n + col - 1 ) % n;
				} // end while
				b[nr][nc] = cnt;
				row = nr; col = nc;
			} // end if
			cnt++;
		} // end while
		rep (i, n ){
			rep (j, n ){
				cout << setw(4) << b[i][j];
			} // end rep
			cout << endl;
		} // end rep
	} // end while

	return 0;
}

Measured memory_bytes: 0
import math
N=int(input())
n= int(math.sqrt(N))
ans = [0]*(N+1)

for x in range(1,n):
    for y in range(1,n):
        for z in range(1,n):
            k = x**2+y**2+z**2+x*y+y*z+z*x
            if k<=N:
                ans[k]+=1

for i in range(1,N+1):
    print(ans[i])

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

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

  int ans = 0;
  int pre = 0;
  int uku = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'R')
      uku++;
    else
      uku--;

    if (uku % 4 == 0) {
      if (uku > pre) ans++;
      pre = uku;
    }
  }

  cout << ans << endl;
}



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

using namespace std;
#define int long long

signed main(){
    string S;
    cin >> S;
    
    string s = S.substr(0,4);
    if(s == "YAKI") cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


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

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	ll k, x; cin >> k >> x;
	if(k*500 >= x){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

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

int main()
{
  int n, a, b;
  cin>>n>>a>>b;

  if(n*a > b)
    cout<<b;
  if(n*a < b)
    cout<<n*a;
  if(n*a == b)
    cout<<b;
    return 0;
}


Measured memory_bytes: 256
N, M = [int(a) for a in input().split()]
S = [[int(i) for i in input().split()] for _ in range(M)]
flag = 0
NUM = 0
LIST = [-1 for _ in range(N)]
for s,c in S:
    s -= 1
    if(LIST[s]==-1):
        NUM += c*(10**(N-s-1))
        LIST[s] = c
    else:
        if(LIST[s]!=c):
            flag = 1
            print(-1)
            break
        else:
            continue
if(LIST[0] == -1):
    if(N>1):
        NUM += 10**(N-1)
    else:
        NUM = 0
elif(LIST[0] == 0):
    if(N>1):
        print(-1)
        flag = 1
    else:
        NUM = 0
if(flag==0):
    print(NUM)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>

using namespace std;

typedef pair<int, int> P;

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

int main() {
	while(true) {
	int T, N;
	cin >> T >> N;
	
		if (T == 0 && N == 0) break;
	// x, y
	set<P> obj;
	
	for(int i = 0; i < N; i++) {
		int x, y;
		cin >> x >> y;
		obj.insert(make_pair(x, y));
	}
	
	P start;
	cin >> start.first >> start.second;
	
	queue<P> Q;
	queue<P> Next;
	set<P> vis;
	Q.push(start);
	
		vis.insert(start);
		
	int cnt = 1;
	
	while(T--) {
		while(!Next.empty()) Next.pop();
		
		while(!Q.empty()) {
			P cur = Q.front(); Q.pop();
			for(int i = 0; i < 6; i++) {
				P p;
				p.first = cur.first + dx[i];
				p.second = cur.second + dy[i];
				if(obj.count(p)) continue;
				if(vis.count(p)) continue;
				vis.insert(p);
				Next.push(p);
				
				cnt++;
			}
		}
		
		Q = Next;
	}
	
	cout << cnt << endl;
	}
}

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

long long calc(vector<long long> H, int start, int end){
  long long i;
  long long min=100;
  long long result=0;
  if(start==end) return 0;
  for(i=start;i<end;i++){
    if(H[i]<min) min = H[i];
  }
  result += min;
  long long new_start = start;
  for(i=start;i<end;i++){
    H[i] -= min;
    if(H[i] == 0){
      result += calc(H,new_start,i);
      new_start = i+1;
    }
  }
  result += calc(H,new_start,end);
  return result;
}
  
int main(){
  long long N;
  long long i;
  cin >> N;
  vector<long long> H(N);
  for(i=0;i<N;i++){
    cin >> H[i];
  }
  cout << calc(H,0,N) << "\n";
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

bool ifprime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=2;i*i<=x;i++){if(x%i==0)return false;}
    return true;
}
ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up

//Start from Here
int main(){
    int a;
    cin>>a;
    string s;
    cin>>s;
    if(a>=3200){
        cout<<s<<endl;
    }
    else{
        cout<<"red"<<endl;
    }
}

Measured memory_bytes: 256
n, k = map(int, input().split())
s = input()
l = [0]
for i in range(n - 1):
    if s[i] != s[i + 1]:
        l.append(i + 1)
l += [n]
le = len(l)
ans = 0
for i in range(le - 1):
    if s[l[i]] == "0":
        ans = max(ans, l[min(le - 1, k * 2 + i)] - l[i])
    else:
        ans = max(ans, l[min(le - 1, k * 2 + i + 1)] - l[i])
print(ans)

Measured memory_bytes: 13060