akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int N, X, Y, Z, W;
      cin >> N;
      
      W = N % 10;
      N = N - W;
      
      Z = N % 100;
      N = N - Z;
      Z = Z / 10;      
      
      Y = N % 1000;
      N = N - Y;
      Y = Y / 100;
      
      X = N / 1000;
      
      if (X == Y && Y == Z){
        cout << "Yes" << endl;
      }
      
      else if (Y == Z && Z == W){
        cout << "Yes" << endl;
      }
      
      else {
        cout << "No" << endl;
      }
      
    }

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100005
#define NIL -1

typedef struct Node{int p,left,right;}N;

N T[MAX];
int n,D[MAX];

int rec(int u,int p){
	D[u] = p;
	if(T[u].right != NIL) rec(T[u].right,p);
	if(T[u].left != NIL) rec(T[u].left,p+1);


}

void print(int u){
	int i,c;
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].p);
	printf("depth = %d, ",D[u]);
	
	if(T[u].p == NIL)printf("root, ");
	else if(T[u].left == NIL)printf("leaf, ");
	else printf("internal node, ");
	
	printf("[");
	
	for(i = 0, c = T[u].left;c != NIL;i++,c = T[c].right){
	if(i)printf(", ");
	printf("%d",c);
	}
	printf("]\n");
	
}


int main(void){
	int i,j,d,v,c,left,right;
	scanf("%d",&n);
	for(i = 0;i < n;i++){
	T[i].p = NIL;
	T[i].left = NIL;
	T[i].right = NIL;
	}
	
	for(i = 0;i < n;i++){
	scanf("%d %d",&v,&d);
		for(j = 0;j < d;j++){
		scanf("%d",&c);
		if(j == 0) T[v].left = c;
		else T[left].right = c;
		left = c;
		T[c].p = v;
		}
	}
	for(i = 0;i < n; i++){
	if(T[i].p == NIL)right = i;
	}
	
	rec(right,0);
	
	for(i = 0;i < n; i++)print(i);

	return 0;
	
}


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

dp=[float('inf') for i in range(n)]
dp[0]=0

for i in range(1,n):
 for j in range(1,k+1):
  if i-j>=0:
   dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
  else:
   break

print(dp[-1])

Measured memory_bytes: 56800
#include <bits/stdc++.h>
using namespace std;
int main(){
	int t,r,p;
	while(1){
		cin>>t>>r>>p;
		if(!t&&!r&&!p)break;
		int wrong[50][10],pena[50],team[50];
		bool flag[50][10];
		for(int i=0;i<t;i++){
			pena[i]=0;team[i]=0;
			for(int j=0;j<r;j++){
				wrong[i][j]=0;flag[i][j]=false;
			}
		}
		while(p--){
			string s;
			int a,b,c;
			cin>>a>>b>>c>>s;a--;b--;
			if(s=="WRONG"){
				wrong[a][b]++;
			}else {
				if(!flag[a][b]){
					pena[a]+=wrong[a][b]*1200+c;
					team[a]++;flag[a][b]=true;
				}
			}
		}
		vector<int> ans[11];
		for(int i=0;i<t;i++){
			ans[team[i]].push_back(i);
		}
		for(int i=1;i<11;i++){
			if(ans[i].size()>0){
				for(int j=0;j<ans[i].size();j++){
//					cout<<i<<" "<<ans[i][j]<<" "<<pena[ans[i][j]]<<endl;
				}
			}
		}
		vector<pair<int,int> > data;
		for(int i=10;i>=0;i--){
			data.clear();
			if(ans[i].size()>0){
				for(int j=0;j<ans[i].size();j++){
					data.push_back(make_pair(pena[ans[i][j]],ans[i][j]));
//					cout<<pena[ans[i][j]]<<" "<<ans[i][j]<<" "<<data.size()<<endl;
				}
				sort(data.begin(),data.end());
				for(int j=0;j<ans[i].size();j++){
					int y=data[j].second;
//					cout<<data[i].first<<" "<<y<<endl;
					cout<<y+1<<" "<<team[y]<<" "<<pena[y]<<endl;
				}
			}
		}
	}
}

Measured memory_bytes: 1244
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

using Pair = pair<int, int>;

int main() {
  int N;
  cin >> N;
  vector<int> as(N + 1);
  map<int, vector<int>> ps;

  for(int i = 1; i <= N; ++i) {
    cin >> as[i];
    ps[as[i]].push_back(i);
  }

  queue<Pair> qs;
  for(auto i : ps[2]) {  // 2が出発点
    qs.push(Pair(i, 1)); // indexがv
  }

  while(!qs.empty()) {
    auto top = qs.front();
    qs.pop();

    if(top.first == 1) {
      cout << top.second << endl;
      return 0;
    }

    if(top.second > N) {
      continue;
    }

    for(auto i : ps[top.first]) {
      qs.push(Pair(i, top.second + 1));
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 11520
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
bool is_right_triangle (int a, int b, int c) {
	if (b < a) std::swap(a, b);
	if (c < b) std::swap(b, c);
	if (b < a) std::swap(a, b);
	return (a * a + b * b == c * c);
}
int main(){
	int cnt;
	cin >> cnt;
	for (int i = 0; i < cnt; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		if (is_right_triangle(a, b, c))		cout << "YES";
		else								cout << "NO";
		cout << "\n";
	}
    return 0;
}

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

typedef long long ll;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

const int INF = 1001001001;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> S(H, vector<char>(W));
    for (int i=0;i<H;i++){
        for (int j=0;j<W;j++){
            cin >> S[i][j];
        }
    }
    int ans = 0;
    for (int ih=0;ih<H;ih++){
        for (int iw=0;iw<W;iw++){
            if (S[ih][iw] == '#') continue;
            vector<vector<int>> dist(H,vector<int>(W,INF));
            queue<pair<int,int>> q;
            auto update = [&] (int i, int j, int x){
                if (dist[i][j] != INF) return;
                dist[i][j] = x;
                q.push(make_pair(i,j));
            };
            update(ih, iw, 0);
            while (!q.empty()) {
                int i = q.front().first;
                int j = q.front().second; q.pop();
                for (int dir=0;dir<4;dir++){
                    int ni =  i+dx[dir], nj = j + dy[dir];
                    if (ni<0||H<=ni||nj<0||W<=nj) continue;
                    if (S[ni][nj] == '#') continue;
                    update(ni, nj, dist[i][j]+1);
                }
            }
            for(int i=0;i<H;i++){
                for (int j=0;j<W;j++){
                    if (dist[i][j] == INF) continue;
                    ans = max(ans, dist[i][j]);
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int main() {
   int n;
   cin >> n;
   vector<int> c(n-1), s(n-1), f(n-1);
   for (int i = 0; i < n-1; i++) {
      cin >> c[i] >> s[i] >> f[i];
   }

   for (int i = 0; i < n; i++) {
      int t = 0;
      for (int j = i; j < n-1; j++) {
         if (t < s[j]) {
            t = s[j];
         } else if (t % f[j] == 0) {

         } else {
            t = t + f[j] - t % f[j];
         }
         t += c[j];
      }
      cout << t << endl;
   }


   return 0;
}

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

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

	int n = N;
	int ans1 = 1;
	for( int i = 0; i < 2; i++ ) {
		ans1 *= n;
		n--;
	}
	int ans = ans1 / 2;
	n = M;
	ans1 = 1;
	for( int i = 0; i < 2; i++ ) {
		ans1 *= n;
		n--;
	}
	ans += ans1 / 2;

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define sz(x) (int)(x.size())
#define mod 1000000007
#define endl "\n"
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;



int32_t main(){
    ios::sync_with_stdio(false);
    int n, x, t;
    cin>>n>>x>>t;
    int ans = n/x;
    if (n%x){
        ans++;
    }
    ans= ans*t;
    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 3632
n = int(input())
start = list(input())
ans = dict()
for i in start:
    if i not in ans:
        ans[i] = 1
    else:
        ans[i] += 1
for i in range(n-1):
    k = dict()
    for j in list(input()):
        if j in k:
            k[j] += 1
        else:
            k[j] = 1
    for j in ans.keys():
        if j in k:
            ans[j] = min(ans[j], k[j])
        else:
            ans[j] = 0
p = ""
for i in ans.keys():
    for j in range(ans[i]):
        p += i
p = list(p)
p.sort()
print("".join(p))

Measured memory_bytes: 40944
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int ar[n];
    int color[9];

    int i,j,sum,ans,flag=0,a,b;
    a=0;
    b=0;
    for(i=0;i<9;i++)
        color[i]=0;
    for(i=0; i<n; i++)
    {
        cin>>ar[i];
        if(ar[i]>=3200)
            color[8]++;
        else if(ar[i]>=2800)
            color[7]++;
        else if(ar[i]>=2400)
            color[6]++;
        else if(ar[i]>=2000)
            color[5]++;
        else if(ar[i]>=1600)
            color[4]++;
        else if(ar[i]>=1200)
            color[3]++;
        else if(ar[i]>=800)
            color[2]++;
        else if(ar[i]>=400)
            color[1]++;
        else if(ar[i]>=1)
            color[0]++;

    }
    for(i=0;i<8;i++)
        if(color[i]!=0)
        {
            a++;
        }
        b=a+color[8];
        if(a==0)
            a=1;
        cout<<a<<" "<<b<<endl;
}


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

using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;



int main() {
const ll INF = 1001001001;
const ld PI = 3.14159265358979323846;
int l=0,max_l=0;
string S;
cin>>S;
rep(i,S.size()){
    if((S[i]=='A')||(S[i]=='C')||(S[i]=='G')||(S[i]=='T')){
        l++;
        max_l=max(max_l,l);
    }
    else{
        l=0;
    }
}
cout<<max_l<<endl;
return 0;
}


Measured memory_bytes: 256
import sys
import re
s = str(input())
if len(s) < 0 or len(s) > 200000:
    sys.exit()

array_str = re.findall(r'A.*Z', s)
max = 0
for I in array_str:
    if len(I) > max:
        max = len(I)
print(max)


Measured memory_bytes: 10092
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        a[i] -= i + 1;
    }
    sort(a.begin(), a.end());
    ll mid;
    if (n % 2 == 0)
    {
        mid = a[n / 2];
    }
    else
    {
        mid = a[(n - 1) / 2];
    }
    // cout << mid << endl;
    ll sum = 0;
    for (ll i = 0; i < n; i++)
    {
        sum += llabs(a[i] - mid);
    }

    cout << sum << endl;
}

Measured memory_bytes: 1792
n,k=map(int,input().split())
s=list(range(n+1))
mod = 10**9+7
for i in range(1,n+1):
    s[i]=(s[i]+s[i-1])%mod
ans=1
for i in range(k,n+1):
    ans=(ans+s[-1]-s[-i-1]-s[i-1]+1)%mod
print(ans)

Measured memory_bytes: 16656
#include <iostream>
#include <vector>
#include <map>
using ll = long long int;
using namespace std;
int main(){
  ll  n;
  cin >> n;
  map<ll, ll> mp;
  
  for (ll i=0;i<n; i++){
    ll ai;
    cin>>ai;
    mp[ai]++;
  }
  ll  ans=0;
  for(auto &&e : mp){
    if(e.first > e.second)
      ans += e.second;
    else if (e.first < e.second)
      ans += (e.second - e.first);
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 6272
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#define ll long long
using namespace std;

int main(){

  int x[5];
  int N=5;
  for (int i=0; i<N; i++)
    cin >> x[i];

  for (int i=0; i<N; i++)
    if (x[i] == 0) cout << i+1 << endl;

  return 0;
}

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

// input
int N, M;
vector<int> A, B;


void input() {
    cin >> N >> M;
    A = B = vector<int>(M);
    rep(i, M) cin >> A[i] >> B[i];
}


int main() {
    input();
    vector<int> w(N);
    rep(i, M) {
        w[A[i] - 1]++;
        w[B[i] - 1]++;
    }
    rep(i, N) cout << w[i] << endl;
}


Measured memory_bytes: 3612
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  [n, m, x, y] <- map (read::String -> Int) . words <$> getLine
  arr1 <- reverse . sort . (++) [x] . map (read::String -> Int) . words <$> getLine
  arr2 <- sort . (++) [y] . map (read::String -> Int) . words <$> getLine
  putStrLn $ if arr2 !! 0 > arr1 !! 0  then "No War" else "War"


Measured memory_bytes: 1020
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
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 SimplyDivine
 */
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);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n + 1];
            for (int i = 1; i <= n; i++) {
                a[i] = in.nextInt();
            }
            boolean sw[] = new boolean[n + 1];
            sw[1] = true;
            int cnt = 0;
            boolean visited[] = new boolean[n + 1];
            int i = 1;
            while (true) {
                if (visited[i]) {
                    break;
                }
                if (sw[2]) {
                    out.println(cnt);
                    return;
                }
                if (sw[i]) {
                    visited[i] = true;
                    sw[i] = false;
                    sw[a[i]] = true;
                    cnt++;
                    i = a[i];
                }

            }
            out.println(-1);
            return;
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 35592
#define  REP(i, s, e) for (int i = s; i <= e; i++)
#define DREP(i, s, e) for (int i = s; i >= e; i--)
#define DEBUG fprintf(stderr, "Passing [%s] in Line %d\n", __FUNCTION__, __LINE__)

#define chkmax(a, b) a = max(a, b)
#define chkmin(a, b) a = min(a, b)

#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;
const int maxn = 4e5 + 10;

int n, ans, m;
int a[maxn], b[maxn], ta[maxn], tb[maxn], tot0, data[maxn], fa[maxn];
int find(int x) {return fa[x] == x ? x : fa[x] = find(fa[x]);}
inline void uni(int x, int y) {fa[find(x)] = find(y);}

int rename(int val) {return lower_bound(data + 1, data + m + 1, val) - data;}

int main()
{
#ifdef CraZYali
	freopen("D.in", "r", stdin);
	freopen("D.out", "w", stdout);
#endif
	cin >> n;
	REP(i, 1, n) scanf("%d", a + i), a[n+1] ^= a[i];
	REP(i, 1, n) scanf("%d", b + i), b[n+1] ^= b[i];
	n++;
	copy(a + 1, a + 1 + n, ta + 1);
	copy(b + 1, b + 1 + n, tb + 1);
	sort(ta + 1, ta + n + 1);
	sort(tb + 1, tb + n + 1);
	REP(i, 1, n - 1) if (ta[i] ^ tb[i]) return puts("-1"), 0;

	REP(i, 1, n) 
		if(a[i] ^ b[i] || i == n)
		{
			data[++m] = a[i];
			data[++m] = b[i];
			if(i < n) ans++;
		}
	if(ans == 0) return puts("0"), 0;
	sort(data + 1, data + m + 1);
	m = unique(data + 1, data + m + 1) - data - 1;
	REP(i, 1, m) fa[i] = i;
	REP(i, 1, n) uni(rename(a[i]), rename(b[i]));
	REP(i, 1, m) ans += (i == fa[i]);
	cout << ans - 1 << endl;
	return 0;
}


Measured memory_bytes: 8832
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
int main()
{
	ll n,l0=2,l1=1,l2=3,cnt=0;
    cin>>n;
    vector<ll> v;
    v.push_back(2);    
    v.push_back(1);
    REP(i,2,n)
    {
        v.push_back(v[i-1]+v[i-2]);       
    }    
    cout<<v[v.size()-1];
}

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

using namespace std;

int main(void){
    int n, k;

    cin >> n >> k;
    vector<long long> h(n,0);

    long long h_sum = 0;
    for(int i=0; i<n; i++){
        cin >> h[i];
        h_sum+=h[i];
    }

    sort(h.rbegin(), h.rend());

    if(n<k)
        k = n;

    for(int i=0; i<k; i++){
        h_sum -= h[i];
    }

    cout << h_sum << endl;

    return 0;
}

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

int k,x;

int main(){
  cin>>k>>x;
  for(int i=x-k+1; i<x+k; i++) {
    if(i>=-1000000 && i<=1000000) cout<<i<<" ";
  }
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    L,R,d = map(int,input().split())
    ans = 0
    for i in range(L,R + 1):
        if i%d == 0:
            ans += 1
    print(ans)
if __name__ == '__main__':
    main()

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

inline void read(int&x){
	char c11=getchar();x=0;while(!isdigit(c11))c11=getchar();
	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();
}

const int N = 201000;
int a[N],b[N],n;

bool check(int c){
	for(int i=1;i<=n+n-1;++i)
		b[i] = (a[i] >= c);
	int l = n, r = n;
	while(l>1 and b[l] != b[l-1]) --l;
	while(r < n+n-1 and b[r] != b[r+1]) ++r;
	
	int tag = 0, res = b[n];
	for(int i=1;i<=n;++i){
		while(l < r and b[l] == (b[l+1] ^ tag)) b[++l] ^= tag;
		while(l < r and b[r] == (b[r-1] ^ tag)) b[--r] ^= tag;
		tag ^= 1;
		if(l < n and n < r) res ^= 1;
	}
	return res;
}

int main(){
	read(n);
	for(int i=1;i<=n+n-1;++i) read(a[i]);
	int l = 1, r = n+n+1, mid, res = 0;
	while(l<=r){
		mid = l + r >> 1;
		if(check(mid)) l = (res = mid) + 1;
		else r = mid - 1;
	}
	printf("%d\n",res);
	return 0;
}

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

int f[50];

int fibo(int n)
{
  if(n <= 1) return 1;
  else{
    if(f[n]){
      return f[n];
    }
    else{
      return f[n] = fibo(n-1)+fibo(n-2);
    }
  }
}

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

  cout << fibo(n) << endl;
  return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 50;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;


itn N, M;
vector<vector<int>> G;

double dp[606], dp2[606];

void solve() {
    for (int i = N - 2; i >= 0; i--) {
        for (auto& nxt : G[i]) {
            dp[i] += dp[nxt] + 1;
        }
        dp[i] /= G[i].size();
    }
    double ans = dp[0];

    FOR(N - 1) {
        if (G[i].size() == 1)
            continue;
        FOR(j, i + 1, N) {
            dp2[j] = dp[j];
        }
        double SUM = 0, MAX = 0;
        for (auto& nxt : G[i]) {
            SUM += dp2[nxt] + 1;
            chmax(MAX, dp[nxt] + 1);
        }
        dp2[i] = (SUM - MAX) / (G[i].size() - 1);
        for (int j = i - 1; j >= 0; j--) {
            dp2[j] = 0;
            for (auto& nxt : G[j]) {
                dp2[j] += dp2[nxt] + 1;
            }
            dp2[j] /= G[j].size();
        }
        chmin(ans, dp2[0]);
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    cin >> N >> M;
    G.resize(N);
    FOR(M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].eb(b);
    }


    solve();
    return 0;
}


Measured memory_bytes: 2560
a = []
for _ in range(3):
    a.append(list(map(int, input().split())))
n = int(input())
b = []
for _ in range(n):
    b.append(int(input()))
b = set(b)
row = []
col = []
diag = []
for i in range(3):
    tmp1 = []
    tmp2 = []
    for j in range(3):
        tmp1.append(a[i][j])
        tmp2.append(a[j][i])
    row.append(set(tmp1))
    col.append(set(tmp2))

tmp3 = []
tmp4 = []
for i in range(3):
    tmp3.append(a[i][i])
    tmp4.append(a[i][2-i])
diag.append(set(tmp3))
diag.append(set(tmp4))

bingo = False
for i in range(3):
    if row[i] <= b or col[i] <= b:
        bingo = True
for i in range(2):
    if diag[i] <= b:
        bingo = True

if bingo:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
def main():
  a, b, c, d = list(map(int, input().split(' ')))
  l = lcm(c, d) if c >= d else lcm(d, c)
  ans = (b - (b//c + b//d - b//l)) - ((a-1) - ((a-1)//c + (a-1)//d - (a-1)//l))
  print(ans)


def gcd(l, s):
  if s == 0:
    return l
  else:
    a = l % s
    return gcd(s, a)


def lcm(l, s):
  return l * s // gcd(l, s)


if __name__ == '__main__':
  main()


Measured memory_bytes: 3064
#include<stdio.h>
#include<limits.h>

#define NK 100000

int main( int argc, char *argv[] ) 
{
	int n, k, w[NK], P = INT_MAX;

	scanf( "%d%d", &n, &k );

	int i, sum = 0, miniLoadings = 0;
	for ( i=0; i<n; i++ ) {
		scanf( "%d", &w[i] );
		sum += w[i];
		if( miniLoadings < w[i] ) {
			miniLoadings = w[i];
		}
	}
	
	int j, start;
	int truck, truckCnt, loadings;
	
	if( 1 == k ) {
        P = sum;    
    } else if( n == k ) {
    	P = miniLoadings;
    } else {
    	miniLoadings = sum/k;
		start = loadings = 0;
		for( i=0; i<n; i++ ) {
			loadings += w[i];
			if( P < loadings ) { 
				loadings -= w[ start++ ];
				loadings -= w[ i-- ];
				continue;
			}
			if( miniLoadings <= loadings ) {
				truck = 0;
				truckCnt = k;
				for( j=0; truckCnt!=0 &&  j<n; j++ ) {
					truck += w[j];
					if( loadings < truck ) {
						truckCnt--;
						j--;
						truck = 0;
					}
				}
				if( truckCnt && loadings <= P ) {
					P = loadings;
					loadings -= w[ start++ ];
					loadings -= w[ i-- ];
				} else {
					miniLoadings = loadings;
				}
			}
		}
	}

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

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

int main() {
    int x;
    cin >> x;
    int a = x / 100;
    int ans = 1;
    if (a < 20) {
        int b = x - a * 100;
        if (b > a * 5) ans = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int a, b, c; cin >> a >> b >> c;
    if (a != b && a != c && b != c) cout << "No" << endl;
    else if (a == b && b == c) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools
import math
def dist(c1,c2):
  return math.sqrt((c1[0]-c2[0])**2+(c1[1]-c2[1])**2)
n = int(input())
cities = {}
s = 0
for i in range(n):
  cities[i] = list(map(int,input().split()))
lis = [x for x in range(n)]
for junjo in itertools.permutations(lis):
  for i in range(len(junjo)-1):
#    print(i,cities[junjo[i]],cities[junjo[i+1]])
    s += dist(cities[junjo[i]],cities[junjo[i+1]])
print(s/math.factorial(n))

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

#define MAX_V 100005

struct edge {
    int to;
    ll cost;
};

ll V, d[MAX_V];
vector<edge> G[MAX_V]; // 隣接リスト表現

void dijkstra(int s) {
    fill(d, d + V, INF_LL);
    d[s] = 0;  // 始点sへの最短距離は0

    priority_queue<P, vector<P>, greater<P>> que;  // 距離が小さい順に取り出せるようgreater<P>を指定
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;  // 更新した頂点の中で距離が最小の頂点v
        if (d[v] < p.first) {
            continue;
        }
        for (auto e : G[v]) {  // 頂点vから出る辺eを走査
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int m;
    cin >> V >> m;

    REP(i, V-1) {
        G[i+1].push_back(edge{i, 0});
    }

    REP(i, m) {
        int l, r;
        ll c;
        cin >> l >> r >> c;
        l--, r--;
        G[l].push_back(edge{r, c});
    }

    dijkstra(0);

    if(d[V-1] == INF_LL) {
        cout << "-1" << endl;
    } else {
        cout << d[V-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 10232
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<ll, ll> P;
bool pairCompare(P firstElof, P secondElof)
{
    if (firstElof.first != secondElof.first) return firstElof.first > secondElof.first;
    else return firstElof.second > secondElof.second;
}
int main()
{
    int N;
    cin >> N;

    vector<ll> AB(N);
    ll sum = 0;
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        AB[i] = a + b;
        sum -= b;
    }

    sort(all(AB));
    reverse(all(AB));

    ll ans = 0;
    rep(i, N) {
        if (i % 2 == 0) {
            ans += AB[i];
        }
    }

    cout << ans + sum << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000
 
int Partition(int [], int, int);
 
int q;
 
int main(void){
 
  int A[MAX+1];
  int i, p, n;
 
  scanf("%d",&n);
 
  for(i=1;i<=n;i++) scanf("%d",&A[i]);
 
  p = 1;
  q = Partition(A,p,n);
 
 
  for(i=1;i< n;i++){
    if(i==q) printf("[%d] ",A[i]);
    else printf("%d ",A[i]);
  }
 
  printf("%d\n",A[i]);
 
  return 0;
}
 
 
int Partition(int A[], int p, int r){
 
  int i, j, x;
  int tmp;
 
  x = A[r];
  i = p - 1;
 
  for(j = p;j<r;j++){
    if(A[j] <= x){
      i = i + 1;
      tmp = A[j];
      A[j] = A[i];
      A[i] = tmp;
    }
  }
   
  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;
 
  return i+1;
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
int main(){
	priority_queue<int> a;
	int n,ans=0;
	cin>>n;
	for(int i=0;i<n;i++){
		int t;
		cin>>t;
		a.push(t);
	}
	bool k=0;
	if(a.top()%2==1){
		k=1;
	}
	ans+=a.top()/2;
	a.pop();
	for(int i=0;i<n-1;i++){
		ans+=a.top();
		a.pop();
	}
	cout<<ans;
	if(k){
		cout<<".5";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		List<String> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			String s = sc.next();
			list.add(s);
		}
		Collections.sort(list);
		for (String str : list) {
			System.out.print(str);
		}
		System.out.println("");
 	}
}

Measured memory_bytes: 21972
from itertools import accumulate
from operator import itemgetter

n, d = map(int, input().split())
aaa = list(map(int, input().split()))
costs_l = [(-i * d + a, i) for i, a in enumerate(aaa)]
costs_r = [(i * d + a, i) for i, a in enumerate(aaa)]

costs_l = list(accumulate(costs_l, min))
costs_r = list(accumulate(reversed(costs_r), min))
costs_r.reverse()

hubs = set(map(itemgetter(1), costs_l))
hubs.intersection_update(map(itemgetter(1), costs_r))
hubs.add(0)
hubs.add(n - 1)
hubs = sorted(hubs)

ans = sum(aaa) - aaa[-1]
s = hubs[0]
for t in hubs[1:]:
    cls = costs_l[s][0]
    crt = costs_r[t][0]
    ans += crt - s * d
    ans += sum(min(cls + i * d, crt - i * d) for i in range(s + 1, t))
    s = t
print(ans)


Measured memory_bytes: 92548
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    ll n,a,b,c,d,x=0;
    cin>>n>>a>>b>>c>>d;
    rep(i,n) if(a+i*c-(n-i-1)*d<=b&&b<=a+i*d-(n-i-1)*c) x=1;
    if(x) cout<<"YES";
    else cout<<"NO";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int n;
int a[200005];
int b;
int mx;

int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &b);
        a[b] = a[b - 1] + 1;
        mx = max(mx, a[b]);
    }
    printf("%d", n - mx);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;

int main(){
    int k, s; 
    cin >> k >> s;
    int ans = 0;
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= k; j++) {
            int l = s - i - j; 
            if (l <= k && l >= 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3588
import numpy as np

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
out = [int(input()) for _ in range(D)]

sat = 0
last = [0] * 26
for d in range(D):
	j = out[d] - 1
	last[j] = d + 1
	for i in range(26):
		sat -= (d + 1 - last[i]) * c[i]
	sat += s[d][j]
	print(sat)

Measured memory_bytes: 27444
#include <stdio.h>

int main()
{
    int N, T, i, menor = 999999999, u = 0;
    
    scanf ("%d%d", &N, &T);
    
    int c[N], t[N];
    
    for (i = 0; i < N; i ++){
        scanf ("%d%d", &c[i], &t[i]);
    }
    
    for (i = 0; i < N; i ++){
        if (t[i] <= T){
            if (menor > c[i]){
            menor = c[i];
            }
            u ++;
        }
    }
    
    if (u == 0)
        printf ("TLE");
    else 
        printf ("%d", menor);
    
    return 0;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  string S;
  cin >> S;

  if (S.size() == 0 || S.size()%2 != 0) {
    cout << "No" << endl;
    return 0;
  }

  for(int i = 0; i < S.size(); i+=2) {
    if(S[i] == 'h' && S[i+1] == 'i') {
      continue;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#define LL long long
#define PP std::pair<LL,int>
bool went[100010];
bool used[100010];
std::vector<int> G[100010];
LL a[100010];
LL ans;
int N, M;

void dfs(int s,LL &m,int &f) {
	went[s] = true;
	if (m > a[s]) {
		m = a[s];
		f = s;
	}
	for (auto u : G[s]) {
		if (!went[u]) {
			dfs(u,m,f);
		}
	}
}


int main() {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cin >> N >> M;
	for (int i = 0; i < N; i++) {
		std::cin >> a[i];
	}
	
	for (int i = 0; i < M; i++) {
		int a, b;
		std::cin >> a >> b;
		G[a].emplace_back(b);
		G[b].emplace_back(a);
	}
	if (M == N - 1) {
		std::cout << 0 << std::endl;
		return 0;
	}
	if (N < 2 * (N - M - 1)) {
		std::cout << "Impossible" << std::endl;
		return 0;
	}
	for (int i = 0; i < N; i++) {
		if (!went[i]) {
			LL m = a[i];
			int f = i;
			dfs(i, m, f);
			used[f] = true;
			ans += m;
		}
	}
	std::vector<LL> S;
	for (int i = 0; i < N; i++) {
		if (!used[i])S.emplace_back(a[i]);
	}
	std::sort(S.begin(), S.end());
	for (int i = 0; i < N - M - 2; i++) {
		ans += S[i];
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 7928
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) (n); i++)
#define ll long long
#define scout cout << fixed << setprecision(10)
ll INF = 9e17;
ll mod = 1e9 + 7;

int main() {
	int n; cin >> n;
	vector<long double> a(n);
	rep(i,n) cin >> a[i];
	long double ans = 0;
	rep(i,n) ans += 1/a[i];
	scout << 1/ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MN 187
typedef std::pair<int,int> P;
int n,m,dp[MN][MN][MN][17];
char mp[MN][MN];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%s",mp[i]+1);
	for(int i=n;i>=1;i--)
	{
		for(int j=m;j>=1;j--)
		{
			for(int k=j;k<=m;k++) {
				if(j==k) dp[i][j][j][0]=1+((mp[i][j]==mp[i+1][j])?dp[i+1][j][j][0]:0);
				else dp[i][j][k][0]=(mp[i][j]==mp[i][k])?std::min(dp[i][j][k-1][0],dp[i][k][k][0]):0;
//				printf("%d %d %d %d %dxx\n",i,j,k,dp[i][j][k][0],1+((mp[i][j]==mp[i+1][j])?dp[i+1][j][j][0]:0));
			}
		}
	}
	for(int l=1;l<=16;l++)
	{
		for(int i=1;i<=n;i++) {
			for(int j=1;j<=m;j++)
				for(int k=j;k<=m;k++) {
					dp[i][j][k][l]=dp[i][j][k][l-1]+dp[i+dp[i][j][k][l-1]][j][k][l-1];
					if(j==k) continue;
					int L=j,R=k-1,ans=j;
					while(L<=R) {
						int mid=L+R>>1;
						if(dp[i][j][mid][l-1]>=dp[i][mid+1][k][l-1]) ans=mid,L=mid+1;
						else R=mid-1;
					}
					dp[i][j][k][l]=std::max(std::min(dp[i][j][ans][l-1],dp[i][ans+1][k][l-1]),dp[i][j][k][l]);
					if(ans!=k-1) dp[i][j][k][l]=std::max(std::min(dp[i][j][ans+1][l-1],dp[i][ans+2][k][l-1]),dp[i][j][k][l]);
				}
		}
	}
	for(int i=0;i<=16;i++) if(dp[1][1][m][i]>=n) return 0*printf("%d\n",i);
}

Measured memory_bytes: 430464
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;

int main(){
    long long A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    map<pair<long long, long long>, long double> T;
 
    for(long long a = 0; a < 31; a++){
        for(long long b = 0; b < 31; b++){
            for(long long c = 0; c < 101; c++){
                for(long long d = 0; d < 101; d++){
                    long long water = 100*A*a + 100*B*b;
                    long long sugar = C*c + D*d;
                    if(water == 0) continue;
                    if(water + sugar > F) continue;
                    if(water * E < sugar*100) continue;

                    T[make_pair(water, sugar)] = (long double)sugar/((long double)water+(long double)sugar);
                }
            }
        }
    }

    long double maxv = 0;

    map<pair<long long, long long>, long double>::iterator it;

    for(it = T.begin(); it  != T.end(); it++){
        if(maxv < it->second) maxv = it->second;
    }

    //printf("maxv %Lf\n", maxv);
    long long W = 0, S = 0;
    for(it = T.begin(); it  != T.end(); it++){
        if(maxv == it->second) W = it->first.first, S = it->first.second;
    }

    cout << W + S << " " <<  S << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	ll n,k; cin >> n >> k;

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

	ll cnt[63]; fill(cnt,cnt+63,0);

	for (int i = 0;i < n;i++){
		for (int j = 0;j < 63;j++){
			if(ll(ll(1) << j) > k) break;
			if(a[i] & ll(ll(1) << j)) cnt[j]++;
		}
	}

	ll t = 0;

	for (ll i = 45;i >= 0;i--){
		//if(ll(ll(1)<<i) > k) break;
		//cout << k << endl;
		if(cnt[i]*2 < n) t += ll(ll(1)<<i); 
		if(t > k) t -= ll(ll(1)<<i);
	}

	ll ans = 0;

	for (int i = 0;i < n;i++){
		ans += ll(t^a[i]);
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 1024
#pragma region
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 1e9
using namespace std;
template <class T = int>
T in() {
  T x;
  cin >> x;
  return (x);
}

typedef long long ll;
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 (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

#pragma endregion

int main() {
  int n = in();

  ll sum = 0;

  reps(i, n) {
    if (i % 3 != 0) {
      if (i % 5 != 0) {
        sum += i;
      }
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
const int maxn=500009;
int sum[maxn];
void add(int pos,int v){
  for(;pos<maxn;pos+=pos&-pos)sum[pos]+=v;
}
int cal(int pos){
  int res=0;
  for(;pos;pos-=pos&-pos)res+=sum[pos];
  return res;
}
int main(){
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int n,q;
  cin>>n>>q;
  vector<int> A(n+1),B(n+1),ans(n+1),Q(q);
  vector<vector<int>> nxt(n+1);
  for(int i=1;i<=n;++i)cin>>A[i];
  for(int i=1;i<=n;++i)nxt[i].push_back(n+1);
  for(int i=n;i>=1;--i)nxt[A[i]].push_back(i);
  for(int i=1;i<=n;++i){
    add(nxt[i].back(),1);
  }
  vector<pair<pair<int,int>,int>> C(q);
  for(int i=0;i<q;++i){
    cin>>C[i].first.first>>C[i].first.second;
    C[i].second=i;
  }
  sort(C.begin(),C.end());
  for(int i=1,j=0;i<=n&&j<q;++i){
    while(j<q&&C[j].first.first==i){
      Q[C[j].second]=cal(C[j].first.second)-cal(C[j].first.first-1);
      ++j;
    }
    nxt[A[i]].pop_back();
    add(i,-1);
    add(nxt[A[i]].back(),1);
  }
  for(int i=0;i<q;++i){
    cout<<Q[i]<<'\n';
  }
  return 0;
}
//2020.08.02 20:53:50


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e3 + 5;

vi g[MAXN];

int used[MAXN], prv[MAXN];
int cnt[MAXN];

char s[MAXN];

int sz[MAXN], sum_dis[MAXN], min_sum_dis[MAXN];

void dfs(int s) {
	used[s] = 1;
	REP(i, 0, SZ(g[s])) {
		int to = g[s][i];
		if (prv[s] != to) {
			prv[to] = s;
			dfs(to);
			sz[s] += sz[to];
			sum_dis[s] += sum_dis[to] + sz[to];
			//min_sum_dis[s] += min_sum_dis[to] + sz[to];
		}
	}
	int fl = 0;
	REP(i, 0, SZ(g[s])) {
		int to = g[s][i];
		if (prv[s] != to) {
			int v1 = min_sum_dis[to] + sz[to];
			int v2 = sum_dis[s] - sum_dis[to] - sz[to];
			if (v1 > v2) {
				fl = 1;
				min_sum_dis[s] = v1 - v2;
			}
		}
	}
	if (!fl) {
		min_sum_dis[s] = sum_dis[s] % 2;
	}
	sz[s] += cnt[s];
}

void solve(){
	int n;
	scanf("%d%s", &n, &s[1]);
	REPN(i, 1, n) {
		cnt[i] = s[i] - '0';
	}
	REP(i, 1, n) {
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].pb(b);
		g[b].pb(a);
	}
	int ans = INF;
	REPN(i, 1, n) {
		REPN(j, 1, n) {
			used[j] = 0;
			prv[j] = 0;
			sz[j] = 0;
			sum_dis[j] = 0;
			min_sum_dis[j] = 0;
		}
		dfs(i);
		
		/*if (i == 1) {
			REPN(k, 1, n) {
				printf("%d %d %d %d\n", i, sz[i], sum_dis[i], min_sum_dis[i]);
			}
		}*/
		
		if (min_sum_dis[i] == 0) {
			ans = min(ans, sum_dis[i] / 2);
		}
	}
	if (ans == INF) {
		ans = -1;
	}
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rbf(a, x) for (auto& a : x)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
#define Fi first
#define Se second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    template<typename Num>
        constexpr Num mypow(Num a, long long b) {
            if(b==0)return 1;
            if (a==0)return 0;
            Num x = 1;
              while (b > 0) {
                if(b & 1)x*=a;
                a*=a;
                b >>= 1;
              }
              return x;
        }

    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;
    }

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo
//mint,dijkstra,gyakugen
    ll n;

    void input(){
        cin>>n;
        return;
    }

    void solve(){
        ll res=0;
        rep(i,n){
            ll x=i+1;
            ll y=n/x;
            res+=y*(x+y*x)/2;
        }
        cout<<res<<"\n";
        return;
    }

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        input();
        solve();
        return 0;
    }

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>
#include <regex>
#include <functional>
#include <algorithm>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int MAX_N = 100000;

typedef long long ll;



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

    ll N, M;
    cin >> N >> M;
    vector<int> H(N + 1);
    vector<vector<int> > Route(N + 1);
    for (int i = 1; i <= N; i++) {
        cin >> H[i];        
    }
    for (int i = 1; i <= M; i++) {
        ll a, b;
        cin >> a >> b;
        Route[a].push_back(b);
        Route[b].push_back(a);
    }

    vector<bool> reject_flag(N + 1);
    vector<bool> good_flag(N + 1);
    int count = 0;
    bool NG_flag = false;
    for (int i = 1; i <= N; i++) {//ここから全部の展望台をサーチ
        NG_flag = false;
        if (reject_flag[i]) {//他の展望台を見るなかでアウトとわかってたら調べない
        }
        else {
            for (auto temp : Route[i]) {
                if (H[i] > H[temp]) {//i番目の展望台のほうが、底からルートでつながってるtemp番目よりもいい
                    reject_flag[temp] = true;
                }
                else{//自分より高い展望台が見つかったらNGフラグ
                    NG_flag = true;
                }
            }
            if (!NG_flag) {//自分より高い展望台が見つからなかった
               // count++;
                good_flag[i] = true;
            }
        }
    }
    for (int i = 1; i <= N; i++) {
        if (good_flag[i]) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 8744