akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

vector<vector<int>>graph;
int dp[100005];

int rec(int v){//メモ化再帰なら更新順が関係ない
    if(dp[v]>=0)return dp[v];
    int maxv=0;
    for(auto x:graph[v]){
        maxv=max(maxv,rec(x)+1);
    }
    return dp[v]=maxv;
}
int main(){
    int n,m;
    cin>>n>>m;
    graph.resize(n+1);
    memset(dp,-1,sizeof(dp));
    int x,y;
    rep(i,m){
      cin>>x>>y;
      x--;y--;
      graph[x].pb(y);
     }
     int maxv=0,ans;
    rep(i,n){
        maxv=max(maxv,rec(i));
    }
    cout<<maxv<<endl;
  return 0;
}


Measured memory_bytes: 8192
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val n = sc.nextDouble
  val points: Array[(Double, Double)] = Array.fill(n.toInt)((sc.nextDouble, sc.nextDouble))
  val sum: Double = points.permutations.map(a => a.sliding(2).map(p => Math.sqrt(Math.pow(p(1)._2 - p(0)._2, 2) + Math.pow(p(1)._1 - p(0)._1, 2))).sum).sum
  println(sum / points.permutations.size)
}

Measured memory_bytes: 76272
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;

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

	int n;
	cin >> n;
	int hap[100005][3];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 3; j++)
			cin >> hap[i][j];

	for (int i = 1; i < n; i++) {
		hap[i][0] += max(hap[i - 1][1], hap[i - 1][2]);
		hap[i][1] += max(hap[i - 1][0], hap[i - 1][2]);
		hap[i][2] += max(hap[i - 1][0], hap[i - 1][1]);
	}

	int ans = max(hap[n - 1][0], max(hap[n - 1][1], hap[n - 1][2]));
	cout << ans << endl;
}

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

using namespace std;

using Number = long double;

const Number EPS = 1e-5;

int FindTheOutlier(const int d, const vector<Number> &v) {
    // v_i : ?????¬???v_j : ??????
    for (int i = 0; i < d + 3; ++i)
        for (int j = 0; j < d + 3; ++j) {
            if (i == j) continue;

            Number p1 = 0.0, p2 = 0.0;

            for (int k = 0; k < d + 3; ++k) {
                if (k == i || k == j) continue;

                Number a1 = v[k], a2 = v[k];
                for (int l = 0; l < d + 3; ++l) {
                    if (l == i || l == j || l == k) continue;
                    a1 *= (Number)(i - l) / (Number)(k - l);
                    a2 *= (Number)(j - l) / (Number)(k - l);
                }

                p1 += a1;
                p2 += a2;
            }

            if (abs(p1 - v[i]) <= EPS && abs(p2 - v[j]) > EPS) return j;
        }

    return -1;
}

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

    int d;

    while (cin >> d, d) {
        vector<Number> v(d + 3);
        for (int i = 0; i < d + 3; ++i)
            cin >> v[i];

        cout << FindTheOutlier(d, v) << '\n';
    }

    return 0;
}

Measured memory_bytes: 3208
import * as fs from "fs"

function Main(input: string) {
  const [a, b, c] = input.split(" ").map(num => parseInt(num, 10)).sort((a, b) => a - b)

  if (a + b === c) {
    console.log("Yes")
  }
  else {
    console.log("No")
  }
}

fs.readFile('/dev/stdin', (err, data) => {
  if(err){
    Main(fs.readFileSync('./input.txt', 'utf8'))
    return false
  }
  Main(data.toString())
})

Measured memory_bytes: 7372
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define INF 1LL<<60

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> s(H);
    REP(i, H) cin >> s[i];

    vector<vector<int>> ans(H, vector<int>(W, -1));

    int k = 1;
    for(int h=0; h<H; h++) {
        for(int w=0; w<W; w++) {
            if(s[h][w] == '#') {
                ans[h][w] = k++;
            } else if(w>0 && ans[h][w-1]>0)
                ans[h][w] = ans[h][w-1];
        }
    }

    for(int h=H-1; h>=0; h--) {
        for(int w=W-1; w>=0; w--) {
            if(w<W-1)
                if(ans[h][w] == -1 && ans[h][w+1]>0)
                    ans[h][w] = ans[h][w+1];
        }
    }

    for(int h=0; h<H; h++) {
        if(ans[h][0] == -1) {
            int ref_row = 0;
            if(h==0) ref_row = 1;
            else ref_row = h-1;

            for(int w=0; w<W; w++)
                ans[h][w] = ans[ref_row][w];
        }
    }

    for(int h=H-1; h>=0; h--) {
        if(ans[h][0] == -1) {
            int ref_row = 0;
            if(h==0) ref_row = 1;
            else ref_row = h+1;

            for(int w=0; w<W; w++)
                ans[h][w] = ans[ref_row][w];
        }
    }

    for(int h=0; h<H; h++) {
        for(int w=0; w<W; w++) {
            cout << ans[h][w] << " ";
        }
        cout << endl;
    }


    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ll long long
long long min(long long x,long long y){return (x<y ? x:y);}
long long max(long long x,long long y){return (x>y ? x:y);}
#define ld long double
int stoi(string s) {return atoi(s.c_str());}

int main(){
  ll N,A,B; cin >> N>>A>>B;
  ll p = A+B;
  ll set_n = N/p;
  ll amari = N%p;
  
  ll r = set_n*A;
  if(amari<=A){
    r += amari;
  }else{
    r += A;
  }
  cout << r << "\n";
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const X = parseInt(arg[0].split(" ")[0]);
    
    if(X >= 400 && X <= 599) {
        console.log(8);
    } else if(X >= 600 && X <= 799) {
        console.log(7);
    } else if(X >= 800 && X <= 999) {
        console.log(6);
    } else if(X >= 1000 && X <= 1199) {
        console.log(5);
    } else if(X >= 1200 && X <= 1399) {
        console.log(4);
    } else if(X >= 1400 && X <= 1599) {
        console.log(3);
    } else if(X >= 1600 && X <= 1799) {
        console.log(2);
    } else if(X >= 1800 && X <= 1999) {
        console.log(1);
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29708
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var isVisited []bool
var g [][]bool
var n int
var m int

func main() {
	sc.Split(bufio.ScanWords)
	n, m = nextInt(), nextInt()
	g = make([][]bool, n)
	for i := 0; i < n; i++ {
		g[i] = make([]bool, n)
	}

	isVisited = make([]bool, n)

	u, v := make([]int, m), make([]int, m)
	for i := 0; i < m; i++ {
		u[i], v[i] = nextInt()-1, nextInt()-1
		g[u[i]][v[i]] = true
		g[v[i]][u[i]] = true
	}

	ans := 0
	for i := 0; i < m; i++ {
		g[u[i]][v[i]] = false
		g[v[i]][u[i]] = false

		for j := 0; j < n; j++ {
			isVisited[j] = false
		}

		dfs(0)

		bridge := false
		for j := 0; j < n; j++ {
			if !isVisited[j] {
				bridge = true
			}
		}
		if bridge {
			ans++
		}

		g[u[i]][v[i]] = true
		g[v[i]][u[i]] = true

	}

	fmt.Println(ans)
}

func dfs(v int) {
	isVisited[v] = true
	for v2 := 0; v2 < n; v2++ {
		if !g[v][v2] {
			continue
		}
		if isVisited[v2] {
			continue
		}
		dfs(v2)
	}
}


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

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

    for(int i=1;i<=n;i++){
        int x=i;
        int sum=0;
        while(x){
            sum+=x%10;
            x/=10;
        }
        if(a<=sum && sum<=b)ans+=i;
    }
    cout<<ans<<endl;

    return 0;
}


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

using namespace std;

#define LL long long
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    LL i,n,x,y,mn,mx,ans=0;
    cin >> n;
    for(i=1;i<=n;i++)ans+=i*(n-i+1);
    for(i=1;i<n;i++)
    {
        cin >> x >> y;
        if(x > y)swap(x,y);
        mn=min(x,n-y+1);
        mx=max(x,n-y+1)-1;
        ans-=mn*(mx+1);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3524
/*

    author : s@if

*/

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

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			99999999
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)


bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)1e5+9;

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    string s;
    
    cin>>s;
    
    for(i=1; i<4; i++)
    {
        if(s[i]==s[i-1])
        {
            cout<<"Bad\n";
            return 0;
        }
    }
    
    cout<<"Good\n";

    return 0;
}


Measured memory_bytes: 256
import numpy as np
list=input().split()

for i in range(2):
    if i==0:
        A=int(list[i])
    if i==1:
        B=int(list[i])

sum=A+B
sub=A-B
product=A*B

if sum>sub:
    if product>sum:
        print(int(product))
    else:#sum>=product
        print(sum)
else:#sum<=sub
    if product>sub:
        print(int(product))
    else:#product<=sub
        print(int(sub))


Measured memory_bytes: 12476
N=int(input())
*A, = map(int,input().split())

if N==0 and A[0] == 1:
    print(1)
    exit()
if A[0] != 0:
    print(-1)
    exit()

INF = 1e18
B = [1]*(N+1)
for i,a in enumerate(A[1:],1):
    B[i] = min(INF,B[i-1]*2 - a)

ans = 0
p = 0
for i,a in enumerate(A[::-1]):
    i = N - i
    m = B[i]
    if p>2*m:
        ans = -1
        break
    p = min(m,p)+a
    ans += p

print(ans)

Measured memory_bytes: 675204
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)
#define sz(c) ((int)c.size())
#define all(c) c.begin(), c.end()

using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

const int INF = 1e9;
template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> using heap = priority_queue<T, vector<T>, greater<T>>;

int DY[4] = {-1, 0, 1, 0};
int DX[4] = {0, 1, 0, -1};

bool inrange(int x, int l, int r) {
    return l <= x and x < r;
}

int table[1010][1010];
pii num2pos[1000006];
bool is_prime[1000006];

void solve(int M, int N) {
    pii p = num2pos[N];
    vvi dp(1010, vi(1010, 0));
    queue<pii> q;
    q.push(p);
    dp[p.first][p.second] = is_prime[N];
    vvi valid(1010, vi(1010, 0));
    valid[p.first][p.second] = 1;
    rep(i, p.first, 1010) {
        rep(j, 0, 1010) {
            if (!valid[i][j]) continue;
            rep(d, -1, 2) {
                int ii = i + 1;
                int jj = j + d;
                if (inrange(jj, 0, 1010) && inrange(ii, 0, 1010) && table[ii][jj] <= M) {
                    valid[ii][jj] = 1;
                    if (chmax(dp[ii][jj], dp[i][j] + is_prime[table[ii][jj]])) {
                        q.push({ii, jj});
                    }
                }
            }
        }
    }

    int mx = 0;
    int last = 0;
    rrep(i, 0, 1010) {
        rrep(j, 0, 1010) {
            if (valid[i][j] && is_prime[table[i][j]]) {
                if (mx < dp[i][j]) {
                    mx = dp[i][j];
                    last = table[i][j];
                } else if (mx == dp[i][j]) {
                    if (last < table[i][j]) {
                        last = table[i][j];
                    }
                }
            }
        }
    }
    cout << mx << " " << last << endl;
}

signed main() {
    memset(is_prime, true, sizeof(is_prime));
    rep(i, 0, 1010) rep(j, 0, 1010) table[i][j] = INF;
    is_prime[0] = is_prime[1] = false;
    rep(i, 2, 1000006) {
        if (!is_prime[i]) continue;
        rep(j, 2, 1000006) {
            if (i * j > 1000006) break;
            is_prime[i * j] = false;
        }
    }

    int y = 505;
    int x = 505;
    int dir = 1;
    int next_turn = 1;
    queue<int> seq;
    seq.push(1);
    rep(i, 2, 1000006) {
        seq.push(i);
        seq.push(i);
    }
    rep(i, 1, 1000003) {
        table[y][x] = i;
        num2pos[i] = {y, x};
        y += DY[dir];
        x += DX[dir];
        if (i == next_turn) {
            dir = (dir + 3) % 4;
            next_turn += seq.front(); seq.pop();
        }
    }

    while (1) {
        int M, N;
        cin >> M >> N;
        if (M == 0 && N == 0) break;
        solve(M, N);
    }
}


Measured memory_bytes: 72788
#include <bits/stdc++.h>
using namespace std;
int main(){ios_base::sync_with_stdio(0);
cin.tie(NULL);
    long long n,k,x[200000],q=0,c=0;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>x[i];
    }sort(x,x+n);
    for(int j=n-1;j>=n-k;j--){
        x[j]=0;
    }
    for(int i=0;i<n-k;i++){c+=x[i];}
    cout<<c;
}


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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 2e5 + 5;

int a[maxr], b[maxr];
int32_t main()
{
	GO;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	sort(a, a + n);
	sort(b, b + n);
	if ((n & 1)) {
		cout << b[n / 2] - a[n / 2] + 1 << endl;
	}
	else {
		int value = (b[n / 2] + b[(n / 2) - 1]) - (a[n / 2] + a[(n / 2) - 1]) + 1;
		cout << value << endl;
	}
	return 0;
}

//!

Measured memory_bytes: 6752
#include <stdio.h>

int main(void)
{
	int w, a, b;
	scanf("%d %d %d", &w, &a, &b);
	int c = a < b ? a : b, d = a < b ? b : a;
	printf("%d", w+c < d ? d-w-c : 0);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define int               long long
#define fr                first
#define sc                second
#define vc                vector
#define endl              '\n'
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define LSB(i)            ((i)&-(i))

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve()
{
    int n, m;
    cin >> n >> m;
    if (m >= n)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}
signed main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin>>t;
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
char Tex[1005];int i=0,j;
void corr() {if (Tex[j-4]=='p' && Tex[j-3]=='e' && Tex[j-2]=='a' && Tex[j-1]=='c') {Tex[j-4]='a',Tex[j-3]=Tex[j-2]='p',Tex[j-1]='l',Tex[j]='e';return;}
	if (Tex[j-4]=='a' && Tex[j-3]=='p' && Tex[j-2]=='p' && Tex[j-1]=='l') Tex[j-4]='p',Tex[j-3]='e',Tex[j-2]='a',Tex[j-1]='c',Tex[j]='h';}
int main() {while (1) {Tex[i]=getchar();if (Tex[i]==EOF) break;i++;}Tex[i]=0;for (j=4;j<i;j++) if (Tex[j]=='h' || Tex[j]=='e') corr();printf("%s",Tex);return 0;}

Measured memory_bytes: 0
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
    }
    let d = n % 10;
    if d == 2 || d == 4 || d == 5 || d == 7 || d == 9 {
        println!("hon");
    } else if d == 3 {
        println!("bon");
    } else {
        println!("pon");
    }
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
#include <stack>
using namespace std;
int main(void){
    long long A,B,C,D;
    cin >> A >> B >> C >> D;
    long long E = C;
    long long F = D;
    long long G = 1;
    while(E != 0){
        G = F % E;
        if(G == 0){
            break;
        }
        F = E;
        E = G;
     }
    long long a = A-1;
    long long H = C*D/E;
    cout << (B-(B/C+B/D-B/H))-(a-(a/C+a/D-a/H))<< endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<int> a(A), b(B), c(C);

  rep(i, A) cin >> a[i];
  rep(i, B) cin >> b[i];
  rep(i, C) cin >> c[i];
  sort(a.rbegin(), a.rend());
  sort(b.rbegin(), b.rend());

  vector<int> p;
  rep(i, X) {
    p.push_back(a[i]);
  }
  rep(i, Y) {
    p.push_back(b[i]);
  }
  rep(i, C) {
    p.push_back(c[i]);
  }
  sort(p.rbegin(), p.rend());

  ll ans = 0;
  rep(i, X + Y) {
    ans += p[i];
  }

  cout << ans << endl;

}

Measured memory_bytes: 3572
#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( void )
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    
    int ans = min(a,b) + min(c,d);
    cout << ans << endl;
}


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


void solve(long long N, std::vector<long long> A){
  sort(A.begin(),A.end());
  long double result=0;
  REP(i,N)result+=1.0l/A[i];
  cout<<fixed<<setprecision(14)<<1.0l/result<<endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N, M;
  cin >> N;
  unordered_map<int64_t, int64_t> counts;
  for (int64_t i = 0; i < N; ++i) {
    int64_t d;
    cin >> d;
    if (counts.find(d) == counts.end()) {
      counts[d] = 1;
    } else {
      ++counts[d];
    }
  }
  cin >> M;
  vector<int64_t> T(M);
  for (int64_t i = 0; i < M; ++i) {
    int64_t d;
    cin >> d;
    if (counts.find(d) == counts.end() || counts[d] == 0) {
      cout << "NO" << endl;
      return 0;
    } else {
      --counts[d];
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 12996
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int N;
    cin >> N;
    int a[N];
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans += a[i] - 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;

int dp[1010][1010];

signed main(){
	int N,K;
	cin>>N>>K;
	vector<int>p(N);
	REP(i,N){
		cin >> p[i];
	}
	REP(i,1010)REP(j,1010)dp[i][j] = INF;
	dp[0][0] = 0;
	REP(i,N){
		REP(j,K + 1){
			CHMIN(dp[i + 1][j + 1],dp[i][j] + p[i]);
			CHMIN(dp[i + 1][j],dp[i][j]);
		}
	}
	out(dp[N][K]);
}

Measured memory_bytes: 11568
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

const int INF = 1e8;

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

	vector<int> a(n);
	cin >> a;

	int ans = 0;
	range(i,1,n){
		if(a[i] == a[i - 1] and a[i - 1] != INF){
			a[i] = INF;
			ans++;
		}
	}
	cout << ans << endl;
}


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


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

    return sorted(divisors)


divisors = get_divisor(M)
for d in divisors:
    if d >= N:
        print(M // d)
        exit()

print(1)


Measured memory_bytes: 38768
/* When Talent doesn't work, Hard work beats Talent*/

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(20);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define sp " "
#define int long long
#define double long double
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI=3.141592653589793;
const int L=1e18;

void solve()
{
	int n;
	cin>>n;
	set<string> ss;
	while(n--)
	{
		string s;
		cin>>s;
		ss.insert(s);
	}
	cout<< ss.size()<<nl;
	return ;
}

int32_t main()
{
	FastIO;
	Fast_D;
	solve();
	return 0;
}


Measured memory_bytes: 19196
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=1e9+7;
int n,now;
char s[500010];
LL ans;
int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	now=0;
	ans=1;
	FOR(i,2,n) ans=ans*i%MO;
	FOR(i,1,n*2){
		int t;
		if (s[i]=='W') t=0;
		else t=1;
		if (((now%2)^t)==0){
			if (now<1) return puts("0"),0;
			ans=ans*now%MO,--now;
		}
		else{
			++now;
		}
	}
	if (now!=0) return puts("0"),0;
	ans=(ans%MO+MO)%MO;
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    n=0;
    for(int i=0;i<k;i++)n+=a[i];
    cout<< n <<'\n';
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////////////////
int a,b,c,d;
cin >> a >> b >> c >> d;
if(a<=c){
	if(b<=c){
		cout << 0 << endl;
	}
	else if(b>=c){
		if(b>=d){
			cout << d-c << endl;
		}
		else if(b<=d){
			cout << b-c << endl;
		}
	}
}

else if(a>=c){
	if(d<=a){
		cout << 0 << endl;
	}
	else if(d>=a){
		if(d<=b){
			cout << d-a << endl;
		}
		else if(b<=d){
			cout << b-a << endl;
		}
	}
}

////////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		long[] counts = new long[5];
		for (int i = 0; i < n; i++) {
			switch (br.readLine().charAt(0)) {
				case 'M' :
				counts[0]++;
				break;
				case 'A' :
				counts[1]++;
				break;
				case 'R' :
				counts[2]++;
				break;
				case 'C' :
				counts[3]++;
				break;
				case 'H' :
				counts[4]++;
				break;
			}
		}
		long count = 0;
		for (int i = 0; i < 3; i++) {
			for (int j = i + 1; j < 4; j++) {
				for (int k = j + 1; k < 5; k++) {
					count += counts[i] * counts[j] * counts[k];
				}
			}
		}
		System.out.println(count);
	}
}


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

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

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

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

int main()
{
    int x;
    cin>>x;
    int a[1000];
    int j=0;
    if(x==1||x==2||x==3){cout<<"1";return 0;}
    for(int i=2;i<x;i++)
    {
        int sum = i;
        int cnt=0;
        while(true)
        {
            if(sum>x) break;
            sum*=i;
            cnt++;
        }
        sum/=i;
        if(cnt>1)
            a[j++] = sum;
        else a[j++] = 1;
    }
    sort(a,a+j-1,cmp);
    cout<<a[0];
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int H,W,i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0&&W==0){
			break;
		}
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
a, b, c, x, y = map(int, input().split())
if a+b <= 2*c:
    print(a*x+b*y)
else:
    if x < y:
        print(min(c*x*2+b*(y-x), 2*y*c))
    else:
        print(min(a*(x-y)+c*y*2, 2*x*c))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=2e5;
const int inf=1e9;
int main(){
	int M,K; cin>>M>>K;
	if((1<<M) <= K) cout<<-1<<endl;
	else if(M == 1 && K == 0) cout<<0<<" "<<0<<" "<<1<<" "<<1<<endl;
	else if(M == 1 && K == 1) cout<<-1<<endl;
	else{
		for(int i = 0; i < (1<<M); i++){
			if(i == K) continue;
			cout<<i<<" ";
		}cout<<K<<" ";
		for(int i = (1<<M)-1; i >= 0; i--){
			if(i == K) continue;
			cout<<i<<" ";
		}cout<<K<<" "<<endl;
	}
}

Measured memory_bytes: 1792
n=int(input())

count=0
ans=0
if n<=104:
    ans=0
else:
    for i in range(105,n+1):
        count=0
        for e in range(1,n+1):
            if i%2==0:
                break
            elif i%e==0:
                count+=1
        if count==8:
            ans+=1
print(ans)

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String W = sc.next();

        int count = 0;

        String Ti = sc.next();

        while(! Ti.equals("END_OF_TEXT")){
            if(W.equals(Ti.toLowerCase())){
                count++;
            }

        Ti = sc.next();
        }

        System.out.println(count);

        sc.close();
    }
}


Measured memory_bytes: 26324
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

ll dp[200200][2]; // dp[i][j]:i番目のグループで(j==0:左、j==1:右)を取った時の最大値
ll dp2[200200][2][2]; // dp2[i][j][k]:i番目のグループで(j==0:左、j==1:右)を取った時の最大値
					  // kは既に1グループ飛ばしたかどうか

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<ll> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<=n;i++){
		// 初期化
		dp[i][0]=dp[i][1]=-1e18;
		dp2[i][0][0]=dp2[i][0][1]=dp2[i][1][0]=dp2[i][1][1]=-1e18;
	}
	int m=n/2;
	if(n%2==0){
		dp[1][0]=a[0],dp[1][1]=a[1];
		for(int i=1;i<m;i++){
			for(int j=0;j<2;j++){
				if(j==0){
					dp[i+1][0]=max(dp[i+1][0],dp[i][j]+a[2*i]);
				}
				dp[i+1][1]=max(dp[i+1][1],dp[i][j]+a[2*i+1]);
			}
		}
		cout << max(dp[m][0],dp[m][1]) << endl;
	}
	else{
		// a[n-1]を使わない場合　上の偶数の場合と一緒
		dp[1][0]=a[0],dp[1][1]=a[1];
		for(int i=1;i<m;i++){
			for(int j=0;j<2;j++){
				if(j==0){
					dp[i+1][0]=max(dp[i+1][0],dp[i][j]+a[2*i]);
				}
				dp[i+1][1]=max(dp[i+1][1],dp[i][j]+a[2*i+1]);
			}
		}
		// a[n-1]を使う場合
		dp2[1][0][0]=a[n-1]+a[0],dp2[1][1][0]=a[n-1]+a[1];
		dp2[1][0][1]=a[n-1];
		for(int i=1;i<m;i++){
			for(int j=0;j<2;j++){
				for(int k=0;k<2;k++){
					if(k==0){
						dp2[i+1][0][1]=max(dp2[i+1][0][1],dp2[i][j][k]);
					}
					if(j==0){
						dp2[i+1][0][k]=max(dp2[i+1][0][k],dp2[i][j][k]+a[i*2]);
					}
					// a[n-2]は使えない事に注意！
					if(i!=m-1)dp2[i+1][1][k]=max(dp2[i+1][1][k],dp2[i][j][k]+a[i*2+1]);
				}
			}
		}
		cout << max({dp[m][0],dp[m][1],dp2[m][0][1],dp2[m][1][1]}) << endl;
	}
}


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

int main(){
	int N, M;
	cin >> N >> M;
	vector<int> fav(M);
	rep(i,N){
		int K;cin >> K;
		rep(j,K){
			int tmp;
			cin >> tmp;
			fav[tmp-1]++;
		}
	}
	int ans = 0;

	rep(i,M){
		if(fav[i] == N) ans++;
	}
	cout << ans << endl;
}













Measured memory_bytes: 3608
n = int(input())

d = []

for i in range(n):
  t = input().split(" ")
  t = [float(j) for j in t]
  d.append(t)

dsum = 0

for i in range(n):
  for j in list(range(i+1, n)):
    dtmp = ((d[i][0] - d[j][0]) ** 2) + ((d[i][1] - d[j][1]) ** 2)
    dsum = dsum + dtmp ** 0.5

res = dsum / (n / 2)

print(res)

Measured memory_bytes: 3444
n=int(input())

A=[list(map(int,input().split()))[::-1] for i in range(n)]

day=0
zan=[n-1]*n
zann=sum(zan)
sumi=set(range(n))

while True:
  day+=1

  kouho=list(sumi)
  sumi=set()
  
  for i in kouho:
    try:
      if A[A[i][-1]-1][-1]-1==i:
        sumi.add(i)
        sumi.add(A[i][-1]-1)
    except:
      pass

  for k in sumi:
    A[k].pop()
    zan[k]-=1

  if zann==sum(zan):
    print(-1)
    exit(0)
  
  zann=sum(zan)
  
  if zann==0:
    print(day)
    exit(0)
    


Measured memory_bytes: 60508
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy


def main():
  n, m = list(map(int, input().split()))
  a = numpy.ones(m)

  for _ in range(n):
    b = numpy.zeros(m)
    b[list(map(lambda x: int(x) - 1, input().split()))[1:]] = 1
    a *= b

  print(int(numpy.sum(a)), flush=True)


if __name__ == '__main__':
  main()



Measured memory_bytes: 12504
N,Q = map(int,input().split())
s = input()
q = [[0,0] for i in range(Q)]
for i in range(Q):
    q[i] = input().split()
    
def L(n):
    pos = n
    for i in range(Q):
        t,d = q[i]
        if s[pos] == t:
            if d == 'L':
                pos -= 1
            elif d == 'R':
                pos += 1
            if pos == -1:
                return True
            if pos == N:
                return False
    return False

def R(n):
    pos = n
    for i in range(Q):
        t,d = q[i]
        if s[pos] == t:
            if d == 'L':
                pos -= 1
            elif d == 'R':
                pos += 1
            if pos == N:
                return True
            if pos == -1:
                return False
    return False

n_mid = N//2
n_l = 0
n_r = N-1
for i in range(25):
    if L(n_mid):
        n_l = n_mid
        n_mid = (n_l+n_r)//2
    else:
        n_r = n_mid
        n_mid = (n_l+n_r)//2

if not L(n_l):
    l = -1
elif L(n_r):
    l = n_r
else:
    l = n_l

n_mid = N//2-1
n_l = 0
n_r = N-1
for i in range(25):
    if R(n_mid):
        n_r = n_mid
        n_mid = (n_l+n_r)//2
    else:
        n_l = n_mid
        n_mid = (n_l+n_r)//2

if not R(n_r):
    r = N
elif R(n_l):
    r = n_l
else:
    r = n_r

ans = 0
for i in range(N):
    if l < i < r:
        ans += 1
print(ans)

Measured memory_bytes: 99872
#include<iostream>
using namespace std;
int main () {
  int S;
  cin >> S;
  int first = S/100;
  int second = S - 100*first;
  
  bool month[2];
  
  if (first > 12 || first == 0) {
    month[0] = false;
  } else {
    month[0] = true;
  }
  if (second > 12 || second == 0) {
    month[1] = false;
  } else {
    month[1] = true;
  }


  if (month[0]) {
    if (month[1]) {
      cout<<"AMBIGUOUS"<<endl;
    } else {
      cout<<"MMYY"<<endl;
    }
  } else {
    if (month[1]) {
      cout<<"YYMM"<<endl;
    } else {
      cout<<"NA"<<endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N;
ll T, a[200000], b[200000];

ll A[200000], B[200000];
// 総時間は (((B1)A2+B2)A3+B3)A4+B4 みたいになる

vector<ll> A1;
vector<ll> wa;
vector<pair<double , pair<ll,ll>>> v; // double の値が小さい方が先に選ばれるべき

ll memo[200000][30];
ll solve(int n, int k){ // 0～n 番目のうちから k 個選ぶ場合の最小時間
    if(n == -1){
        if(k == 0) return 0;
        else return T+1;
    }
    if(memo[n][k] != -1) return memo[n][k];
    ll ret = min(solve(n-1, k), T+1);
    if(k > 0) ret = min(ret, solve(n-1, k-1)*v[n].second.first+v[n].second.second);
    return memo[n][k] = ret;
}

signed main(){
    cin >> N >> T;
    rep(i, N) cin >> a[i] >> b[i];

    rep(i, N){
        A[i] = a[i]+1;
        B[i] = a[i]+b[i]+1;
        //cout << A[i] << " " << B[i] << endl;
        if(A[i] == 1) A1.pb(B[i]);
        else v.pb({ (double)B[i]/(double)(A[i]-1), {A[i], B[i]} });
    }
    sort(all(A1));
    sort(all(v));
    rep(i, A1.size()) wa.pb((i != 0 ? wa.back() : 0) + A1[i]);

    //rep(i, A1.size()) cout << "1 " << A1[i] << endl;
    //rep(i, v.size()) cout << v[i].second.first << " " << v[i].second.second << " " << v[i].first << endl;
    //rep(i, A1.size()) cout << wa[i] << endl;
    
    memset(memo, -1, sizeof(memo));
    int ans = 0;
    rep(i, 30){
        ll t = solve(v.size()-1, i);
        if(t > T) continue;
        ans = max(ans, i + (int)(upper_bound(all(wa), T-t)-wa.begin()));
        //cout << i + (int)(upper_bound(all(wa), T-t)-wa.begin()) << endl;
    }
    cout << ans << endl;
}

/*
5 10
0 2
0 3
0 4
0 5
0 6
*/

Measured memory_bytes: 71920
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long sum = 0;
        for(int i = 1; i <= N; i++) {
            if(i % 3 == 0 || i % 5 == 0) continue;
            sum += i;
        }

        System.out.println(sum);
    }
}

Measured memory_bytes: 35796
#if !defined(ONLINE_JUDGE)
    #include "prettyprint.hpp" 
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 1729
    #define cer(x) 13
#endif
const bool testcase=0;
typedef long long int ll;
#define INF LONG_MAX
#define MINF LONG_MIN 
#define MAXR 111111
const ll mod1 = 1000000007;
const ll mod2 = 998244353;



//loop 
#define loop(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define loope(i,L,R) for (int i = L; i <= R; i++)
#define rloop(i,L,R) for (int i = L; i > R; i--)
#define rloope(i,L,R) for (int i = L; i >= R; i--)
#define nl cout<<'\n'



//misc
#define sz(x) ((int)((x).size()))
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL) 
#define checkbit(n,b) ( (n >> b) & 1)
#define test int _T_=1;if(testcase){cin>>_T_;}while(_T_--)



//vector
#define lastEle(vec) vec[vec.size()-1]
#define all(ve) ve.begin(),ve.end()
#define rall(x) x.rbegin(),x.rend()
#define fi first
#define se second



template<typename T>inline T mmod(T a,T b,T mod){return ((a%mod)*(b%mod))%mod;}
template<typename T>inline T smod(T a,T b,T mod){return ((a%mod)+(b%mod))%mod;}
template<typename T>bool isPrime(T n){for(T i=2;i*i<=n;i++)if(n%i==0)return 0;return 1;}
template<typename TAIL>inline void inp(TAIL& T){cin>>T;}
template<typename HEAD,typename... TAIL>inline void inp(HEAD &H,TAIL&... T){cin>>H;inp(T...);}
template<typename T>inline bool in_range(T a,T l,T r){return (a>=l&&a<=r);}
template<typename T,typename U>inline istream& operator >>(istream& in,pair<T,U> &a){in>>a.fi>>a.se;return in;}
template<typename T>inline istream& operator >>(istream& in,vector<T> &a){for(auto &x : a)in>>x;return in;}

ll lcm(ll a,ll b){return (max(a,b)/__gcd(a,b))*min(a,b);} 

// MAIN
void solve();
int main(){
    std::chrono::time_point<std::chrono::high_resolution_clock> start, end;
    start = std::chrono::high_resolution_clock::now();
    fast;
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
        // for debug in error.txt
        freopen("error.txt", "w", stderr);
    #endif
    test {
        solve();
    }
    end = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
    cerr << "\nElapsed Time: " << elapsed_time << "ms\n";
    return 0;
}


// SOLVE 

void solve() {
    string s;
    cin >> s;
    ll n = s.size();
    if(s[n-1]!='s') {
        s += "s";
    }else{
        s += "es";
    }
    cout << s << '\n';
}



Measured memory_bytes: 3652
fn solve(hs: Vec<usize>) -> bool {
    let mut n = 0;

    for h in hs {
        if n < h {
            n = h - 1;
        } else if n == h {
            // pass
        } else {
            return false;
        }
    }

    true
}

fn solve_test() {
    assert_eq!(solve(vec![1, 2, 1, 1, 3]), true);
    assert_eq!(solve(vec![1, 3, 2, 1]), false);
    assert_eq!(solve(vec![1, 2, 3, 4, 5]), true);
    assert_eq!(solve(vec![1000000000]), true);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let _ = parse_line!(usize);
    let hs = parse_vec!(usize);
    println!("{}", if solve(hs) { "Yes" } else { "No" });
}


Measured memory_bytes: 8444
import numpy as np
s=np.array(list(input()))
t=np.array(list(input()))
is_eq=np.array(s[:,None]==t[None,])
# is_eq[i][j]:sのi文字目とtのj文字目が等しいかどうか
# print(is_eq)
ns=len(s)
nt=len(t)
dp=np.zeros((ns+1,nt+1),np.int64)

# dp[i+1][j+1]:sのi文字目までとtのj文字目までで最長の部分列
# dp[0][j]=0,dp[i][0]=0,dp[n+1][w+1]の値がsとtで最長の部分列の長さ
for i in range(ns): #sのi文字目までの文字列で調査
    dp[i+1][1:]=np.maximum(dp[i][:-1]+is_eq[i],dp[i][1:])#左上からの更新、真上からの更新
    dp[i+1]=np.maximum.accumulate(dp[i+1])#左からの更新
i=ns
j=nt
ans=['']
while i>0 and j>0:
      if dp[i][j]==dp[i-1][j]:
            i-=1
      elif dp[i][j]==dp[i][j-1]:
            j-=1
      else:
            ans.append(s[i-1])
            i-=1
            j-=1
a=''
for _ in range(len(ans)):
      a+=ans.pop()
print(a)



Measured memory_bytes: 91760
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main(){
  int a, b, c, d; cin >> a >> b >> c >> d;
  int x = a*b, y=c*d;
  if(x>y)cout << x << ln;
  else cout << y << ln;
}


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

#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);

using namespace std;
const int N = 2e6 + 41;
const int mod = 1e9 + 7;
const long long INF = 1e18 + 12;
const int inf = 1e9;

int a[N], p[N];

int main () {
	boost;
	int a, b, c;
	cin >> a >> b >> c;
	int h = min (a, c);
	int ans = h;
	c -= h;
	h = min (b, c);
	ans += h * 2;
	b -= h;
	c -= h;
	cout << ans + b + min (1, c);
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC129 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m = LI()
a = [I() for _ in range(m)]
dp = [0]*(n+1)
dp[0],dp[1] = 1,1
for i in a:
    dp[i] = -1
for i in range(2,n+1):
    if dp[i] < 0:
        continue
    if dp[i-1] < 0:
        dp[i] = dp[i-2]
        continue
    if dp[i-2] < 0:
        dp[i] = dp[i-1]
        continue
    dp[i] = (dp[i-1] + dp[i-2]) % mod
if dp[-1] == -1:
    print(0)
else:
    print(dp[-1])


Measured memory_bytes: 45276
#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 RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int max_bit = 29;

	int n;
	cin >> n;

	vector<int> a;
	vector<int> b;

	rep(i,n){
		int t;
		cin >> t;
		a.push_back(t);
	}

	rep(i,n){
		int t;
		cin >> t;
		b.push_back(t);
	}

	int ans = 0;
	rep(k,max_bit){
		vector<int> v;
		rep(i,n){
			v.push_back(b[i] % (1 << (k+1)));
		}

		sort(v.begin(), v.end());

		int t = 1 << k;
		rep(i,n){
			int x = a[i] % (1 << (k+1));

			auto c = lower_bound(v.begin(), v.end(), t - x);
			auto d = lower_bound(v.begin(), v.end(), 2 * t - x);
			auto e = lower_bound(v.begin(), v.end(), 3 * t - x);
			auto f = lower_bound(v.begin(), v.end(), 4 * t - x);

			ans ^= t * ((distance(c, d) + distance(e, f)) & 1);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3700
taro_point = 0
hanako_point = 0

n = int(input())
for i in range(n):
    taro, hanako = input().split()
    if taro == hanako:
        taro_point += 1
        hanako_point += 1
    elif taro > hanako:
        taro_point += 3
    else:
        hanako_point += 3
print(taro_point, hanako_point)



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

int main(void) {
    string s;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    cout << s.substr(0, 5) << " " << s.substr(5 + 1, 7) << " " << s.substr((5 + 1) + (7 + 1), 5) << "\n";
    return 0;
}

Measured memory_bytes: 256