akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] p = sc.nextIntArray(n);
    Arrays.sort(p);
    int sum = 0;
    for (int i = 0; i < k; i++) {
      sum += p[i];
    }
    System.out.println(sum);
  }
}

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

struct st{int a,b,c;}s[200000];
ll sumx[200000],sumy[200000];

int main(){
	int x,y,z;cin>>x>>y>>z;
	int n=x+y+z;
	rep(i,n){
		scanf("%d%d%d",&s[i].a,&s[i].b,&s[i].c);
	}
	sort(s,s+n,[](st a,st b){
		return a.a-a.b>b.a-b.b;
	});
	ll sum=0;
	priority_queue<int>que;
	rep(i,x){
		que.push(s[i].c-s[i].a);
		sum+=s[i].c-s[i].a;		
	}
	sumx[x-1]=sum;
	for(int i=x;i<n;i++){
		que.push(s[i].c-s[i].a);
		sum+=s[i].c-s[i].a;
		if(que.size()>x)sum-=que.top(),que.pop();
		sumx[i]=sum;
	}
	sum=0;
	while(!que.empty())que.pop();
	for(int i=n-1;i>=n-y;i--){
		que.push(s[i].c-s[i].b);
		sum+=s[i].c-s[i].b;
	}
	sumy[n-y]=sum;
	for(int i=n-y-1;i>=0;i--){
		que.push(s[i].c-s[i].b);
		sum+=s[i].c-s[i].b;
		if(que.size()>y)sum-=que.top(),que.pop();
		sumy[i]=sum;
	}
	ll ans=LLONG_MIN;
	for(int i=x-1;i<n-y;i++){
		ans=max(ans,-(sumx[i]+sumy[i+1]));
	}
	rep(i,n)ans+=s[i].c;
	cout<<ans<<endl;
}

Measured memory_bytes: 3712
use std::vec::Vec;
use std::cmp::*;

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()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: usize = read();

    let mut a: Vec<i64> = Vec::new();

    for _ in 0..n {
      let t: i64 = read();
      a.push(t);
    }

    let mut seg = SegmentTree::new_max(&a);

    for i in 0..n {
      println!("{}", max(seg.get_max(0, i), seg.get_max(i+1, n)));
    }
}


#[derive(Debug, PartialEq)]
struct SegmentTree {
  n: usize, //元の配列に一番近い2の冪乗を格納する
  tree: Vec<i64>,
}


// 区間の最小の値を求めるセグメント木
impl SegmentTree {

  // 元の配列をセグメント木で表現
  // 2^nが元の配列のサイズ以上になる最小のnをNとする
  // O(N)
  fn new_max(v: &Vec<i64>) -> SegmentTree {
    let mut n: usize = 1;
    // セグメント木の葉の要素数
    while n < v.len() { n *= 2; }

    // セグメント木を表現するベクター
    let mut tree = vec![std::i64::MIN; 2 * n - 1];  // 区間における最小値を求めるセグメント木に注意


    // 葉から順に値を格納していく
    // まず最下段に値を格納する
    for i in 0..v.len() { tree[i + n - 1] = v[i]; }

    // 最下段の次の下段から値を書くのしていく
    for i in (0..(n-1)).rev() {
      tree[i] = max(tree[2 * i + 1], tree[2 * i + 2]);  // 区間における最小値を求めるセグメント木に注意
    }

    SegmentTree { n: n, tree: tree }
  }


  // 元の配列のi番目の値が変更された時にセグメント木を更新
  // O(logN) Nは元の配列の長さを超える最小の2の冪乗
  fn update_max(&mut self, i: usize, val: i64) {
    // 最下段の葉を更新
    let mut m = i + self.n - 1;
    self.tree[m] = val;
    while m > 0 {
      m = (m - 1) / 2;
      self.tree[m] = max(self.tree[2 * m + 1], self.tree[2 * m + 2]); // 区間における最大値を求めるセグメント木に注意
    }
  }


  // 指定された区間の最大値を求める
  // 区間は半開区間[i, j)での最小値を求める
  // O(logN)
  fn get_max(&self, i: usize, j: usize) -> i64 {
    fn get_max_sub(t: &SegmentTree, a: usize, b: usize, k: usize, l: usize, r: usize) -> i64 {
      // 求めたい区間が今いるノードの対応する区間と交差していない
      if r <= a || b <= l { return std::i64::MIN; } // 区間における最小値を求めるセグメント木に注意

      // 求めたい区間が今いるノードの対応する区間を被覆してる
      if a <= l && r <= b { return t.tree[k]; }

      // 求めたい区間と今いるノードと対応している区間が交差してるとき
      // 子を探索する
      // 左の子の値
      let vl = get_max_sub(t, a, b, 2 * k + 1, l, (l + r) / 2);
      // 右のこの値
      let vr = get_max_sub(t, a, b, 2 * k + 2, (l + r) / 2, r);

      return max(vl, vr);
    }

    return get_max_sub(&self, i, j, 0, 0, self.n);
  }

}


Measured memory_bytes: 11772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    long double l; cin>>l;
    long double l2 = l/3;
    cout << l2*l2*l2 <<endl;
}

Measured memory_bytes: 256
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        s: chars,
    }
    let mut map = std::collections::HashMap::new();
    for i in 0..(1 << n) {
        let mut a = vec![];
        let mut b = vec![];
        for j in (0..n).rev() {
            if ((i >> j) & 1) == 1 {
                a.push(s[n + j]);
            } else {
                b.push(s[n + j]);
            }
        }
        let h = (a, b);
        let po = map.entry(h).or_insert(0);
        *po += 1;
    }
    let mut ans: u64 = 0;
    for i in 0..(1 << n) {
        let mut a = vec![];
        let mut b = vec![];
        for j in 0..n {
            if ((i >> j) & 1) == 1 {
                a.push(s[j]);
            } else {
                b.push(s[j]);
            }
        }
        let h = (a, b);
        match map.get(&h) {
            Some(&v) => ans += v,
            _ => (),
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 75944
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

from collections import Counter

def main():
    N = II()
    A = LI()
    idxs = [0] * (N + 1)
    for i, a in enumerate(A):
        idxs[a] = i
    ll = list(range(N + 1))
    rr = list(range(N + 1))
    ans = 0
    for a in range(N, 0, -1):
        idx = idxs[a]
        l, r = ll[idx], rr[idx]
        ans += (idx - l + 1) * (r - idx + 1) * a
        ll[r + 1] = l
        rr[l - 1] = r

    return ans

print(main())

Measured memory_bytes: 72528
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <utility>
#include <memory>
#include <sstream>
#include <complex>
#include <cassert>
#include <bitset>
#define rep(i, n) for(int i = 0; i < n; i++)
#define fi first
#define se second
using namespace std;
typedef long long int ll; typedef pair <int, int> P; typedef vector <int> vecint; typedef pair<int, P> P1; typedef pair<P, P> P2;
const int inf = 1000000000;
const ll INF = 9000000000000000000;
const double EPS = 10e-9;
int n, root;
vecint G[100001];
int num[100001];
int res;
vecint edge;
int dfs(int v, int p)
{
	//cout << "v " << v << endl;
	int num0 = 0;
	rep(i, G[v].size())
	{
		if (G[v][i] == p) continue;
		if (G[G[v][i]].size() == 1) num0++;
		else
		{
			int chi = dfs(G[v][i], v);
			//cout << "chi " << chi << endl;
			if (chi == 0)
				num0++;
			else num[v] += chi;
		}
	}
	//cout << "num0 " << num0 << endl;
	if (num0) num[v] += (num0 - 1);
	//cout << "numv " << num[v] << endl << endl;
	return num[v];
}
void dfs1(int v, int p)
{
	if (p == -1 && G[v].size() == 1) edge.push_back(v);
	rep(i, G[v].size())
	{
		if (G[v][i] == p) continue;
		if (G[G[v][i]].size() == 1)
		{
			edge.push_back(G[v][i]);
		}//{ root = G[v][i]; break; }
		else dfs1(G[v][i], v);
		//if (root >= 0) break;
	}
}
int main()
{
	cin >> n;
	res = inf;
	rep(i, n - 1)
	{
		int a, b; cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	root = -1;
	dfs1(0, -1);
	//cout << "root" << root << endl;
	rep(i, min(310, (int)edge.size()))
	{
		memset(num, 0, sizeof(num));
		res = min(res, dfs(edge[i], -1));
	}
	//int res = dfs(root, -1);
	res++;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 13952
// https://beta.atcoder.jp/contests/abc106

#define SUBMIT

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#include <unordered_map>
#include <map>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

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

    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        if (i % 2 == 0) continue;

        int count = 0;
        for (int j = 1; j <= i; ++j) {
            if (i % j == 0) count++;
        }

        if (count == 8) ans++;
    }

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

Measured memory_bytes: 256
s = str(input())

num = [int(s[-1])]
for i in range(1, len(s)):
    tmp = num[-1] + pow(10, i, 2019) * int(s[-i - 1])
    num.append(tmp % 2019)

mod = [1] + [0] * 2018
ans = 0
for i in num:
    ans += mod[i]
    mod[i] += 1
print(ans)


Measured memory_bytes: 76412
#include<iostream>
//#include<map>
#include<algorithm>
#include<vector>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define p(s) cout << (s) << endl
#define p2(s,t) cout << (s) << " " << (t) << endl 
#define ALL(v) (v).begin(), (v).end()
typedef long long ll;
using namespace std;

static const ll mod  = 1e9 + 7;
static const ll inf  = 1e18;

void printvector(vector<int> A){
    cout << "[vector]";
    for(int i = 0; i < A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b){
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
} 

int main(){
    int n, m;
    cin >> n >> m;
    int a, b;
    vector<pair<int,int> > pairs, pairs1;

    //代入
    REP(i,m){
        cin >> a >> b;
        pairs.push_back(make_pair(a,b));
    }

    //b順にソート
    sort(ALL(pairs), compare_by_b);

    int k = 0, cnt = 0;
/*
    for(int i = 0; i < pairs.size()-1; i++){
        if(pairs[i].first == pairs[i+1].first){
            pairs.erase(pairs.begin() + i + 1);
            i--;
        }
    }


    for(int i = 0; i < pairs.size()-1;){
        if(pairs[i].second >= pairs[i+1].second){
            pairs.erase(pairs.begin() + i);
        }
        else{
            i++;
        }
    }
*/

    int lastBridgeBreak = 0;

    for(auto pair : pairs){
        int left = pair.first;
        int right = pair.second;

        if(lastBridgeBreak < left){
            if(lastBridgeBreak < right - 1){
                lastBridgeBreak = right - 1;
                cnt++;
            }
        }
    }

    p(cnt);
/*
    REP(i,pairs.size()){
        cout << pairs[i].first << " " << pairs[i].second << endl;
    }
    for(int i = 0; i < pairs.size() ;i++){
        if(pairs[k].second <= pairs[i].first ){
            k = i;
            cnt++;
        }
    }
    p(cnt);
    */
}

Measured memory_bytes: 1400
#include <stdio.h>

int main(void) {
  
  char S[3];
  char s[3];
  int ans = 0;
  
  scanf("%s", S);
  scanf("%s", s);
  	for (int i = 0; i < 3; i++)
      if (S[i] == s[i])
        ans++;
  
  printf("%d \n", ans);
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
vector<int>v[4];
int n,w,y,x,ans;
void dfs(int W,int cost,int d){
  if(d==4){
    if(W<=w)ans=max(ans,cost);
    return ;
  }
  dfs(W,cost,d+1);
  int sum=0;
  for(int i=0;i<v[d].size();i++){
    sum+=v[d][i];
    dfs(W+(x+d)*(i+1),cost+sum,d+1);
  }
}
main(){
  cin>>n>>w;
  cin>>x>>y;
  v[0].push_back(y);
  r(i,n-1){
    int p1,p2;
    cin>>p1>>p2;
    v[p1-x].push_back(p2);
  }
  r(i,4)sort(v[i].begin(),v[i].end(),greater<int>());
  dfs(0,0,0);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())
m = []
for i in range(N):
	s,t = input().split()
	m.append((s,int(t)))
X = input()
ans = 0
flag = False
for i in range(N):
	if flag:
		ans += m[i][1]
	if not flag and m[i][0] == X:
		flag = True
print(ans)

Measured memory_bytes: 3064
N = 10**5
prime_list = [True] * (N+1)        # True が素数
count_list = [0] * (N+1)
for i in range(2, N+1, 1):
    if prime_list[i]:
        for j in range(i+i, N+1, i):
            prime_list[j] = False

for i in range(3, N+1, 2):
    if prime_list[i] and prime_list[(i+1)//2]:
        count_list[i] += 1

for i in range(3, N+1, 1):
    count_list[i] += count_list[i-1]

Q = int(input())
query = [list(map(int, input().split())) for _ in range(Q)]
for q in query:
    l, r = q
    print(count_list[r] - count_list[l-1])

Measured memory_bytes: 31984
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{Write, BufWriter};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
    }
    if k > (n-1)*(n-2)/2 {
        println!("{}", -1);
        return;
    }

    let mut ans: Vec<(usize, usize)> = Vec::new();

    for i in 2..n+1 {
        ans.push((1, i));
    }

//    println!("{} {}", k, (n-1)*(n-2)/2);
    let mut k = (n-1)*(n-2)/2 - k;

    for i in 2..n+1 {
        for j in 2..i {
            if k > 0 {
                ans.push((i, j));
                k -= 1;
            }
        }
    }

    println!("{}", ans.len());
    for (a, b) in ans {
        println!("{} {}", a, b);
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    
    int all[n];
    
    bool check = true;
    
    for(int i = 0; i < n; ++i){
    	cin >> all[i];
    	
    	if(all[i] % 2 == 0){
    		if(all[i] % 3 != 0 and all[i] % 5 != 0) check = false;
		}
	}
	
	if(check == true) cout << "APPROVED";
	else{
		cout << "DENIED";
	}

	return 0;
}



Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n;
    int[] a;
    int i, p;

    n = sc.nextInt();
    a = new int[n];
    for(i = 0;i < n;i++){
      a[i] = sc.nextInt();
    }

    p = partition(a, n);

    for(i = 0;i < (n - 1);i++){
      if(i == p){
        System.out.print("[" + a[i] + "] ");
      }else{
        System.out.print(a[i] + " ");
      }
    }
    if(i == p){
      System.out.println("[" + a[i] + "]");
    }else{
      System.out.println(a[i]);
    }



/*fin*/
    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }

  private static int partition(int[] a, int n){
    int tmp, k, j;

    for(k = -1;;){
      for(j = k + 1;j < n;j++){
        if(a[j] <= a[n - 1]){
          k++;
          tmp = a[k];
          a[k] = a[j];
          a[j] = tmp;
          if(j == n - 1)return k;
          break;
        }
      }
    }
  }
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    vector<int> b(N);
    rep(i, N) cin >> b[i];

    vector<int> ans;
    for (int i = 0; i < N; ++i) {
        for (int j = b.size() - 1; j >= 0; --j) {
            if (b[j] == j + 1) {
                ans.push_back(b[j]);
                b.erase(b.begin() + j);
                break;
            }
        }
    }

    if (ans.size() == N) {
        for (int i = N - 1; i >= 0; --i) cout << ans[i] << endl;
    } else {
        puts("-1");
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <math.h>
#include <vector>





using namespace std;

typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end());
const int MOD = 1000000007;
const int INF = INT_MAX;
const double PI = 3.14159265358979323846;



int main(int argc, char const *argv[])
{



    int n, x;
    cin >> n >> x;
    int m[n];
    rep(i, n){
        cin >> m[i];
    }

    int cnt = n;
    rep(i, n){
        x -= m[i];
    }

    int min = 1000;
    rep(i, n){
        if (m[i] < min){
            min = m[i];
        }
    }

    cnt += x/min;


    cout << cnt << endl;
    






    return 0;
}




//              g++ -std=c++1z  

Measured memory_bytes: 256
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (n, m) = InputLine.to_ia
  a = InputLine.to_ia

  s = a.reduce(:+)
  d = -1
  if n >= s then
    d = n - s
  end
  puts d.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 14700
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int M = stdIn.nextInt();
		int ans = N * (N - 1) / 2 + M * (M - 1) / 2;

		System.out.println(ans);
		stdIn.close();
	}
}


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

#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define ll      long long

void solve() {
        long long n;
        cin >> n;
        vector<int> pf;
        for (int i = 1; i <= 80; i ++) pf.push_back(i);
        deque<int> ps;
        long long now = n + 1;
        vector<bool> front;
        while (now > 1) {
                if (now & 1) front.push_back(true);
                front.push_back(false);
                now /= 2;
        }
        reverse(all(front));
        //for (int i = 0; i < front.size(); i ++) cout << front[i] << ' ';
        //cout << endl;
        int k = 1;
        for (int i = 0; i < front.size(); i ++) {
                if (front[i]) ps.push_front(k ++);
                else ps.push_back(k ++);
        }
        cout << pf.size() + ps.size() << endl;
        for (int i = 0; i < pf.size(); i ++) cout << pf[i] << ' ';
        for (int i = 0; i < ps.size(); i ++) cout << ps[i] << (i == ps.size() - 1 ? '\n' : ' ');
        return;
}

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

        //int T;
        //freopen("a.in", "r", stdin);
        //cin >> T;
        //while (T --) solve();
        
        solve();
        return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

void solve() {
	int n; cin >> n;
    vector<int> a(n);
    vector<int> c(n + 1, 0);
    rep(i, n) {
        cin >> a[i];
        c[a[i]] ++;
    }
    vector<int> e(n + 1, 0);
    rep1(i, n) {
        e[c[i]] ++;
    }
    vector<int> f(n + 2, 0), g(n + 2, 0);
    rep(i, n + 1) {
        f[i + 1] = f[i] + i * e[i];
        g[i + 1] = g[i] + e[i];
    }
    vector<int> d(n + 1, 0);
    rep(x, n + 1) {
        d[x] = f[x + 1] + x * (g[n + 1] - g[x + 1]);
    }
    for(int k = 1; k <= n; ++k) {
        int ok = 0, ng = n + 1;
        while(ng - ok > 1) {
            int mid = (ok + ng) / 2;
            if(d[mid] >= k * mid) ok = mid;
            else ng = mid;
        }
        cout << ok << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#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 FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1000005
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class DYetAnotherPalindromePartitioning {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        string s;
        cin >> s;

        int n = s.size();
        vector<int> dp(1 << 26), ans(n);
        REP(i, 1 << 26) dp[i] = INF;
        dp[0] = 0;
        int x = 0;
        REP(i, n) {
            int c = s[i] - 'a';
            x ^= 1 << c;

            int val = INF;
            val = min(val, dp[x]);
            REP(j, 26) {
                int nx = x ^(1 << j);
                val = min(val, dp[nx]);
            }
            dp[x] = min(dp[x], val + 1);
            ans[i] = val + 1;
        }

        cout << ans[n - 1] << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DYetAnotherPalindromePartitioning solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 263572
a, b, c, d, e, f = map(int, input().split())
res = (100 * a, 0)
for aa in range(0, f + 1, 100 * a):
    for bb in range(0, f + 1, 100 * b):
        w = aa + bb
        if w == 0 or w >= f:
            continue
        r = f - w
        for cc in range(0, r + 1, c):
            for dd in range(0, r + 1, d):
                s = cc + dd
                t = w + s
                if t > f or 100 * s > e * w:
                    continue
                if s * res[0] > res[1] * t:
                    res = (t, s)
print(*res)

Measured memory_bytes: 3064
#include <memory>
#include <utility>

template <class Key, class T> class splay_associative_array {
public:
	using key_type = Key;
	using value_type = T;
	using reference = value_type &;

private:
	class node_type {
	public:
		typename splay_associative_array::key_type key;
		typename splay_associative_array::value_type value;
		::std::unique_ptr<node_type> left, right;
		node_type(const key_type &key) : key(key), value(), left(), right() {}
	};
	using pointer = ::std::unique_ptr<node_type>;

	pointer root;

public:
	splay_associative_array() : root() {}

	reference operator[](const key_type &key) {
		pointer left, right;
		pointer *next_l = &left, *next_r = &right;
		while (1) {
			if (!root)
				root = ::std::make_unique<node_type>(key);
			if (!(root->key <= key)) {
				if (!root->left)
					root->left = ::std::make_unique<node_type>(key);
				if (!(root->left->key <= key)) {
					*next_r = ::std::move(root->left);
					root->left = ::std::move((*next_r)->right);
					(*next_r)->right = ::std::move(root);
					next_r = &(*next_r)->left;
					root = ::std::move(*next_r);
				}
				else if (!(key <= root->left->key)) {
					*next_r = ::std::move(root);
					next_r = &(*next_r)->left;
					*next_l = ::std::move(*next_r);
					next_l = &(*next_l)->right;
					root = ::std::move(*next_l);
				}
				else {
					*next_r = ::std::move(root);
					next_r = &(*next_r)->left;
					root = ::std::move(*next_r);
				}
			}
			else if (!(key <= root->key)) {
				if (!root->right)
					root->right = ::std::make_unique<node_type>(key);
				if (!(root->right->key <= key)) {
					*next_l = ::std::move(root);
					next_l = &(*next_l)->right;
					*next_r = ::std::move(*next_l);
					next_r = &(*next_r)->left;
					root = ::std::move(*next_r);
				}
				else if (!(key <= root->right->key)) {
					*next_l = ::std::move(root->right);
					root->right = ::std::move((*next_l)->left);
					(*next_l)->left = ::std::move(root);
					next_l = &(*next_l)->right;
					root = ::std::move(*next_l);
				}
				else {
					*next_l = ::std::move(root);
					next_l = &(*next_l)->right;
					root = ::std::move(*next_l);
				}
			}
			else {
				*next_l = ::std::move(root->left);
				root->left = ::std::move(left);
				*next_r = ::std::move(root->right);
				root->right = ::std::move(right);
				return root->value;
			}
		}
	}
};

#include <cstdio>
#include <map>
using i64 = long long;
void scan(i64 &d) {
	d = 0;
	bool f = 0;
	int c;
	while (c = fgetc(stdin), c == ' ' || c == '\n');
	if (c == '-') f = 1, c = fgetc(stdin);
	do d = d * 10 + c - '0'; while (c = fgetc(stdin), c != ' '&&c != '\n');
	if (f) d = -d;
}

int main() {
	using i64 = long long;
	i64 n;
	scan(n);

	::std::map<i64, i64> mp;
	i64 a, sum = 0, ans = 0;
	mp[0] = 1;

	while (n--) {
		scan(a);
		
		sum += a;
		ans += mp[sum]++;
	}

	printf("%lld\n", ans);

	return 0;
}


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

#define loop(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
P p[202];
P q[1002];

int main(){
	int m, n, x, y;
	cin >> m;
	while (m){
		loop(i, m){
			cin >> x >> y;
			p[i] = P(x, y);
		}
		cin >> n;
		loop(i, n){
			cin >> x >> y;
			q[i] = P(x, y);
		}
		sort(p, p + m);
		sort(q, q + n);
		loop(j, n){
			int dx = q[j].first - p[0].first;
			int dy = q[j].second - p[0].second;
			bool f = 1;
			loop(i, m){
				if (i == 0)continue;
				if (!binary_search(q, q + n, P(p[i].first + dx, p[i].second + dy))){
					f = 0;
					break;
				}
			}
			if (f){
				cout << dx << " " << dy << endl;
				break;
			}
		}
		cin >> m;
	}
	return 0;
}

Measured memory_bytes: 3004
#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;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define n_max 5005


int A[n_max];
int n,k;

bool judge( int ind){
    int dp[5000]={};
    if(A[ind] >=k) return true;
    dp[0]=1;
    REP(i,n){
        int a= A[i];
        if(i==ind) continue;
        REPR(j,k){
            if( j-a >= 0 and dp[j-a] ==1 ) dp[j]=1;
        }
    }
    FOR(i,k-A[ind],k) if(dp[i] == 1) return true;
    return false;
}
int main(){
    cin >> n >> k;
    REP(i,n) cin >> A[i];
    sort(A,A+n);
    int left = -1;
    int right = n-1;
    int mid;
    while(1){
        if(left + 1 >= right ) break;
        mid=(left + right) / 2;
        if(judge(mid)){
            right= mid-1 ;
        }
        else left = mid;
    }

    if(judge(right)){
        cout << left + 1  << endl;
    }
    else cout << right +1 << endl;


}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define LL long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;

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

int main(){
	int n;

	while(cin >> n, n){
		vector<LL> a;
		REP(i, n){
			LL n;
			cin >> n;
			a.pb(n);
		}
		sort(a.begin(), a.end());

		LL ans = INF;

		REP(i, n - 1){
			if(abs(a[i] - a[i + 1]) < ans) {
				ans = abs(a[i] - a[i + 1]);
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll x[5];
	ll ans;
	for(int i=0;i<5;i++){
		cin>>x[i];
		if(x[i]==0)ans=i+1;
	}
	cout<<ans;
	return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  ll a,b,n; cin>>a>>b>>n;
  if(n<b-1)cout<<a*n/b<<endl;
  else cout<<a*(b-1)/b<<endl;
}


Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main()
{
int a,b,c,d,e;
cin>>a>>b>>c>>d>>e;
if(a==0)cout << 1;
if(b==0)cout << 2;
if(c==0)cout << 3;
if(d==0)cout << 4;
if(e==0)cout << 5;


}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include <stdlib.h>
#define M 100000
using namespace std;
  
int main(){
    int n, m,l = 0;
    int pos = 0;
    int ans = 0;
    int x[100010];
    scanf("%d %d",&n,&m);
    x[0] = 0;
    for (int i = 1; i < n; i++){
        scanf("%d", &x[i]);
        x[i] += x[i - 1];
    }
    while (m--){
        scanf("%d", &l);
        if(l > 0){
            ans += x[pos + l] - x[pos];
        }
        else{
            ans -= x[pos + l] - x[pos];
        }
        pos += l;
        ans %= M;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 1580
N, M = map(int, input().split())

answer = [0] * N
penalty = [0] * N
P = 0

for i in range(M):
    p_tmp, s_tmp = input().split()   
    p_tmp = int(p_tmp) - 1

    if(answer[p_tmp] == 0):
        # 正解
        if s_tmp == 'AC':
            answer[p_tmp] = 1
            P += penalty[p_tmp]
        else:
            penalty[p_tmp] += 1

print(sum(answer), P)

Measured memory_bytes: 4596
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

int main(){
    ll a,b,k;
    cin >> a >> b >> k;

    rep(i,k){
        if(i%2==0){
            if(a%2==1){
                a--;
            }
            a /= 2;
            b += a;
        }
        else{
            if(b%2 == 1){
                b--;
            }
            b /= 2;
            a += b;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}

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

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)

class UnionFindTree{

private:
  // indexツづ個青板づ個親ツノツーツド
  vector<int> par;
  // indexツづーツ債ェツづつキツづゥツ姪伉づ個δ可δ督ク
  vector<int> rank;
  // ツ姪伉づ個催妥・ツ値
  int treeSize;
  
public:
  UnionFindTree(int initTreeSize = 1000){
     // ツ暗クツ青板づ与ツつヲツづァツづェツつスツ値ツづーツ催妥・ツ格ツ納ツ青板づつキツづゥUnionFindTreeツづ個催ャツ青ャ
    treeSize = initTreeSize;
    init();
  }
  
  
  void init(){
    
    for(int i = 0; i < treeSize; i++){
      par.push_back(i);
      rank.push_back(0);
    }
    
  }

  // ツ与ツつヲツづァツづェツつスツ青板つェツ格ツ納ツつウツづェツづつ「ツづゥツ姪伉づ個δ仰ーツトツづーツ探ツ催オ
  int find(int x){
    
    if(par[x] == x){
      return x;
    }
    else{
      return par[x] = find(par[x]);
    }
    
  }
  
  void unite(int x,int y){
    
    x = find(x);
    y = find(y);
    
    if(x == y)
      return;
    
    if(rank[x] < rank[y]){
      par[x] = y;
    }
    else{
      par[y] = x;
      if(rank[y] == rank[x]){
	rank[x]++;
      }
    }
    
  }
  
  bool same(int x,int y){
    return find(x) == find(y);
  }

};
class Circle{
public:
	double x,y,z,r;
	Circle(){}
	Circle(double x_,double y_,double z_,double r_){
		x=x_;
		y=y_;
		z=z_;
		r=r_;
	}
};

const int MAX_V = 200;

double cost[MAX_V][MAX_V];
double mincost[MAX_V];
bool used[MAX_V];

int V;
const double INF = 1000000000;

double prim(){
	for(int i = 0; i < V; i++){
		mincost[i] = INF;
		used[i] = false;
	}
	mincost[0] = 0;
	double res = 0;
	while(1){
		int v = -1;
		// Xツづ可堕ョツつウツづ按つ「ツ陳クツ点ツづ個つ、ツつソXツつゥツづァツづ個陛督づ個コツスツトツつェツ催渉ャツづ可づ按づゥツ点ツづーツ探ツつキ
		for(int u = 0; u < V; u++){
			if(!used[u] && (v == -1 || mincost[u] < mincost[v]))
				v = u;
		}
		if(v==-1)
			break;
		used[v] = true;
		res += mincost[v];
		
		for(int u = 0; u < V; u++){
			mincost[u] = min(mincost[u],cost[v][u]);
		}
	}
	return res;
}


int main(){

	int n;
	while(cin>>n&&n!=0){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cost[i][j]=INF;
			}
		}
		V=n;
		vector<Circle> vc;
		for(int i = 0; i < n; i++){
			Circle c;
			cin>>c.x>>c.y>>c.z>>c.r;
			vc.push_back(c);
		}
		//UnionFindTree uft(n);
		//for(int i = 0; i < n; i++){
		//	for(int j = i+1; j < n; j++){
		//		//if(i==j)
		//		//	continue;
		//		double dist=sqrt((vc[i].x-vc[j].x)*(vc[i].x-vc[j].x)
		//			+(vc[i].y-vc[j].y)*(vc[i].y-vc[j].y)
		//			+(vc[i].z-vc[j].z)*(vc[i].z-vc[j].z));
		//		// ツ重ツづ按づづつ「ツづゥ
		//		if(EQ(dist,(vc[i].r+vc[j].r))||(dist<(vc[i].r+vc[j].r))){
		//			uft.unite(i,j);
		//			break;
		//		}
		//	}
		//}
		// ツ重ツづ按づづつ「ツづゥツづÍRXg0Ìm[hð£ÁÄ¨­
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(i==j)
					continue;
				//if(uft.same(i,j)){
				//	cost[i][j]=0;
				//}
				//else{
				double dist=sqrt((vc[i].x-vc[j].x)*(vc[i].x-vc[j].x)
					+(vc[i].y-vc[j].y)*(vc[i].y-vc[j].y)
					+(vc[i].z-vc[j].z)*(vc[i].z-vc[j].z));
				cost[i][j]=dist-(vc[i].r+vc[j].r);
				if(cost[i][j]<0)
					cost[i][j]=0;
				//}
			}
		}
		double res=prim();
		printf("%.3f\n",res);
	}


	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, X,j,x;
  int L[100], A;
  cin >> N >> X;
  
  for(int i=0; i < N;i++){
  	cin >> A;
    L[i] = A;
  } 
 
   x = 0;
   for(int i=0;i<N;i++){
     x += L[i];
     j++;
     if(x > X){
     	break;
     }
   }
  cout << j << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N; cin >> N;
	ll res = 0;
	FOR(i,1,N+1) {
		if (i % 3 == 0 || i % 5 == 0) continue;
		res += i;
	}
	cout << res << endl;
}

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


Measured memory_bytes: 3624
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;
 
 int main()
 {
   string A,B;
   int n;
   int is_first=1;
   long long int result=1;
   while(cin>>n>>A>>B)
   {
     for(int i=0;i<n;i++)
     {
       if(A[i]==B[i])
       {
         if(is_first)
         {
           result=(result*3)%1000000007;
         }
         else
         {
           if(A[i-1]!=B[i-1]) result=result*1;
           else result=(result*2)%1000000007;    
         }                
       }
       else
       {
         if(is_first) result=(result*6)%1000000007;
         else 
         {
           if(A[i-1]!=B[i-1]) result=(result*3)%1000000007;
           else result=(result*2)%1000000007;  
         }
         i++;
       }        
       is_first=0;
     }                  
     cout<<result<<endl;
   }
   //while(1);
   return 0;
 }
 

Measured memory_bytes: 256
#%%
N = int(input())
A = list(map(int, input().split()))
l = []

for i in range(N):
    for j in range(len(A)-1, -1, -1):
        if A[j] == j+1:
            l.append(A[j])
            A.pop(j)
            break

l = l[::-1]

if len(A) == 0:
    for i in range(len(l)):
        print(l[i])
else:
    print(-1)



#%%


Measured memory_bytes: 3064
r,c=gets.split(" ").map(&:to_i)
h = Array.new(r+1).map{Array.new(c+1,0)} 

for i in 1..r

a= gets.split.map(&:to_i)
    for j in 1..c
    h[i-1][j-1] = a[j-1]
    h[i-1][c] += a[j-1]
    h[r][j-1] += a[j-1]
    h[r][c] += a[j-1]
    end
end
for i in 0..r
    for j in 0..c
      print " " unless j == 0
      print h[i][j]
    end
    print "\n"
  end



Measured memory_bytes: 7048
#include <stdio.h>

#define N 8
#define FREE 1
#define NOT_FREE 0

void scan();
void putQueen(int);
void printBoard();

int row[N], col[N], dpos[15], dneg[15], Queen[N][N], c=0;

int main(){
  int a, b;
  for(a = 0; a < N; a++){
    row[a] = col[a] = FREE;
  }
  for(a = 0; a < 15; a++){
    dpos[a] = dneg[a] = FREE;
  }
  for(a = 0; a < N; a++){
    for(b = 0; b < N; b++){
      Queen[a][b] = -1;
    }
  }
  scan();
  putQueen(0);
  //printBoard();
  return 0;
}

void scan(){
  int a, k, r, c;
  scanf("%d",&k);
  for(a = 0; a < k; a++){
    scanf("%d%d",&r,&c);
    Queen[r][c] = 0;
  }
}

void putQueen(int a){
  int b;
  if(a == N){
    printBoard();
    return;
  }
  for(b = 0; b < N; b++){
    if(col[b] == FREE && dpos[a+b] == FREE && dneg[a-b+N-1] == FREE){
      row[a] = b;
      col[b] = NOT_FREE;
      dpos[a+b] = NOT_FREE;
      dneg[a-b+N-1] = NOT_FREE;
      putQueen(a+1);
      row[a] = col[b] = FREE;
      dpos[a+b] = dneg[a-b+N-1] = FREE;
    }
  }
}

void printBoard(){
  int a, b;
  for(a = 0; a < N; a++){
    for(b = 0; b < N; b++){
      if(Queen[a][b] != -1){
	if(row[a] != b) return;
      }
    }
  }
  for(a = 0; a < N; a++){
    for(b = 0; b < N; b++){
      if(row[a] == b) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}



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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	int mx = 0, s = 0;
	for (int i = 0; i < n; i++) {
		int a; cin >> a; s += a;
		mx = max(mx, a);
	}
	cout << s - mx / 2 << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}
// 最大公約数を求める(ユークリッドの互除法).
long long gcd (long long x, long long y) {
  if (y > x) swap(x,y);
  if (y == 0) return x;
  return gcd(x%y,y);
}

// 最小公倍数を求める(lcm(a,b) = a*b / gcd(a,b)). overflowに気をつけよう
ll lcm (long long  x, long long y) {
  ll t = gcd(x,y);
  return (x / t) * y;
}
int main() {
  ll a,b;
  cin >> a >> b;
  auto t = lcm(a,b);
  cout << t << endl;
}


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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

struct segment_tree {
 private:
  int n;
  vector<int> node;

 public:
  segment_tree(vector<int> v) {
    int sz = v.size();
    n = 1;
    while (n < sz) n *= 2;
    node.resize(2 * n - 1);
    for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
    for (int i = n - 2; i >= 0; i--) node[i] = gcd(node[2 * i + 1], node[2 * i + 2]);
  }

  int get(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return node[k];

    int vl = get(a, b, 2 * k + 1, l, (l + r) / 2);
    int vr = get(a, b, 2 * k + 2, (l + r) / 2, r);
    return gcd(vl, vr);
  }
};

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &e : a) cin >> e;

  segment_tree s(a);
  int r = max(s.get(0, n - 1), s.get(1, n));
  for (int i = 1; i < n - 1; i++) {
    r = max(r, gcd(s.get(0, i), s.get(i + 1, n)));
  }
  cout << r << endl;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> P;
//#define rep(i,a,b) for(ll i=a ; i<b ; i++)
const int max_n = 1e5;
const ll mod = 1e9+7;
ll prime[max_n+1];
bool isp[max_n+1];
bool iss[max_n+1];
void segsieve(ll a, ll b){
  for(int i=0 ; (ll)i*i<b;i++) iss[i] = true;
  for(int i=0 ; i<b-a ; i++) isp[i] = true;

  for(int i=2 ;(ll)i*i<b; i++){
    if(iss[i]){
      for(int j=2*i; (ll)j*j<b ; j+=i){
        iss[j] = false;
      }
      for(ll j=max(2LL, (a+i-1)/i)*i ; j<b;j+=i){
        isp[j-a] = false;
      }
    }
  }
}
bool ispp[max_n+1];
bool isss[max_n+1];
void segsievee(ll a, ll b){
  for(int i=0 ; (ll)i*i<b;i++) isss[i] = true;
  for(int i=0 ; i<b-a ; i++) ispp[i] = true;

  for(int i=2 ;(ll)i*i<b; i++){
    if(isss[i]){
      for(int j=2*i; (ll)j*j<b ; j+=i){
        isss[j] = false;
      }
      for(ll j=max(2LL, (a+i-1)/i)*i ; j<b;j+=i){
        ispp[j-a] = false;
      }
    }
  }
}
int main(){
  ll n,k; cin >> n;
  int MAX = 101010;
    vector<int> is_prime(MAX, 1);
    is_prime[0] = 0, is_prime[1] = 0;
    for (int i = 2; i < MAX; ++i) {
        if (!is_prime[i]) continue;
        for (int j = i*2; j < MAX; j += i) is_prime[j] = 0;
    }

    // 2017-like 数かどうか
    vector<int> a(MAX, 0);
    for (int i = 0; i < MAX; ++i) {
        if (i % 2 == 0) continue;
        if (is_prime[i] && is_prime[(i+1)/2]) a[i] = 1;
    }

    // 累積和
    vector<int> s(MAX+1, 0);
  for(int i=0 ; i<MAX ; i++){
    s[i+1] = s[i] + a[i];
  }
  for(int i=0 ; i<n ; i++){
    int l,r;  cin >> l >> r;
    ++r;
    cout << s[r]-s[l] << endl;
  }
  return 0;
}


Measured memory_bytes: 1792