akhauriyash/Code-Regression huggingface dataset:
def solve():
  while True:
    n,m = map(int,input().split())
    if not n and not m: break
    
    lst = [int(input()) for _ in range(n)]
    lst.append(0)
    lst = sorted(lst)
    lst2 = [i + j for i in lst for j in lst if i <= j]
    lst2 = sorted(lst2)
    A = []
    index = len(lst2) - 1
    for i in lst2:
      if i + lst2[-1] <= m:
        A.append(i + lst2[-1])
      elif i <= m:
        while True:
          if i + lst2[index] <= m:
            break
          index -= 1
        A.append(i + lst2[index])
      else:
        break
    print(max(A))
solve()




Measured memory_bytes: 66824
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll a; cin >> a;
    ll b; cin >> b;
    ll n; cin >> n;
    ll x = min(b-1, n);
    ll val = ll(a*x)/b + a*ll(x/b);
    cout << val << endl;
    return 0;
}

Measured memory_bytes: 3596
N = int(input())
nameArr = []
chNum = 1

n = N - 1

while True:
    if n < 26*(26**chNum-1)//25:
        break
    chNum += 1

if chNum == 1:
    nameArr.append(n%26)
else:
    n = n - 26*(26**(chNum-1)-1)//25
    for i in range(chNum):
        nameArr.append(n//(26**(chNum-1-i)))
        n = n % (26**(chNum-1-i))

s = ""
for item in nameArr:
    if item == 0:
        s = s + "a"
    if item == 1:
        s = s + "b"
    if item == 2:
        s = s + "c"
    if item == 3:
        s = s + "d"
    if item == 4:
        s = s + "e"
    if item == 5:
        s = s + "f"
    if item == 6:
        s = s + "g"
    if item == 7:
        s = s + "h"
    if item == 8:
        s = s + "i"
    if item == 9:
        s = s + "j"
    if item == 10:
        s = s + "k"
    if item == 11:
        s = s + "l"
    if item == 12:
        s = s + "m"
    if item == 13:
        s = s + "n"
    if item == 14:
        s = s + "o"
    if item == 15:
        s = s + "p"
    if item == 16:
        s = s + "q"
    if item == 17:
        s = s + "r"
    if item == 18:
        s = s + "s"
    if item == 19:
        s = s + "t"
    if item == 20:
        s = s + "u"
    if item == 21:
        s = s + "v"
    if item == 22:
        s = s + "w"
    if item == 23:
        s = s + "x"
    if item == 24:
        s = s + "y"
    if item == 25:
        s = s + "z"

print(s)


Measured memory_bytes: 9320
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AFerrisWheel solver = new AFerrisWheel();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFerrisWheel {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int a = s.nextInt();
            int b = s.nextInt();
            if (a >= 13) {
                out.println(b);
            } else if (a >= 6) {
                out.println(b / 2);
            } else {
                out.println(0);
            }


        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21332
# -*- coding: utf-8 -*-

X, Y = map(int, input().split())

max_num = 10**18 // X


if X % Y == 0:
    print(-1)
else:
    for i in range(max_num + 1):
        if i == 0:
            continue
        else:
            if (i * X) % Y != 0:
                print(i * X)
                break
            else:
                continue


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using P = pair<long long, int>;

int main() {
    int N;
    cin >> N;
    vector<P> A(N);
    for(int i=0; i<N; ++i) {
        cin >> A[i].first;
        A[i].second = i + 1;
    }
    sort(begin(A), end(A), greater<P>());

    long long res = 0;
    set<int> S;
    S.insert(0); S.insert(N + 1);
    for(P a : A) {
        int index = a.second;
        auto itr = S.upper_bound(index);
        if(++itr != S.end()) {
            int com = *itr--;
            com -= *itr--;
            com *= (index - *itr);
            res += a.first * com;
        }
        itr = S.upper_bound(index);
        if(--itr != S.begin()) {
            int com = *itr--;
            com -= *itr++;
            com *= *(++itr) - index;
            res += a.first * com;
        }
        S.insert(index);
    }
    cout << res << endl;
}

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

using namespace std;

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

const int N = 1e5 + 10;

int a[N], b[N];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	a[n] = a[0];
	b[0] = 0;
	for (int i = 0; i < n; ++i)
		b[i + 1] = a[i] * 2 - b[i];
	for (int i = 0; i < n; ++i)
		cout << b[i] + (i % 2 ? 1 : -1) * (b[n - 1] / 2 - a[n - 1]) << ' ';
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
const int INF=1000010000;
int main() {
  int n,W; cin >> n >> W;
  vector<int> w(n),v(n);
  for(int i=0; i<n; i++){
    cin >> w[i] >> v[i];
  }
  int dp[110][100010];
  for(int i=0; i<110; i++){
    for(int j=0; j<100010; j++){
      dp[i][j]=INF;
    }
  }
  dp[0][0]=0;
  for(int i=0; i<n; i++){
    for(int j=0; j<=n*1000; j++){
      if(j<v[i]) dp[i+1][j]=dp[i][j];
      else{
        dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
      }
      //cout << dp[i+1][j] << endl;
    }
  }
  int res=0;
  for(int i=0; i<=n*1000; i++){
    if(dp[n][i]<=W) res=i;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 43264
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn gcd(mut x: i64, mut y: i64) -> i64 {
    while y != 0 {
        let r = x % y;
        x = y; y = r;
    }
    x
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(k: i64);
    let mut sum = 0;
    for i in 1..k + 1 {
        for j in 1..k + 1 {
            for l in 1..k + 1 {
                sum += gcd(gcd(i, j), l);
            }
        }
    }
    puts!("{}\n", sum);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2248
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define MOD 1000000007
using namespace std;

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);cout.tie(NULL);
	int n;
	cin>>n;
	vector<int> h(n);
	vector<int> dp(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>h[i];
	}
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;++i){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n-1];
	// cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
	return 0;
}

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

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

  vector<ll> v(N + 1, 0);
  for (int i = 1; i <= N; i++) {
    int max_multiple = N / i;
    for (int j = 1; j <= max_multiple; j++) {
      v.at(i * j)++;
    }
  }

  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += i * v.at(i);
  }

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


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

struct Edge
{
    int to, id;
};

vector<vector<Edge>> g(100005);
vector<int> ans(100005);

void dfs(int v, int c = -1, int p = -1)
{
    DUMP(v);
    int k = 1;
    for (auto nv : g[v])
    {
        int ei = nv.id;
        if (nv.to == p)
            continue;
        if (k == c)
            ++k;
        ans[ei] = k;
        ++k;
        dfs(nv.to, ans[ei], v);
    }
}

void Main()
{
    int n;
    cin >> n;
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        g[a].pb({b, i});
        g[b].pb({a, i});
    }
    dfs(0);
    int mx = 0;
    rep(i, n) mx = max(mx, int(g[i].size()));
    cout << mx << endl;
    rep(i, n - 1) cout << ans[i] << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

multiset<int> edge[100005];

int my(int now,int from)
{
	int ans=0,cnt=0;
	for (auto to:edge[now])
	{
		if (to==from)
		{
			continue;
		}
		int tmp=my(to,now);
		if (tmp==0)
		{
			++cnt;
		}
		else
		{
			ans+=tmp;
		}
	}
	if (cnt>0)
	{
		ans+=cnt-1;
	}
	return ans;
}

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int a,b,st=-1;
	for (int i = 0; i < n-1; ++i)
	{
		cin>>a>>b;
		edge[a].insert(b);
		edge[b].insert(a);
		if (edge[a].size()>2)
		{
			st=a;
		}
		else if (edge[b].size()>2)
		{
			st=b;
		}
	}
	if (st==-1)
	{
		cout<<"1\n";
	}
	else
	{
		cout<<my(st,-1)<<endl;
	}
	return 0;
}


Measured memory_bytes: 17024
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	if (b == 0) return a;
	return gcd(b, a % b);
	//return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	ll g = gcd(a, b);
	return a / g * b; // Be careful not to overflow
	//return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数


template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
//vector<vector<int>> data(3, vector<int>(4));

int main() {
	unsigned long long N;cin >> N;
	unsigned long long ans = 1, t;
	vector<unsigned long long> T(N+1);
	for (unsigned long long i = 1;i <= N;i++)cin >> T[i];
	for (unsigned long long i = 1;i <= N;i++) {
		t = T[i];
		ans = lcm(t, ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <string>

using namespace std;

int main()
{
  set <string> st1;
  string s;int n;

  cin>>n;

  while(n)
  {
    cin>>s;

    st1.insert(s);

    n--;
  }

  cout<<st1.size();

  return 0;

}


Measured memory_bytes: 15608
// while( !(succeed == try()) );

#include "bits/stdc++.h"
using namespace std;

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


#define int long long int
#define loop(i,s,e) for(int i=s; i<e; i++)
#define endl '\n'
#define vii vector<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX

void INP();

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


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

	int sum = 0;
	loop(i,1,n+1){
		if(i%3 != 0 and i%5!=0) sum+=i;
	}

	cout<<sum;
}

int32_t main(){

	ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//INP();
    int t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}






















inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}
 
 

Measured memory_bytes: 3648
/*
       Hi there <3 
──────▄▀▄─────▄▀▄
─────▄█░░▀▀▀▀▀░░█▄
─▄▄──█░░░░░░░░░░░█──▄▄
█▄▄█─█░░▀░░┬░░▀░░█─█▄▄█

*/
#include <bits/stdc++.h>
#define MOD 1000000007
#define re return
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define y0 y32479
#define y1 y95874
#define next next239
#define prev prev239
#define fill(x, y) memset(x, y, sizeof(x))
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define ba back()
#define popcount __builtin_popcountll
#define fastIO()                 \
    {                            \
        ios::sync_with_stdio(0); \
        cin.tie(0);              \
        cout.tie(0);             \
    }
#define in(x) \
    int x;    \
    cin >> x;
#define in1(x) \
    int x;     \
    cin >> x;  \
    x--;
#define inll(x) \
    ll x;       \
    cin >> x;
#define ins(x) \
    string x;  \
    cin >> x;

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef pair<double, double> pdd;
typedef long double LD;
typedef double D;

struct book
{
    int cost;
    vector<int> v;
};
void Solve()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<book> books;
    for (int i = 0; i < n; i++)
    {
        book temp;
        cin >> temp.cost;
        for (int j = 0; j < m; j++)
        {
            int temp2;
            cin >> temp2;
            temp.v.emplace_back(temp2);
        }
        books.emplace_back(temp);
    }
    int mincost = -1;
    for (int i = 0; i < (1 << n); ++i)
    {
        vector<book> ans;
        for (int j = 0; j < n; ++j)
        {
            if (i & (1 << j))
            {
                ans.emplace_back(books[j]);
                //cout << books[j].cost << " ";
            }
           
        }
         //cout<<endl;
        int tempcost = 0;
        vector<int> arr(m,0);

        for (int l = 0; l < ans.size(); l++)
        {
            tempcost += ans[l].cost;
            for (int o = 0; o < m; o++)
            {
                arr[o] += ans[l].v[o];
            }
        }
        bool flag = true;
        for (int o = 0; o < m; o++)
        {
            if (arr[o] < x)
            {

                flag = false;
                break;
            }
        }
        if (flag)
        {
            if (mincost == -1)
                mincost = tempcost;
            mincost = min(mincost, tempcost);
        }
    }

    cout << mincost << endl;
}

int main()
{
    fastIO();
    int t;
    t = 1;
    while (t--)
    {
        Solve();
    }
    return 0;
}

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

int main() {
	
	int n;
	cin >> n;
	cout << n / 3 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define abs(a) (((a)<0)?-(a):(a))
long long a[200000];
int main(int argc, char const *argv[]){
	long i,n;
	long long min,sum,s;
	scanf("%ld",&n);
	for(i=0;i<n;i++){
		scanf("%lld",&a[i]);
		sum+=a[i];
	}
	s=a[0];
	min=abs(2*s-sum);
	for(i=1;i<n-1;i++){
		s+=a[i];
		if(min>abs(2*s-sum)) min=abs(2*s-sum);
	}
	printf("%lld\n",min);
	return 0;
}

Measured memory_bytes: 1664
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let mut ans = "".to_string();
    let s:String = read();
    for c in s.chars() {
        if c == '0' {
            ans += "0";
        } else if c == '1' {
            ans += "1"
        } else {
            if !ans.is_empty() {
                ans = ans[0..ans.len()-1].to_string();
            }
        }
    }
    println!("{}", ans);
}

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

using namespace std;

int main(){
    int n, t, mini = INT_MAX; cin >> n >> t;
    for(int i = 0; i < n; ++i){
        int c, x; cin >> c >> x;
        if(x <= t){
            mini = min(mini, c);
        }
    }
    if(mini != INT_MAX)cout << mini;
    else cout << "TLE";
    return 0;

}


Measured memory_bytes: 256
use std::collections::*;
fn main() {
    let _ = read::<usize>();
    let v = read_vec::<u32>();
    let mut hm = HashMap::new();
    let mut over3200 = 0;

    for a in v {
        if a >= 3200 {
            over3200 += 1;
        }
        let color = match a {
            1...399 => 0,
            400...799 => 1,
            800...1199 => 2,
            1200...1599 => 3,
            1600...1999 => 4,
            2000...2399 => 5,
            2400...2799 => 6,
            2800...3199 => 7,
            _ => 8,
        };
        let count = hm.entry(color).or_insert(0);
        *count += 1;
    }
    let colors = hm.keys().count();
    if colors == 1 && over3200 > 0 {
        println!("1 {}", over3200);
    } else if over3200 > 0 {
        println!("{} {}", colors - 1, colors - 1 + over3200);
    } else {
        println!("{} {}", colors, colors);
    }
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main() {
	int a=0, c=0,d=0;
	cin >> a;
	vector<int>b(a*2);
	for (int i = 0; i < a*2;i++) {
			cin >> b[i];
		}
	for (int i = 0; i + 5 <a*2;i += 2) {
		if ((b[i] == b[i + 1]) &&( b[i + 2] == b[i + 3]) &&( b[i + 4] == b[i + 5])) {
			c++;
		}
	}
	if (c >= 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3596
l = []

for _ in range(3):
  l += list(map(int, input().split()))

n = int(input())
for _ in range(n):
  b = int(input())
  if b in l:
    l[l.index(b)] = 0

for i in range(3):
  if sum(l[0+3*i:3+3*i]) == 0:
    print("Yes")
    exit()
  
  if sum(l[i:9:3]) == 0:
    print("Yes")
    exit()

if (l[0]+l[4]+l[8]) == 0:
  print("Yes")
  exit()
if (l[2]+l[4]+l[6]) == 0:
  print("Yes")
  exit()
  
print("No")


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

int main(){
    ll n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;
    cout << max({(n-1)/a,(n-1)/b,(n-1)/c,(n-1)/d,(n-1)/e}) + 5 << endl;
    
}


Measured memory_bytes: 256
while true
  m,f,r = gets.split.map {|s| s.to_i}
  if m == -1 && f == -1 && r == -1
    break
  end
  if m == -1 || f == -1
    puts "F"
  elsif m + f >= 80
    puts "A"
  elsif m + f >= 65
    puts "B"
  elsif m + f >= 50
    puts "C"
  elsif m + f >= 30
    if r >= 50
      puts "C"
    else
      puts "D"
    end
  else
    puts "F"
  end
end

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

#define ED return 0;
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) int(pow(x,y))
#define FI first
#define SE second
const long mod = 1000000007;

int main(){
    long long int N, K;
    cin >> N >> K;
    vector<pair<long long int,long long int>> vec (N);
    for(long long int i = 0;i < N;i++){
        cin >> vec.at(i).FI >> vec.at(i).SE;
    }
    SORT(vec);
    for(long long int i = 0;i < N;i++){
        K -= vec.at(i).SE;
        if(K < 1){
            cout << vec.at(i).FI << endl;
            ED
        }
    }
}


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

using namespace std;

typedef long long ll;

ll sum = 0;

void split(string s, ll left)
{
    for (int i = 0; i < s.size(); i++)
    {
        if (i == 0)
        {
            sum += left + stol(s);
            continue;
        }
        split(s.substr(i), left + stol(s.substr(0, i)));
    }
}

int main()
{
    string s;
    cin >> s;
    split(s, 0);
    cout << sum << endl;
}

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

int main() {

    int N, X;
    cin >> N >> X;

    int l[N + 1];
    l[0] = 0;
    rep(i, N) cin >> l[i + 1];
    int d = 0;
    int cnt = 0;
    rep(i, N+1) {
        d += l[i];
        if (d <= X) {
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3592
#!/bin/ruby

k = gets.chomp.split("")
words = [*'a'..'z']

k.each do |i|
  words.delete(i)
end

if words != []
  k << words[0]
  puts k.join("")
  exit
end
#prev_min = k[-1]
#boolean = false
prev = []
k.reverse.each_with_index do |i, idx|
  #if prev > i
    #if !boolean
    #  prev_min = i
    #  boolean = true
    #else
      #puts (k[0...-idx-1] ).join("") + prev_min
      #exit
   #end
  #end
  #prev = i
  if prev != [] && i < prev[-1]
    puts (k[0...-idx-1] ).join("") + prev.select{|t| t > i}[0]
    exit
  end

  prev << i
  prev.sort!
end
puts -1

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[33;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
const int maxn=2e5+7;
int main()
{
	int h,w,n;
	cin>>h>>w>>n;
	int stx,sty;
	cin>>stx>>sty;
	string s,t;
	cin>>s>>t;
	bool ok=1;
	int miny=sty,maxy=sty,minx=stx,maxx=stx;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='L') maxy--;
		else if(s[i]=='R') miny++;
		else if(s[i]=='U') maxx--;
		else if(s[i]=='D') minx++;
		if(miny>w||maxy<=0||minx>h||maxx<=0)
		{
			ok=0;break;
		}
		if(t[i]=='L') miny=max(1,miny-1);
		else if(t[i]=='R') maxy=min(w,maxy+1);
		else if(t[i]=='U') minx=max(1,minx-1);
		else maxx=min(h,maxx+1);
	}
	if(ok) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}


Measured memory_bytes: 776
/*https://atcoder.jp/contests/abc156/tasks/abc156_c*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int n, a[100];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	int sum = 0, min_sum = 1e9, mina = a[0], max = a[n - 1];
	// cout << min << max << endl;
	for (int i = mina; i <= max; i++)
	{
		sum = 0;
		for (int j = 0; j < n; j++)
			sum += (a[j] - i) * (a[j] - i);
		min_sum = min(min_sum, sum);
	}
	cout << min_sum << endl;
}

Measured memory_bytes: 3644
/* kadai3_2
   Saikyo_Kazune
*/
#include <stdio.h>
#include <string.h>
 
 
 
int main(void){
   //本の数を要れる変数num_booksを宣言
   int num_pencils;
   scanf("%d",&num_pencils);
   //1の位の数で場合分け
   switch(num_pencils%10){
       case 2:case 4:case 5:case 7: case 9:printf("hon\n");break;
       case 0:case 1:case 6:case 8:printf("pon\n");break;
       case 3:printf("bon\n");break;
   }
   return 0;
}

Measured memory_bytes: 1616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define all(x) (x).begin(), (x).end()
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD1 1000000007LL
#define MOD2 999999937LL

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

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

  if (n > 80000) {
    ll gcdall = a[0];
    bool allone = true;
    for (int i = 0; i < n; i++) {
      gcdall = __gcd(gcdall, a[i]);
      if (a[i] != 1) allone = false;
    }
    if (allone) cout << "pairwise coprime" << endl;
    else if (gcdall == 1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
    return 0;
  }

  vector<bool> isuse(1000001, false);
  bool ispairwise = true;
  ll gcdall = a[0];
  for (int i = 0; i < n; i++) {
    gcdall = __gcd(gcdall, a[i]);
    ll tar = a[i];
    for (int p = 2; p * p <= a[i]; p++) {
      if (tar % p == 0) {
        if (!isuse[p]) isuse[p] = true;
        else ispairwise = false;
        while (tar % p == 0) tar /= p;
      }
    }
    if (tar != 1) {
      if (!isuse[tar]) isuse[tar] = true;
      else ispairwise = false;
    }
  }
  if (ispairwise) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  if (gcdall == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }
  cout << "not coprime" << endl;
  
}


Measured memory_bytes: 11040
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;


//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  string s;
  cin >> s;
  int n,k;
  n = s.size();
  cin >> k;
  vector<vector<vector<int64_t>>> 
    DP(n+1,vector<vector<int64_t>>(2,vector<int64_t>(n+1)));
  //i桁目,smaller?,0以外の数
  int counter = 0;
  DP[0][0][0] = 1;
  rep(i,n){
    rep(smaller,2){
      rep(exczero,n+1){
        for(int64_t j=0;j <= (smaller ? 9 : s[i]-'0');j++){
          counter++;
          DP[i+1][smaller || (j < s[i]-'0')][exczero + (j != 0)]
            += DP[i][smaller][exczero];
        }
      }
    }
  }
  /*rep(i,n+1){
    rep(j,4){
      printf("%ld %ld//",DP[i][0][j],DP[i][1][j]);
    }
    cout << endl;
  }*/
  cout << DP[n][0][k] + DP[n][1][k] << endl;
  //cout << counter << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); ++i)
#define rrep(i, to) for (int i = to - 1; i >= 0; --i)
#define repf(i, from, to) for (int i = (from); i < (to); ++i)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

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

  // find first A
  int head;
  rep(i, s.size()) {
    if(s[i] == 'A') {
      head = i;
      break;
    }
  }

  // find last Z
  int tail;
  rrep(i, s.size()) {
    if(s[i] == 'Z') {
      tail = i + 1;
      break;
    }
  }


  cout << tail - head << endl;
}


Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int N,M,n[1000],m[1000];

int main(){
	while(cin>>N>>M){
		for(int i=0;i<N;i++)cin>>n[i];
		for(int i=0;i<M;i++)cin>>m[i];
		if(!N)return 0;
		int p=1,ans;
		for(int i=0;i<M;i++){
			p+=m[i]+n[p+m[i]-1];
			if(p>=N){ans=i+1;break;}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 0
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main(){
    int n,x,t; cin >> n >> x >> t;
    cout << t*((n+x-1)/x) << '\n';
    
}


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

bool pairCompare(const pair<int, int> & f, const pair<int, int> & s)
{
    return f.first < s.first;
}

int main()
{
    int n, m;
    ll ans;
    cin >> n >> m;
    vector<pair<int,int>> mise(n);
    rep(i, n) {
        int a1, b1;
        cin >> a1 >> b1;
        mise[i].first = a1;
        mise[i].second = b1;
    }

    sort(mise.begin(), mise.end(), pairCompare);
    ans = 0;
    int mm = m;
    rep(i, n) {
        if (mise[i].second >= mm) {
            ans += (ll)mise[i].first * mm;
            break;
        }
        mm -= mise[i].second;
        ans += (ll)mise[i].first * mise[i].second;
    }

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

Measured memory_bytes: 3984
package main

import (
	"fmt"
)

func trace(arr []int) {
	for i, e := range arr {
		if i == len(arr)-1 {
			fmt.Printf("%d\n", e)
		} else {
			fmt.Printf("%d ", e)
		}
	}
}

func bubbleSort(arr []int, len int) {
	count := 0
	change := true
	for i := 0; change; i++ {
		change = false
		for j := len - 1; j > i; j-- {
			if arr[j-1] > arr[j] {
				arr[j-1], arr[j] = arr[j], arr[j-1]
				change = true
				count++
			}
		}
	}
	trace(arr)
	fmt.Println(count)
}

func main() {
	var n int
	fmt.Scan(&n)

	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	bubbleSort(arr, n)

}



Measured memory_bytes: 1152
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var b = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(b.Zip(b.Skip(1), Min).Sum() + b.First() + b.Last());
    }
}


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

int main() {
	int n;
   	cin >> n;
  if(n%2==0) cout<< "0.5000000000"<<endl;
  else {
    double k = n/2+1;
    double m = n;
    cout <<  k/m << endl;
  }
  
}


Measured memory_bytes: 256
n = int(input())
ls = []
for i in range(n):
    a = int(input())
    p = []
    for i in range(a):
        x,y = map(int,input().split())
        p.append([x-1,y])
    ls.append(p)

ans = 0

for i in range(2**n):
    flag = 0
    for j in range(n):
        if (i >> j) & 1:
            for k in ls[j]:
                if (i>>k[0])&1 != k[1]:
                    flag = 1
                    break
    if flag == 0:
        ans = max(ans, bin(i)[2:].count('1'))
print(ans)

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

int cari_faktor(int a,int b, int faktor[]){
	int counter=1;
	for(int i=1; i<=a; i++){
		if(a%i==0&&b%i==0){
			faktor[counter]=i;
			counter++;
		}
	}
	
	return counter;
}

void bubble_sort(int left, int right,int angka[]){
	for(int i=left; i<right; i++){
		for(int j=i+1; j<right; j++){
			if(angka[j]>angka[i]){
				int temp=angka[i];
				angka[i]=angka[j];
				angka[j]=temp;
			}
		}
	}
}

int main(){
	int a,b, idx;
	int faktor[1005];
	scanf("%d %d %d", &a,&b,&idx);
	if(b>a){
		int temp=b;
		b=a;
		a=temp;
	}
	int banyak=cari_faktor(b,a,faktor);
	bubble_sort(1,banyak,faktor);
	printf("%d\n", faktor[idx]);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream> 
#include <cmath>
using namespace std;
int main() {
	int n;
	int ans = 0, max = 0;
	cin >> n;
	int l = 0;
	int b = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (b >= a) l++;
		else {
			 l = 0;
		}
		if (l > ans) ans = l;
		b = a;
	}
	cout << ans;
}



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

int main() {
  int a,b;
  cin >> a >> b;
  if(a+b>=24){
    cout << a+b-24 << endl;
  }else{
    cout << a+b << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

#define INF 999999999

int pr[250000];

void elato(int pr[250000]){
	for(int k = 0;k<250000;k++){
		if(k==0||k==1){
			pr[k] = 0;
		}
		else{
			int flag = 1;
			for(int m=2;m*m<=k;m++){
				if(k%m==0){
					flag=0;
					break;
				}
			}
			if(flag){
				pr[k] = pr[k-1] + 1;
			}
			else{
				pr[k] = pr[k-1];
			}
		}
	}
}

int main(){
	int n;
	elato(pr);
	while(1){
		cin >> n;
		if(!n) break;
		cout << pr[2*n]-pr[n] << endl;
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int h[110];
    for (int i = 0; i < n; i++) cin >> h[i];

    int ans = 0;
    for (int i = 0; i < n; i++) {
        while (h[i] > 0) {
            int j;
            //どこに0があるか
            for (j = i + 1; j < n; j++) {
                if (h[j] == 0) break;
            }
            //0のところまで引き算
            for (int k = i; k < j; k++) {
                h[k]--;
            }
            ans++;
        }
    }

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

Measured memory_bytes: 256
#include <stdio.h>
#define N 1000

int main(void){
	int a[N], n, i, temp;
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}

	for(i = 0; i < n / 2; i++){
		temp = a[i];
		a[i] = a[n - 1 - i];
		a[n - 1 - i] = temp;
	}

	for(i = 0; i < n; i++){
		if(i == n - 1){
			printf("%d\n", a[i]);
		}
		else{
			printf("%d ", a[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define rg register
#define ll long long 
#define maxn 230044
inline ll read()
{
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            f=-1;
        }
        c=getchar();
    } 
    while(c<='9'&&c>='0')
    {
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return x*f;
}
ll n,m,ans;
struct node
{
	ll a,b,id;
	bool vis;
	friend bool operator <(node a,node b)
	{
		return a.b>b.b;
	}
}s[maxn];// a天后 获得b的奖励 
priority_queue <node> q;
inline bool cmp(node a,node b)
{
	if(a.a!=b.a) return a.a>b.a;
	return a.b>b.b;
}
int main()
{
	n=read(),m=read();
	for(rg int i=1;i<=n;++i)
	{
		s[i].a=read(),s[i].b=read();
		s[i].id=i;
	}
	sort(s+1,s+1+n,cmp);
	int tag=1;
	while(s[tag].a>m) ++tag; 
	ll res=1;
	q.push(s[tag]); 
	ans+=s[tag].b;
	for(rg int i=tag+1;i<=n;++i)
	{
		if(s[i].a+res<=m) ans+=s[i].b,q.push(s[i]),res++;
		else
		{
			if(s[i].b>q.top().b)
			{
				ans-=q.top().b;
				q.pop();
				q.push(s[i]);
				ans+=s[i].b;
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 10352
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int a,b;
    cin>>a>>b;
    if((a%2)==(b%2)){
        cout<<(a+b)/2<<endl;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }





    return 0;
}


Measured memory_bytes: 256
n,x=map(int,input().split())
len_b=2**(n+2)-3
p=[2**(i+1)-1 for i in range(n)]
start=1
end=len_b
center=(end+1)//2
count1=0
count2=n-1
while True:
    if count2==-1:
        count1+=1
        break
    elif x==start:
        break
    elif x==center:
        count1+=p[count2]+1
        break
    elif x==end:
        count1+=p[count2]*2+1
        break
    elif x<center:
        start=start+1
        end=center-1
        center=(start+end)//2
        count2-=1
    else:
        start=center+1
        end=end-1
        center=(start+end)//2
        count1+=p[count2]+1
        count2-=1
print(count1)

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

int main(void){
	int n;
	cin >> n;
	vector<int> l(n);
	for(auto &x : l){
		cin >> x;
	}
	sort(l.begin(), l.end());
	int sum = 0;
	for(int i = 0; i < n-1; ++i){
		sum += l[i];
	}
	cout << (sum>l[n-1]?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
	char ch=getchar();int f=0;
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') {f=f*10+(ch^48);ch=getchar();}
	return f;
}
int n,m,v[30];char s[1005];
int main()
{
	int n=read(),m=read();
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s+1);
		for(int j=1;j<=m;j++)
		{
			v[s[j]-'a']++;
		}
	}
	if(n%2==0&&m%2==0)
	{
		for(int i=0;i<26;i++)
		{
			if(v[i]%4!=0)
			{
				printf("No");
				return 0;
			}
		}
		printf("Yes");
		return 0;
	}
	if(n%2==1&&m%2==1)
	{
		int temp=0;
		for(int i=1;i<=(n-1)/2;i++)
		{
			for(int j=1;j<=(m-1)/2;j++)
			{
				bool ok=0;
				for(int k=0;k<26;k++)
				{
					if(v[k]>=4)
					{
						v[k]-=4;
						ok=1;
						break;
					}
				}
				if(!ok)
				{
					printf("No");
					return 0;
				}
			}
		}
		for(int i=0;i<26;i++)
		{
			if(v[i]%2!=0)
			temp++;
		}
		if(temp!=1)
		printf("No");
		else printf("Yes");
		return 0;
	}
	else
	{
		if(n%2==0)
		swap(n,m);
		int temp=0;
		//cout<<n<<" "<<m;
		for(int i=1;i<=(n-1)/2;i++)
		{
			for(int j=1;j<=(m)/2;j++)
			{
				bool ok=0;
				for(int k=0;k<26;k++)
				{
					if(v[k]>=4)
					{
						v[k]-=4;
						ok=1;
						break;
					}
				}
				if(!ok)
				{
					printf("No");
					return 0;
				}
			}
		}
		for(int i=0;i<26;i++)
		{
			if(v[i]%2!=0)
			{
				printf("No");
				return 0;
			}
		}
		printf("Yes");
		return 0;
	}
}


Measured memory_bytes: 384
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstring>
#include<vector>
#include<list>
#include<set>
#include<map>
using namespace std;
#define LL long long
#define pi (4*atan(1.0))
#define eps 1e-14
#define bug(x)  cout<<"bug"<<x<<endl;
const int N=1e5+10,M=1e6+10,inf=1e9+10;
const LL INF=1e18+10,mod=2147493647;

vector<int>v[100005];
int get_sg(int u,int pre){
    int ret=0;
    for(int i=0;i<v[u].size();i++){
        if(v[u][i]!=pre)
            ret^=(1+get_sg(v[u][i],u));
    }
    return ret;
}
int main(){
    int n;
        scanf("%d",&n);
        for(int i=1;i<=n;i++)
            v[i].clear();
        for(int i=1;i<n;i++){
            int x,y;
            scanf("%d%d",&x,&y);
            v[x].push_back(y);
            v[y].push_back(x);
        }
        if(get_sg(1,-1))
            puts("Alice");
        else
            puts("Bob");
    return 0;
}



Measured memory_bytes: 11904