akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

int main()
{
    int n, sum = 0;
    cin >> n;
    float ans = 0;

    rep(i, n)
    {
        float a;
        string s;
        cin >> a >> s;
        if (s == "JPY")
            ans += a;
        else
            ans += a * 380000;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

int main(){
    int N,K,mi;
    scanf("%d %d",&N,&K);
    vector<int> h(N+1);
    vector<int> dp(N+1);

    for(int i=1;i<=N;i++)
        scanf("%d",&h[i]);

    dp[1] = 0;
    for(int i=2;i<=N;i++){
        mi = INT_MAX;
        for(int j=1;j<=K;j++){
            if(i-j<=0)
                break;
            mi = min(mi,dp[i-j]+abs(h[i]-h[i-j]));
        }
        dp[i] = mi;
    }

    printf("%d\n",dp[N]);
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#define maxn 10004
#define mp make_pair
#define fi first
#define se second
using namespace std;
int n, m, p;
vector < pair <int, int> > G[maxn];
long long d[maxn];
bool inq[maxn], vis[maxn], tag[maxn];
int times[maxn];
queue <int> q;
bool dfs(int u, int t){
    if (vis[u])
        return false;
    if (u == t)
        return true;
    vis[u] = 1;
    for (int i = 0; i < G[u].size(); ++ i)
        if (dfs(G[u][i].fi, t))
            return true;
    return false;
}
long long SPFA(int s){
    d[s] = 0;
    q.push(s);
    inq[s] = 1;
    while (! q.empty()){
        int u = q.front();
        q.pop();
        inq[u] = 0;
        if ((++ times[u]) >= n)
            return 1;
        for (int i = 0; i < G[u].size(); ++ i){
            pair <int, int> p = G[u][i];
            if (tag[p.fi] && d[u] + p.se < d[p.fi]){
                d[p.fi] = d[u] + p.se;
                if (! inq[p.fi]){
                    q.push(p.fi);
                    inq[p.fi] = 1;
                }
            }
        }
    }
    return min(d[n], 0LL);
}
int read(){
    int cnt = 0;
    char ch = getchar();
    while (ch < '0' || '9' < ch)
        ch = getchar();
    while ('0' <= ch && ch <= '9'){
        cnt = cnt * 10 + ch - '0';
        ch = getchar();
    }
    return cnt;
}
int main(){
    n = read(), m = read(), p = read();
    for (int i = 1; i <= m; ++ i){
        int a = read(), b = read(), c = read();
        G[a].push_back(mp(b, p - c));
    }
    for (int i = 1; i <= n; ++ i){
        memset(vis, 0, sizeof(vis));
        if (dfs(i, n))
            tag[i] = 1;
    }
    for (int i = 1; i <= n; ++ i)
        d[i] = 1LL << 60;
    cout << -SPFA(1) << endl;
}


Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<vector>
#include <cmath>
#include <limits>
#include <iomanip>
using namespace std;
const long long INF=20000000000;

int main(){
	string s;
	cin>>s;
	bool ans=true;
	for(int i=0;i<s.length();i++){
		if(i%2==1){
			//even
			if(s[i]=='L' | s[i]=='U' | s[i]=='D'){}
			else ans=false;
			
		}else {
			if(s[i]=='R' | s[i]=='U' | s[i]=='D'){}
			else ans=false;
		}
	}
	if(ans)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	
}
	


Measured memory_bytes: 256
s = input()
len_s = len(s)

ans=0
for i in range(2**(len_s-1)):
    tmp=0
    start=0
    end=0
    for j in range(len_s-1):
        if ((i>>j)&1):
            tmp+=int(s[start:end+1])
            start=j+1
            end=j+1
        else:
            end+=1
    tmp+=int(s[start:end+1])
    ans+=tmp
print(ans)

Measured memory_bytes: 3064
s=input()
n = 2**(len(s)-1)
ans=""

for i in range(n):
    t = ""
    a = str(bin(i))[2:].zfill(len(s)-1)
    for j in range(len(a)):
        if a[j] == "1":
            t += s[j] + "+"
        else:
            t += s[j] + "-"
    t += s[-1]
    if eval(t)==7:
        ans = t + "=7"
        break
print(ans)

Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

#define TIME_MAX 100000

int main(void) {
    int num, limit;
    get_int2(&num, &limit);
    static int map[TIME_MAX+1];
    int i;
    for(i = 0; i < num; i++) {
        int in, out;
        get_int2(&in, &out);
        map[in]++;
        map[out]--;
    }

    int ans = map[0];
    for(i = 1; i <= limit; i++) {
        map[i] += map[i-1];
        ans = max(ans, map[i]);
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2232
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int n;
	cin>>n;
	printf("Christmas");
	for(int i=25-n;i>0;i--)
	{
		printf(" Eve");
	}
	puts("");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool dp[100001];

int main()
{
    int n,k;
    cin>>n>>k;
    memset(dp,0,sizeof(dp));
    int a[n];
    for(int i=0; i<n; i++)
        cin>>a[i];
    for(int i=0; i<=k; i++)
        for(int j=0; j<n; j++)
            if(i>=a[j] && !dp[i-a[j]])
                dp[i]=1;
    if(dp[k]) cout<<"First\n";
    else cout<<"Second\n";
    return 0;
}


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

int main() {
  int N, num;
  cin >> N;
  string result = "APPROVED";
  for (int i = 0; i < N; i++) {
    cin >> num;
    if (num % 2 == 0) {
      if (num % 3 != 0 && num % 5 != 0) {
        result = "DENIED";
        break;
      }
    }
  }
  cout << result << endl;
}

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

int main(){
  int n,k;
  cin>>n>>k;
  int ans=0;
  vector<int> a;
  for(int i=0;i<n;i++){
    int b;
    cin>>b;
    a.push_back(b);
  }
  for(int i=0;i<n;i++){
    if(a[i]>=k){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 892
N=int(input())
A=list(map(int,input().split()))
k=1
x=0
if 0 in A:
  print(0)
  x=1
else:
  for i in range(N):
    if k*A[i]>10**18:
      print(-1)
      x=1
      break
    else:
      k=k*A[i]
if x!=1:
  print(k)

Measured memory_bytes: 21660
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXSIZE = 200002;
int a[MAXSIZE];
bool cmp(int x,int y)
{
	return x > y;
}
int main()
{
	int n,k;
	long long int sum = 0;
	scanf("%d %d",&n,&k);
	for(int i = 0;i < n;i++)
		scanf("%d",&a[i]);
	if(k >= n)
		printf("0\n");
	else
	{
		sort(a,a+n,cmp);
		for(int i = k;i < n;i++)
			sum += a[i];
		printf("%lld\n",sum);
	}
	return 0; 
}

Measured memory_bytes: 1024
import bisect
n,k= (int(i) for i in input().split())
array = []
for i in range(n):
 a,b= (int(j) for j in input().split())
 array.append((a,b))
array = sorted(array)
cnt = 0
for ab in array:
    a,b = ab
    cnt += b
    if cnt >= k:
        print(a)
        break

Measured memory_bytes: 17804
while True:
    H, W = map(int, input().split())
    if H == W == 0:
        break
    frame = [['#' if ( abs(i-j) %2 ==0) else '.' for i in range(W)] for j in range(H)]
    print('\n'.join([''.join(frame[j]) for j in range(H)]))
    print()


Measured memory_bytes: 5776
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#define ll long long
using namespace std;
ll t,n;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll k;
	while(cin>>n>>k)
	{
		ll a=n/k;
		if(n%k)
		cout<<min(min(k,n),abs(k-n%k))<<endl; 
		else
		cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;
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(){
  int n,d;
  double x[10][10];

  cin>>n>>d;
  rep(i,n)
  rep(j,d) cin>>x[i][j];

  int ans=0;
  for(int i=0;i<n-1;i++)
  for(int j=i+1;j<n;j++){
    double det=0;
    rep(k,d) det+=pow(x[i][k]-x[j][k],2);
    det=sqrt(det);

    if(ceil(det)==floor(det)) ans++;
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
N, M, C = map( int, input().split() )
B = list( map( int, input().split() ) )
A = [ list( map(int, input().split()) ) for _ in range(N) ]


ans = 0
for i in range(N):
    cond = 0
    for j in range(M):
        cond += A[i][j]*B[j]
    if cond + C > 0: ans += 1

print( ans )

Measured memory_bytes: 3064
#!/usr/bin/env python3

import sys

def answer(s):
    count = 0
    for c in s:
        if c == 'o':
            count += 1
    return 700 + count * 100

def main():
    line = list(sys.stdin)[0].rstrip()
    print(answer(line))

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int dig(lint a){
	return to_string(a).size();
}
int main()
{
	int out=15;lint n;
	cin>>n;
	for(lint i=1;i*i<=n;i++){
		if(n%i>0) continue;
		out=min(out,max(dig(i),dig(n/i)));
	}
	cout<<out<<endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {

	int N = 0;
	int p[10] = {};
	int max = 0;
	int ans = 0;

	cin >> N;

	for (int i = 0; i < N; i++) {

		cin >> p[i];
		if (max < p[i])max = p[i];
		ans += p[i];

	}

	cout << ans - max / 2 << endl;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
int main(){
	string s;cin>>s;
	int ans=0;
	rep(i,s.length())rep(j,s.length())if(s[i]!=s[j]&&i!=j)ans++;
	cout<<(ans==(s.length())*(s.length()-1)?"yes":"no")<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

	int n, m, a[1000][1000], b[1000], c;
	cin >> n >> m;
	for (int y = 0; y < n; y++){
		for (int z = 0; z < m; z++){
			cin >> a[y][z];
		}
	}
	for (int zz = 0; zz < m; zz++){
		cin >> b[zz];
	}
	for (int yy = 0; yy < n; yy++){
		c = 0;
		for (int za = 0; za < m; za++){
			c += a[yy][za] * b[za];
		}
		cout << c << endl;
	}
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n;
  string st;
  cin >> n;
  cin >> st;

  vll dd(n-2);
  set<char> s;
  set<string> ss;
  s.insert(st[n-1]);

  for(ll i = n-2; i >= 1; i--){
    auto it = s.begin();
    while(it != s.end()){
      string now = "";
      now.push_back(st[i]);
      now.push_back(*it);
      ss.insert(now);
      it++;
    }
    dd[i-1] = ss.size();
    s.insert(st[i]);
  }

  ll ans = 0;
  REP(i, 10){
    ll pos = st.find('0'+i);
    if(pos == -1 || pos >= n-2)
      continue;
    ans += dd[pos];
  }


  cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int gcd(int a, int b) {
    if(a % b == 0) {
        return b;
    }
    else {
        return(gcd(b, a % b));
    }
}


int main() {
    string s, ans;
    cin >> s;
    rep(i, s.size()) {
        if (s.at(i) != 'B') ans.push_back(s.at(i));
        else if (ans.size() > 0) ans.pop_back();
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n; cin >> n;
  vector<int> div;
  for(long long i = 1; i * i <= n; ++i){
    if(n % i == 0){
      div.push_back(i);
    }
  }
  int temp = div[div.size() - 1];
  string comp1 = to_string(n / temp);
  string comp2 = to_string(temp);
  cout << max(comp1.length(), comp2.length()) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    ll h,w;
    cin>>h>>w;
    bool ok=true;
    if(w==1 || h==1) cout<<1<<endl; 
    else if(w%2==0 && h%2==0){
        cout<<(w/2)*h<<endl;
    }
    else if(h%2==0){
        cout<<w*(h/2)<<endl;
    }
    else if(w%2==0){
        cout<<(w/2)*h<<endl;
    }
    else{
        cout<<w*(h/2)+w/2+1<<endl;
    }   
}

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

int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a,a+3);
  int count=0;
  count+=(a[2]-a[0])/2;
  a[0]+=(a[2]-a[0])/2*2;
  count+=(a[2]-a[1])/2;
  a[1]+=(a[2]-a[1])/2*2;
  sort(a,a+3);
  if(a[2]==a[1]){
    if(a[2]!=a[0]){
      count+=2;
    }
  }else{
    count+=1;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class ASheepAndWolves {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            long s = in.nextLong();
            long w = in.nextLong();
            out.println(w >= s ? "unsafe" : "safe");
            //out.print("Case #"+ testNumber + ": ");
        }

    }

    static class FastReader {
        public BufferedReader br;
        public StringTokenizer st;
        String context = null;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            if (context != null) {
                System.err.print("[" + context + "] Wait for input ...");
            }
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                }
            }
            String res = st.nextToken();
            if (context != null) {
                System.err.println("[" + context + "] ... received : " + res);
            }
            return res;
        }

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

    }
}



Measured memory_bytes: 32804
import scala.io.StdIn

object Main {

  def main(args: Array[String]): Unit = {

    val Array(a, b, c) = StdIn.readLine().trim.split(' ').map(_.toInt)

    println(if (a + b == c || a + c == b || b + c == a) "Yes" else "No")
  }
}


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

using namespace std;
typedef long long ll;

ll n, p, res;
vector <pair<ll, ll> > V;

int main() {
    cin>>n>>p;
    for (ll i=2; i*i <=p; i++)
    {
        if (p%i==0)
        {
            int m=0;
            while (p%i==0)
            {
                m++;
                p/=i;
            }
            V.push_back({i, m});
        }
    }
    if (p>1)
        V.push_back({p, 1});
    ll res=1;
    for (auto i : V)
    {
        if (i.second>=n)
            res *= pow(i.first, (i.second/n));
    }
    cout<<res;
    return 0;
}

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

int main(){
	int n;	cin>>n;
	vector<int> a(n+1);	for(int i=1;i<=n;i++)cin>>a[i];
	vector<int> b(n+1);	for(int i=1;i<=n;i++)cin>>b[i];
	vector<int> c(n);	for(int i=1;i<n;i++)cin>>c[i];

	int ans=0;
	for(int i=1;i<=n;i++){
		int now=a[i];
		ans+=b[now];
		//cout<<b[now]<<endl;

		if(i+1<=n){
			int next=a[i+1];
			if(now+1==next){
				ans+=c[now];
				//çcout<<"BONUS: "<<c[now]<<endl;
			}
		}

	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
int x[100005];
using namespace std;
int main()
{
    int n,k,q,v;
    cin>>n>>k>>q;
    for(int i=0;i<q;i++)
    {
        cin>>v;
        x[v]++;
    }
    for(int i=1;i<=n;i++)
    {
        if((x[i]+k-q)>0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
//#include <bitset>
#include <iterator>
#include <tuple>
#include <utility>
#include <string>
#include <vector>
//#include <queue>
//#include <deque>
//#include <map>
//#include <unordered_map>
//#include <set>
//#include <unordered_set>
//#include <stack>
using namespace std;

#define V             vector
#define PQ            priority_queue

#define pb            push_back
#define mp            make_pair
#define ins           insert
#define endl          '\n'
#define all(x)        x.begin(),x.end()
#define debug(X)      { cerr<<endl<<(#X)<<" = "<<(X)<<endl; }
//#define cerr if(0)cerr

#define mod           (1e9+7)

typedef long long ll;
typedef unsigned long long ull;


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll x,hp=0;
    cin>>x;

    hp += (x/500)*1000;
    x %= 500;
    hp += (x/5)*5;
    cout<<hp<<endl;

}



Measured memory_bytes: 256
N,M,X,Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

x.sort()
x.reverse()
y.sort()


answer = 'War'

if X>=Y:
	answer = 'War'
if X<Y:	
	for i in range(X+1,Y+1):
		if x[0] < i <= y[0]:
			answer = 'No War'
	
print(answer)


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int fact(int n){
	if(n == 0) return 1;
	return n * fact(n-1);
}

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	cout << fixed << setprecision(10);
	int n;
	cin >> n;
	vector<ld> x(n), y(n);
	rep(i, n) cin >> x[i] >> y[i];

	vi p(n);
	rep(i, n) p[i] = i;
	vector<ld> dist(fact(n), 0);
	rep(i, fact(n)){
		rep(j, n - 1){
			dist[i] += sqrt(pow(x[p[j]]-x[p[j+1]], 2) + pow(y[p[j]]-y[p[j+1]], 2));
		}
		next_permutation(all(p));
	}
	ld ans = 0;
	rep(i, fact(n)){
		ans += dist[i];
	}

	cout << ans / fact(n) << endl;
	return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

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

    // 標準入力から上底a、下底b、高さhを取得
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int h = scanner.nextInt();

    // 台形の面積を求める：(上底 + 下底) * 高さ / 2
    System.out.println((a + b) * h / 2);
  }
}

Measured memory_bytes: 35604
import kotlin.math.max

fun main() {
    val s = readLine() ?: return
    val t = readLine() ?: return
    var c = 0
    0.until(s.length - t.length + 1).forEach { i ->
        var count = 0
        0.until(t.length).forEach { j ->
            if (s[i + j] == t[j]) {
                count++
            }
        }
        c = max(c, count)
    }
    println((t.length - c).toString())
}


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

int n;
lli L;
char str[100100];

struct node{
    node *nxt[2];
    int l;
    node () {
        l=0; nxt[0]=nxt[1]=nullptr;
    }
}*root;

void add(node *cur, char *str,int d) {
    if(!(*str)) return;
    int nx=*str - '0';
    if(!cur->nxt[nx]) cur->nxt[nx] = new node(),cur->nxt[nx]->l=d+1;
    add(cur->nxt[nx],str+1,d+1);
}
lli get_least(lli v) {
    lli ret=1;
    while(!(v&1)) v>>=1,ret<<=1;
    return ret;
}
lli dfs(node *cur) {
    int cnt=0;
    lli v=0;
    for(int i=0;i<2;i++) if(cur->nxt[i]) v^=dfs(cur->nxt[i]),cnt++;
    if(cnt==1) {
        v^=get_least(L-cur->l);
    }
    return v;
}

int main() {
    root = new node();
    scanf("%d%lld",&n,&L);
    for(int i=0;i<n;i++) {
        scanf("%s",str);
        add(root,str,0);
    }
    puts(dfs(root) ? "Alice" : "Bob");
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

int main(void) {
    int H, W, M;
    cin >> H >> W >> M;
    // map<int,int> X, Y;
    // map< pair<int,int> ,int> mp;
    vector< vector<int> > X(H);
    vector<int> Y(W);
    for(int i=0; i<M; i++) {
        int x, y;
        cin >> x >> y;
        --x; --y;
        X[x].emplace_back(y);
        Y[y]++;
        // X[x]++;
        // Y[y]++;
        // mp[make_pair(x, y)]++;
    }

    multiset<int> mst;
    for(auto e: Y) {
        mst.insert(e);
    }

    int ans = 0;
    for(int i=0; i<H; i++) {
        for(auto y: X[i]) {
            ans = max(ans, (int)X[i].size() + Y[y] - 1);
        }
        for(auto y: X[i]) {
            mst.erase(mst.find(Y[y]));
        }
        if(mst.size()) ans = max(ans, (int)X[i].size() + *mst.rbegin());
        for(auto y: X[i]) {
            mst.insert(Y[y]);
        }
    }

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


Measured memory_bytes: 34912
PROGRAM RemainderMinimization2019
      IMPLICIT NONE
      integer(16) :: l,r, i,j
      integer(16) :: ans=2*10**8+1,buffer
      
      read*,l,r
      
      do i = l,r-1
        do j = i+1,r
          buffer = mod(i*j,2019)
          ans = min( ans,buffer )
          if( ans==0 )then
            print*,ans;stop
          end if
        end do
      end do
      
      print*,ans
      
      
      
      
      
      END PROGRAM

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

int main(){
    int n, m, sum = 0;
    cin >> n >> m;
    vi a(n);
    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }
    double cmp = sum / (4.0*m);
    sort(a.begin(), a.end(), greater<int>());
    bool flg = true;
    rep(i, m){
        if(a[i] < cmp) flg = false;
    }

    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;




int main() {
	int i,j,k,n,t;
	cin>>k;
	string s;
	cin>>s;
	n=s.size();
	if (n<=k)cout<<s;
	else{
	    string a;
	    for (i=0;i<k;i++)a+=s[i];
	    a+="...";
	    cout<<a;
	}
	
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#define mp make_pair
#define ft first
#define sc second
using namespace std;
const int Inf = 1e9 + 7;
int w[200010], Hash[200010], Min[800010][2], ans[200010];

void build(int l, int r, int cnt) {
	if (l == r) {
		scanf("%d", &w[l]), Hash[w[l]] = l;
		Min[cnt][l & 1] = w[l], Min[cnt][1 ^ (l & 1)] = Inf;
		return ;
	}
	build(l, (l + r) / 2, cnt * 2); build((l + r) / 2 + 1, r, cnt * 2 + 1);
	Min[cnt][l & 1] = min(Min[cnt * 2][l & 1], Min[cnt * 2 + 1][l & 1]);
	Min[cnt][1 ^ (l & 1)] = min(Min[cnt * 2][1 ^ (l & 1)], Min[cnt * 2 + 1][1 ^ (l & 1)]);
}

int ask(int x, int y, int l, int r, int cnt, int bit) {
	
	if (x == l && y == r) return Min[cnt][bit & 1];
	int mid = (l + r) / 2;
	if (mid >= y) return ask(x, y, l, mid, cnt * 2, bit);
	else if (mid < x) return ask(x, y, mid + 1, r, cnt * 2 + 1, bit);
	else return min(ask(x, mid, l, mid, cnt * 2, bit), ask(mid + 1, y, mid + 1, r, cnt * 2 + 1, bit));
	
}

priority_queue < pair< int, pair<int, int> > > q;

int main() {

//	freopen("B.in", "r", stdin);
//	freopen("B.out", "w", stdout);

	int n, tot = 0; scanf("%d", &n);
	build(1, n, 1);
	q.push(mp(-ask(1, n, 1, n, 1, 1), mp(1, n)));
	while (!q.empty()) {
		pair< int, pair<int, int> > x = q.top(); q.pop();
		if (x.sc.sc - x.sc.ft == 1) {
			ans[++tot] = w[x.sc.ft], ans[++tot] = w[x.sc.sc];
			continue;
		}
		int Min1 = ask(x.sc.ft, x.sc.sc, 1, n, 1, x.sc.ft);
		int place1 = Hash[Min1];
		if (place1 - 1 > x.sc.ft) q.push(mp(-ask(x.sc.ft, place1 - 1, 1, n, 1, x.sc.ft), mp(x.sc.ft, place1 - 1)));
		int Min2 = ask(place1 + 1, x.sc.sc, 1, n, 1, place1 + 1);
		int place2 = Hash[Min2];
		if (place2 - 1 > place1 + 1) q.push(mp(-ask(place1 + 1, place2 - 1, 1, n, 1, place1 + 1), mp(place1 + 1, place2 - 1)));
		if (x.sc.sc > place2 + 1) q.push(mp(-ask(place2 + 1, x.sc.sc, 1, n, 1, place2 + 1), mp(place2 + 1, x.sc.sc)));
		ans[++tot] = Min1, ans[++tot] = Min2;
	}
	for (int i = 1; i <= tot; ++i)
		printf("%d ", ans[i]);
	return 0;
	
}

Measured memory_bytes: 10744
#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 fi first
#define se second

#define all(n) (n).begin(), (n).end()
#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);	
    cout << setprecision(15);
    ll n, k;
    cin >> n >> k;
    vll nums(n);
    FOR(i, n) cin >> nums[i];
    vector<ld> prob(n);
    FOR(i, n) 
    {
        prob[i] =  ((nums[i] + 1)) / 2.00;
        if (i > 0) prob[i] += prob[i - 1];
    }
    ld m = 0;
    FOR(i, n - k + 1)
    {
        ld sum = prob[i + k - 1];
        if (i > 0) sum -= prob[i - 1];
        m = max(m, sum);
    }
    cout << m << '\n';
}



Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
    map<ll, ll> ma;
    ll N;
    ll a;
    cin >> N;
    for (ll i = 0; i < N; ++i) {
        cin >> a;
        ma[a] += 1;
    }

    for(auto c : ma){
        if(c.second > 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 12800
def main():
    n = int(input())
    inlis = list(map(int, input().split()))

    ans = 0

    for i in range(n):
        flg = 0
        a = inlis[i]
        while flg == 0:
            if a % 2 != 0:
                flg += 1
            else:
                ans += 1
                a /= 2
    print(ans)
        



if __name__ == "__main__":
    main()

Measured memory_bytes: 73516
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
//****************************************
// Graph template
//****************************************

// status of edge
template <typename X>
struct Edge{
  int from;
  int to;
  X cost;
  int idx;
  
  Edge() = default;

  Edge(int from, int to, int idx, X cost) : from(from), to(to), idx(idx), cost(cost) {}
};

// status of node
template <typename X>
struct Node{ 
  int idx;
  vector<Edge<X>> edge;
  int color;
  int d;
  
  Node() = default;

  explicit Node(int idx) : idx(idx) {}
};

template <typename X>
class Graph{
private:
  int n; // number of node
  int m; // number of edge
  vector<Node<X>> node; 
  vector<bool> used;
  
  void Init_Node() {
    rep(i,n) node.emplace_back(i);
  }
public:
  explicit Graph(int n) : n(n) {
    Init_Node();
  }

  // edges have no-weight 
  Graph(int n, int m, vector<int> from, vector<int> to) : n(n), m(m) {
    Init_Node();
    rep(i,m) {
      add_edge(from[i], to[i], i);
      add_edge(to[i], from[i], i);      
    }
  }  

  // edges have weight
  Graph(int n, int m, vector<int> from, vector<int> to, vector<X> cost) : n(n), m(m) {
    Init_Node();
    rep(i,m) {
      add_edge(from[i], to[i], i, cost[i]);
      add_edge(to[i], from[i], i, cost[i]);      
    }
  }

  void add_edge(int from, int to, int idx, X cost = 1) {
    node[from].edge.emplace_back(from, to, idx, cost);
  }

  void Build(vector<int> a) {
    rep(i,n) {
      node[i].d = a[i];
      node[i].color = 0;
    }
  }

  void DFS(int v, int c) {
    if(node[v].color != 0) return ;
    node[v].color = c;
    for(auto next: node[v].edge) {
      int w = next.to;
      if(used[next.idx]) DFS(w, -c);
    }
  }
  
  void solve() {
    vector<int> res(m, 1e+9);
    used.assign(m, false);
    rep(v,n) {
      int mini = 1e+9+10;
      int idx;
      for(auto next: node[v].edge) {
	int w = next.to;
	if(chmin(mini, node[w].d)) {
	  idx = next.idx;
	}
      }
      if(node[v].d < mini) {
	cout << -1 << "\n";
	return ;
      }
      res[idx] = node[v].d;
      used[idx] = true;
    }

    rep(i,n) {
      DFS(i, 1);
    }

    rep(i,n) {
      cout << (node[i].color == 1 ? "W" : "B");
    }
    cout << "\n";
    rep(i,m) cout << res[i] << "\n";
  }
  
};


int main()
{
  int n,m; cin >> n >> m;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> u(m),v(m);
  rep(i,m) {
    cin >> u[i] >> v[i];
    u[i]--; v[i]--;
  }
  
  Graph<int> gp(n, m, u, v);
  gp.Build(a);
  gp.solve();
  
  return 0;
}


Measured memory_bytes: 18636
n = int(input())
N = len(str(n))
k = int(input())
s = [int(i) for i in str(n)]
dpi = [[0]*(k+1) for _ in range(N+1)]
dpj = [[0]*(k+1) for _ in range(N+1)]
dpi[0][0] = 1
for i in range(N):
    for j in range(k+1):
        dpi[i+1][j] += dpi[i][j]*(s[i]==0)
        dpj[i+1][j] += dpj[i][j]+dpi[i][j]*(s[i]>0)
        if j < k:
            dpi[i+1][j+1]+=dpi[i][j]*(s[i]>0)
            dpj[i+1][j+1]+=dpj[i][j]*9+dpi[i][j]*max(0,s[i]-1)
print(dpi[N][k]+dpj[N][k])


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int n, d[110], f[110], t = 0;
set<int> st;
vector<int> g[110];

void dfs(int m) {
  t++;
  d[m] = t;
  st.erase(m);
  for(int i = 0; i < g[m].size(); i++) {
    if(d[g[m][i]] == -1) {
      dfs(g[m][i]);
    }
  }
  t++;
  f[m] = t;
}

int main() {
  cin >> n;
  for(int i = 0; i < n; i++) {
    int index, k, v;
    cin >> index >> k;
    for(int j = 0; j < k; j++) {
      cin >> v;
      g[index].push_back(v);
    }
    st.insert(index);
    d[index] = -1;
  }
  while(!st.empty()) {
    auto itr = st.begin();
    dfs(*itr);
  }
  for(int i = 0; i < n; i++)
    cout << i+1 << " " << d[i+1] << " " << f[i+1] << endl;

  return 0;
}

    

Measured memory_bytes: 3156
import java.util.Scanner;

public class Main {

	private static final int X = 600;

    public static void main(String[] args) {

        //input
        Scanner sc = new Scanner(System.in);



        int S,d;
        while(sc.hasNext()){
            S = 0;
        	d = sc.nextInt();
        	for(int i=1,j=d;j<X;j+=d,i++){
        		S += Math.pow(d*i,2)*d;
        	}

        	//output
        	System.out.println(S);
        }
    }
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = 1e9 + 7;

const int MAX_N = 112345;

vector<int> g[MAX_N];
ll K;

ll ans;

void dfs(int cur, int prev, int c, int depth) {

  if (depth == 0) {
    ans = ans * K % MOD;
  }
  if (depth == 1) {
    ans = ans * (K-1-c) % MOD;
  }
  if (depth >= 2) {
    ans = ans * (K-2-c) % MOD;
  }

  int nc = 0;
  for (int nxt : g[cur]) if (nxt != prev) {
    dfs(nxt, cur, nc, depth + 1);
    nc++;
  }
}

int main2() {
  int N = nextLong();
  K = nextLong();
  REP(i, N-1) {
    int a = nextLong() - 1;
    int b = nextLong() - 1;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  ans = 1;
  dfs(0, -1, 0, 0);
  cout << ans << endl;

  REP(i, N) g[i].clear();

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 14076
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    A = [[int(input()), i] for i in range(n)]
    B = list(reversed(sorted(A)))
    a_1 = B[0][0]
    m = B[0][1]
    a_2 = B[1][0]

    for i in range(n):
        if i==m:
            print(a_2)
        else:
            print(a_1)
    


if __name__ == '__main__':
    main()

Measured memory_bytes: 39448
#include <bits/stdc++.h>
using namespace std;
string s;
long long f[13];
int main(){
  cin>>s;
  f[0]=1;
  for(char c: s){
  	long long g[13];
    for(int i=0; i<13; i++) g[i]=0;
    int low=0, high=0;
    if(c=='?'){
    	low=0;
      	high=9;
    }
    else low=high=c-48;
    for(int j=low; j<=high; j++) for(int k=0; k<13; k++) g[(k*10+j)%13]+=f[k];
    for(int j=0; j<13; j++) f[j]=g[j]%1000000007;
  }
  cout<<f[5]<<'\n';
}

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

int cnt[100001];
int sp[15];

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

	for (int i = 1; i <= N; i++) cnt[i] = N;
	cnt[0] = 0;

	set<int> steps;
	steps.insert(1);
	int pow6 = 6;
	for (;;) {
		if (pow6 <= N) {
			steps.insert(pow6);
			pow6 *= 6;
		} else {
			break;
		}
	}

	int pow9 = 9;
	for (;;) {
		if (pow9 <= N) {
			steps.insert(pow9);
			pow9 *= 9;
		} else {
			break;
		}
	}

	int pos = 0;
	int step_size = steps.size();
	for (auto it = steps.begin(); it!= steps.end(); it++) {
		sp[pos++] = *it;
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < step_size; j++) {
			int next_num = i + sp[j];
			if (next_num <= N) {
				cnt[next_num] = std::min(cnt[next_num], cnt[i]+1);
			}
		}
	}

	cout << cnt[N] << endl;


	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c, d;
  cin >> a>> b >> c >>d;
  bool toggle = true;
  // True when player1 turn
  while(true){
    if(toggle){
      toggle = false;
      c -= b;
      if(c <= 0){
        cout<<"Yes \n";
        break;
      }
    }
    else{
      toggle = true;
      a -= d;
      if(a <= 0){
        cout<<"No \n";
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3600
x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(x[k-1])

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

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

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
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();
}

//
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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int a, b;
  cin >> a >> b;

  cout << max({a + b, a - b, a * b}) << endl;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

ans = 0
step = 0
i = 0
while i < len(h)-1:
    if h[i] >= h[i+1]:
        step +=1
        ans = max(ans, step)
    else:
        step = 0
    i += 1

print(ans)

Measured memory_bytes: 20212
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;

        ll n;
        cin >> n;
        ll ans  =0;
        rep1(i,1, n){
        if (i%3!=0 && i%5!=0)
            ans += i;
        }
        cout<<ans<<endl;

return 0;
}



Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int n,i;
    cin>>n;
    int a[100];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    int out=0;
    for(i=0;i<n;i=i+2){
        if(a[i]%2==1){
            out++;
        }
    }
    cout<<out;}


Measured memory_bytes: 3760
#include<stdio.h>

int main(void){
  char s[1000];
  int n,i;
  scanf("%s",s);
  scanf("%d",&n);  
  if(n==1){
    printf("%s",s);
    return 0;
  }
  
  while(s[i]){
    if((i+1)%n==1){
      printf("%c",s[i]);
    }
    i++;
  }
  
  printf("\n");
  
  return 0;
}


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

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class AWeatherPrediction {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        string s;
        in>>s;
        if(s=="Sunny") out<<"Cloudy"<<endl;
        else if(s=="Cloudy") out<<"Rainy"<<endl;
        else out<<"Sunny"<<endl;
    }
};

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


Measured memory_bytes: 256
N = int(input())
F = []
P = []

for i in range(N):
    Fi = list(map(int, input().split()))
    F.append(Fi)

for i in range(N):
    Pi = list(map(int, input().split()))
    P.append(Pi)

ans = -10 ** 18

# print(F)
for i in range(1, 2**10):
    kaburi_list = []
    tmp = 0
    for tenpo in range(N):
        kaburi = 0
        for j in range(10):
            if i >> j & F[tenpo][-(j+1)] == 1:
                kaburi += 1
        kaburi_list.append(kaburi)
        tmp += P[tenpo][kaburi]
    ans = max(ans, tmp)

print(ans)


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,k;
    cin>>n>>k;
    vi h(n);
    ll sum = 0;
    REP(i,n) {
        cin>>h[i];
        sum += h[i];
    }

     sort(ALL(h), greater<int>());

     REP(i,min(n,k)){
         sum = max(0LL, sum-h[i]);
     }

    cout<< sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;
typedef long long int lli;


void solve(){
    string s,t;
    getline(cin>>ws, s);
    getline(cin>>ws, t);
    int n=s.length();
    int m=t.length();
    vector< vector<int> > dp(n+1, vector<int>(m+1));
    for(int i=0; i<=n; i++){
        for(int j=0; j<=m; j++){
            if(i==0 || j==0){
                dp[i][j]==0;
            }
            else if(s[i-1]==t[j-1]){
                dp[i][j]=1+dp[i-1][j-1];
            }
            else{
                dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    string ans;
    int i=n,j=m;
    while(dp[i][j]!=0){
        if(s[i-1]==t[j-1]){
            ans=s[i-1]+ans;
            i--;
            j--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1]){
                i--;
            }
            else{
                j--;
            }
        }
    }
    cout<<ans<<endl;
}

signed main(){
	//#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    //freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    //freopen("output.txt", "w", stdout);
    //#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
}


Measured memory_bytes: 35584
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

//
// # Examples
//
// # integers
// input! { n: i32, m: i32, ... }
//
// # array
// input! { n: i32, v: [i32; n], }
//
// # matrix
// input! { n: i32, m: i32, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: i32,
//     w: i32,
//     board: [chars; h],
// }

// https://practice.contest.atcoder.jp/tasks/practice_1
//fn main() {
//    input!{
//        a: i32, b: i32, c: i32,
//        foo: chars,
//    }
//    let s: String = foo.into_iter().collect();
//    println!("{} {}", a+b+c, s);
//}
fn main() {
    input! { x: usize, a: usize, b: usize }
    println!("{}", (x-a)%b);
}

Measured memory_bytes: 4352
use std::collections::HashMap;
use std::io;

fn main() {
    let mut next_weather = HashMap::new();
    next_weather.insert("Sunny".to_string(), "Cloudy".to_string());
    next_weather.insert("Cloudy".to_string(), "Rainy".to_string());
    next_weather.insert("Rainy".to_string(), "Sunny".to_string());
    let line = parse_line::<String>();
    println!("{}", next_weather.get(&line).unwrap());
}

fn parse_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
  int n;
  ll a,b;
  cin >> n >> a >> b;
  vector<ll> v(n);
  rep(i,n)
    cin >> v.at(i);
  ll d=0;
  rep(i,n-1){
    if((v.at(i+1)-v.at(i))*a<=b){
      d+=(v.at(i+1)-v.at(i))*a;
      continue;
    }
    d+=b;
  }
  cout << d << endl;
}

Measured memory_bytes: 1024