akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void) {
  int N, i;
  scanf("%d", &N);
  for (i=1; i<=50000; i++) {
    if (27*i/25==N) {
      printf("%d", i);
      return 0;
    }
  }
  if (i==50001) printf(":(");
  return 0;
}

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

int main(){
  int A,B,C;  cin >> A >> B >> C;
  for(int i = 1;i <= B;i++){
    if(A * i % B == C){
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;


main(){
    ll x;cin>>x;
    for(int i = -120;i<=120;i++){
        for(int j=(-120);j<=120;j++){
            if((pow(i,5) - pow(j,5)) == x){
                cout<<i<<' '<<j;
                exit(0);
            }
        }
    }
}

Measured memory_bytes: 4060
# import bisect
# import copy
import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    A,B=map(int,input().split())
    print(A*B//fractions.gcd(A,B))


resolve()

Measured memory_bytes: 65388
#include <iostream>
#include<vector>
#include<cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
typedef long long ll;

using namespace std;



int main() {
    int n;
    cin>>n;
    vector<ll>f(1e7+1);
    rrep(i,n){
        for(int j = i; j <= n; j+=i){
            f[j]+=j;
        }
    }
    ll ans = 0;
    rrep(i,n)ans += f[i];
    cout<<ans<<endl;
    

    return 0;
}

Measured memory_bytes: 81324
n=gets.to_i
a=gets.split.map(&:to_i)
@aa = Array.new(3).map{[]}
a.each do |e|
  @aa[(e<=>0)+1] << e
end
@aa.map!(&:sort)

@r = []
def pp
  if @aa[0].size >= 2
    a = @aa[2].pop
    b = @aa[0].pop
    @aa[2] << a-b
    @r << [a,b]
    return true
  elsif @aa[2].size >= 2
    a = @aa[0].pop
    b = @aa[2].pop
    @aa[0] << a-b
    @r << [a,b]
    return true
  elsif @aa[0].size!=0 && @aa[2].size!=0
    a = @aa[2].pop
    b = @aa[0].pop
    @aa[2] << a-b
    @r << [a,b]
    return false
  else
    if @aa[0].size==1
      @aa[2] << @aa[0].pop*-1
      r = @r.pop
      @r << [r[1], r[0]]
    end
    return false
  end
end

while @aa[1].pop
  if @aa[0].size < @aa[2].size
    @aa[0].unshift(0)
  else
    @aa[2].unshift(0)
  end
end

if @aa[0].size.zero?
  a = @aa[2].shift
  b = @aa[2].shift
  @aa[0] << a-b
  @r << [a,b]
elsif @aa[2].size.zero?
  a = @aa[0].pop
  b = @aa[0].pop
  @aa[2] << b-a
  @r << [b,a]
end


while pp
end


puts @aa[2][0]
puts @r[0...n].map{|m|m.join(' ')}


Measured memory_bytes: 35044
//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}

	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

inline void out(ll x, ll y) {
	print(x, ' '), print(y, ' ');
}

int main() {
	ll s;
	rd(s);
	ll n = sqrt(s);
	while (n * n >= s) --n;
	while (n * n < s) ++n;
	ll k = n * n - s;
	if (k < n) out(0, 0), out(n, 1), out(k, n);
	else out(0, 0), out(n, 1), out(k - n, n - 1);
	return 0;
}

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

int main(){
    int K;
    cin>>K;
    int a=7;
    if(K%2==0){
        cout<<-1<<endl;
        return 0;
    }
    int i=0;
    for(;i<K+1;i++){
        if(a%K==0)break;
        int b=a%K;
        a=b*10+7;
    }
    if(i==K+1)i=-2;
    cout<<i+1<<endl;
    return 0;
}

Measured memory_bytes: 3676
#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() { cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    FOR(i, 1, n) {
        ans += i;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        System.out.println(((a+b)%2==0)?(a+b)/2:"IMPOSSIBLE");
    }
}


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

using namespace std;

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k)
  {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k)
  {
    return (-data[find(k)]);
  }
};

struct edge
{
  int u, v, cost;

  bool operator<(const edge &e) const
  {
    return (cost < e.cost);
  }
};

#define SQR(x) ((x)*(x))

int main()
{
  int N, M, X[10000], Y[10000];

  scanf("%d %d", &N, &M);
  vector< edge > edges(M);
  for(int i = 0; i < N; i++) {
    scanf("%d %d", X + i, Y + i);
  }
  for(int i = 0; i < M; i++) {
    int U, V;
    scanf("%d %d", &U, &V);
    --U, --V;
    edges.push_back((edge) {U, V, SQR(X[U] - X[V]) + SQR(Y[U] - Y[V])});
  }
  sort(begin(edges), end(edges));
  reverse(begin(edges), end(edges));

  double all = 0;
  UnionFind tree(N);
  for(auto &e : edges) {
    if(!tree.unite(e.u, e.v)) all += sqrt(e.cost);
  }
  printf("%.10lf\n", all);
}

Measured memory_bytes: 3576
// #include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
	int n, r;
	cin >> n;
	if (n % 1000 == 0)
	{
		cout << 0 << endl;
	}
	else {
		r = n % 1000;
		cout << (1000 - r) << endl;
	}

	return 0;

}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

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

const int infI=1e9+5;
const long long infL=1e16;
const int MOD=1e9+7;
const int MAX=2e5+5;

#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<ii,int>
#define ll long long
#define pll pair<ll,ll>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define popb pop_back()
#define se second
#define fi first
#define test(t) int t;cin>>t;while(t--)
#define debug(x) cerr<<"=>"<<#x<<" = "<<x<<endl

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    if(b==1){
        return a;
    }
    ll temp=power(a,b/2);
    temp=(temp*temp)%MOD;
    if(b%2){
        temp=(temp*a)%MOD;
    }
    return temp;
}

//only use if mod is prime
ll mod_inv(ll a,ll mod){
    a%=mod;
    return power(a,mod-2);
}

void extended_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return;
    }
    ll x1,y1;
    extended_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-((a/b)*y1);
    return;
}

//TLE can also occur if vectors are not passed by reference, debug statements can also cause TLE.
//priority_queue implements max heap by default

int main(){
    fastio;
    // think about edge cases like n=1(especially graph questions).
    ll n,d;
    cin>>n>>d;
    ll ans = 0;
    d *= d;
    forn(i,0,n){
        ll x,y;
        cin>>x>>y;
        ll tmp = (x*x) + (y*y);
        if(tmp<=d){
            ++ans;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  int cur = n;
  vector <int> ans;
  while(cur > 0) {
    for(int j = max(0, cur - m); j <= cur; j++) {
      if(s[j] == '1') continue;
      if(j == cur) {
        puts("-1");
        return 0;
      }
      ans.push_back(cur - j);
      cur = j;
      break;
    }
  }
  reverse(ans.begin(), ans.end());
  for(auto x : ans) cout << x << ' ';
}

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

using namespace std;

using ll = long long;

template <class T>
struct FenwickTree {
    int n;
    std::vector<T> x;
    FenwickTree(int _n = 0) : n(_n), x(n + 1, 0) {}
    int size() const { return n; }
    T Sum(int r) const {
        T S = 0;
        for (r = r - 1; r >= 0; r = (r & (r + 1)) - 1) S += x[r];
        return S;
    }
    T Sum(int l, int r) const { return Sum(r) - Sum(l); }
    void Add(int k, const T &a) {
        for (; k < n; k |= k + 1) x[k] += a;
    }
    void Set(int k, const T &a) { Add(k, a - Sum(k, k + 1)); }
};


class ProblemD {
public:
    ProblemD(ll _n) : n(_n), a(_n + 1), s(_n + 1, 0) {}
    void Input() { for (int i = 1; i <= n; ++i) cin >> a[i]; }

    int Solve() {
        const ll lim = ceil(n * (n + 1) / 4.0);

        ll lb = 0, ub = *max_element(a.begin(), a.end()) + 1;
        while (ub - lb > 1) {
//            cout << "lb = " << lb << ", ub = " << ub << endl;
            ll mid = 0.5 * (lb + ub), res = Check(mid);
//            cout << "x = " << mid << ", num = " << res << ", lim = " << lim << endl;

            if (lim <= res) lb = mid;
            else ub = mid;
        }

        return lb;
    }

private:
    ll n;
    vector<int> a;
    vector<ll> s;

    ll Check(const int x) {
        for (int i = 1; i <= n; ++i) s[i] = (x <= a[i] ? 1 : -1);
        for (int i = 1; i <= n; ++i) s[i] += s[i - 1];

        // cout << "a = ";
        // for (int i = 0; i <= n; ++i) cout << a[i] << ", ";
        // cout << endl;
        // cout << "s = ";
        // for (int i = 0; i <= n; ++i) cout << s[i] << ", ";
        // cout << endl;
        // cout << "s = ";
        // for (int i = 0; i <= n; ++i) cout << s[i] << ", ";
        // cout << endl;
        // cout << endl;

        ll res = 0;
        FenwickTree<int> tree(2 * n + 1);

        tree.Add(s[0] + n, 1);
        for (int i = 1; i <= n; ++i) {
            res += tree.Sum(0, s[i] + n + 1);
            tree.Add(s[i] + n, 1);
        }

        return res;
    }
};

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

    int n;
    cin >> n;
    ProblemD p(n);
    p.Input();
    cout << p.Solve() << endl;

    return 0;
}


Measured memory_bytes: 2288
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
ans = 0

for i in range(1, n+1):
    b[i-1] = a[i-1] - i

sort_b = sorted(b)
num = sort_b[n // 2]

for i in range(n):
    ans += abs(b[i] - num)

print(ans)

Measured memory_bytes: 26020
# include<iostream>
# include<vector>
# include<string>

using namespace std;

int main(){
  int n;
  string ans = "Yes";
  cin >> n;
  vector<int> h(n);
  for(int i=0; i<n; ++i)
    cin >> h[i];

  for(int i=0; i<n-1; ++i){
    if((h[i] == h[i+1] + 1) || (h[i] == h[i+1] && h[i] > h[i-1])){
      h[i]--;
      // cout << "1: " << i << '\n';
    }
    if(h[i] >= h[i+1]){
      if(h[i] > h[i+1] + 1)
        ans = "No";
      if(h[i+1] < h[i-1])
        ans = "No";
      // cout << "2: " << i << '\n';
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.awt.geom.*;
public class Main {

	private void doit(){
		Scanner sc= new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			double [][]inputdata = new double[4][n];
			for(int i = 0; i < 4; i++){
				for(int j = 0; j < n; j++){
					inputdata[i][j] = sc.nextDouble();
				}
			}
			//getline
			Line2D [] abLineList = new Line2D[n];
			Line2D [] cdLineList = new Line2D[n];
			for(int i = 0; i < n; i++){
				abLineList[i] = new Line2D.Double(inputdata[0][i], 0.0, inputdata[1][i], 1.0);
				cdLineList[i] = new Line2D.Double(0,inputdata[2][i],1,inputdata[3][i]);
			}
			
			//get intersect point
			
			////set flame
			Point2D [][] pointList = new Point2D.Double[n + 2][n + 2];
			pointList[0][0] = new Point2D.Double(0,0);
			pointList[n+1][0] = new Point2D.Double(0,1.0);
			pointList[0][n+1] = new Point2D.Double(1.0,0);
			pointList[n+1][n+1] = new Point2D.Double(1.0,1.0);
			for(int i = 0; i < n; i++){
				//x flame
				pointList[0][i + 1] = new Point2D.Double(inputdata[0][i], 0.0);
				pointList[n+1][i + 1] = new Point2D.Double(inputdata[1][i], 1.0);
				
				//yflame
				pointList[i + 1][0] = new Point2D.Double(0.0, inputdata[2][i]);
				pointList[i + 1][n+1] = new Point2D.Double(1.0, inputdata[3][i]);
			}
			
			////set point
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					pointList[i+1][j+1] = intersectPt(abLineList[j], cdLineList[i]);
				}
			}
			
			//get area
			double res = -1.0;
			for(int i = 0; i <= n; i++){
				for(int j = 0; j <= n; j++){
					double nowresult = getS(pointList[i][j], pointList[i][j+1], pointList[i+1][j+1], pointList[i+1][j]);
					res = Math.max(res, nowresult);
				}
			}
			System.out.printf("%.6f\n",res);
		}
	}

	private double getS(Point2D a, Point2D b, Point2D c, Point2D d) {
		double res = 0.0;
		res+= getC(a,b);
		res+= getC(b,c);
		res+= getC(c,d);
		res+= getC(d,a);
		return res;
	}

	private double getC(Point2D a, Point2D b) {
		double s = a.getX() * b.getY() - a.getY() * b.getX();
		return s /2;
	}

	private Point2D intersectPt(Line2D l, Line2D m) {
		
		Point2D lVec = getV(l.getP2(), l.getP1());
		Point2D mVec = getV(m.getP2(), m.getP1());
		Point2D m1l1Vec = getV(m.getP1(), l.getP1());
		double a = getC(m1l1Vec, lVec);
		double b = getC(lVec, mVec);
		double t = a / b;
		double resx = m.getX1() + t * mVec.getX();
		double resy = m.getY1() + t * mVec.getY();
		return new Point2D.Double(resx, resy);
	}

	private Point2D getV(Point2D p2, Point2D p1) {
		Point2D res = new Point2D.Double(p2.getX() - p1.getX(), p2.getY() - p1.getY());
		return res;
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

int main(){
    ll a,b;
    cin >> a >> b;
    ll x;
    cin >> x;
    a--;
    if(b == 0) cout << 1 << endl;
    else if(a == -1) cout << b/x+1 << endl;
    else cout << b/x-a/x << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
using namespace std;
typedef long long ll;
ll n,l,a[200005];
int main()
{
       cin>>n>>l;
       for(int i=1;i<=n;i++)
    	   cin>>a[i];	
	for(int i=1;i<n;i++)
	if(a[i]+a[i+1]>=l)
	{
		cout<<"Possible"<<endl;
		for(int j=1;j<i;j++)
		cout<<j<<endl;
		for(int j=n-1;j>=i;j--)
		cout<<j<<endl;
		return 0;	
	}
	cout<<"Impossible"<<endl;
	return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))
#define each(i, map) for (auto& i : map)

bool is_complete(const vector<int> &tmp, const int &X)
{
    for (int i = 0; i < tmp.size(); ++i) {
        if (tmp[i] < X)
            return false;
    }
    return true;
}

int main()
{
    int N, M, X; cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M, 0));
    rep (i, 0, N) {
        cin >> C[i];
        rep (j, 0, M) {
            cin >> A[i][j];
        }
    }

    int ans = INF;
    for (int bit = 0; bit < (1 << N); ++bit) {
        int c = 0;
        vector<int> tmp(M, 0);
        for (int i = 0; i < N; ++i) {
            if (bit & (1 << i)) {
                for (int m = 0; m < M; ++m) {
                    tmp[m] += A[i][m];
                }
                c += C[i];
            }
        }
        if (is_complete(tmp, X))
            ans = min(ans, c);
    }

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

Measured memory_bytes: 3608
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
const int N = 1e5 + 10;
int a[N];

int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for (int i = 1;i <= n;i++) scanf("%d",&a[i]);
	if (k >= n) return puts("1") * 0;
	int ma = -1;
	for (int i = 1;i <= n;i++)
	{
		if (a[i] == 1) ma = i;
	}
	int ans = N;
	for (int i = 0;i < k;i++)
	{
		int cnt = 0;
		int pre = ma - i - 1;
		int sub = pre + k;
		sub = n - sub;
		if (pre > 0 && pre <= n)
		{
			cnt += pre / (k-1);
			if (pre % (k-1)) cnt++;
		}
		if (sub > 0)
		{
			cnt += sub / (k-1);
			if (sub % (k-1)) cnt++;
		}
		ans = min(cnt,ans);
	}
	printf("%d\n",++ans);
	return 0;
}

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

using namespace std;

const int MAX_N = 50;

int main(int argc, char const *argv[])
{
    int n, h[MAX_N];
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    int max_h = h[0], ans = 1;
    for (int i = 1; i < n; ++i) {
        if (h[i]>=max_h) {
            ans++;
            max_h = h[i];
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> D(N + 1);
    for (int i = 0; i < N; ++i)
        cin >> D[i];
    sort(D.begin(), D.end());

    for (int i = 0; i < D.size(); ++i)
        if (i & 1)
            D[i] = 24 - D[i];

    int ans = 13;
    for (int i = 0; i < D.size(); ++i) {
        for (int j = i + 1; j < D.size(); ++j) {
            int stmp = abs(D[i] - D[j]);
            ans = min(ans, min(stmp, 24 - stmp));
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3548
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e6 + 6;

ll a[N];

int main() {
	ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int n;
    cin >> n;
    ll sum = 0;
    forn(i, 1, n) {
        cin >> a[i];
        sum += a[i];
    }

    ll sum2 = 0, ans = ool;
    forn(i, 1, n - 1) {
        sum -= a[i];
        sum2 += a[i];
        ans = min(ans, abs(sum - sum2));
    }

    cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1792
import itertools
n = int(input())
dic = {}
for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      f_xyz = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if f_xyz in dic:
        dic[f_xyz] += 1
      else:
        dic[f_xyz] = 1
for i in range(1, n+1):
  if i in dic:
    print(dic[i])
  else:
    print(0)

Measured memory_bytes: 11300
class Shop:

    def __init__(self, s, p):
        self.s = str(s)
        self.p = int(p)

    def __eq__(self, other):
        return (self.s, self.p) == (other.s, other.p)

    def __ne__(self, other):
        return not self.__eq__(other)

    def __lt__(self, other):
        return (self.s, -self.p) < (other.s, -other.p)

    def __le__(self, other):
        return (self.s, -self.p) < (other.s, -other.p)


def read():
    N = int(input().strip())
    shops = []
    for i in range(N):
        s, p = list(input().strip().split())
        shops.append(Shop(s, p))
    return N, shops


def solve(N, shops):
    order = sorted(range(N), key=lambda k: shops[k])
    return order


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    for i in outputs:
        print("%d" % (i + 1))

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

typedef long long ll;

#define PB push_back
#define MP make_pair

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    string s; cin >> s;
    string t; cin >> t;
    int n = s.size();
    map<char, char> mps, mpt;
    for (int i = 0; i < n; ++i) {
        if (mps.count(s[i]) == 0) mps[s[i]] = t[i];
        else if (mps[s[i]] != t[i]) {
            cout << "No\n";
            return 0;
        }
        
        if (mpt.count(t[i]) == 0) mpt[t[i]] = s[i];
        else if (mpt[t[i]] != s[i]) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}

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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &a[i]);
  sort(a.begin(), a.end());
  int ans = 0;
  for (int sum = 1 << 30; sum > 1; sum >>= 1) {
    vector<int> depan, belakang;
    int i = 0, j = (int)a.size()-1;
    while (i < j) {
      if (a[i] + a[j] == sum) {
        ++i, --j;
        ++ans;
      }
      else if (a[i] + a[j] < sum)
        depan.push_back(a[i++]);
      else
        belakang.push_back(a[j--]);
    }
    if (i == j)
      depan.push_back(a[i]);
    for (int k = (int)belakang.size()-1; k >= 0; --k)
      depan.push_back(belakang[k]);
    a.swap(depan);
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		StackImpl e = new Main().new StackImpl();
//		while(s.hasNext()) {
			String[] line = s.nextLine().split(" ");
			for(int i=0 ; i<line.length ; i++) {
			if("+".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a+b);
			} else if("-".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a-b);
			} else if("*".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a*b);
			}else {
				e.push(new Integer(line[i]).intValue());
			}
//			}
		}
		System.out.println(e.pop());
	}

	public class StackImpl {

		int[] stack;
		int index;

		public StackImpl() {
			stack = new int[100];
			index = 0;
		}

		public void push(int value) {
			stack[index] = value;
			index++;
		}

		public int pop() {
			index--;
			int returnV = stack[index];
			stack[index] = 0;
			return returnV;
		}
	}
}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if (a - b >= c) {
		cout << 0;
	} else {
		cout << c - a + b;
	}
	return 0;
}


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

x.sort()

if n>=m:
    print(0)
    exit()
sa=[]
for i in range(m-1):
    sa.append(x[i+1]-x[i])
sa.sort(reverse=True)
ans=x[-1]-x[0]
for i in range(n-1):
    ans-=sa[i]
print(ans)

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

long n, k;
long a[200000];

long sub(long th) {
  long sum = 0;
  for (int i = 0; i < n; ++i) {
    long v = a[i];
    if (v == 0) {
      sum += th > 0 ? n - (i + 1) : 0;
    } else if (v > 0) {
      int lo = i;
      int hi = n;
      while (hi - lo > 1) {
        int mid = (lo + hi) / 2;
        if (v * a[mid] < th) {
          lo = mid;
        } else {
          hi = mid;
        }
      }
      sum += hi - (i + 1);
    } else {
      int lo = i;
      int hi = n;
      while (hi - lo > 1) {
        int mid = (lo + hi) / 2;
        if (v * a[mid] < th) {
          hi = mid;
        } else {
          lo = mid;
        }
      }
      sum += n - hi;
    }
  }
  return sum;
}

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  long lo = -2e18;
  long hi = 2e18;
  while (hi - lo > 1) {
    long mid = (lo + hi) / 2;
    if (sub(mid) < k) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  cout << lo << endl;
}


Measured memory_bytes: 1792
typedef long long ll;

#include <cmath>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

class BIT{
  vector<int> bit;
public:
  BIT(int n) : bit(n + 1) {}
  void add(int idx, int val){
    idx++;
    while(idx < (int)bit.size()){
      bit[idx] += val;
      idx += idx & -idx;
    }
  }
  int sum(int i){
    int s = 0;
    i++;
    while(i > 0){
      s += bit[i];
      i -= i & -i;
    }
    return s;
  }
};

const ll mod = 1000000007;
ll fact[100000 + 10];

int main(){
  fact[0] = 1;
  REP(i,100000) fact[i + 1] = (fact[i] * (i + 1)) % mod;

  while(const int n = getInt()){
    const int r = getInt();
    vector<int> v(n);
    BIT b(n);
    REP(i,n) b.add(i, 1);

    REP(i,n) v[i] = i;
    REP(i,r){
      const int a = getInt() - 1;
      const int b = getInt() - 1;
      swap(v[a], v[b]);
    }

    // REP(i,n) printf("%d ", v[i]); puts("");

    ll ret = 0;
    REP(i,n){
      b.add(v[i], -1);
      ret += (b.sum(v[i]) * fact[n - i - 1]) % mod;
      ret %= mod;
    }

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

Measured memory_bytes: 2456
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N;
  map<string, int> counter;

  cin >> N;

  ll ans = 0;

  for (int i=0; i<N; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    ans += counter[s];
    counter[s]++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11136
#include <stdio.h>

int main()
{
  int mh[10], m;
  int i, j;

  for(i=0; i<10; i++){
    scanf("%d", mh+i);
  }

  for(i=0; i<3; i++){
    for(j=i+1; j<10; j++){
      if(mh[i] < mh[j]){
        m = mh[i];
        mh[i] = mh[j];
        mh[j] = m;
      }
    }
  }

  for(i=0; i<3; i++){
    printf("%d\n", mh[i]);
  }
  return(0);
}

Measured memory_bytes: 600
#include<stdio.h>
 
int main(){
 long int n,i,sum;
  scanf("%ld",&n);
  sum=0;
  for(i=1;i<=n;i++){
    if(i%3!=0 && i%5!=0){
      sum=sum+i;
    }
  }
    printf("%ld",sum);
           
  }

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

int main() {
  string N;
  cin >> N;
  long long sum=0;
  for(int i=0;i<N.size();i++){
    int A=N.at(i)-'0';
    sum+=A;
  }
  if(sum%9==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3704
#include<stdio.h>
#include<iostream>

using namespace std;

int main(){
    long long int a[10],temp,i,j;
    for(i=0;i<10;i++){
        cin>>a[i];
    }
    for(i=0;i<10;i++){
        for(j=0;j<10-i-1;j++){
            if(a[j]>a[j+1]){
                temp=a[j];
                a[j]=a[j+1];
                a[j+1]=temp;
            }
        }
    }
    for(int i=10-1;i>6;i--){
        cout<<a[i]<<"\n";
    }
    return 0;
}

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

int main() {
  int k; string s;
  cin >> k >> s;
  if (s.size() <= k) cout << s << endl;
  else cout << s.substr(0, k) << "..." << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
using namespace std;
int main() {
  int N,T;
  cin>> N>>T;
  int min=2000;

  for(int i=0; i<N; i++){
    int t,c;
    cin>>c>>t;
    if(t<=T && c<min) min=c;
  }
  if(min==2000) cout <<"TLE"<<endl;
  else cout<<min<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
typedef vector<int> vint;
int INF=2e+9+1;
int main(){
	int N;
	int a[50];
	int maxa=-INF,mina=INF;
	int argmaxa=-1,argmina=-1;
	scan(N);
	rep(i,N){
		scan(a[i]);
		if(a[i]>maxa){
			maxa=max(maxa,a[i]);
			argmaxa=i;
		}
		if(a[i]<mina){
			mina=min(mina,a[i]);
			argmina=i;
		}
	}
	int kaisu=0;
	if(mina>=0){
		prin(N-1);
		rep(i,N-1){
			printf("%d %d\n",i+1,i+2);
		}
	}
	else if(maxa<=0){
		prin(N-1);
		for(int i=N;i>1;i--){
			printf("%d %d\n",i,i-1);
		}
	}
	else if(abs(maxa)>=abs(mina)){
		prin(2*N-1);
		rep1(i,N){
			printf("%d %d\n",argmaxa+1,i);
		}
		rep(i,N-1){
			printf("%d %d\n",i+1,i+2);
		}
	}
	else{
		prin(2*N-1);
		rep1(i,N){
			printf("%d %d\n",argmina+1,i);
		}
		for(int i=N;i>1;i--){
			printf("%d %d\n",i,i-1);
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<bitset>
#include<tuple>
#include<cassert>
#include<time.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)

typedef long long i64;
typedef pair<i64,i64> P;

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


string s;
int k;

i64 mod_pow(i64 x, i64 y, i64 mod){
	i64 res = 1;
	while(y > 0){
		if(y & 1) res = res * x % mod;
		x = x*x %mod;
		y >>= 1;
	}
	return res;
}

int main(){
	cin >> s;
	cin >> k;
	int n = s.size();
	
	P p[3];
	int c = 0;
	for(int i = 0; i < n; i++){
		if(s[i] != '0'){
			p[c] = P(s[i]-'0', n-i-1);
			c++;
		}
		if(c == k) break;
	}
	
	i64 ans = 0;
	if(k == 3){
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			for(int k = j+1; k < n; k++){
				if(k < n-1){
					ans += 9 * 9 * 9;
				}
				else{
					if(p[1].second > j){
						ans += 9 * 9 * p[0].first;
					}
					else if(p[1].second == j && p[2].second > i){
						ans += 9 * p[1].first;
						ans += 9 * 9 * (p[0].first-1);
					}
					else if(p[1].second == j && p[2].second == i){
						ans += (p[2].first);
						ans += 9 * (p[1].first-1);
						ans += 9 * 9 * (p[0].first-1);
					}
					else if(p[1].second == j){
						ans += 9 * (p[1].first-1);
						ans += 9 * 9 * (p[0].first-1);
					}
					else{
						ans += 9 * 9 * (p[0].first-1);
					}
				}
				ans %= INF;
			}
		}
	}
	}
	if(k == 2){
		for(int j = 0; j < n; j++){
			for(int k = j+1; k < n; k++){
				if(k < n-1){
					ans += 9 * 9;
				}
				else{
					if(p[1].second > j){
						ans += 9 * p[0].first;
					}
					else if(p[1].second == j){
						ans += 9 * (p[0].first-1);
						ans += p[1].first;
					}
					else{
						ans += 9 * (p[0].first-1);
					}
				}
				ans %= INF;
			}
		}
	}
	if(k == 1){
		for(int k = 0; k < n; k++){
			if(k < n-1){
				ans += 9;
			}
			else{
				ans += p[0].first;
			}
			ans %= INF;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int i,n,m,p,x[128];
	double total=0;
	while(1){
		scanf("%d %d %d",&n,&m,&p);
		if(n==0&&m==0&&p==0)break;
		for(i=0;i<n;i++)scanf("%d",&x[i]);
		for(i=0;i<n;i++)total+=x[i]*(100-p);
		if(x[m-1])printf("%d\n",(int)(total/(double)x[m-1]));
		else printf("0\n");
		total=0;
	}
	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
using namespace std;

int main(){
    int n;
    cin >> n;
    int v[n];
    REP(i, n) cin >> v[i];

    double val  = 0.0;
    double result = 0.0;
    sort(v, v+n);

    val = v[0];
    for(int i=0; i<n-1; i++){
        val = (val+v[i+1])/2.0;
    }

    cout << val << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int h = s.nextInt();
    int w = s.nextInt();
    boolean[][] visited = new boolean[h+1][w+1];
    for (int i = 0; i < h; i++) {
      String line = s.next();
      for (int j = 0; j < w; j++) {
        visited[i][j] = line.charAt(j) == '#';
      }
    }
    
    int pi = 0;
    int pj = 0;
    while (pi != h-1 || pj != w-1) {
      visited[pi][pj] = false;
      if (visited[pi][pj+1]) {
        pj++;
      } else if (visited[pi+1][pj]) {
        pi++;
      } else {
        throw new RuntimeException("No destination");
      }
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          if (i < pi || j < pj) {
            if (visited[i][j]) {
              System.out.println("Impossible");
              return;
            }
          }
        }
      }
    }
    System.out.println("Possible");
  }
}


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

inline int rd() {
  int x = 0;
  bool f = 0;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = 1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + (c ^ 48);
    c = getchar();
  }
  return f ? -x : x;
}

int main() {
  int n = rd();
  int x = rd();
  int t = rd();
  printf("%d\n", (n + x - 1) / x * t);
  return 0;
}


Measured memory_bytes: 3692
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
  
typedef long long ll;
const int N = 15;
const ll mod = 1e9 + 7;

int main()
{
    ll a, b, c, d, e, f, g;
    cin >> a >> b >> c >> d >> e >> f >> g;
    cout << max(a / 2 * 2 + b + d / 2 * 2 + e / 2 * 2, ((a > 0) && (d > 0) && (e > 0)) * (3 + (a - 1) / 2 * 2 + b + (d - 1) / 2 * 2 + (e - 1) / 2 * 2)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<iterator>
#include<math.h>
using namespace std;
int main()
{
        int n,c=0;
        double s, x,y,d;
        cin>>n>>d;
        while(n--)
        {
            cin>>x>>y;
            s=sqrt(x*x+y*y);
            if(s<=d)
                c++;
        }
        cout<<c<<endl;

}


Measured memory_bytes: 3752
program kadai
implicit none
integer  ::  n,a,b,c,d,i,flag,open_flag,op
integer,allocatable  ::  rock(:)
character(len=200000)  ::  s

read(*,*) n,a,b,c,d
read(*,*) s
allocate(rock(n))

do i=1,n
    if(s(i:i)==".") then
        rock(i)=1
    end if
    if (s(i:i)=='#') then
        rock(i)=2
    end if
end do

flag=0
open_flag=0
op=0


do i=b,d
    if (rock(i)==2) then
        if (flag==1) then
            write(*,*) "No"
            stop
        else
            flag=1
        end if
    end if
    if(rock(i)==1) then
        flag=0
    end if
end do


flag=0
do i=a,c
    if (rock(i)==2) then
        if (flag==1) then
            write(*,*) "No"
            stop
        else
            flag=1
            open_flag=0
        end if
    end if
    if(rock(i)==1) then
        flag=0
        if (i>b-2 .and. i<d+2) then
            open_flag=open_flag+1
            if(open_flag==3) then
                op=1
            end if
        end if
    end if
end do

if (c>d) then
    if (op==1) then
        write(*,*) "Yes"
    else
        write(*,*) "No"
    end if
end if

if (c<d) then
    write(*,*) "Yes"
end if

end program kadai


Measured memory_bytes: 1548
Program RGB;
const   finput='RGB.inp';
        foutput='RGB.out';
var     r,g,b:byte;
        n:longint;

begin
    read(r,g,b);
    n:=r*100+g*10+b;
    if n mod 4=0 then write('YES')
    else write('NO');
end.


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	N := ReadInt()
	v := ReadInts(N)
	em, om := make(map[int]int), make(map[int]int)
	evens := make([]int, 0)
	odds := make([]int, 0)
	for i, vi := range v {
		if i%2 == 0 {
			if em[vi] == 0 {
				evens = append(evens, vi)
			}
			em[vi]++
		} else {
			if om[vi] == 0 {
				odds = append(odds, vi)
			}
			om[vi]++
		}
	}
	sort.Slice(evens, func(i, j int) bool {
		return em[evens[i]] > em[evens[j]]
	})
	sort.Slice(odds, func(i, j int) bool {
		return om[odds[i]] > om[odds[j]]
	})
	if evens[0] != odds[0] {
		fmt.Println(N - em[evens[0]] - om[odds[0]])
		return
	}

	ans := N - Max(em[evens[0]], om[evens[0]])
	if len(odds) > 1 {
		ans = Min(ans, N-em[evens[0]]-om[odds[1]])
	}
	if len(evens) > 1 {
		ans = Min(ans, N-em[evens[1]]-om[odds[0]])
	}
	fmt.Println(ans)
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 11104
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 

using namespace std; 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() << x; }
template<typename T> void db(T x , T y){ debug() << x <<" "<< y; }
template<typename T> void db(T x , T y , T z){ debug() << x <<" "<< y <<" "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() << x <<" " << y <<" "<< z <<" "<< a; }

const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;


signed main(){
  ios::sync_with_stdio(false);cin.tie(0);
  int n , k;
  cin >> n >> k;
  int ans = 0;
  int Mn = 0 , Mx = 0;
  int l = 1 , r = n+1;
  while(l <= n+1){
    Mn += l;
    Mx += r;
    if(l >= k)
    ans = (ans + (Mx - Mn + 1)) % Mod;

    l++;
    r--;
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3156
sx,sy,tx,ty = map(int,input().split())
[print("U",end="") for i in range(ty-sy)]
[print("R",end="") for i in range(tx-sx)]
[print("D",end="") for i in range(ty-sy)]
[print("L",end="") for i in range(tx-sx+1)]
[print("U",end="") for i in range(ty-sy+1)]
[print("R",end="") for i in range(tx-sx+1)]
print("D",end="")
print("R",end="")
[print("D",end="") for i in range(ty-sy+1)]
[print("L",end="") for i in range(tx-sx+1)]
print("U")

Measured memory_bytes: 4468
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True

def factorization(n):
    if n <= 1:
        return []

    ret = []
    while n > 2 and n % 2 == 0:
        ret.append(2)
        n //= 2
    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            ret.append(i)
            n //= i
        else:
            i += 2
    ret.append(n)
    return ret


def main():
    N = I()
    a = factorization(N)
    ans = 0
    cnts = Counter(a)
    cursor = defaultdict(int)
    d = [i for i in range(1, 1000)]
    d = list(accumulate(d))

    for k in cnts.keys():
        sep = bisect.bisect_right(d, cnts[k])
        # print(k ,cnts[k], sep)
        ans += sep

    # print(cnts)
    print(ans)



if __name__ == '__main__':
    main()


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

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    
    int max;
    if(a>=b)max=b;
    if(b>a)max=a;
    cout<<max;
    
    int min;
    if(a+b<=n)min=0;
    if(a+b>n)min=a+b-n;
    cout<<" "<<min<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int ans = 0;
    rep(i,n){
        if(s[i]!=t[i])ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3828
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");
        sc.close();

        // 主処理
        int result = 0;
        for (String num : s) {
            result += Integer.parseInt(num);
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 21844
import java.util.*;
import java.io.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      String[] S = br.readLine().split(" ");
      int N = Integer.parseInt(S[0]);
      int M = Integer.parseInt(S[1]);

      S = br.readLine().split(" ");
      int[] alt = new int[N];
      for(int i = 0; i < N; i++){
        alt[i] = Integer.parseInt(S[i]);
      }

      boolean[] flag = new boolean[N];
      for(int i = 0; i < M; i++){
        S = br.readLine().split(" ");
        int A = Integer.parseInt(S[0])-1;
        int B = Integer.parseInt(S[1])-1;
        if(alt[A] <= alt[B]) flag[A] = true;
        if(alt[B] <= alt[A]) flag[B] = true;
      }
      int ans = 0;
      for(boolean b : flag){
        if(!b) ans++;
      }
      System.out.println(ans);
    }catch(Exception e){
      e.printStackTrace();
    }
  }
}

Measured memory_bytes: 59180
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String args[]) {
	int N = scan.nextInt();
	int T = scan.nextInt();
	int[] t = new int[N];
	for(int i=0; i<N; i++) {
	    t[i] = scan.nextInt();
	}

	int ans = t[N-1] - t[0] + T;
	for(int i=1; i<N; i++) {
	    int delta = t[i] - t[i-1] - T;
	    ans = ans - ( delta > 0 ? delta : 0);
	}
	System.out.println(ans);
	scan.close();
    }
}


Measured memory_bytes: 64596