akhauriyash/Code-Regression huggingface dataset:
from math import ceil


def log(s):
    # print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


def input_ints():
    return map(int, input().split())


cache = dict()


def solve(goal, count, meta):
    if (goal <= 0):
        return count

    s = frozenset([m[1] for m in meta])
    if s in cache:
        return cache[s]

    min_count = 999999999

    for m in meta:
        meta2 = list(meta)
        meta2.remove(m)
        c = solve(goal - m[3], count + m[0], meta2)
        if c < min_count:
            min_count = c

    for m in reversed(meta):
        if goal - m[0] * m[1] > 0:
            continue
        c = count + ceil(goal / m[1])
        if c < min_count:
            min_count = c
        break

    cache[s] = min_count

    return min_count


def main():
    d, goal = tuple(input_ints())

    meta = list()
    for i in range(d):
        problems, bonus = tuple(input_ints())
        score = (i + 1) * 100
        meta.append((problems, score, bonus, score * problems + bonus))

    count = solve(goal, 0, meta)
    print(count)


main()


Measured memory_bytes: 3428
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n,k; cin >> n >> k;
    vector<int>h(n);
    for(auto & e: h) cin >> e;
    vector<int>d(n,INF);d[0] = 0;
    vector<vector<pii>>edge(n);
    for(int v = 0; v < n;v++){
        for(int nv = v+1; nv <= v + k  and nv < n ;nv++){
            edge[v].push_back(pii(nv,abs(h[v] - h[nv])));
        }
    }
    priority_queue<pii,vector<pii>,greater<>>que;
    que.push(pii(d[0],0LL));
    while(!que.empty()){
        auto top = que.top();
        que.pop();
        int dis = top.first;
        int v = top.second;
        if(dis > d[v])continue;
        for(auto e : edge[v]){
            int nv = e.first;
            int cost = e.second;
            if(dis + cost < d[nv]){
                d[nv] = dis + cost;
                que.push(pii(d[nv],nv));
            }
        }
    }
    cout << d.back() << endl;
}



Measured memory_bytes: 207736
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		String s = scan.next();
		if (s.length() < 6) {
			System.out.println("No");
		}
		
		if (s.charAt(2) == s.charAt(3)
				&& s.charAt(4) == s.charAt(5)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>>  var(n, vector<int>(m, 0))
#define vecb2(var, n, m)   vector<vector<bool>> var(n, vector<bool>(m, false))
#define vecll2(var, n, m)  vector<vector<ll>>   var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arrll(a,n);

  rep(i,n){
    a[i] -= i;
  }

  sortall(a);
  ll ans=0;
  ll b;
  if(n%2==1){
    b = a[n/2];
  } else {
    b = (a[n/2]+a[n/2-1])/2;
  }

  rep(i,n){
    ans += abs(a[i]-b);
  }

  prt(ans);
}


Measured memory_bytes: 4788
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n, x;
	cin >> n >> x;
	if (n < x)cout << 0 << endl;
	else {
		cout << 10 << endl;
	}
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int t = (s.size()-1)/2, c = 0;
  for(int i = 0;i <=t/2;i++){
      if(s.at(i) != s.at(t-1-i) || s.at(i) != s.at(t+1+i) || s.at(i) != s.at(t-i+t)){
        cout << "No" << endl;
        c = 1;
        break;
      }
  }
  if(c==0){cout << "Yes" << endl;
  }
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    string tmp;
    vi a(n);
    REP(i, n) {
      cin >> tmp;
      a[i] = SZ(tmp);
    }
    REP(i, n) {
      vi b = {5, 7, 5, 7, 7};
      int cnt = 0;
      bool ok = false;
      FOR(j, i, n) {
        if(b[cnt] < a[j]) {
          break;
        } else if(b[cnt] == a[j]) {
          if(cnt == 4) {
            ok = true;
            break;
          } else {
            cnt++;
          }
        } else {
          b[cnt] -= a[j];
        }
      }
      if(ok) {
        cout << i+1 << endl;
        break;
      }
    }
  }
}



Measured memory_bytes: 3016
from operator import itemgetter
from scipy.sparse import lil_matrix, csr_matrix
from scipy.sparse.csgraph import minimum_spanning_tree

def main():
    N = int(input())
    M = 10**10
    XY = [tuple(map(int, input().split())) for _ in range(N)]
    xy = [(x, i) for i, (x, _) in enumerate(XY)]
    yx = [(y, i) for i, (_, y) in enumerate(XY)]
    xy.sort()
    yx.sort()
    d = {}
    x1, i1 = xy[0]
    for x, i in xy[1:]:
        t = (i1, i) if i1 < i else (i, i1)
        d[t] = min(abs(x1 - x), d.get(t, M))
        x1, i1 = x, i
    x1, i1 = yx[0]
    for x, i in yx[1:]:
        t = (i1, i) if i1 < i else (i, i1)
        d[t] = min(abs(x1 - x), d.get(t, M))
        x1, i1 = x, i
    row = list(map(itemgetter(0), d.keys()))
    col = list(map(itemgetter(1), d.keys()))
    c = csr_matrix((list(d.values()), (row, col)), shape=(N, N))
    a = minimum_spanning_tree(c, overwrite=True)
    return int(a.sum())

print(main())


Measured memory_bytes: 95172
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
//============================================================
var sc = bufio.NewScanner(os.Stdin)

func setScSplit() { sc.Split(bufio.ScanWords) }

func readStr() string {
	sc.Scan()

	return sc.Text()
}

func readInt() int {
	i, _ := strconv.Atoi(readStr())

	return i
}

func readFloat() float64 {
	f, _ := strconv.ParseFloat(readStr(), 64)

	return f
}
//=============================================================
var s string

func main(){
	s = readStr()

	for i := 0; i < len(s) - 1; i++ {
		if s[i: i + 2] == "AC" {
			fmt.Println("Yes")
			return
		}
	}

	fmt.Println("No")

	return
}

Measured memory_bytes: 640
#!/usr/bin/env python3
import sys

def kaijyo(n):
    if n == 0:
        return 1
    return n * kaijyo(n-1)

def z(n):
    return -n if n<0 else n

def numi(X, y):
    T = sorted(X)
    i = T.index(y)
    #print("#",X,i)
    return i

def solve(N: int, P: "List[int]", Q: "List[int]"):
    ans=0
    for i in range(N):
        ans+=(numi(P[i:], P[i]) - numi(Q[i:], Q[i])) * kaijyo(N - i - 1)
        #print(ans)
    print(z(ans))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    Q = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P, Q)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include<cstring>
#include <math.h>
typedef long long ll;
using namespace std;
using namespace std;
const int MAXN = 2e5+7;
int main()
{
    long long int n,m;
    scanf("%lld %lld",&n,&m);
    if(n==1||m==1)
    {
        cout<<1;
        return 0;
    }
    if(m%2==0)
    {
        cout<<n*(m/2);
    }
    else
    {
        if(n%2==0)
        {
            cout<<n*(m/2)+n/2;
        }
        else
        {
            cout<<n*(m/2)+n/2+1;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int min(int a, int b) {
  if (a < b) return a;
  else return b;
}
int ze(int a) {
  int t = min(a, 0);
  int j = a - 2 * t;
  return j;
}
int main () {
  int N;
  cin >> N;
  int h[1100000];
  for (int i = 0; i < N; i ++) {
    cin >> h[i];
  }
  int cost[100000];
  cost[2] = ze(h[1] - h[0]);
  int k = cost[2] + ze(h[2] - h[1]);
  int j = ze(h[2] - h[0]);
  cost[3] = min(k, j);
  for(int i = 4; i <= N; i ++) {
    int a = cost[i - 1] + ze(h[i - 1] - h[i - 2]);
    int b = cost[i - 2] + ze(h[i - 1] - h[i - 3]);
    cost[i] = min(a, b);
  }
  cout << cost[N] << endl;
}
    


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+10;

long long x[N];

int main ()
{
	long long n, a, b;
	cin >> n >> a >> b;
	for (int i = 0 ; i < n ; i ++) {
		cin >> x[i];
	}
	long long sum = 0;
	for (int i = 1; i < n ; i++) {
		sum += min((x[i]-x[i-1]) * a, b);
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    string S;
    cin >> N >> S >> K;
    char c = S[K - 1];
    REP(i, N) {
        if (S[i] != c) {
            S[i] = '*';
        }
    }
    cout << S << endl;
    return 0;
}


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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  int n,m;cin>>n>>m;

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

  int p=0; int q=0;
  rep(i, n-1){
    p +=(x[i+1]-x[i])*(1+i)*(n-1-i);
    p %=MOD;
  }
  rep(i, m-1){
    q +=(y[i+1]-y[i])*(1+i)*(m-1-i);
    q %=MOD;
  }
  cout << (p*q)%MOD << endl;


  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 1792
#include "stdio.h"

int main(void)
{
	int i,j;
	int max = 0;
	int K,T;
	int a[100] = {0};


	scanf("%d %d", &K,&T);
	for(i = 0; i < T; i++)
	{
		scanf("%d", &a[i]);
	}

	for(i = 0; i < T; i++)
	{
		if (max < a[i])
		{
			max = a[i];
		}
	}

	if (max <= K / 2)
	{
		printf("0\n");
	}else
	{
		printf("%d\n", 2 * max - K - 1);
	}


	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,flag=0;
	cin>>n;
	while(n>0){
		if(n%10==7){
		flag=1;
		cout<<"Yes"<<endl;
		return 0; 
		} 
		n/=10;
} 
	if(flag==0){
		cout<<"No"<<endl;
	}
    return 0;
}

Measured memory_bytes: 3636
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//int→string
//string→int
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//sqrt
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define REPR(i, n) for(int i = n;i >= 0;i--)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


//#define EPS (1e-10)
//
//struct Point{
//    Point(double _x = 0, double _y = 0){
//        x = _x;
//        y = _y;
//    }
//    double x;
//    double y;
//
//    Point operator + (Point p){
//        return Point(x + p.x, y+ p.y);
//    }
//
//    Point operator - (Point p){
//        return Point(x - p.x, y - p.y);
//    }
//
//    Point operator * (double a){
//        return Point(a * x, a * y);
//    }
//
//    Point operator / (double a){
//        return Point(x / a, y / a);
//    }
//
//    double abs(){
//        return sqrt(norm());
//    }
//
//    double norm(){
//        return x * x + y * y;
//    }
//
//    bool operator < (const Point &p) const{
//        return x!=p.x ? x < p.x : y < p.y;
//    }
//
//    bool operator == (const Point &p) const{
//        return fabs(x - p.x) && fabs(y - p.y) < EPS;
//    }
//
//};
//
//typedef Point Vector;
//
//double dot(Vector a, Vector b){
//    return a.x * b.x + a.y * b.y;
//}

int main() {

    int N; scanf("%d", &N);
    VI a(N);
    REP(i,N){
        scanf("%d", &a[i]);
    }
    SORT(a);
    printf("%d", a[a.size()-1] - a[0]);

    return 0;

}

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(){
  int64_t n,z,w;
  cin >> n >> z >> w;
  int64_t k[n];
  rep(i,n)cin >> k[i];
  int64_t y[n];
  int64_t u[n];
  y[0]=0;
  u[0]=0;
  int64_t mi=1000000000000;
  int64_t ma=0;
  rep(i,n-1){
    int q=n-2-i;
    y[q]=max(ma,abs(k[q]-k[n-1]));
    u[q]=min(mi,abs(k[q]-k[n-1]));
    mi=min(mi,y[q]);
    ma=max(ma,u[q]);
  }
  int64_t ans=0;
  rep(i,n-1)ans=max(ans,u[i]);
  cout << max(ans,abs(w-k[n-1])) << endl;
}


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

using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace

#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);	
    ll a, b, t;
    cin >> a >> b >> t;
    cout << t / a * b << '\n';
}



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

int main(){
  int size_a, size_b;
  int ans = 0;
  cin >> size_a >> size_b;
  
  for(int i=0; i<2; i++){
	if(size_a > size_b){
      ans += size_a;
      size_a--;
    }else{
      ans += size_b;
      size_b--;
    }
  }
  cout << ans << endl;
}


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

int main()
{
    size_t N;
    cin >> N;
    vector<double> V(N);
    for (auto&& v : V)
    {
        cin >> v;
    }

    sort(begin(V), end(V), [](auto a, auto b) { return a > b; });

    while (true)
    {
        if (V.size() == 1)
        {
            cout << V.at(0) << endl;
            break;
        }
        double result = (V.at(V.size() - 1) + V.at(V.size() - 2)) / 2;
        V.resize(V.size() - 2);
        V.push_back(result);
        sort(begin(V), end(V), [](auto a, auto b) { return a > b; });
    }
}


Measured memory_bytes: 256
import numpy as np
N,K = map(int,input().split())
p = list(map(int,input().split()))

l = []
for i in range(N):
    l.append((1+p[i])/2)

a = [0] * N
a[0] = l[0]
for i in range(1,len(l)):
    a[i] = a[i-1] + l[i]

ans = 0
for i in range(K,len(l)):
    ans = max(ans,a[i]-a[i-K])

if N - K == 0:
    print(max(a))
else:
    print(ans)

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

int main(){
	vector<int> v;
	for(int i = 0;i < 10;i++){
		int n;
		cin >> n;
		v.push_back(n);
	}
	sort(v.begin(), v.end());
	//cout << endl;
	for(int i = 9; i >=7;i--){
		cout << v[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
import java.io.*;
import java.util.*;
import java.util.ArrayList;
public class Main{
	public static void main(String [] args)throws IOException{
    InputStreamReader isr = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(isr);
		String s = br.readLine();
		int count=0;
		for(int i=0;i<s.length()-1;i++)
		{
			if(s.charAt(i)!=s.charAt(i+1))
		  count++;
}
System.out.println(count);
}
}


Measured memory_bytes: 24916
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)



int main() {
	int n, m,cnt=0,elem0;
	cin >> n >> m;
	VI y(m), pla(m);
	vector<tuple<int, int,int>> t;
	vector <pair<int, int>> pair_ans(m);
	rep(i, m) {
		cin >> pla[i] >> y[i];
		t.emplace_back(pla[i],y[i],i);
	}
	sort(all(t));

	rep(i, m) {
		cnt++;
		elem0 = get<0>(t[i]);
		if (i != 0 && elem0 != get<0>(t[i - 1])) {
			cnt = 1;
		}
		//cout << elem0 << endl;
		pair_ans[get<2>(t[i])].first = elem0;
		pair_ans[get<2>(t[i])].second = cnt;
	}


	/*rep(i, m) {
		cout << get<0>(t[i]) << " " << get<1>(t[i]) << " " << get<2>(t[i]) << endl;
	}*/

	rep(i,m) {
		cout<< setfill('0') << right <<setw(6)<< pair_ans[i].first;
		cout<< setfill('0') << right << setw(6) << pair_ans[i].second << endl;
	}

	return 0;
}




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

ll a,b,c,d;

int main(){
    cin >> a >> b >> c >> d;
    ll ans=max({a*c,a*d,b*d,b*c});
    cout << ans << endl;
    return 0;
}  


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int ans=0;
  for(int i=0; i<7; i++){
    N/=2;
    if(N<1){
      ans=i;
      break;
    }
  }
  int a=pow(2,ans);
  cout<<a<<endl;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e6+50;
char s[maxn];
int main(){
    std::ios::sync_with_stdio(false);
    cin>>s;
    string x;
    int n=strlen(s);
    int ans=0;
    for(int i=n-1;i>=1;i--){
        if(s[i]=='0'+10){
            s[i-1]+=1;
            s[i]='0';
            continue;
        }
        if(s[i]>='6'||(s[i-1]>='5'&&s[i]=='5')){
            s[i-1]+=1;
            ans+='0'+10-s[i];
        }else{
            ans+=s[i]-'0';
        }
    }
    if(s[0]=='0'+10){
        ans+=1;
    }
    else{
        if(s[0]>='6'){
            ans+='0'+10-s[0]+1;
        }else{
            ans+=s[0]-'0';
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;


int main(){
  ll n;
  cin >> n;
  vll a(n);
  vin(a);
  bool ans = false;
  ll now = 0, time = 0;
  rep(i, 0, n){
    now = a.at(now) - 1;
    time++;
    if(now == 1){
      ans = true;
      break;
    }
  }
  cout << (ans ? time : -1) << endl;
}

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

using namespace std;

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

    vector<char> l;
    l.push_back('a');
    l.push_back('b');
    l.push_back('c');
    l.push_back('d');
    l.push_back('e');
    l.push_back('f');
    l.push_back('g');
    l.push_back('h');
    l.push_back('i');
    l.push_back('j');
    l.push_back('k');
    l.push_back('l');
    l.push_back('m');
    l.push_back('n');
    l.push_back('o');
    l.push_back('p');
    l.push_back('q');
    l.push_back('r');
    l.push_back('s');
    l.push_back('t');
    l.push_back('u');
    l.push_back('v');
    l.push_back('w');
    l.push_back('x');
    l.push_back('y');
    l.push_back('z');

    //バケット
    int b[30] = {0};
    for(int i=0;i<s.size();++i){
        for(int j=0;j<l.size();++j){
            if(s[i] == l[j]) b[j]++;
        }
    }

    char answer;
    bool hasAllChar = true;
    for(int i=0;i<l.size();++i){
        if(b[i] == 0){
            answer = l[i];
            hasAllChar = false;
            break;
        }
    }
    if(hasAllChar == false) cout << answer <<endl;
    else  cout << "None" <<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;

int main(){
    ll N, T;
    cin >> N >> T;
    vector<ll> t;
    for(ll i = 0; i < N; ++i){
        ll tmp;
        cin >> tmp;
        t.push_back(tmp);
    }
    ll ans = 0;
    for(ll i = 0; i < N-1; ++i){
        if (t[i+1] - t[i] < T) ans += t[i+1] - t[i];
        else ans += T;
    }
    ans += T;
    cout << ans << endl;
    return 0;
}

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

int main(){
  ll N;cin>>N;
  vector<ll> A(N);rep(i,N)cin>>A[i];
  sort(A.begin(),A.end(),greater<ll>());
  ll i=0,k=0,edge[2];
  edge[0]=0;edge[1]=0;
  while(k<2&&i<N-1){
    if(A[i]==A[i+1]){
      edge[k]=A[i];
      ++k;
      ++i;
    }
    ++i;
  }
  cout << edge[0]*edge[1] << endl;
}

Measured memory_bytes: 1024
n = int(input())
h = list(map(int,input().split()))
count = 0
for i in range(n-1):
    if h[i] > h[i+1] + 1:
        print('No')
        exit()
    elif h[i] == h[i+1] + 1:
        count += 1
        if count > 1:
            print('No')
            exit()
    elif h[i] == h[i+1]:
        count = count
    else:
        count = 0
print('Yes')


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const ll mod = 1777777777ll;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  map<string, int> mp;
  rep(i, n) {
    string s; cin >> s;
    ++mp[s];
  }
  int m; cin >> m;
  rep(i, m) {
    string t; cin >> t;
    --mp[t];
  }
  int ans = 0;
  for(auto x : mp) chmax(ans, x.second);
  cout << ans << endl;
}

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

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

#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)

const long double PI = acos(-1);

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}

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

Measured memory_bytes: 256
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n:usize,
        a:[u64;n],
    }
    let mut ans=0;
    for &aa in &a {
        ans+=aa-1;
    }
    println!("{}", ans);

}

Measured memory_bytes: 4352
let () =
    let split s =
        let rec loop i cur flag acc =
            if i = String.length s then ( if flag then cur :: acc else acc) else (
                match flag, s.[i] with
                | true,  ' ' -> loop (i + 1) "" false (cur :: acc)
                | false, ' ' -> loop (i + 1) "" false acc
                | true,  v   -> loop (i + 1) (Printf.sprintf "%s%c" cur v) true acc
                | false, v   -> loop (i + 1) (Printf.sprintf "%s%c" cur v) true acc
            )
        in
        List.map int_of_string (List.rev (loop 0 "" false []))
    in
    let main () =
        let n, d = Scanf.sscanf (read_line ()) "%d %d" (fun n d -> n, d) in
        let x = Array.init n (fun _ -> Array.of_list (split (read_line ()))) in
        let judge i =
            let f = float i in
            let sf = sqrt f |> floor in
            let g = int_of_float  (sf *. sf) in
            if i = g then 1 else 0
        in
        let rec loop_i i acc =
            let rec loop_j j acc =
                let rec loop_k k sum =
                    if k = d then judge sum else
                        let xd = x.(i).(k) - x.(j).(k) in
                        loop_k (k + 1) (sum + xd * xd)
                in
                if j = n then acc else loop_j (j + 1) (acc + loop_k 0 0)
            in
            if i = n - 1 then acc else loop_i (i + 1) (loop_j (i + 1) acc)
        in
        Printf.printf "%d\n" (loop_i 0 0)
    in
    main ()

Measured memory_bytes: 2432
//
//  main.cpp

#include <iostream>
using namespace std;

bool checked[501];
int n,m;
bool matrix[501][501];

void reset(){
	for(int i=0;i<501;i++){
		checked[i] = false;
		for(int j=0;j<501;j++){
			matrix[i][j] = false;
		}
	}
	n = m = 0;
}
void dfs(int depth,int now,int parent){
	if(depth >= 2)return;
	for(int i=1;i<501;i++){
//		if(checked[i])continue;
		if(i == now)continue;
		if(i == parent)continue;
		if(matrix[now][i]){
			checked[i] = true;
			dfs(depth+1,i,now);
		}
	}
}

int main(){
	while(1){
		reset();
		cin >> n >> m;
		if(n == 0 && m == 0)break;
		int input1,input2;
		for(int i=0;i<m;i++){
			cin >> input1 >> input2;
			matrix[input1][input2] = true;
			matrix[input2][input1] = true;
		}
		checked[1] = true;
		dfs(0,1,-1);
		int answer = 0;
		for(int i=2;i<501;i++){
			if(checked[i])answer++;
		}
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 3224
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());

        var data = new int[n];

        string str = Console.ReadLine();

        var strlist = str.Split(' ');

       for (int i = 0; i < n; i++)
        {
            data[i] = int.Parse(strlist[i]);
        }

        for (int i = n-1; i >= 0; i--)
        {
            if (i == 0)
            {
                Console.Write(data[i]);
            }
            else
            {
                Console.Write(data[i] + " ");
            }          
        }
        Console.WriteLine();
       
    }
}


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

using namespace std;
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}

int main() {
	fastio();

	int n; cin >> n;
	vector<double> p(n + 1); 
	for (int i = 1; i <= n; i++) cin >> p[i];
		
	vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0)); //STATE(No of coins, No. of Heads)
	
	dp[0][0]=1;
	double ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= i; j++) {
			dp[i][j] = ((dp[i - 1][j - 1] * p[i]) + (dp[i - 1][j] * ((double)1 - p[i])));
		}
	}

	cout << fixed << setprecision(15) ;
	for (int j = 1; j <= n; j++) if (j > n - j) ans += dp[n][j];
	cout << ans;

	return 0;
}


Measured memory_bytes: 73716
// 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 main() {
    input! {
        n: usize,
        a: [usize; n]
    }
    let mut a = a;
    a.sort();
    a.reverse();
    let mut alice =0;
    let mut bob = 0;
    for (i, &ai) in a.iter().enumerate() {
        if i % 2 == 0 {
            alice += ai;
        } else {
            bob += ai;
        }
    }
    println!("{}", alice - bob);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n;cin>>n;
  ll sum=0;
  for(auto i=1;i<=n;++i)
    if(i%3!=0&&i%5!=0)
      sum+=i;
  cout<<sum<<endl;
}

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

using namespace std;

const int INF_32 = 2e9;

struct PersistentUF {
	vector<int> par;
	vector<int> size;
	vector<int> time;
	int clock = 0;

	PersistentUF(int n) { init(n); }

	void init(int n) {
		par.resize(n);
		size.assign(n,1);
		time.assign(n,INF_32);
		for (int i = 0; i < n; ++i) par[i] = i; 
	}
	
	int scale(int x, int t = INF_32 - 1) {
		return size[find(x,t)];
	}

	int find(int x, int t = INF_32 - 1) {
		if(time[x] > t) return x;
		return find(par[x],t);
	}

	bool is_same(int x, int y, int t = INF_32 - 1) {
		return find(x,t) == find(y,t);
	}

	int unite(int x, int y) {
		++clock;
		x = find(x);
		y = find(y);
		if(x != y) {
			if(size[x] < size[y]) swap(x,y);
			size[x] += size[y];
			par[y] = x;
			time[y] = clock; 
		}
		return clock;
	}
};

int main(){
	int n,e;
	cin >> n >> e;
	PersistentUF puf(n);
	vector<tuple<int,int,int>> v;
	for(int i = 1; i <= e; ++i){
		int s,t,w;
		cin >> s >> t >> w;
		v.push_back(make_tuple(w,s,t));
	}
	int ans = 0;
	sort(begin(v),end(v));
	for(auto p : v){
		int c = get<0>(p);
		int s = get<1>(p);
		int t = get<2>(p);
		if(!puf.is_same(s,t)){ puf.unite(s,t),ans += c; }
	}
	cout << ans << endl;
}








Measured memory_bytes: 4636
import sys
input=sys.stdin.readline #文字列入力はするな！！
import heapq
n,m=map(int,input().split())
a=[]
for i in input().split():
    heapq.heappush(a,-int(i))
for i in range(m):
    p=-heapq.heappop(a)
    p=p//2
    heapq.heappush(a,-p)
print(-sum(a))



Measured memory_bytes: 85972
#include<iostream>

int r,c;//r縦c横
bool senbei[10][10000];//0の数を増やす
bool yotei[10];
int ans=0;

int keisan(){
	int res=0;
	for(int j=0;j<c;j++){
		int t=0;
		for(int i=0;i<r;i++){
			if((!yotei[i]&&senbei[i][j])||(yotei[i]&&!senbei[i][j])){
				t++;//裏返してないならせんべいの０を　裏返してるならせんべいの１を数える
			}
		}
		if(t>r-t)res+=t;
		else res+=(r-t);
	}
	return res;
}


void func(int _r){
	if(_r==r){
		ans=std::max(ans,keisan());
		return ;
	}
	yotei[_r]=false;//裏返す
	func(_r+1);
	yotei[_r]=true;//裏返さない
	func(_r+1);
}

int main(){
	while(std::cin>>r>>c,r*c){
		for(int i=0;i<r;i++)for(int j=0;j<c;j++)std::cin>>senbei[i][j];
		func(0);
		std::cout<<ans<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	k := iScan()
	s := iScan()
	ans := 0
	for i := 0; i <= k; i++ {
		for j := 0; j <= k; j++ {
			if s-i-j >= 0 && s-i-j <= k {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


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

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

    int p=0;
    for(int i=1; i<20; i++){
        if(pow(2,i) > l) break;
        p += 1;
    }

    l = l - pow(2,p);
    int count = 0;
    vector<vector<int>> ans;
    for(int i=p; i>=1; i--){
        if(l - pow(2,i-1) >= 0){
            ans.push_back({i, p+1, l - (int)pow(2,i-1) + (int)pow(2,p)});
            count += 1;
            l -= pow(2,i-1);
        }
    }

    cout << p+1 << " " << 2*p + count << endl;
    for(int i=0; i<p; i++){
        cout << i+1 << " " << i+2 << " " << 0 << endl;
        cout << i+1 << " " << i+2 << " " << pow(2,i) << endl;
    }
    for(int i=0; i<count; i++){
        cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
private val readString: ()->String = {readLine()!!}
private val readInt: ()->Int = { readLine()!!.toInt() }
private val readLong: ()->Long = { readLine()!!.toLong() }
private val readListInt: ()->List<Int> = { readLine()!!.split(' ').map(String::toInt) }
private val readListLong: ()->List<Long> = { readLine()!!.split(' ').map(String::toLong) }
private val errPrintln: (String)->Unit = { msg -> System.err.println(msg) }
private const val MOD = 1_000_000_007L


fun solveD(N: Int, K: Long, A:Array<Int>): Int {

    var step = Array<Long>(N){-1}
    tailrec fun dfs(x: Int, sp:Long): Pair<Int, Long> {
        if (sp>=K) {
            return Pair(x, -1L);
        }

        if (step[x] >= 0L) {
            return Pair(x,sp)
        }

        step[x] = sp
        return dfs(A[x], sp + 1L)
    }

    var pos = dfs(0, 0L)
    if (pos.second < 0L) {
        return pos.first + 1;
    }

    errPrintln("pos: ${pos.first}")
    errPrintln("step[start]: ${step[pos.first]}")
    errPrintln("step[end]: ${pos.second}")

    val move = (K - step[pos.first]) % (pos.second - step[pos.first])
    errPrintln("move: $move")
    assert(move < K)

    tailrec fun dfs2(n: Long, x: Int): Int {
        if (n >= move) {
            return x
        }
        return dfs2(n + 1L, A[x])
    }

    return dfs2(0L, pos.first) + 1
}


fun main(args: Array<String>) {
    val (n,K) = readListLong()
    val N = n.toInt()
    val a = readListInt()
    var A = Array<Int>(N){0}
    for(i in 0 until N) {
        A[i] = a[i] - 1
    }

    val ans = solveD(N, K, A)

    println(ans)
}


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

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class ACurtain {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int A, B;
        in>>A>>B;
        out<<max(0, A-2*B)<<'\n';
    }
};


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


Measured memory_bytes: 3644