akhauriyash/Code-Regression huggingface dataset:
a, b = map(int, input().split(" "))
positive = 0
 
for i in range(a + 1):
  value = 0
  stock = 0
  stock = a - i
  for j in range(stock + 1):
    value = 10000 * i + 5000 * j + 1000 * (a - i - j)
    if value == b:
      print(i, j, a - i - j)
      positive = 1
      break
  else:
    continue
  break

if positive == 0:
  print(-1, -1, -1)

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
  int paSize = printArray.size();
  for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
  if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

using vi = vector<int>;

map<vi, int> mp;

void bfs(vi origin) {
  queue<vi> que;
  que.push(origin);
  mp[origin] = 0;

  while (que.size()) {
    vi axis = que.front(); que.pop();

    int zeroPos = 0;
    rep (i, axis.size()) {
      if (axis[i] == 0) zeroPos = i;
    }
    int y = zeroPos / 4, x = zeroPos % 4;
    int pos = y * 4 + x;

    rep (i, 4) {
      int ny = y + dy[i], nx = x + dx[i];
      if (ny < 0 || ny >= 2 || nx < 0 || nx >= 4) continue;
      int npos = ny * 4 + nx;
      vi next = axis;
      swap(next[npos], next[pos]);
      if (mp.count(next)) continue;
      mp[next] = mp[axis] + 1;
      que.push(next);
    }
  }
}


signed main() {
  vector<int> origin(8);
  iota(all(origin), 0);
  bfs(origin);

  string s;
  while (getline(cin, s)) {
    vi v;
    for (int i = 0; i < s.size(); i+=2) {
      v.push_back(s[i] - '0');
    }
    cout << mp[v] << endl;
  }

  return 0;
}


Measured memory_bytes: 6164
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;

int main(){
  int N,M;
  cin >>N>>M;
  vector<vector<int>> jobs(M);
  rep(i,N){
    int a,b;
    cin >>a>>b;
    if (a > M) continue;
    jobs[M-a].push_back(b);
  }
  priority_queue<int> q;
  ll ans = 0;
  for(int i=M-1;i>=0;i--){
    for(int b : jobs[i]){
      q.push(b);
    }
    if (!q.empty()){
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
#define mkp make_pair
#define pb push_back
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<int> vi
	;for(int i=0;i<s.size();i++)
	{
		int k;
		k = (int)s[i]+n;
		if(k>90)
		{
			k-=90;
			k+=64;
		}
		cout<<(char)k;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;


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

    long long a[n];

    for(long long i=0;i<n;i++){
        cin >> a[i];
        a[i] = a[i] - (i+1LL);
    }

    long long ans=0;
    long long b;
    
    sort(a, a+n);
    b = a[n/2];

    for(int i=0;i<n;i++){
        ans = ans + abs(a[i] - b);
    }

    cout << ans << endl;
    return 0;
}

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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int main() {

	IOS

	int n;
	cin >> n;

	map<string, int> mp;
	string x;

	for (int i = 0; i < n; i++) {
		cin >> x;
		mp[x]++;
	}

	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;

	return 0;
}

Measured memory_bytes: 3664
n,l=map(int,input().split())
ap=[l+int(i)-1 for i in range(1,n+1)]

s=sum(ap)
ans=100000
idx=0
for i,a in enumerate(ap):
  if abs(a)<=ans:
    ans=abs(a)
    idx=i

print(s-ap[idx])


Measured memory_bytes: 3060
n=int(input())
l=[int(i) for i in input().split()]
chk1=ans1=chk2=ans2=0

for a,i in enumerate(l):
    chk1+=i
    chk2+=i
    if a%2:
        if chk1<=0:
            ans1+=1-chk1
            chk1=1
        if chk2>=0:
            ans2+=chk2+1
            chk2=-1
    else:
        if chk1>=0:
            ans1+=1+chk1
            chk1=-1
        if chk2<=0:
            ans2+=1-chk2
            chk2=1
print(min(ans1,ans2))


Measured memory_bytes: 14332
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define int long long
#define mod 1000000007
using namespace std;
signed main() {
	int n; cin >> n;
	vector<pair<int, int>>v; int p;
	for (int i = 1; i <= n; i++) { cin >> p; v.push_back(make_pair(p, i)); }
	sort(v.begin(), v.end());
	for (int i = 0; i < n; i++) {
		if (i)cout << ' ';
		cout << v[i].second;
	}cout << endl;
}

Measured memory_bytes: 2544
fn solve() {
    let (n, x, m): (usize, usize, usize) = (read::<usize>(), read::<usize>(), read::<usize>());
    let mut v = vec![];
    let mut k = HashSet::new();
    let mut base = x;
    let mut res: usize = 0;
    // 周期後
    let mut cyc = vec![];
    let mut rem: usize = 0;
    for i in 0..n {
        // 周期発見
        // 周期の長さを取る
        if k.contains(&base) {
            // 残り回数は, n-i
            rem = n - i;
            while let Some(u) = v.pop() {
                if u == base {
                    cyc.push(base);
                    cyc.reverse();
                    break;
                }
                cyc.push(u);
            }
            break;
        }
        k.insert(base);
        // println!("{}", base % m);
        v.push(base);
        res += base;
        base *= base;
        base %= m;
    }
    if rem != 0 {
        // 商だけ答えに和を足して,
        let (q, r) = (rem / cyc.len(), rem % cyc.len());
        res += q * cyc.iter().sum::<usize>();
        // あまりは調整
        for i in 0..r {
            res += cyc[i];
        }
    }
    println!("{:?}", res);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 998_244_353;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2588
import itertools
n, k = map(int, input().split())
max_val = (n - 1) * (n - 2) // 2
if max_val < k:
    print(-1)
    quit()
m = max_val - k

print (n - 1 + m)
for i in range(2, n + 1):
    print("{} {}".format(1, i))

for i, j in itertools.combinations(range(2, n + 1), 2):
    if m == 0:
        break
    print("{} {}".format(i, j))
    m -= 1

Measured memory_bytes: 74656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
typedef tuple<ll, ll, ll, ll>T;
#define PI 3.14159265359
#define MOD 1000000007
int main(){
  ll N,M,X;
  cin>>N>>M>>X;
  int C[N];
  int A[N][M];
  rep(i,N){
  	cin>>C[i];
  	rep(j,M){cin>>A[i][j];}
  }
  int flag=0;//可能なら１に
  ll minsum=10000000;
  for(int tmp=0;tmp<(1<<N);tmp++){
  	bitset<12> s(tmp);
     ll rikai[M];
  	rep(i,M){rikai[i]=0;}
     ll sum=0;
  	for(int i=0;i<N;i++){
    	if(s.test(i)){
    		sum+=C[i];
            rep(j,M){
            	rikai[j]+=A[i][j];
            }       
    	}
    }
    int dame=0;
  	for(int j=0;j<M;j++){
    	if(rikai[j]<X){dame=1;}
    }
  	if(dame==0){
    	flag=1;
      	minsum=min(minsum,sum);
    }
  }
  if(flag==0){cout<<-1;}
  else{cout<<minsum;}
  
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(void)
{
	int n, i;
	long long int a[10000];
	long long int min, max, sum=0;
	
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%lld", &a[i]);
	}
	min = a[0];
	max = a[0];
	for(i=0; i<n; i++){
		sum = sum+a[i];
		if(min>=a[i]){
			min = a[i];
		}
		if(max<=a[i]){
			max = a[i];
		}
	}
	
	printf("%lld %lld %lld\n", min, max, sum);
	
	return 0;
}

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

int main(){
    ll K, A, B;  cin >> K >> A >> B;
    ll ans = 1;
    if(A < B){
        if(A - 1 >= K){
            ans += K;
        }else if(B - A <= 2){
            ans += K;
        }else{
            ans += (A - 1);
            K -= (A - 1);
            ans += (B-A)*(K/2);
            ans += (K%2);
        }
    }else if(A >= B){
        ans += K;
    }
    cout << ans << endl;
}


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

int main(){
  string S;
  int Q;
  cin >> S >> Q;
  vector<int> query(Q);
  vector<int> F(Q);
  vector<string> C(Q);
  for(int i=0; i<Q; i++){
    cin >> query.at(i);
    if(query.at(i)==2){
      cin >> F.at(i) >> C.at(i);
    }
  }
  int one_seen=0;
  string T;
  for(int i=0; i<Q; i++){
    if(query.at(i)==1) one_seen++;
    else{
      if(one_seen%2==0 && F.at(i)==2) S+=C.at(i);
      else if(one_seen%2==1 && F.at(i)==1) S+=C.at(i);
      else T+=C.at(i);
    }
  }
  std:: reverse(T.begin(), T.end());
  S=T+S;
  if(one_seen%2==1) std::reverse(S.begin(), S.end());

  cout << S << endl;
}

Measured memory_bytes: 13788
#include<map>
#include<iostream>
#include<algorithm>
using namespace std;
string s;
int T;
long long ans;
map<string,int>f;
int main()
{
	cin>>T;
	while(T--)
	{
		cin>>s;
		sort(s.begin(),s.end());
		ans+=f[s]++;
	}
	printf("%lld",ans);
	return 0;
}


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

using namespace std;

int main () {
  int a,b,c;
  int arri[3];
  
  cin>> arri[0] >> arri[1]>> arri[2];
  
  sort(arri, arri+3);
  
  cout << abs(arri[0] - arri[1]) + abs(arri[1] - arri[2]) << endl;
  
  
  return 0;
}

Measured memory_bytes: 256
N = input()

num = {}
for a in map(int, input().split()):
  if not a in num.keys(): num[a] = 1
  else: num[a] += 1

res = 0
for a, a_num in num.items():
  if a_num < a: res += a_num
  else: res += a_num - a
print(res)

Measured memory_bytes: 27016
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

void dfs(const vector<vector<pair<int64_t, int64_t>>>& links,
         vector<int64_t>& dist, int64_t current, int64_t parent) {
  for (auto p : links[current]) {
    auto v = p.first;
    auto d = p.second;
    if (v == parent) {
      continue;
    }

    dist[v] = dist[current] + d;
    dfs(links, dist, v, current);
  }
}

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

  vector<vector<pair<int64_t, int64_t>>> links(n);
  for (auto _ : irange(0L, n - 1)) {
    int64_t a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    links[a].emplace_back(b, c);
    links[b].emplace_back(a, c);
  }

  int64_t q, k;
  cin >> q >> k;
  --k;

  vector<int64_t> dist(n);
  dfs(links, dist, k, -1);

  for (auto _ : irange(0L, q)) {
    int64_t x, y;
    cin >> x >> y;
    --x;
    --y;

    cout << dist[y] + dist[x] << "\n";
  }
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORS(i, m, n) for (int i = m; i <= n; i++)
#define bit(n) (1LL << (n))
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
const int STRLEN = 4;
const int STRLEN2 = STRLEN * STRLEN;
const int STRLEN3 = STRLEN2 * STRLEN;
map<char, int> mp = {{'_', 0}, {'A', 0}, {'C', 1}, {'G', 2}, {'T', 3}};
int dnaI(string s)
{
    return mp[s[0]] * STRLEN2 + mp[s[1]] * STRLEN + mp[s[2]];
}
int AGCval = dnaI("AGC");
int ACGval = dnaI("ACG");
int GACval = dnaI("GAC");
int A_Gval = dnaI("A_G");
int _GCval = dnaI("_GC");
void removeVal(vector<int> &s)
{
    s[AGCval] = 0;
    s[ACGval] = 0;
    s[GACval] = 0;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> dp0(STRLEN3, 0);
    vector<int> dp1(STRLEN3, 0);

    //基本的に4倍できる。
    //*AG -> Cを追加は不可能.
    //*AC -> Gを追加は不可能.
    //*GA -> Cを追加は不可能.
    //A*G -> Cを追加は不可能.
    if (N <= 2)
    {
        cout << (int)pow(STRLEN, N) << "\n";
    }
    else
    {
        REP(i, STRLEN * STRLEN * STRLEN)
        {
            dp0[i] = 1;
        }
        removeVal(dp0);
        FORS(i, 4, N)
        {
            //*AC => AC*
            int sum[STRLEN2] = {0};
            REP(i, STRLEN3)
            {
                sum[i % STRLEN2] += dp0[i];
                sum[i % STRLEN2] %= MOD;
            }
            REP(j, STRLEN)
            {
                REP(k, STRLEN)
                {
                    REP(l, STRLEN)
                    {
                        dp1[j * STRLEN2 + k * STRLEN + l] = sum[j * STRLEN + k];
                        // cout << "dp1 " << dp1[i * STRLEN + j] << "\n";
                    }
                }
            }
            removeVal(dp1);

            REP(j, STRLEN)
            {
                //  _GC=   A_G.
                dp1[j * STRLEN2 + _GCval] -= dp0[j * STRLEN + A_Gval];
                dp1[j * STRLEN2 + _GCval] %= MOD;
            }
            copy(ALL(dp1), dp0.begin());
        }

        int ans = 0;
        REP(i, STRLEN3)
        {
            ans += dp0[i];
            ans %= MOD;
        }
        cout << (MOD + ans) % MOD << "\n";
    }
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    while (true) {
        int n, r;
        scan(n, r);

        if (n == 0 && r == 0) return;

        auto a = iota(1, n + 1).retro.array;

        foreach (i ; 0 .. r) {
            int p, c;
            scan(p, c);
            p--;

            a = a[p .. p + c] ~ a[0 .. p] ~ a[p+c .. $];
        }

        writeln(a[0]);
    }
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 3116
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

using ll = long long int;
using namespace std;

int main(){

  string S;
  cin >> S;
  ll N = S.length();

  ll flag = 1;
  for(ll i = 0; i < (N-1)/2; i++){
    if(S[i] != S[N-1-i]){
      flag = 0;
      break;
    }
  }
  for(ll i = 0; i < (N-1)/2; i++){
    if(S[i] != S[(N-1)/2 -1 -i]){
      flag = 0;
      break;
    }
  }

  if(flag){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
  
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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; }

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

// ------------------------------------------------------------------------------------------

signed main() {
  int n, h, w;
  cin >> n >> h >> w;

  // cout << max(1LL, (n-h)) * max(1LL, (n-w)) << endl;
  cout << 1 +  (n-w) + (n-h) + (n-w)*(n-h) << endl;

  return 0;
}

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

#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 INF 1e10
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef unsigned long long ll;

ll gcd(ll a, ll b){
    if (a < b) swap(a,b);
    if (a % b == 0) return b;
    return gcd(a % b, b);
}
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

int main(){
    ll n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;

    ll lcm2 = lcm(n, m);
    ll gcd2 = gcd(n, m);

    ll n2 = n/gcd2;
    ll m2 = m/gcd2;

    REP(k, gcd2){
        if (s[k*n2] != t[k*m2]){
            cout << "-1" << endl;
            return 0;
        }
    }

    cout << lcm2 << endl;
    return 0;
    
}
        


Measured memory_bytes: 3688
import java.io.*;
import java.util.*;
import java.lang.Math.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        if (A + B >= 10) {
            System.out.println("error");
        } else {
            System.out.println(A + B);
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() {
            try {
                return Integer.parseInt(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public double nextDouble() {
            try {
                return Double.parseDouble(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public long nextLong()  {
            try {
                return Long.parseLong(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }
    }
}


Measured memory_bytes: 22612
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> A(N);
    REP(i, N)cin >> A[i];
    vector<vector<int> > res(H, vector<int>(W, 0));
    int y = 0;
    int x = 0;
    REP(i, N){
        REP(j, A[i]){
            res[y][x] = i+1;
            x += 1 - 2*(y%2);
            if(x==W){x--;y++;}
            if(x==-1){x++;y++;}
        }
    }
    REP(i, H)REP(j, W)cout << res[i][j] << (j==W-1 ? '\n' : ' ');
    return 0;
}


Measured memory_bytes: 384
if __name__ == '__main__':
    
    ans = []
    ans2 = []
    
    while True:
        n,m = map(int,input().split(","))
        
        if n == 0 and m == 0:
            break
        
        if m not in ans:
            ans.append(m)
        ans2.append((n,m))
        
        ans.sort()
        ans.reverse()
        
    while True:
        try:
            x = int(input())
            y = ans2[x-1][1]
            ind = ans.index(y) + 1

            print(ind)
        except EOFError:
            break



Measured memory_bytes: 5592
#include <stdio.h>

int main(void)
{
	int a, b, c;		//Value a, b, c.

	scanf("%d %d %d", &a, &b, &c);
	if(a < b && b < c)
		printf("Yes\n");
	else
		printf("No\n");

	return (0);
}



Measured memory_bytes: 2076
#include<cstdio>
int n,a,b;
int main(){
	scanf("%d%d%d",&n,&a,&b);
	if(n==1)return puts(a==b?"1":"0"),0;
	if(a>b)return puts("0"),0;
	long long L=1ll*a*(n-1)+b,R=1ll*b*(n-1)+a;
	printf("%lld\n",R-L+1);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>


using lli = long long int;
template <class T> using Vec = std::vector<T>;
template <class T> using Wec = std::vector<Vec<T>>;


int main(void){
    /* 入力 */
    int n, m; scanf("%d%d", &n, &m);
    Wec<int> Edge(n, Vec<int>(0));
    for(int i = 0; i < m; ++i){
        int a, b; scanf("%d%d", &a, &b);
        Edge[--a].push_back(--b);
        Edge[b].push_back(a);
    }

    /* 計算 */
    std::deque<int> Q{0, Edge[0][0]};
    Vec<bool> Visited(n, false); Visited[0] = true; Visited[Edge[0][0]] = true;
    bool flag1 = true, flag2 = true;
    while(true){
        if(flag1){
            int f = Q.front(); flag1 = false;
            for(int v : Edge[f]) if(not Visited[v]){
                Q.push_front(v); flag1 = true; Visited[v] = true;
                break;
            }
        }
        if(flag2){
            int b = Q.back(); flag2 = false;
            for(int v : Edge[b]) if(not Visited[v]){
                Q.push_back(v); flag2 = true;  Visited[v] = true;
                break;
            }
        }
        if(not (flag1 or flag2)) break;
    }

    /* 出力 */
    printf("%lu\n", Q.size());
    printf("%d", Q.front() + 1); Q.pop_front();
    while(not Q.empty()){ printf(" %d", Q.front() + 1); Q.pop_front(); }
    putchar('\n');
    return 0;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

int N, M, K, Q, W, H, R, C;
string S;

int dp[110][33000];

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

    cin >> N >> W;
    vector<int> w(N), v(N);
    REP(i, N) cin >> w.at(i) >> v.at(i);

    int ans = 0;
    if (W <= 30000) {
        memset(dp, 0, sizeof(dp));
        REP(i, N) {
            REP(j, 30000) {
                if (j + w[i] <= 30000) chmax(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
                chmax(dp[i + 1][j], dp[i][j]);
            }
        }

        REP(i, W + 1) { chmax(ans, dp[N][i]); }
        cout << ans << endl;
        return 0;
    }

    vector<int> tmp = v;
    sort(ALL(tmp), greater<int>());
    REP(i, W / (w[0] + 3)) { ans += tmp[i]; }

    if (W / w[0] == W / (w[0] + 3)) {
        cout << ans << endl;
        return 0;
    } else {
        W -= w[0] * (W / w[0]);
        memset(dp, 0, sizeof(dp));
        REP(i, N) {
            REP(j, 300) {
                chmax(dp[i + 1][j + w[i] - w[0]], dp[i][j] + v[i]);
                chmax(dp[i + 1][j], dp[i][j]);
            }
        }

        REP(i, W + 1) { chmax(ans, dp[N][i]); }
        cout << ans << endl;
        return 0;
    }
}


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

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

    vector<ll> a(n*3);
    for(int i=0; i<n*3; i++)  cin >> a.at(i);
    sort(a.begin(), a.end(), greater<ll>());
    ll sum=0;
    for(int i=1; i<2*n; i+=2) sum += a[i];
    
    cout << sum << endl;

}
    

Measured memory_bytes: 2560
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int n;
    cin >> n;
    cout << 800*n-200*(n/15);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<bool> Vb;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;


class UnionFind {
	vector<int> parent;
public:
	UnionFind() {}
	UnionFind(int n) : parent(n + 1, -1) {}
	void init(int n);
	int root(int a);
	bool unite(int a, int b);
	int size(int a);
	bool operator() (int a, int b);
	int operator[] (int i);
};

int n;
Vi vx, vy;
map<int, int> mx, my;
vector<set<int>> vsx, vsy;
UnionFind uf;

void init()
{
	cin >> n;
	vx.resize(n);
	vy.resize(n);
	vsx.resize(n);
	vsy.resize(n);
	uf.init(n);

	REP(i, n)
	{
		int x, y; cin >> x >> y;
		vx[i] = x;
		vy[i] = y;

		if (mx.count(x)) uf.unite(i, mx[x]);
		mx[x] = i;
		if (my.count(y)) uf.unite(i, my[y]);
		my[y] = i;
	}
}

int main()
{
	init();

	REP(i, n)
	{
		vsx[uf.root(i)].insert(vx[i]);
		vsy[uf.root(i)].insert(vy[i]);
	}

	ll ans = 0;
	REP(i, n)
		ans += 1LL * SZ(vsx[i]) * SZ(vsy[i]);

	cout << ans - n << endl;
}


inline void UnionFind::init(int n)
{
	parent.assign(n + 1, -1);
}

inline int UnionFind::size(int a)
{
	return -parent[root(a)];
}

inline bool UnionFind::operator() (int a, int b)
{
	return unite(a, b);
}

inline int UnionFind::operator[](int i)
{
	return root(i);
}

inline int UnionFind::root(int a)
{
	return (parent[a] < 0) ? a : parent[a] = root(parent[a]);
}

inline bool UnionFind::unite(int a, int b)
{
	int root_a = root(a), root_b = root(b);
	if (root_a == root_b) return false;

	int size_a = -parent[root_a], size_b = -parent[root_b];
	if (size_a < size_b) swap(a, b), swap(size_a, size_b), swap(root_a, root_b);

	parent[root_a] += -size_b;
	parent[root_b] = root_a;
	return true;
}


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

int main()
{
	int a,b,c,d,sum=0;
	string s;
    cin>>a>>b;
    cin>>c>>d;
    cout<<(a-c)*(b-d);
	
	
	return 0;
}
	

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

int main(void)
{
        char s[10];
        char ans[10];
        char sun[] = "Sunny";
        char clo[] = "Cloudy";
        char rai[] = "Rainy";

        scanf("%s", s);

        if(strcmp(s, sun) == 0){
                printf("%s\n", clo);
        }else if(strcmp(s, clo) == 0){
                printf("%s\n", rai);
        }else if(strcmp(s, rai) == 0){
                printf("%s\n", sun);
        }

        return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }

  int ans= 0;
  int i= 0;
  while(i+1 < N){
    if(data.at(i)==data.at(i+1)){
      ans++;
      i+= 2;
    }
    else{
      i++;
    }
  }

  cout << ans << endl;
}

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

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;

#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)

int main(){
    ll N;
    vector<ll> A;
    
    cin >> N;
    REP(i,0,N){
        ll a;
        cin >> a;
        A.push_back(a);
    }

    for(ll a : A){
        if(a % 2 == 0 && a % 3 != 0 && a % 5 != 0){
            cout << "DENIED" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] values = new int[N];
        for (int i=0; i<N; i++) {
            values[i] = sc.nextInt();
        }
        int count = 0;
        hoge: while (true) {
            for (int i=0; i<N; i++) {
                if (values[i] % 2 != 0) {
                    break hoge;
                }
                values[i] = values[i] / 2;
            }
            count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21588
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,count=0;

    cin >> a >> b >> c;

    if(a==7)
        count++;
    if(b==7)
        count++;
    if(c==7)
        count++;

    if(count>=2)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
#ifdef __LOCAL
#include <dump.hpp>
#define dump(...) DUMPOUT << "  " << string(#__VA_ARGS__) << ": " << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl << "    ", dump_func(__VA_ARGS__)
#else
#define dump(...)
#endif
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct IOInit { IOInit() { cin.tie(nullptr); ios::sync_with_stdio(false); dump("READY"); /*cout << unitbuf;*/} } IO_INIT;
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;



signed main(void) {
  int n, q; cin >> n >> q;
  dsu uf(n);
  rep(i,q) {
    int t, u, v; cin >> t >> u >> v;
    if (t == 0) {
      uf.merge(u, v);
    } else {
      if (uf.same(u, v)) {
        pl(1)
      } else {
        pl(0)
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3896
#include <bits/stdc++.h>
using namespace std;
#define rep(n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for (int i=0;i<(n);i++)
#define rep3(i,a,b) for (int i=a;i<(b);i++)
#define out(ans) cout << ans << endl;
#define outs(ans) cout << ans;
using ll = long long;

int main(){

    //imput n, a(n), b(n)
    int n,k;
    string s;
    cin >> n>>k>>s;
    string small = "abcdefghijklmnopqrstuvwxyz";
    string large = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    //main process
    int ans;
    rep(26){
        if(s[k-1] == large[i]){
            s[k-1]=small[i];
        }
    }

    rep(n){outs(s[i])}
    out("")
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;
typedef tuple<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef unordered_set<ll> si;
typedef unordered_map<ll, ll> mii;

bool ok;

void dfs(const vvii &g, si &s, mii &c, int i) {
	if (!ok) return;
	for (auto z : g[i]) {
		ll j, d;
		tie(j, d) = z;
		if (c.find(j) != c.end()) {
			if (c[j] - c[i] != d) {
				ok = false;
				return;
			}
		} else c[j] = c[i] + d;
		auto it = s.find(j);
		if (it != s.end()) {
			s.erase(it);
			dfs(g, s, c, j);
		}
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	vvii g(n);
	for (int i = 0; i < m; i++) {
		ll l, r, d;
		cin >> l >> r >> d;
		l--;
		r--;
		g[l].push_back(make_tuple(r, d));
		g[r].push_back(make_tuple(l, -d));
	}
	si s;
	for (int i = 0; i < n; i++) s.insert(i);
	ok = true;
	while (!s.empty()) {
		auto it = s.begin();
		s.erase(it);
		mii c;
		c[*it] = 0;
		dfs(g, s, c, *it);
	}
	cout << (ok ? "Yes\n" : "No\n");
}

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

int main()
{
  typedef long long ll;
  ll a, b, x;
  cin >> a >> b >> x;
  auto min = a/x + ((0 == a%x) ? 0 : 1);
  auto max = b/x;
  auto cnt = max - min + 1;
  cout << ((cnt < 0) ? 0 : cnt);
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from heapq import heappop, heappush


def prim(edges, *, start=0, adj_matrix=False, default_value=float('inf')):
    n = len(edges)

    costs = [float('inf')] * n
    costs[start] = 0
    prevs = [-1] * n

    pq = [(0, start)]
    T = [True] * n

    while pq:
        tmp_cost, tmp_node = heappop(pq)
        T[tmp_node] = False

        nxt_edges = ((node, cost) for node, cost in enumerate(edges[tmp_node]) if cost != default_value and T[node]) if adj_matrix else\
                    ((node, cost) for node, cost in edges[tmp_node] if T[node])

        for nxt_node, nxt_cost in nxt_edges:
            if costs[nxt_node] > nxt_cost:
                costs[nxt_node] = nxt_cost
                prevs[nxt_node] = tmp_node
                heappush(pq, (nxt_cost, nxt_node))
                T[nxt_node] = True

    else:
        if len([prev for prev in prevs if prev != -1]) != n - 1:
            raise NoSpanningError(
                'There is no spanning tree in this graph (search started from node{})'.
                format(start))
        else:
            return prevs, costs


class NoSpanningError(Exception):
    pass


if __name__ == '__main__':
    n = int(input())
    edges = [[(j, int(cost)) for j, cost in enumerate(input().split())
              if int(cost) != -1] for i in range(n)]

    prevs, costs = prim(edges)
    print(sum(costs))



Measured memory_bytes: 6468
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
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; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  double a, b;
  while (cin >> a >> b) cout << prec(8) << a * b / 3.305785 << endl;
}

Measured memory_bytes: 3260
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using ll = long long;


class DKi {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        int n, q;
        cin >> n >> q;
        map<int, vector<int>> ab_map;
        for (int i = 0; i < n - 1; ++i) {
            int a, b;
            cin >> a >> b;
            ab_map[a].emplace_back(b);
            ab_map[b].emplace_back(a);
        }
        vector<int> px_vec(n + 1, 0);
        for (int j = 0; j < q; ++j) {
            int p, x;
            cin >> p >> x;
            px_vec[p] += x;
        }
        vector<bool> seen(n+1, false);

        auto dfs = [&](auto dfs, int start, int goal) -> void {
            seen[start] = true;
            for (const auto &item : ab_map[start]) {
                if (seen[item] == true) continue;
                px_vec[item] += px_vec[start];
                dfs(dfs, item, start);
            }
        };
        dfs(dfs, 1, 0);
        for (int k = 1; k < n + 1; ++k) {
            cout << px_vec[k] << " ";
        }
        cout << endl;
//        cin.tie(nullptr); ios::sync_with_stdio(false);
//        int N, Q; cin >> N >> Q;
//        vector<vector<int>> G(N);
//        rep(i, N-1) {
//            int a, b; cin >> a >> b; a--; b--;
//            G[a].push_back(b);
//            G[b].push_back(a);
//        }
//        vector<ll> val(N);
//        rep(i, Q) {
//            int p, x; cin >> p >> x; p--;
//            val[p] += x;
//        }
//        auto dfs = [&](auto dfs, int u, int p) -> void {
//            for (int v : G[u]) if (v != p) {
//                    val[v] += val[u];
//                    dfs(dfs, v, u);
//                }
//        };
//        dfs(dfs, 0, -1);
//        rep(i, N) cout << val[i] << (i == N - 1 ? '\n' : ' ');
    }
};


int main() {
	DKi solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 33920
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
	int n;
	cin >> n;
	int ans = 0;
	loop(i,1,n+1)if(i%2){
		int cnt = 0;
		for(int j = 1; j <= i; j++)if(i%j == 0)cnt++;
		if(cnt == 8){
			ans++;
		}
	}
	cout << ans << endl;

}


Measured memory_bytes: 3140
/*
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineerin College
    Date:19/04/2020
*/
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
#define ld long double
#define ff first
#define ss string 
#define se second
#define alt(v) v.begin(),v.end()
#define pb emplace_back
#define mp make_pair
#define tc(t) cin>>t;while(t--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fab(i,a,b) for(ll i=(a);i<(b);i++)
#define fba(i,a,b) for(ll i=(b);i>=(a);i--)
#define arr(i,n) fab(i,0,n)
#define getmx(v) *max_element(alt(v))
#define gcd(x,y) __gcd(x,y)
#define bs(a,n,x) binary_search(a,a+n,x)
#define up_to_low(c) c|=' '  //"A" -> 'a'
#define low_to_up(c) c&="_"  //'a' -> "A"
#define cb(n) __builtin_popcount(n)
#define rep(a,d,s) iota(a,a+d,s) // s->starting point 
#define lb(v,x) lower_bound(alt(v),x)
#define ub(v,x) upper_bound(alt(v),x)
int dx[4]={0,-1,1,0};
ll mod=1000000007;
int dy[4]={1,0,0,-1};
ll max(ll a,ll b){if(a>b)return a;else return b;} 
ll min(ll a,ll b){if(a<b)return a;else return b;}
bool chckpoweroftwo(ll x){return x && !(x&(x-1));}


ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1;  
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
} 
ll modInverse(ll a, ll m) 
{ 
    ll x, y,res; 
    ll g = gcdExtended(a, m, &x, &y); 
    if(g!=1)
    res=1;
    else
    res = (x%m + m) % m;
    return res;
} 

ll f[200005];
void factorial()
{ 
    f[0]=1;
    fab(i,1,200005)
    {
        f[i]=(i*f[i-1])%mod;
    }

}
ll ncr(ll n,ll r)
{
    if(r==0)
    return 1;
    return (f[n]*modInverse(f[r],mod)%mod*modInverse(f[n-r],mod)%mod)%mod;
}
ll func(ll r,ll l)
{
    ll x=r*(r+1)/2;
    ll y=l*(l-1)/2;
    return (x-y);
}

bool test=0;
void solve()
{
    
   factorial();    
   ll n,k;
   cin>>n>>k;
   ll ans=0;
   n++;
   fab(i,k,n+1)
   {
       if(i>2)
       {
        ll x=i*(i-1)/2;
        ll y=func(n-1,n-i+1);
        ans=(ans+(n-i)+(y-x+1))%mod;
       }
       else if(i==2)
       ans=(ans+(n-1)+(n-2))%mod;
       else
       ans=(ans+n)%mod;
   }
    cout<<ans<<endl;
}


















int main()
{
    int t=1;
    if(test)
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5200
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int ccw(pll a, pll b) {
    llong val = a.fs * b.se - a.se * b.fs;
    if (val > 0) return 1;
    if (val < 0) return -1;
    return 0;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    vector<pll> ps;
    int n;
    cin >> n;
    while (n--) {
        int x, y;
        cin >> x >> y;
        if (x == 0 && y == 0) continue;
        ps.emplace_back(x, y);
    }
    sort(ps.begin(), ps.end(), [&](pll a, pll b) {
        if (a.se == 0 && b.se == 0) {
            return a.fs > b.fs;
        }
        if (a.se * b.se < 0) {
            return a.se > 0;
        }
        if (a.fs > 0 && a.se == 0) {
            return true;
        }
        if (b.fs > 0 && b.se == 0) {
            return false;
        }
        return ccw(a, b) > 0;
    });
    n = ps.size();
    llong ans = 0;
    for (int i = 0; i < n; ++i) {
        llong X = ps[i].fs;
        llong Y = ps[i].se;
        ans = max(ans, X * X + Y * Y);
        for (int j = (i + 1) % n; j != i; j = (j + 1) % n) {
            X += ps[j].fs;
            Y += ps[j].se;
            ans = max(ans, X * X + Y * Y);
        }
    }
    cout.precision(50);
    cout << fixed;
    cout << sqrtl((ld)ans) << endl;
    return 0;
}

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

int h1(long long key){
    return key%M;
}

int h2(long long key){
    return 1+(key%(M-1));
}

int h(long long key,int i){
    return (h1(key)+i*h2(key))%M;
}

int insert(vector<int> &T,long long key){
    int i=0;
    while(1){
        int j=h(key,i);
        if(T.at(j)==-1){
            T.at(j)=key;
            return j;
        }
        else i++;
    }
}

int search(vector<int> &T,long long key){
    int i=0;
    while(1){
        int j=h(key,i);
        if(T.at(j)==key){   
            return 0;
        }
        else if(T.at(j)==-1||i>=M){
            return -1;
        }
        else i++;
    }
}

long long henkan(char s2[12]){
    long long key=0;
    long long I=1;
    for(int i=0;i<12;i++){
        if(s2[i]=='a') break;
        else if(s2[i]=='A'){
            key+=I;
        }
        else if(s2[i]=='C'){
            key+=2*I;            
        }
        else if(s2[i]=='G'){
            key+=3*I; 
        }
        else if(s2[i]=='T'){
            key+=4*I;
        }
        I*=5;
    }
    return key;
}

int main(){
    int n;
    scanf("%d",&n);
    vector<int> T(1046527,-1);
    for(int i=0;i<n;i++){
        char s1[10];
        char s2[12]={'a','a','a','a','a','a','a','a','a','a','a','a'};
        scanf("%s %s",s1,s2);
        long long key=henkan(s2);
        if(s1[0]=='i'){
            insert(T,key);
        }
        else if(s1[0]=='f'){
            if(search(T,key)==-1) printf("no\n");
            else printf("yes\n");
        }
    }
}


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

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll N,K,S;
    cin>>N>>K>>S;
    N-=K;
    rep(i,K){
        cout<<S<<" ";
    }
    if(S==pow(10,9)){
        S=0;
    }
    rep(i,N){
        cout<<S+1<<" ";
    }
    cout<<endl;   

    return 0;
}

//a=97,z=122

Measured memory_bytes: 1280