akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
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: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
//**Snippetリスト**//
//rep, vin, all//
//gcdlcm, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l, m, n; ll N, M, K, H, W, L;
ll MOD = 1000000007; ll INF = 9999999999999; ll ans = 1;
vll flag, color; vll path; vl D;
//***********//
int main() {
	cin >> N;
	vl A(N);
	ll sum = 0;
	ll mini = INF;
	for (i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
		mini = min(mini, A[i]);
	}
	if (N % 2 == 1 || mini % 2 == 0) {
		if (sum % 2 == 1) { cout << "First" << endl; exit(0); }
		if (sum % 2 == 0) { cout << "Second" << endl; exit(0); }
	}
	else {
		cout << "First" << endl;
	}
}


Measured memory_bytes: 4664
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = j; i < (int)n; ++i)

int main() {

    string s; cin >> s;
    int n = (int)s.size();
    reverse(s.begin(), s.end());
    int ten = 1, all = 0;
    ll ans = 0;
    vector<int> cnt(2019);
    rep(i, 0, n) {
        cnt[all]++;
        int x = (s[i] - '0') * ten % 2019;
        all = (all + x) % 2019;
        ans += cnt[all];
        ten = ten * 10 % 2019;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;


const int N = 105;
int a[N];


int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    sort(a, a + n);

    bool good = true;
    if (n != 2)
    {
        if (a[2] == a[0])
            good = false;

        int it = 1;
        if (a[0] == a[1])
        {
            if (a[n - 1] != 2 * a[0] - 1)
                good = false;
            it++;
        }
        else
        {
            if (a[n - 1] != 2 * a[0])
                good = false;
        }
        while (it < n)
        {
            if (a[it] != a[it - 1] + 1)
            {
                good = false;
                break;
            }
            if (a[it] != a[it + 1])
            {
                good = false;
                break;
            }
            while (a[it] == a[it + 1])
                it++;
            it++;
        }
    }

    if (good)
        printf("Possible\n");
    else
        printf("Impossible\n");


	return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		no1();
	}

	static void no1() {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();

			int[] t = new int[n];
			int[] a = new int[n];
			int[] b = new int[n];

			for (int i = 0; i < n; i++) {
				t[i] = sc.nextInt();
				a[i] = sc.nextInt();
				b[i] = sc.nextInt();
			}

			int tt = 0;
			int aa = 0;
			int bb = 0;

			int dt;
			int dd;

			for (int i = 0; i < n; i++) {
				dt = t[i] - tt;
				dd = Math.abs(a[i] - aa) + Math.abs(b[i] - bb);

				if (dd > dt) {
					System.out.println("No");
					return;
				}

				if((dd-dt) % 2 != 0) {
					System.out.println("No");
					return;
				}

				tt = t[i];
				aa = a[i];
				bb = b[i];
			}

			System.out.println("Yes");

		}
	}

}


Measured memory_bytes: 90248
N, M = map(int, input().split())
H = list(map(int, input().split()))

AB = []		# どことどこが繋がってるか
for i in range(M):
    AB.append(list(map(int, input().split())))

# Trueで初期化
isBest = [True for i in range(N)]

# 自分より高いものが一つでもあったらFalseにする
# ・同じ展望台の組を結ぶ道が複数あってもFalseを上書きするだけなので問題ない
for ab in AB:
    numA = ab[0] - 1
    numB = ab[1] - 1
    if (H[numA] <=H[numB]):
        isBest[numA] = False
    if (H[numB] <=H[numA]):
        isBest[numB] = False

# 良い展望台を数える
ans = 0
for z in isBest:
    if (z == True):
        ans += 1
print(ans)

Measured memory_bytes: 31924
s = input().split(" ")
A = int(s[0])
B = int(s[1])
K = int(s[2])

for i in range(K):
    if(i%2 == 0):
        if (A%2) == 1:
            A -= 1
        A = A/2
        B = B + A
    elif(i%2==1):
        if (B%2) == 1:
            B -= 1
        B = B/2
        A = A+B

print(int(A), int(B))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;

	struct max_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	constexpr max_t max;
	constexpr min_t min;

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min();

	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
}

template<class T, class Op = std::plus<>>class binary_indexed_tree
{
	std::vector<T> vec;
	std::size_t sz;
	Op op;
public:
	binary_indexed_tree(std::size_t size, Op f = Op()) :vec(size), sz(size), op(f)
	{

	}
	void add(int i, T const& val)
	{
		++i;
		while (i <= sz)
		{
			vec[i - 1] = op(vec[i - 1], val);
			i += i & -i;
		}
	}
	auto get(int i)const
	{
		++i;
		T ret{};
		while (i != 0)
		{
			ret += vec[i - 1];
			i -= i & -i;
		}
		return ret;
	}
};

void Main()
{
	int N, Q;
	std::cin >> N >> Q;
	std::vector<int> vec(N);
	for (auto& v : vec)
	{
		std::cin >> v;
	}
	std::vector<std::tuple<int, int, int>> query(Q);
	for (auto i : boost::irange(Q))
	{
		int x, y;
		std::cin >> x >> y;
		query[i] = std::make_tuple(x - 1, y, i);
	}
	std::vector<int> answer(Q), appear(N, -1);
	binary_indexed_tree<int> bit(N + 1);
	boost::sort(query, lib::order_by([](auto&& v) {return std::get<1>(v); }));
	int last = 0;
	for (auto [x, y, i] : query)
	{
		for (; last < y; ++last)
		{
			bit.add(last + 1, 1);
			if (appear[vec[last]] != -1)
			{
				bit.add(appear[vec[last]], -1);
			}
			appear[vec[last]] = last + 1;
		}
		answer[i] = bit.get(y) - bit.get(x);
	}
	for (auto&& v : answer)
	{
		std::cout << v << std::endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 17400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
template<typename T>
T gcd(T x, T y){
    if ((x==1)||(y==1)) return 1;
    if (x>y) {
        if (x%y==0) {
            return y;
        }else{
            return gcd(y, x%y);
        }
    }else{
        if (y%x==0) {
            return x;
        }else{
            return gcd(x, y%x);
        }
    }
}

ll goch(ll a){
    for (ll i = 0; i*i*i*i*i <= a; i++) {
        if (i*i*i*i*i == a) {
            return i;
        }
    }
    return -1;
}


int main() {
    IN(int, a);
    IN(int, b);
    IN(int, c);
    IN(int, k);
    
    if (k<=a+b) {
        COUT(min(a, k));
    }else{
        COUT(a-(k-a-b));
    }
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int x;
  cin >> x;
  int ans = x / (5 + 6) * 2;
  x %= 5 + 6;
  if (x > 0) {
    ans++;
    x -= 6;
  }
  if (x > 0) {
    ans++;
    x -= 5;
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3620
from itertools import permutations
from math import factorial
N = int(input())
city = [list(map(int,input().split())) for i in range(N)]
result = 0
for v in permutations(city):
  for c in range(1, N):
    result += ((v[c-1][0] - v[c][0]) ** 2 + (v[c-1][1] - v[c][1]) ** 2) ** 0.5
print(result / factorial(N))

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

template<class T>
inline bool chmax(T &a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
};

template<class T>
inline bool chmin(T &a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  int a;
  int free = 0;
  vi color(8, 0);
  rep(i, 0, N) {
    cin >> a;
    a /= 400;
    if (a >= 8) {
      free++;
      continue;
    }
    color[a] = 1;
  }

  int mi = 0;
  rep(i, 0, 8) {
    mi += color[i];
  }

  int ma = mi + free;

  cout << max(mi, 1) << " " << ma << endl;

  return 0;
};


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

    if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u')
    {
        cout<<"vowel";

    }
    else
    {
        cout<<"consonant";
    }
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
#define INF 114514
using namespace std;




int main(){
	int w;
	while (1) {
		int p = 1150;
		cin >> w;
		if (w == -1) return 0;
		if (w > 10 && w <= 20) {
			p += 125 * (w - 10);
		}
		if (w > 20 && w <= 30) {
			p += 1250;
			p += 140 * (w - 20);
		}
		if (w > 30) {
			p += 2650;
			p += 160 * (w - 30);
		}
		cout << 4280 - p << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    string s;
    cin >> s;

    bool flug = true;

    REP(i,s.size()) {
        if (i % 2 == 0) {
            if (s[i] == 'L') flug = false;
        } else {
            if (s[i] == 'R') flug = false;
        }
    }

    ATYN(flug)

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
    
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// struct chash { int operator()(int x) const { return x ^ RANDOM; }};
// cc_hash_table<int, int, hash<int>> cnt;

const int MAXN = 106;
map<int,int> findd;

void solve(){
   int X,N; cin>>X>>N;

   FOR(i,1,N) {
       int y; cin>>y; findd[y] = 1;
   }

   int ans = 1e5,val = 1e5;

   RFOR(i,0,101){
       if(findd[i] == 1) continue;
       if(abs(i-X) <= ans){
           ans = abs(i-X);
           val = i;
       }
   }

   cout<<val<<endl;
}
    
signed main(){
    
    FastRead;     
    
    int t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}
    




Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}

/*------------------------------------------------------------------------*/

struct edge {
    ll cost, from, to;

    edge(ll c, ll f, ll t) : cost(c), from(f), to(t) {  }

    bool operator<(edge x) { return cost < x.cost; }
    bool operator>(edge x) { return cost > x.cost; }
    bool operator==(edge x) { return cost == x.cost; }
};

struct union_find {
    vll data;

    union_find(ll size) : data(size, -1) {  }

    ll root(ll x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }

    bool merge(ll x, ll y) {
        if ((x = root(x)) == (y = root(y))) return false;

        if (data[x] > data[y]) std::swap(x, y);

        data[x] += data[y], data[y] = x;

        return true;
    }
};

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}

void solve() {
    ll n;
    std::cin >> n;

    std::vector<pll> x(n), y(n);
    for (ll i = 0; i < n; i++) {
        std::cin >> x[i].first >> y[i].first;
        x[i].second = y[i].second = i;
    }

    auto compare = [](pll a, pll b) {
        return a.first != b.first ? a.first < b.first
                                  : a.second < b.second;
    };
    std::sort(x.begin(), x.end(), compare);
    std::sort(y.begin(), y.end(), compare);

    std::deque<edge> es;
    for (ll i = 0; i < n - 1; i++) {
        ll cost_x = x[i + 1].first - x[i].first;
        ll cost_y = y[i + 1].first - y[i].first;
        es.push_back(edge(cost_x, x[i].second, x[i + 1].second));
        es.push_back(edge(cost_y, y[i].second, y[i + 1].second));
    }

    auto kruskal = [&]() {
        std::sort(es.begin(), es.end());

        ll res = 0; union_find uf(n);
        for (edge e : es) if (uf.merge(e.from, e.to))
            res += e.cost;

        return res;
    };

    std::cout << kruskal() << '\n';
}


Measured memory_bytes: 11884
package main

import (
	"fmt"
)

func main() {

	var s string
	fmt.Scan(&s)

	result := "Yes"
	if s[0] == 'A' {
		if s[1] == 'A' {
			if s[2] == 'A' {
				result = "No"
			}
		}
	} else if s[0] == 'B' {
		if s[1] == 'B' {
			if s[2] == 'B' {
				result = "No"
			}
		}
	}

	fmt.Println(result)

}


Measured memory_bytes: 512
import java.util.Scanner;
//atcoderはScannerクラスのsc.next()で行ける
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        System.out.println(x==1 ? 0 : 1);
    }
}

Measured memory_bytes: 35548
object Main extends App {

  val sc = new java.util.Scanner(System.in)
  val a = sc.nextInt
  val b = sc.nextInt
  val c = sc.nextInt
  val d = sc.nextInt
  val e = sc.nextInt
  val k = sc.nextInt

  val numbers = List(a,b,c,d,e)

  val max = numbers.max
  val min = numbers.min

  val diff = max - min

  val ans = if (k >= max-min) "Yay!" else ":("

  println(ans)

}


Measured memory_bytes: 25524
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <set>
#include <ctime>
#include <map>
#include <cstring>
#include <iterator>
#include <queue>
#include <assert.h>
#include <bitset>
#include <complex>
#include <unordered_map>

//#pragma comment(linker, "/STACK:512000000")

using namespace std;

#define pb emplace_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define forab(i, a, b) for (int i = (a); i < (b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int infi = 1e9 + 7;
const ll infl = (ll)1e18 + (ll)7;

ll ar[200500];
ll dp1[200500];
ll dp2[200500];
ll tmp[200500];
ll cnt[200500];
int get_cnt(ll a, ll pr) {
    a = abs(a), pr = abs(pr);
    int ans = 0;
    while (a * 4 <= pr)
        a *= 4, ans++;
    return ans;
}

int32_t main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    //srand(time(NULL));
   // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    //freopen("customs.in", "r", stdin); freopen("customs.out", "w", stdout);
    int n;
    cin >> n;
    forn(i, n)
        cin >> ar[i];
    dp1[0] = 1;
    
    vector<int> pos;
    cnt[0] = infi;
    pos.pb(0);
    for (int i = 1; i < n; ++i) {
        dp1[i] = dp1[i - 1] + 1;
        if (ar[i] <= ar[i - 1]) {
            cnt[i] = get_cnt(ar[i], ar[i - 1]);
            if (cnt[i])
                pos.pb(i);
            continue;
        }
        int qq = 0;
        ll a = ar[i];
        ll b = ar[i - 1];
        while (a > b)
            b *= 4, ++qq;
        while (qq--) {
            int j = pos.back();
            dp1[i] += (i - j) * 2;
            --cnt[j];
            if (cnt[j] == 0)
                pos.pop_back();
        }
    }
    forn(i, n)
        cnt[i] = 0;
    pos.clear();
    cnt[n - 1] = infi;
    pos.pb(n - 1);
    dp2[n - 1] = 0;
    for (int i = n - 2; i >= 0; --i) {
        dp2[i] = dp2[i + 1];
        tmp[i] = ar[i];
        if (ar[i] <= ar[i + 1]) {
            cnt[i] = get_cnt(ar[i], ar[i + 1]);
            if (cnt[i])
                pos.pb(i);
            continue;
        }
        int qq = 0;
        ll a = ar[i];
        ll b = ar[i + 1];
        while (a > b)
            b *= 4, ++qq;
        while (qq--) {
            int j = pos.back();
            dp2[i] += (j - i) * 2;
            --cnt[j];
            if (cnt[j] == 0)
                pos.pop_back();
        }
    }
    ll ans = min(dp2[0], dp1[n - 1]);
    for (int i = 1; i < n; ++i)
        ans = min(ans, dp1[i - 1] + dp2[i]);
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 8064
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    int k;
    int i;
    int num=1;
    scanf("%d",&n);
    scanf("%d",&k);

    for(i=0;i<n;i++){
        if(num<k){
            num=num*2;
        }else{
            num+=k;
        }
    }
    printf("%d\n\r",num);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long 
#define all(v) v.begin() , v.end()
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define tr(con) for(auto it = con.begin(); it!= con.end() ; it++)
#define INF 1e9+7   // 1 * 10^9+ 7
#define rep(l,i,r) for(ll i=l;i<=r;i++)
#define fo(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, l; cin >> n >> l;
	vector  < int > v(n+1);
	int sum = 0 ,m = INF;
	for(int i=1;i<=n;i++){
		sum += i +l -1;
		m = min(m , abs(i+l-1));
	}
	if(l < 0 && n+l-1<0) cout << sum + m ;
	else 
	cout << sum -m;
	

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace atcorder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            atcorder.Test.Run();
        }
    }



    public class Test
    {
        public static void Run()
        {
            string s = Console.ReadLine();
            double a, b;
            string[] ss = s.Split(' ');
            a = double.Parse(ss[0]);
            b = double.Parse(ss[1]);
            Console.WriteLine(a / b);
        }
    }
}



Measured memory_bytes: 11092
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

int main() {
    int n;
    cin >> n;
    int d[n];

    int sum = 0;
    rep(i, n) {
        cin >> d[i];
        sum += d[i];
    }

    int ans = 0;
    rep(i, n) { ans += (sum - d[i]) * d[i]; }

    cout << ans / 2 << endl;
}

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

using namespace std;

int n;
int a[100010];
int _sticky[100010];
int *sticky = _sticky + 1;

int main() {
    int ai_max = 0;

    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        sticky[a[i]]++;
        sticky[a[i] - 1]++;
        sticky[a[i] + 1]++;
        ai_max = max(a[i], ai_max);
    }

    int best = 0;

    for(int i = -1; i <= ai_max + 1; i++) {
        if(sticky[i] > best) {
            best = sticky[i];
        }
    }

    cout << best << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 int n;
	 cin>>n;
	 int AC=0,WA=0,TLE=0,RE=0;
	 for(int i=0;i<n;i++)
	 {
		 string s;
		 cin>>s;
		 if(s=="AC")
		 AC++;
		 else if(s=="TLE")
		 TLE++;
		 else if(s=="WA")
		 WA++;
		 else
		 RE++;
	 }
	 cout<<"AC x "<<AC<<'\n';
	 cout<<"WA x "<<WA<<'\n';
	 cout<<"TLE x "<<TLE<<'\n';
	 cout<<"RE x "<<RE<<'\n';
	 
	 return 0;
}


Measured memory_bytes: 3656
// Problem : A - We Love Golf
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/**
 * @author dwij
 */

#include <bits/stdc++.h>

#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>

using namespace std;

//******* Debugging Class Template *******/
#define sim template <class c
#define ris return *this
#define dor > deb& operator<<
#define eni(x) \
    sim > typename enable_if<sizeof dud<c>(0) x 1, deb&>::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 deb {
#ifdef LOCAL
    ~deb() { 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 log(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// End of weird debugging stuff.

typedef long long ll;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pll pair<ll, ll>

#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(), c.end()
#define mem(a, val) memset(a, val, sizeof(a))
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define endl "\n"

void solution() {
    // deb() << log();
    int k;
    int a, b;
    cin >> k;
    cin >> a >> b;

    if ((b / k) * k >= a) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
}

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

    int T = 1;
    // cin >> T;
    // cin.ignore(); must be there when using getline(cin, s)
    for (int tt = 1; tt <= T; tt++) {
        // cout << "Case #" << tt << ": ";
        solution();
    }

    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
vector<int> g[2][100001];
vector<int> ord;
int mx=0;
int road[100001];
bool vis[100001];
int n,m;
void dfs(int v){
    vis[v]=1;
    for(int i=0;i<g[0][v].size();i++)
        if(!vis[g[0][v][i]])
            dfs(g[0][v][i]);
    ord.push_back(v);
}
int main(){
    cin>>n>>m;
    for(register int i=0;i<m;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        g[0][a].push_back(b);
        g[1][b].push_back(a);
    }
    for(int i=0;i<n;i++)
        if(!vis[i])
            dfs(i);
    reverse(ord.begin(),ord.end());
    for(register int i=0;i<ord.size();i++){
        int now=ord[i];
        for(int j=0;j<g[1][now].size();j++)
            road[now]=max(road[now],road[g[1][now][j]]+1);
        mx=max(mx,road[now]);
    }
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 13564
#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;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    char c;
    cin>>c;
    if(c>='A'&&c<='Z')puts("A");
    else puts("a");
    
    return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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


int main()
{
  int x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int ax = x2 - x1;
  int ay = y2 - y1;
  int bx = -ay, by = ax;
  int cx = -by, cy = bx;

  int x3 = bx + x2, y3 = by + y2;
  int x4 = cx + x3, y4 = cy + y3;
  cout << x3 << ' ' << y3 << ' '
       << x4 << ' ' << y4 << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; string S; 
	cin >> N >> S; 
	int L[30010][11] = {}; 
	int R[30010][11] = {}; 
	for(int i = 1; i <= N; i++){
		for(int j = 0; j < 10; j++){
			L[i][j] = L[i-1][j]; 
		}
		L[i][S.at(i-1) - '0'] ++; 
	}
	for(int i = N; i >= 1; i--){
		for(int j = 0; j < 10; j++){
			R[i][j] = R[i+1][j]; 
		}
		R[i][S.at(i-1) - '0'] ++; 
	}
	bool ok[1010] = {}; 
	for(int i = 1; i <= N; i++){
		for(int j = 0; j < 10; j++){
			for(int k = 0; k < 10; k++){
				if(L[i-1][j] > 0 && R[i+1][k] > 0){
					ok[100 * j + 10 * (S.at(i-1) - '0') + k] = 1;
				}
			}
		}
	}
	int ans = 0; 
	for(int i = 0; i < 1000; i++){
		if(ok[i]) ans ++; 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 2944
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>

using namespace std;

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

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

string s,t;

int main() {

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

 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
cin>>s>>t;
int ans = 1000;
int n = s.size(), m = t.size();
for(int i = 0;i+m-1 < n;i++) {
  int tans=0;
  for(int j = 0;j < m;j++) {
    if(t[j] != s[i+j]) tans++;
  }
  ans=min(ans,tans);
}
cout<<ans;

 return 0;
}


Measured memory_bytes: 3656
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    ll x,a;
    std::cin >> x>>a;
    if(x<a){
        std::cout << 0 << std::endl;
    }else{
        std::cout << 10 << std::endl;
    }
}


Measured memory_bytes: 384
INF = 10**18 + 7


def main():
    from collections import deque
    N = int(input())
    G = [[] for _ in range(N)]
    for _ in range(N):
        u, k, *A = (int(i)-1 for i in input().split())
        G[u] = A

    def bfs(s=0):
        que = deque([])
        dist = [INF]*N
        dist[s] = 0
        que.append(s)
        while que:
            pos = que.popleft()
            for v in G[pos]:
                if dist[v] != INF:
                    continue
                dist[v] = dist[pos] + 1
                que.append(v)
        return dist

    dist = bfs()
    for i, d in enumerate(dist, start=1):
        print(i, d if d != INF else -1)


if __name__ == '__main__':
    main()



Measured memory_bytes: 6036
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

template <class T> struct FenwickTree {

   vector<T> node;
   FenwickTree (int n) : node(n,0) {}

   void add(int idx, T val) {
      for (int i = idx; i < node.size(); i |= i + 1) {
         node[i] += val;
      }
   }

   T sum(int idx) {
      T ret = 0;
      for (int i = idx - 1; i >= 0; i = (i & (i + 1)) - 1) {
         ret += node[i];
      }
      return ret;
   }

};

int main() {

   int n,q; cin >> n >> q;
   FenwickTree<int> inst(100010);

   REP(i,q) {
      int com,x,y; cin >> com >> x >> y;
      if(com == 0) {
         inst.add(x,y);
      } else {
         cout << inst.sum(y+1) - inst.sum(x) << endl;
      }
   }
	
  return 0;
}

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

int main() {
	int n,i,j,cur,ans;
	cin >> n;
	
	ans=0;
	for(i=1; i<=n; i++){
		ans+=n/i;
		if(n%i==0){
			ans--;
		}
	}
	cout << ans << endl;
	return 0;
}

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

def main():
    N, *W = map(str, open(0).read().split())
    
    if not int(N) == len(set(W)):
        print('No')
    else:
        for i in range(1, int(N)):
            if not W[i][0] == W[i -1][-1]:
                print('No')
                exit()
        print('Yes')


main()

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main()
{
	int mot, bai, ama;
	int i, f = 1;

	cin >> mot >> bai >> ama;

	for (i = 1; i <= bai; i++)
	{
		//cout << mot * i << " " << mot * i % bai << endl;
		if (mot * i % bai == ama)
		{
			f = 0;
			cout << "YES" << endl;
			break;
		}
	}
	if (f)
	{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;

int main() {
    ll x,y,z; cin >> x >> y >> z;
    cout << (x-z)/(y+z) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6+5;
const ll N = 1e3+5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;

ll a[maxn];
int main(){
    // in;
    // out;
    ll n,m;
    cin>>n>>m;
    for(ll i=0;i<=n;i++){
        a[i]=i;
    }
    ll sum=0;
    for(ll i=m;i<=n+1;i++){
        ll minn=(i-1)*i/2;
        ll maxx=(n)*(n+1)/2;
        ll hh=(n-i)*(n-i+1)/2;
        if(n-i+1<0) hh=0;
        maxx-=hh;
        // cout<<minn<<" "<<maxx<<endl;
        // cout<<maxx-minn+1<<endl;
        sum+=maxx-minn+1;
        sum%=mod;
    }
    cout<<sum<<endl;
}


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

lli n;

int main(void){
	cin >> n;
	vector<lli> a(3*n);
	rep(i, 3*n) cin >> a[i];
	sort(a.begin(), a.end());
	lli ans = 0;
	rep(i, n){
		ans+=a[3*n-2*i-2];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5612
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

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

    int a = 0;
    while(--n >= 0){
        char c;
        int x;
        cin >> c >> x;

        if(c == '('){
            a += x;
        }else{
            a -= x;
            if(a < 0){
                cout << "NO" << endl;
                return 0;
            }
        }
    }

    if(a == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 1160
//  getline(cin, s);//空白スペースを関係なく1行で入力できる
//  string t = "keyence";//で文字列入力ができる
//s.empty() //emptyなら1を出力 入っていれば0を出力
/*//ABC018-B 部分的にreverseをかける解法
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  rep(i,n) cin>>a.at(i)>>b.at(i);
  rep(i,n)a.at(i)--;
  rep(i,n)b.at(i)--;
  string t;
  rep(i,n){
    t = s;
    for(int k=0;k<=b.at(i)-a.at(i);k++){
      t.at(a.at(i)+k) = s.at(b.at(i)-k);
    }
    s = t;
  }
  cout << s << endl;
}
*///ABC018-B
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int kan_hyaku(int n){
  int kurai = 0;
  for(int i=0;i<3;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int kan_ju(int n){
  int kurai = 0;
  for(int i=0;i<2;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int kan_ichi(int n){
  int kurai = 0;
  for(int i=0;i<1;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  if(a>b){
    cout<<0<<endl;
    return 0;
  }
  else if(n==1&&a!=b){
    cout<<0<<endl;
    return 0;
  }
  else if(n==1&&a==b){
    cout<<1<<endl;
    return 0;
  }
  else{
    cout<<(b-a)*(n-2)+1<<endl;
    return 0;
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  if (n%k==0) {
    printf("0\n");
  } else {
    printf("1\n");
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

template< typename T >
struct edge {
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x) {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
    const auto INF = numeric_limits< T >::max();
    vector< T > dist(g.size(), INF);

    using Pi = pair< T, int >;
    priority_queue< Pi, vector< Pi >, greater< Pi > > que;
    dist[s] = 0;
    que.emplace(dist[s], s);
    while(!que.empty()) {
        T cost;
        int idx;
        tie(cost, idx) = que.top();
        que.pop();
        if(dist[idx] < cost) continue;
        for(auto &e : g[idx]) {
            auto next_cost = cost + e.cost;
            if(dist[e.to] <= next_cost) continue;
            dist[e.to] = next_cost;
            que.emplace(dist[e.to], e.to);
        }
    }
    return dist;
}


signed main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    WeightedGraph<int> graphYen(n + 1), graphSnuuk(n + 1);
    for (int i = 0; i < m; i++) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        graphYen[u].emplace_back(v, a);
        graphYen[v].emplace_back(u, a);
        graphSnuuk[u].emplace_back(v, b);
        graphSnuuk[v].emplace_back(u, b);
    }
    auto yen = dijkstra(graphYen, s), snuuk = dijkstra(graphSnuuk, t);
    vector<int> ans(n + 2, INF);
    for (int i = n; i >= 0; i--) {
        int temp = snuuk[i] + yen[i];
        ans[i] = min(ans[i + 1], temp);
    }
    int base = 1e15;
    for (int i = 1; i <= n; i++) {
        cout << base - ans[i] << endl;
    }
}


Measured memory_bytes: 21832
#include <bits/stdc++.h>
#include <time.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<ll,ll>;
using vi = vector<ll>;
using vv = vector<vi>;
const ll INF = 1001001001001001;
const ll NUM = 1<<10;

vector<ll> prime;//素数だけのリスト
vector<ll> p(1000001,0);

void sieve(ll n){
    if(n<2)return;
    for(ll i=2; i<=n; i++){
        if(p[i])continue;
        prime.push_back(i);
        p[i] = i;
        
        for(ll j=i*i; j<=n; j+=i){
            if(!p[j])p[j] = i;
        }
    }
}


int main(){
    
    int n;
    cin >> n;
    
    sieve(1000000);
    vi count(1000001, 0);
    
    rep(i,n){
        ll a;
        cin >> a;
        for(int j=0; prime[j]*prime[j]<=a; j++){
            if(a%prime[j])continue;
            
            count[prime[j]]++;
            while(a%prime[j]==0)a /= prime[j];
            
        }
        if(a!=1)count[a]++;
        
    }
    
    //
    bool setwise = false;
    rep(i,1000001){
        if(count[i]==n){
            cout<<"not coprime"<<endl;
            return 0;
        }
        if(count[i]>1)setwise = true;
    }
    
    if(setwise)
        cout<<"setwise coprime"<<endl;
    else
        cout<<"pairwise coprime"<<endl;
    
    return 0;
}

Measured memory_bytes: 19656
import sys
from collections import Counter
n=int(input())
v=[int(x) for x in input().split()]

v1=[] # odd
v2=[] # even

for i in range(n):
    if i%2==0:
        v1.append(v[i])
    else:
        v2.append(v[i])

m1=Counter(v1).most_common()
m2=Counter(v2).most_common()




ans=0
for i in range(min(len(m1),len(m2))):
    # 最頻値が異なる
    if m1[i][0]!=m2[i][0]:
        ans=sum(list(m1[j][1] for j in range(i+1,len(m1))))+sum(list(m2[j][1] for j in range(i+1,len(m2))))
        print(ans)
        sys.exit()
    # 最頻値が同じ
    else:
        # v1の最頻値の回数のほうが大きい
        if m1[i][1]>m2[i][1]:
            ans=m2[i][1]+sum(list(m1[j][1] for j in range(i+1,len(m1))))+sum(list(m2[j][1] for j in range(i+2,len(m2))))
            print(ans)
            sys.exit()
        
        # v2の最頻値の回数ほうが大きい
        elif m1[i][1]<m2[i][1]:
            ans=m1[i][1]+sum(list(m1[j][1] for j in range(i+2,len(m1))))+sum(list(m2[j][1] for j in range(i+1,len(m2))))
            print(ans)
            sys.exit()
            
        # 最頻値の回数同じだった
        else:
            # 最頻値の回数が少ないほうを探す おそらくここが間違い
            cnt1=m1[i][1]+sum(list(m1[j][1] for j in range(i+2,len(m1)))) + sum(list(m2[j][1] for j in range(i+1,len(m2))))
            cnt2=m2[i][1]+sum(list(m2[j][1] for j in range(i+2,len(m2)))) + sum(list(m1[j][1] for j in range(i+1,len(m1))))
            ans=min(cnt1,cnt2)
            print(ans)
            sys.exit()
                    
                    
                    
                    

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    string s;cin>>s;

    if(s[5]=='0'&&(s[6]-'a'+49)<=4){
        cout<<"Heisei"<<endl;
        return 0;
    }
    cout<<"TBD"<<endl;
}


Measured memory_bytes: 768
from collections import Counter

n = int(input())
A = [int(i) for i in input().split()]

D = Counter(A)

res = 0
for i in D.items():
    if i[0] < i[1]:
        res += i[1]-i[0]
    elif i[0] > i[1]:
        res += i[1]

print(res)

Measured memory_bytes: 18676