akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

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

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

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

pair<double, double> dis[625];
double d[625][625];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout<<setprecision(10)<<fixed;
	int n, m;
  cin>>n>>m;
  vi g[625], h[625];
  REP(i, m){
    int s, t;
    cin>>s>>t;
    --s;--t;
    g[s].push_back(t);
    h[t].push_back(s);
  }
  dis[n-1]=make_pair(1, 0);
  FORR(i, 0, n){
    if(!h[i].size()) continue;
    auto a=dis[i];
    for(auto& x : h[i]){
      double p=1.0/(int)g[x].size();
      auto b=make_pair(a.first*p, p*(a.second+a.first));
      auto c=dis[x];
      dis[x]=make_pair(b.first+c.first, b.second+c.second);
      d[x][i]+=b.second;
    }
  }
  // REP(i, n){
  //   REP(j, n){
  //     cout<<d[i][j]<<" \n"[j==n-1];
  //   }
  // }
  // REP(i, n){
  //   cout<<dis[i].first<<' '<<dis[i].second<<'\n';
  // }
  REP(i, n){
    dis[i]=make_pair(0, 0);
  }
  dis[0]=make_pair(1, 0);
  REP(i, n){
    if(!g[i].size()) continue;
    double p=1.0/(int)g[i].size();
    auto a=dis[i];
    auto b=make_pair(a.first*p, p*(a.second+a.first));
    for(auto& x : g[i]){
      auto c=dis[x];
      dis[x]=make_pair(b.first+c.first, b.second+c.second);
    }
  }
  double ans=dis[n-1].second;
  REP(i, n){
    double ma=-1;
    int idx=-1;
    if((int)g[i].size()==1) continue;
    for(auto& x : g[i]){
      if(ma<d[i][x]){
        ma=d[i][x];
        idx=x;
      }
    }
    vi f[625];
    REP(j, n){
      for(auto& x : g[j]){
        if(j==i && x==idx) continue;
        f[j].push_back(x);
      }
    }
    REP(j, n){
      dis[j]=make_pair(0, 0);
    }
    dis[0]=make_pair(1, 0);
    REP(j, n){
      if(!f[j].size()) continue;
      double p=1.0/(int)f[j].size();
      auto a=dis[j];
      auto b=make_pair(a.first*p, p*(a.second+a.first));
      for(auto& x : f[j]){
        auto c=dis[x];
        dis[x]=make_pair(b.first+c.first, b.second+c.second);
      }
    }
    CHMIN(ans, dis[n-1].second);
  }
  cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 6400
import copy
def bubble_sort(nums,n):
    flag=1
    while flag:
        flag=0
        for i in range(n-1,0,-1):
            if int(nums[i][1])<int(nums[i-1][1]):
                flag=1
                nums[i],nums[i-1]=nums[i-1],nums[i]

    return nums

def selection_sort(nums,n):
    for i in range(n):
        minj=i
        for j in range(i+1,n):
            if nums[j][1]<nums[minj][1]:
                minj=j
        nums[minj],nums[i]=nums[i],nums[minj]

    return nums

n=int(input())
nums=list(input().split())
nums_2=copy.deepcopy(nums)
b_nums=bubble_sort(nums,n)
s_nums=selection_sort(nums_2,n)

def show(nums):
    for i in range(len(nums)):
        if i!=len(nums)-1:
            print(nums[i],end=' ')

        else:
            print(nums[i])

show(b_nums)
print("Stable")
show(s_nums)
if b_nums==s_nums:
    print("Stable")

else:
    print("Not stable")


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

int h, w;
char maze[20][20];
bool visited[20][20]={};

bool isValid(int left, int right){
    return (left>=0 && left<h && right>=0 && right<w && maze[left][right]=='.' && !visited[left][right]);
}

int solve(int x, int y){

    int count = 0;

    queue<pair<int,pair<int,int>>> q;
    visited[x][y] = true;
    q.push({0,{x,y}});
    bool flag = false;

    while(!q.empty()){

        pair<int,int> t = q.front().second;
        int dist = q.front().first;
        q.pop();

        flag=false;
        if(isValid(t.first+1, t.second)){
            visited[t.first+1][t.second]=true;
            q.push({dist+1,{t.first+1, t.second}});
            count = max(count, dist+1);
        }
        if(isValid(t.first-1, t.second)){
            visited[t.first-1][t.second]=true;
            flag =true;
            q.push({dist+1,{t.first-1, t.second}});
            count = max(count, dist+1);
        }
        if(isValid(t.first, t.second-1)){
            visited[t.first][t.second-1]=true;
            flag =true;
            q.push({dist+1,{t.first, t.second-1}});
            count = max(count, dist+1);
        }
        if(isValid(t.first, t.second+1)){
            visited[t.first][t.second+1]=true;
            flag =true;
            q.push({dist+1,{t.first, t.second+1}});
            count = max(count, dist+1);
        }

    }

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            visited[i][j]=false;
        }
    }
    return count;
}

int main(){

    cin >> h >> w;

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> maze[i][j];
        }
    }

    int ans = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(maze[i][j]=='.'){
                ans = max(ans, solve(i,j));
            }
        }
    }

    cout << ans << '\n';

    return 0;
}


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

using ll = long long;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    {
        bool check = a[0] == 0;
        for(int i = 0; i + 1 < n; ++i) {
            check &= a[i + 1] - a[i] <= 1;
        }
        if(!check) {
            cout << -1 << endl;
            return 0;
        }
    }

    ll ans = 0, len = 1;
    for(int i = 0; i + 1 < n; ++i) {
        if(a[i] >= a[i + 1]) {
            ans += a[i + 1] + len - 1;
            len = 1;
        } else {
            len += 1;
        }
    }
    ans += len - 1;

    cout << ans << endl;
}

Measured memory_bytes: 1024
from collections import defaultdict
d = defaultdict(int)

N,M = map(int,input().split())
li = []
for m in range(M):
  x,y = input().split()
  li.append([int(x), y])

sets = set()

ac = 0
wa = 0

for i in li:
  if i[1] == 'AC':
    if i[0] not in sets:
      sets.add(i[0])
      ac += 1
      wa += d[i[0]]

  else:
    if i[0] not in sets:
      d[i[0]] += 1

print('{} {}'.format(ac, wa))

Measured memory_bytes: 82648
import java.util.Scanner;

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

	while (scan.hasNext()) {
	    int n = scan.nextInt();
	    int count = -2;
	    
	    for(int i = 2; i <=n; i++) {
		if (prime[i]) continue;
		else {
		    for(int j = i*2; j <=n; j += i) {
			prime[j] = true;
		    }
		}
	    }

	    for (int k=0; k<=n; k++) {
		if(prime[k]) continue;
		count++;
	    }

	    System.out.println(count);
	}
    }
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int a, b, c, d, n, m, x, y, h, w;
    string s, t;


    auto Yes = [&](bool t){
        cout << (t ? "Yes" : "No") << endl;
    };
    auto YES = [&](bool t){
        cout << (t ? "YES" : "NO") << endl;
    };
    auto tri = [&](bool t, string a, string b){
        cout << (t ? a : b) << endl;
    };

    cin >> s;
    cout << count(s.begin(), s.end(), '1') << endl;

}


Measured memory_bytes: 256
from sys import exit
import math
A,B = map(int,input().split())

for i in range(1,10000):
  if int(math.floor(i*0.08))==A and int(math.floor(i*0.1))==B:
    if math.floor(i*0.1) <= 100:
      print(i)
      exit()
    else:
      break

print(-1)

Measured memory_bytes: 3060
def ok(p):
    n = len(p)
    for i in range(n-1):
        if p[i] > p[i+1]:
            return False
    return True

def solve(n, p):
    if ok(p):
        return "YES"
    for i in range(n):
        for j in range(i+1, n):
            q = p.copy()
            q[i], q[j] = q[j], q[i]
            if ok(q):
                return "YES"
    return "NO"

n = int(input())
p = list(map(int, input().split()))
print(solve(n, p))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;

int N,M,a,b;
int C[100010];
vector<vector<int>> v(100000);
int visited[100010] = {0};
int depth[100010] = {0};
int mini[100010] = {0};
int inf = 1e9;
vector<int> ans;

int dfs(int n,int m){
	visited[n] = 1;
	for(int i=0;i<v[n].size();i++){
		if(visited[v[n][i]]==0){
			depth[v[n][i]] = depth[n] + 1;
			dfs(v[n][i],n);
		}
	}
	for(int i=0;i<v[n].size();i++){
		if(v[n][i]!=m) mini[n] = min(mini[n],min(depth[n],depth[v[n][i]]));
	}
}

int dfs2(int n){
	visited[n] = 1;
	for(int i=0;i<v[n].size();i++){
		if(visited[v[n][i]]==0){
			dfs2(v[n][i]);
			mini[n] = min(mini[n],mini[v[n][i]]);
			if(n!=0 && depth[n]<=mini[v[n][i]]) ans.push_back(n);
		}
	}
}


int main(){
    cin >> N >> M;
    for(int i=1;i<=M;i++){
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
        C[a]++; C[b]++;
    }
    bool judge = true;
    int ma = 0,cnt = 0;
    for(int i=1;i<=N;i++){
        if(C[i]%2==1) judge = false;
        if(C[i]==4) cnt++;
        ma = max(C[i],ma);
    }
    if(!judge || (ma<6 && cnt<2)){
        cout << "No" << endl;
        return 0;
    }
    if(ma<6 && cnt==2){
        for(int i=1;i<=N;i++) mini[i] = inf;
        dfs(1,-1);
        int count = 0;
        for(int i=1;i<=N;i++){
            visited[i] = 0;
            if(depth[i]==1) count++;
        }
        if(count>=2) ans.push_back(1);
        dfs2(1);
        count = 0;
        for(auto x:ans) if(C[x]==4) count++;
        if(count!=2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 10368
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

int main(void){
  int x, i, j, k, n;
  cin >> x;

  if(x<10){
    cout << x << endl;
    return 0;
  }

  string s = "10";

  for(i=10;i<x;i++){
    //cout << s << endl;

    n = s.size();

    for(j=n-1;j>0;j--){
      if(s[j]<=s[j-1]&&s[j]<'9'){
        ++s[j];
        for(k=j+1;k<n;k++){
          if(s[k-1]=='0'){
            s[k] = '0';
          }
          else{
            s[k] = s[k-1] - 1;
          }
        }

        break;
      }

    }

    if(j>0) continue;

    if(s[0]<'9'){
      ++s[0];
      for(j=1;j<n;j++){
        if(s[j-1]=='0'){
          s[j] = '0';
        }
        else{
          s[j] = s[j-1] - 1;
        }
      }
      continue;
    }
    else{
      s[0] = '1';
      for(j=1;j<n;j++){
        s[j] = '0';
      }
      s += '0';
    }
  }

  cout << s << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define REVE(x) reverse(x.begin(),x.end())
#define all(x) (x).begin(),(x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(),x.end(),x.begin() ,::toupper);
#define down(x) transform(x.begin(),x.end(),x.begin() ,::tolower);
using LL = long long;
using ULL = unsigned long long;
#define FOR(i, m, n) for(int i = m;i < n;i++)
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
int main(){
    string n,a,b,c;
    cin >> a >> b >> c;
    if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]){
      cout <<"YES";
    }else{
        cout <<"NO";
    }
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n, t;
    cin >> n >> t;

    double a = 0;
    FOR(i, 0, n) {
        double x, h;
        cin >> x >> h;
        chmax(a, h / x);
    }
    cout << t * a << "\n";
}


Measured memory_bytes: 3320
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

bool isPrime(int n) {
    if (n < 2)
        return false;
    if (n == 2)
        return true;
    if (n % 2 == 0)
        return false;

    for (int i = 3; i * i <= n; i += 2) {
        if (n % i == 0)
            return false;
    }
    return true;
}

void main() {
    string s;
    while ((s = readln.chomp) != null) {
        int n = s.to!int;

        int ans = 0;
        for (int i = 1; i <= n; i++) {
            int a = i;
            int b = n - i + 1;
            if (isPrime(a) && isPrime(b))
                ans++;
        }
        writeln(ans);
    }
}

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

int main() {
	int n;
    cin >> n;
    map<int, int> data;

    for (int i = 0; i < n; i++){
        int num;
        cin >> num;
        data[num - 1]++;
        data[num]++;
        data[num + 1]++;
    }

    int max = -1;
    for (auto it : data){
        if (it.second > max){
            max = it.second;
        }
    }

    cout << max << endl;
}

Measured memory_bytes: 4736
import java.util.*;
import java.io.*;

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

        int N = Integer.parseInt(sc.next());
        String S = sc.next();
        char[] s = new char[N];
        s = S.toCharArray();
        sc.close();

        char[] ans = new char[N];
        ans[0] = s[0];
        int count = 1;
        for (int i = 1; i < N; i++) {
            if (ans[count-1] == s[i]) {
                continue;
            }
            ans[count] = s[i];
            count ++;
        }
        out.printf("%d\n", count);
        out.flush();
    }
}


Measured memory_bytes: 26444
let n = Scanf.scanf " %d" (+) 0
let hs = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let _ = Array.fold_left (fun (c, m) h -> if h >= m then c + 1, h else c, m) (0, 0) hs |> fst |> Printf.printf "%d\n"

Measured memory_bytes: 384
row = int(input())
s = [input() for i in range(row)]
ac = 0
wa = 0
tle = 0
re = 0
for j in s:
    if j == "AC":
        ac += 1
    elif j == "WA":
        wa += 1
    elif j == "TLE":
        tle += 1
    elif j == "RE":
        re += 1
ac = str(ac)
wa = str(wa)
tle = str(tle)
re = str(re)
print("AC x " + ac)
print("WA x " + wa)
print("TLE x " + tle)
print("RE x " + re)

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

typedef long long ll;

ll p[51], s[51];

int main()
{
  ll n, x;
  cin >> n >> x;

  p[0] = 1, s[0] = 1;
  for(int i = 1; i <= 50; i++){
    p[i] = p[i-1]*2 + 1;
    s[i] = s[i-1]*2 + 3;
  }

  ll ans = 0;
  while(n > 0){
    if(s[n] == x){
      ans += p[n];
      break;
    }else if(s[n]/2-n+1 <= x){
      ans += p[n-1];
      if(s[n]/2 < x){
        ans++;
        x--;
      }
      x -= s[n]/2;
    }else{
      x--;
    }
    n--;
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define rep(i, a, b) for (int i = (a), _b = (int)(b); i < _b; ++i)

typedef complex<ld> cplex;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int inf = 1000000007;
const ll linf = 1ll * inf * inf;
const int N = 100000 + 7;
const int M = 10;
const int multipleTest = 0;

string s;
int cnt[30];


void solve() {
    cin >> s;
    for (int i = s.size() - 1; i >= 0; --i) cnt[s[i] - 'a']++;
    ll res = 0;
    rep(i, 0, s.size()) {
        rep(j, 0, 26) if (s[i] - 'a' != j) res += cnt[j];
        cnt[s[i] - 'a']--;
    }
    cout << res + 1;
}

int main() {
#ifdef _LOCAL_
    freopen("in.txt", "r", stdin);
    //    freopen("out.txt", "w", stdout);
#endif
    int Test = 1;
    if (multipleTest) {
        cin >> Test;
    }
    for(int i = 0; i < Test; ++i) {
        solve();
    }
#ifdef _LOCAL_
    cout<<"\n" << 1.0 * clock() / CLOCKS_PER_SEC <<endl;
#endif
}


Measured memory_bytes: 640
import math
import sys
a, b, h, m = map(int,sys.stdin.readline().rstrip().split())
deg = min(abs(30*h - 5.5*m),360-abs(30*h - 5.5*m))
rad=math.radians(deg)
c = math.sqrt(a**2 + b**2 -2*a*b*math.cos(rad))
print(f'{c:.9f}')

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

using namespace std;

const double EPS = 1e-8;

struct Point {
    long long x,y;
    Point() {}
    Point(long long _, long long __){
        x = _, y = __;
    }

};

Point operator -(const Point &a, const Point &b) {
    return Point(a.x - b.x, a.y - b.y);
}

long long cross(const Point &a, const Point &b) {
    return a.x * b.y - a.y * b.x;
}

long long area(const Point &a, const Point &b, const Point &c) {
    return cross(b - a, c - a);
}

bool operator < (const Point &a, const Point &b) {
    if(abs(a.x - b.x) > EPS) return a.x < b.x;
    return a.y + EPS < b.y;
}

long long dis(const Point &a, const Point &b) {
    return abs(a.x - b.x) + abs(a.y - b.y);
}


vector<Point> convexHull(vector<Point> v) {
    sort(v.begin(), v.end());
    int n = v.size(), k = 0;
    Point H[2 * n];

    for (int i = 0; i < n; ++i) {
        while(k >= 2 and area(H[k - 2], H[k - 1], v[i]) <= 0) --k;
        H[k++] = v[i];
    }

    for (int i = n - 2, t = k; i >= 0; i--) {
        while(k > t and area(H[k - 2], H[k - 1], v[i]) <= 0) --k;
        H[k++] = v[i];
    }
    return vector<Point> (H, H + k - 1);
}


int n;

int main() {
    vector<Point> pol;
    int n;
    scanf("%d", &n);

    for (int i = 0; i < n; ++i) {
        double x,y;
        scanf("%lf %lf", &x, &y);
        pol.push_back(Point(x,y));
    }

    if(n == 1) {
        puts("0");
        return 0;
    }

    pol = convexHull(pol);
    n = pol.size();
    long long ans = 0;
    int cur = 0;
    for (int i = 0; i < n; ++i) {
        while(dis(pol[i],pol[(cur + 1) % n]) > dis(pol[i],pol[cur]))
            cur = (cur + 1) % n;
        ans = max(ans,dis(pol[i],pol[cur]));
    }

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

    return 0;
}


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

int main() {
    int N,M;cin>>N>>M;
    map<int,int>mp;
    vector<vector<int>>A(M,vector<int>(2));
    rep(i,M){
        cin>>A[i][0]>>A[i][1];
        if(A[i][0]==1)mp[A[i][1]]++;
        if(A[i][1]==N)mp[A[i][0]]++;
    }
    bool judge =false;
    for(auto p:mp){
        if(p.second>=2)judge =true;
    }
    if(judge){
        cout<<"POSSIBLE"<<endl;
    }
    else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 26752
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;


int main() {
	int N; cin >> N;
	vector<pair<int, int>> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i].first;
	}
	for (int i = 0; i < N; i++) {
		cin >> A[i].second;
	}

	int ans = 100000000;

	for (int k = 0; k < (1 << N); k++) {
		vector<pair<int, pair<int, bool>>> p;
		{
			for (int j = 0; j < N; j++) {
				if (k & (1 << j)) {
					p.push_back({ A[j].first, {j , false} });// そのまま
				}
				else {
					p.push_back({ A[j].second, {j , true} });// 反転
				}
			}
		}
		sort(p.begin(), p.end());

		bool flag = true;

		int o = 0, e = 0;

		for (int i = 0; i < N; i++) {
			if (i % 2 == 0) { e++; }
			else { o++; }
			if ((p[i].second.first + p[i].second.second) % 2 == 0) {
				e--;
			}
			else {
				o--;
			}
			if (i == N - 1 || (p[i + 1].first != p[i].first)) {
				if (e == 0 && o == 0) {
					;
				}
				else {
					flag = false;
					break;
				}
			}
		}
		if (flag) {
			int a = 0;
			vector<int> v;
			queue<int> ve, vo;
			for (int i = 0; i < N; i++) {
				if ((p[i].second.first + p[i].second.second) % 2 == 0) {
					ve.push(p[i].second.first);
				}
				else {
					vo.push(p[i].second.first);
				}
				if (i == N - 1 || (p[i + 1].first != p[i].first)) {
					if (v.size() % 2 == 0) {
						while (1) {
							if (ve.size() == 0) { break; } v.push_back(ve.front()); ve.pop();
							if (vo.size() == 0) { break; } v.push_back(vo.front()); vo.pop();
						}
					}
					else {
						while (1) {
							if (vo.size() == 0) { break; } v.push_back(vo.front()); vo.pop();
							if (ve.size() == 0) { break; } v.push_back(ve.front()); ve.pop();
						}
					}
				}
			}
			for (int i = 0; i < N; i++) {
				for (int j = 0; j < N; j++) {
					if (v[j] == i) {
						for (int k = j - 1; k >= i; k--) {
							v[k + 1] = v[k];
							a++;
						}
						v[i] = i;
					}
				}
			}
			ans = min(ans, a);
		}
	}

	if (ans == 100000000) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC119B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt;

            decimal ans = 0;
            for (int i = 0; i < N; i++)
            {
                var input = Console.ReadLine().Split();
                decimal x = decimal.Parse(input[0]);
                string y = input[1];
                if (y == "JPY") ans += x;
                else ans += x * 380000;
            }

            Console.WriteLine(ans);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] NextLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 11220
n, m, q = map(int, input().split())
queries = [tuple(map(int, input().split())) for _ in range(q)]
ans = 0

def calc_score(p):
    score = 0
    for a, b, c, d in queries:
        if p[b-1] - p[a-1] == c:
            score += d
    return score

def f(p):
    if len(p) == n+1:
        global ans
        ans = max(ans, calc_score(p))
        return
    while p[-1] <= m:
        f(p + [p[-1]])
        p[-1] += 1

f([1])

print(ans)


Measured memory_bytes: 9196
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

int main() {
	std::vector<int> D(5);
	int min = 10;
	int I;
	for (int i = 0; i < 5; ++i) {
		std::cin >> D[i];
		if (D[i] % 10 < min && D[i] % 10 != 0) {
			min = D[i] % 10;
			I = i;
		}
	}
	int ans = 0;
	for (int i = 0; i < 5; ++i) {
		if (i == I)
			ans += D[i];
		else {
			if (D[i] % 10 == 0)
				ans += D[i];
			else
				ans += ((D[i] / 10) + 1) * 10;
		}
	}
	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

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

        int N = sc.nextInt();
        char[] S = sc.next().toCharArray();

        for (int i = 0; i < S.length; i++) {
            S[i] = (char) ((S[i] + N - 65) % 26 + 65);
        }

        for (char e : S
        ) {
            System.out.print(e);
        }
    }
}


Measured memory_bytes: 25380
// contest.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#include "bits/stdc++.h"
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
//不可解すぎるバグは配列外参照（配列の長さ）を検討
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int LL
#define zero 0LL

using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l<r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l>r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5 * 1e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 400;
const int SIZE = SIZE1;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
string s;
ut N, M, K, X, L, Y;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], nums[SIZE], maps[SIZE2][SIZE2], answer = zero;

////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////
void init() {

}
int k = 0;
VI v[SIZE];
LL solve() {
	cin >> N;
	REP(i, 10000) {
		if (i*(i - 1) / 2 == N) {
			k = i;
		}
	}
	if (k == 0) return 0;
	int now = 1;
	REP(i,k)
		REP(j, i) {
		v[i].PB(now);
		v[j].PB(now);
		now++;
	}
	return 1;
}
signed main() {
	if (solve()) {
		cout << "Yes" << endl;
		cout << k << endl;
		REP(i, k) {
			cout << v[i].size();
			REP(j, v[i].size()) cout << " " << v[i][j];
			cout << endl;
		}
	}
	else {
		cout << "No" << endl;
	}
	cin >> k;
	return 0;
}


Measured memory_bytes: 27904
#include <bits/stdc++.h>
#if ONLINE_JUDGE
#define DEBUG false
#else
#define DEBUG true
#endif
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rep1(i, n) REP(i, 1, n)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)
#define rrep(i, n) rREP(i, 0, n)
#define forlist(i, vec) for(auto &&i : vec)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define truecheck assert
#define dump(x) cerr << #x << ": " << (x) << endl
using namespace std;
typedef long long LL;
typedef long long int64;
typedef std::vector<int> VI;
typedef std::vector<VI> VVI;
typedef std::vector<LL> VL;
typedef std::vector<VL> VVL;
typedef std::vector<std::string> VS;
typedef std::pair<int, int> PII;
typedef std::pair<LL, LL> PLL;
typedef std::queue<int> QI;
typedef std::priority_queue<int> PQI;
template<class T,class U>inline bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>inline bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>inline void vcinpb(T &v, U n){rep(i, n){typename T::value_type a;cin >> a;v.pb(a);}}

const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;
// M_PI 3.1415...

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    int ans = 0;
    rep(i, 4){
        char c;
        cin >> c;
        if (c == '+'){
            ans++;
        } else{
            ans--;
        }
    }

    co(ans);
    return 0;
}

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

int main()
{
    
	  string x;
	  cin>>x;
	
 ll p=x.length();
    
	  	if(x[p-1]=='s')
      {
        x=x+"es";
      }
        if(x[p-1]!='s')
      {
    	x=x+'s';
	  }
	  
	  cout<<x<<endl;	

	
}


Measured memory_bytes: 3632
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
//最大公約数
template<typename T>
constexpr T gcd(T a, T b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

//最小公倍数
template<typename T>
constexpr T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}
int main() {
	int a, b;
	cin >> a >> b;
	if (a <= 8 && b <= 8) {
		PRI("Yay!");
	}
	else PRI(":(");
	return 0;
}

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

void solve(string& s1, string& s2){

    vector<vector<ll> >  dp(s1.length()+1, vector<ll>(s2.length()+1,INT_MAX));

    dp[0][0] = 0;
    for (ll i = 0; i < s1.length(); i++)
    {
        dp[i+1][0] = i+1;
    }
    for (ll i = 0; i < s2.length(); i++)
    {
        dp[0][i+1] = i+1;
    }

    for (ll i = 1; i < s1.length()+1; i++)
    {
        for (ll j = 1; j < s2.length()+1; j++)
        {
            dp[i][j] = min(dp[i][j-1] + 1, dp[i-1][j] + 1 );
            dp[i][j] = min(dp[i][j], dp[i-1][j-1] + (s1[i-1] == s2[j-1] ? 0:1));
        }
    }

/*
    for (ll i = 0; i < dp.size(); i++)
    {
        for (ll j = 0; j < dp[i].size(); j++)
        {
            cout << dp[i][j] << " ";
        }
        cout << endl;
        
    }
   */ 

    cout << dp[s1.length()][s2.length()] << endl;

}

int main(){
    string s1,s2;
    cin >> s1 >> s2;
    solve(s1,s2);

    return 0;
}


Measured memory_bytes: 10804
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main() {
	int n;
	cin >> n;
	int d[100100];
	rep(i, n) cin >> d[i];

	sort(d, d+n);
	int l_max = d[n/2-1];
	int r_min = d[n/2];

	int res = 0;
	for (int i=l_max+1; i<=r_min; i++) res++;
	cout << res << endl;
}

Measured memory_bytes: 640
#include<iostream>
#define REP(i,n) for(int i=1;i<=n;i++)
using namespace std;

#define N 10

int main()
{
    int t;
    while(cin >> t)
    {
        int ans = 0;
        for(int i=0;i<=9;i++)for(int j=0;j<=9;j++)for(int k=0;k<=9;k++)for(int l=0;l<=9;l++)if((i+j+k+l)==t)ans++;

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 330030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;
using namespace std;

int main() {
string s;
int n;
bool b=false;
cin>>s;
n=s.size();
if(n==2)
{
	if(s[0]==s[1])
	{
		cout<<"1 2";
		
	}
	else
	cout<<"-1 -1";
	return 0;
}
int x=-1,y=-1;

rep(i,0,n-1)
{
	if(s[i]==s[i+1])
	{

	b=true;
	x=i+1,y=i+2;
}
}
rep(i,0,n-2)
{
	if(s[i]==s[i+2])
	{
		b=true;
		x=i+1;
		y=i+3;
}
}
cout<<x<<" "<<y;
}


Measured memory_bytes: 512
/*
    Author : zzugzx
    Lang : C++
    Blog : blog.csdn.net/qq_43756519
*/
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define SZ(x) (int)x.size()
#define mem(a, b) memset(a, b, sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int mod = 1e9 + 7;
//const int mod = 998244353;
const double eps = 1e-6;
const double pi = acos(-1.0);
const int maxn = 2e6 + 10;
const int N = 2e4 + 5;
const ll inf = 0x3f3f3f3f;
const int dir[][2]={{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
    int n;
    string s;
    cin >> n >> s;
    int cnt = 0, ans = 0;
    for (int i = 0; i < s.length(); i++)
        if (s[i] == 'R') cnt++;
    ans = cnt;
    for (int i = 0; i < s.length(); i++)
        if (i < cnt && s[i] == 'R') ans--;
    cout << ans;
    return 0;
}


Measured memory_bytes: 3756
#include<iostream>
using namespace std;
class Vector {
public:
  double x;
  double y;
  Vector(double xx=0,double yy=0) {x=xx;y=yy;}
  Vector operator+(Vector p) ;
  Vector operator-(Vector p);
};
Vector Vector::operator+(Vector p) {
  Vector tmp;
  tmp.x=x+p.x;
  tmp.y=y+p.y;
  return tmp;
}
Vector Vector::operator-(Vector p) {
  Vector tmp;
  tmp.x=x-p.x;
  tmp.y=y-p.y;
  return tmp;
}
bool check_hit(Vector A,Vector B,Vector C,Vector P);

int main() {
  double x1,x2,x3,y1,y2,y3,x,y;
  while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x>>y) {
    Vector A(x1,y1);
    Vector B(x2,y2);
    Vector C(x3,y3);
    Vector P(x,y);
    if(check_hit(A,B,C,P))
      cout<<"YES\n";
    else
      cout<<"NO\n"; 
   }
  return 0;
}
bool check_hit(Vector A,Vector B,Vector C,Vector P) {
  Vector AB=B-A;
  Vector BC=C-B;
  Vector CA=A-C;
  Vector AP=P-A;
  Vector BP=P-B;
  Vector CP=P-C;
  double calc1=AB.x*BP.y - AB.y*BP.x;
  double calc2=BC.x*CP.y - BC.y*CP.x;
  double calc3=CA.x*AP.y - CA.y*AP.x;
  if( (calc1>0 && calc2>0 && calc3>0)||(calc1<0 && calc2<0 && calc3<0) )
    return true;
  return false;
      }



Measured memory_bytes: 3112
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
typedef string::const_iterator State;

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


int main(void) {

	string s;
	bool flag = true;
	int count = 0;

	cin >> s;

	if (s[0] != 'A') {
		flag = false;
	}

	FOR(i, 2, s.size() - 2) {
		if (s[i] == 'C') {
			count++;
		}
	}
	if (count != 1) {
		flag = false;
	}
	count = 0;
	FOR(i, 0, s.size() - 1) {
		if (s[i] >= 'A'&&s[i] <= 'Z') {
			count++;
		}
	}
	if (count != 2) {
		flag = false;
	}
	
	if (flag) {
		cout << "AC" << endl;
	}
	else {
		cout << "WA" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		
	Scanner sc = new Scanner(System.in);
	
	int a = sc.nextInt();
	int b = sc.nextInt();
	int c = sc.nextInt();
	int count = 0;
	
	for(int x = a; x <= b; x++){
		if(c % x == 0){
			count ++;
		}
	}
	System.out.println(count);
	sc.close();
	}
}


Measured memory_bytes: 26288
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	sum := N * (N + 1) / 2
	n3 := N / 3
	sum3 := 3 * n3 * (n3 + 1) / 2
	n5 := N / 5
	sum5 := 5 * n5 * (n5 + 1) / 2
	n15 := N / 15
	sum15 := 15 * n15 * (n15 + 1) / 2
	fmt.Println(sum - (sum3 + sum5 - sum15))
}

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


Measured memory_bytes: 1792
// In the name of GOD
 
#include <bits/stdc++.h>
#define ll long long
#define pp pair <int, int>
using namespace std;
const int N = 1e5 + 10;
string s;
int n;

void solve() {
	cin >> n;
	ll ans = 0LL;
	for (int i = 1; i <= n; ++i) {
		if (i % 3 != 0 && i % 5 != 0) 
			ans += i;
	}
	cout << ans;
}
int main () {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int tt = 1;
    // cin >> tt;
    for (int tc = 1; tc <= tt; ++tc) {
        solve();
    }
}                                  

Measured memory_bytes: 3644
#include<iostream>
#include <climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N, K;
	cin >> N >> K;
	
	int q = N%K;
	ll p = N / K;
	ll res = 0;
	for (int amod = 0;amod < K;amod++) {
		int bmod = K - amod;
		if (2 * bmod % K == 0) {
			if (amod > 0 && amod <= q) {
				if (bmod > 0 && bmod <= q) res += (p + 1)*(p + 1)*(p + 1);
				else res += (p + 1)*p*p;
			}
			else if (bmod > 0 && bmod <= q) res += p*(p + 1)*(p + 1);
			else res += p*p*p;
		}
	}
	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 256
/**
 * @author yuzining
 * @date 2020/08/17 16:13
 */

#ifdef local
#include "D:\vscode\acm\local.hpp"
#else
#include<bits/stdc++.h>
using namespace std;
#define debug(...) do { } while(false)
void Main();
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
  return 0;
}
#endif

int64_t Function(int64_t b, int64_t n) {
  if (n < b) return n;
  return Function(b, n / b) + n % b;
}

void Main() {
  int64_t n, s; cin >> n >> s;
  if (n == s) {
    cout << (n + 1) << '\n';
    return;
  }
  for (int64_t b = 2; b <= n / b; b++) {
    if (Function(b, n) == s) {
      cout << b << '\n';
      return;
    }
  }
  if (s > n) {
    cout << "-1\n";
    return;
  }
  int64_t ans = LLONG_MAX;
  for (int64_t x = 1; x <= (n - s) / x; x++) {
    if ((n - s) % x == 0) {
      const int64_t b = (n - s) / x + 1;
      if (Function(b, n) == s) {
        ans = min(ans, b);
      }
    }
  }
  if (ans == LLONG_MAX) {
    ans = -1;
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3620
while True :
 n, x = map(int, input().split())
 if(n == 0 and x == 0) :
   break
 else :
   s = 0
   for i in range(1, n + 1) :
     for j in range(1, i) :
       for k in range(1, j) :
         if(i + j + k == x) :
           s += 1
         else :
           pass
   print(s)


Measured memory_bytes: 5596
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<complex>
#include<random>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-8
#define REP(i, m) for(long long i = 0; i < m; ++i)
#define FOR(i, n, m) for(long long i = n; i < m; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<ll> vl;
typedef vector<vector<ll> > vll;
 
int main() {
	ios::sync_with_stdio(false);
	ll q,h,s,d;
	cin>>q>>h>>s>>d;
	ll n;
	cin>>n;
	ll lc2=min(q*8,min(min(h*4,s*2),d));
	ll lc1=min(q*4,min(h*2,s));
	ll res=0;
	res+=(n/2)*lc2;
	res+=(n%2)*lc1;
	cout<<res<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
#define d lld
#define pii pair<int,int>
#define fst first
#define sec second
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 0
using namespace std;

int h[300007] = {};
int w[300007] = {};

int cal_h[300007] = {};
int cal_w[300007] = {};

unordered_map<int,bool> mp[300007];

main() {
    int i,j;
    int H,W,M;

    cin >> H >> W >> M;

    for(i=1; i<=M; i++) {
        cin >> h[i] >> w[i];
        cal_h[ h[i] ]++;
        cal_w[ w[i] ]++;
        mp[ h[i] ][ w[i] ] = 1;
    }

    int maxi_h = 0;
    int maxi_w = 0;
    for (i=1; i<=H; i++) {
        maxi_h = max(maxi_h, cal_h[i]);
    }
    for (i=1; i<=W; i++) {
        maxi_w = max(maxi_w, cal_w[i]);
    }
    int ans = maxi_h + maxi_w - 1;

    vector<int> keep;
    for (i=1; i<=W; i++) {
        if (cal_w[i] == maxi_w)
            keep.push_back(i);
    }

    bool flag = 0;
    for (i=1; i<=H; i++) {
        if (cal_h[i] == maxi_h) {
            for (auto it: keep) {
                de(1) printf(">>> %lld %lld\n", i, it);
                if ( !mp[i][it]) {
                    flag = 1;
                    ans = maxi_h + maxi_w;
                    break;
                }
            }
        }
        if (flag)
            break;
    }

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


    return 0;
}

//
//          ___ ___  __________  __________
//         /////\  \/\   ______\/\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \ \  \ \  \_____/\ \\\\_____/      New Empire of CHSH ...
//       ////   \ \  \ \  \      \ \\\\\\\\\\\
//      ////__   \ \  \ \  \      \ \\\\_____/
//     ///////\   \ \  \ \  \______\ \\\\_______   ________
//    ////____/    \ \__\ \___   ___\ \\\\\\\\\\\ _\  ___  \_
//   /__/           \/__/\/__/\  \__/\ \\\\_____//\  .\_/\_  \
//                           \ \  \   \ \\\\\\\\\\\\  \_\/_\  \
// ... with the AC Power of   \ \  \   \ \\\\_____/ \   _____  \
//   The Great Tsundere Doggy. \ \  \   \ \\\\     \ \  \  \ \  \
//                              \ \__\   \ \\\\\\\\\\ \__\  \ \__\
//                               \/__/    \/________/\/__/   \/__/
//


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

int main(){
  string s; cin>>s;
  int len = s.size();
  ll ans = 0;
  rep(bit, 1<<len-1){
    ll tmp = 0;
    rep(i,len-1){
      tmp *= 10;
      tmp += s[i]-'0';
      if  (bit & (1<<i)){
        ans += tmp;
        tmp = 0;
      }
    }
    tmp *= 10;
    tmp += s[len-1]-'0';
    ans += tmp;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
m-=1
l=[-1]*n
z=n*(n-1)//2
input()
b=[input().split() for _ in range(m)]
c=[0]*m+[z]
def r(s):
  t=l[s]
  if t<0:
    return s
  else:
    l[s]=r(t)
    return l[s]
def f(s):
  return r(int(s)-1)
for i in range(m-1,-1,-1):
  x,y=map(f,b[i])
  if x!=y:
    s,t=l[x],l[y]
    z-=s*t
    if s>t:
      l[x]=y
      l[y]+=s
    else:
      l[y]=x
      l[x]+=t
  c[i]=z
for x in c:
  print(x)

Measured memory_bytes: 39484
def inint(): return int(input())
def inlint(): return list(map(int, input().split()))
def infloat(): return float(input())
def inlffloat(): return list(map(float, input().split()))
def inl(): return list(input())
def putlint(): return "".join(list(map(str, ans)))

a = list(map(str,input().split()))
print(a[0][0]+a[1][0]+a[2][0])

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

int main(){
  int t[10];
  for(int i=0;i<10;i++){
    cin>>t[i];
  }
  sort(t,t+10,greater<int>());
  cout<<t[0]<<endl;
  cout<<t[1]<<endl;
  cout<<t[2]<<endl;
}

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

int main(){
  int n;
  cin>>n;
  vector<long long>d(n);
  for(int i=0;i<n;i++){
    cin>>d[i];
  }
  int sum=0;
  
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      sum+=d[i]*d[j];
    }
  }

  cout<<sum<<endl;
  
}

Measured memory_bytes: 256