akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;


long long int two[60] = { 1 }, check[60] = {};

struct ab{
	long long int a, b;
};

bool cmp(ab x, ab y) {
	if (x.a < y.a) { return true; }
	else return false;
}

void solve(long long int a) {

	if(a%4==1||a%4==2)check[0] ++;
	for (int i = 2; i <= 55; i++) {
		if (a % two[i] <= two[i - 1] - 1) { continue; }
		check[i - 1] += ((a % two[i]) - two[i - 1] + 1) % 2;
	}
	return ;
}

int main() {
	//cout << fixed << setprecision(10);
	ab num[200050];
	long long int a, b,res=0;
	cin >> a >> b;
	for (int i = 1; i <= 59; i++) {
		two[i] = 2 * two[i - 1];
	}
	if(a!=0)solve(a - 1);
	solve(b);
	for (int i = 0; i <= 55; i++) {
		res += (check[i] % 2)*two[i];
	}
	cout << res;
}

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

using namespace std;

int main() {
	int H, W, K;
	cin >> H >> W >> K;
	vector<string> c(H);
	for (int i = 0; i < H; ++i) { cin >> c[i]; }

	int ans = 0;
	int n = H + W;
	for (int i = 0; i < (1<<n); ++i) {
		vector<bool> h(H, true), w(W, true);
		for (int j = 0; j < n; ++j) {
			if ((i>>j) & 1) { continue; }
			if (j < H) { h[j] = false; }
			else { w[j - H] = false; }
		}

		int cnt = 0;
		for (int j = 0; j < H; ++j) {
			for (int k = 0; k < W; ++k) {
				if (h[j] && w[k] && c[j][k] == '#') { ++cnt; }
			}
		}
		if (cnt == K) { ++ans; }
	}
	cout << ans << endl;

	return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = LLONG_MAX;
 
using vc = vector<char>;
using vi = vector<int>;
using pii = pair<int, ll>;

vector<vector<pii>> graph (20);

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

    ll M = 0;

    FOR(i, 2, 14) {
        ll base = pow(3, 13-i);
        M += 3;
        graph[i].push_back({i+1, 0*base});
        graph[i].push_back({i+1, 1*base});
        graph[i].push_back({i+1, 2*base});
    }
    int L; cin >> L;
    
    ll curOps = pow(3, 13);
    ll index = 1;
    ll base = 0;

    while (base < L && curOps > 1) {
        while (base + curOps > L) {
            curOps /= 3; ++index;
        }
        ++M;
        graph[1].push_back({index, base});
        base += curOps;
    }

    while (base < L) {
        ++M;
        graph[1].push_back({14, base});
        ++base;
    }
    cout << 14 << " " << M << endl;
    FOR(i, 1, 15) {
        for (pii x : graph[i]) {
            cout << i << " " << x.first << " " << x.second << endl;
            --M;
        }
    }
}

Measured memory_bytes: 384
//Articulation Point
#include <iostream>
#include <vector>
#include <set>

using namespace std;

static const int MAX = 100000;
static const int NIL = -1;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int N, num = 1;
vector<int> G[MAX];
set<int> st;
int colors[MAX], prenum[MAX], parent[MAX], lowest[MAX];

void dfs(int u) {
    prenum[u] = num++;
    lowest[u] = prenum[u];
    for(auto i : G[u]) {
        if(colors[i] == WHITE) {
            parent[i] = u;
            colors[i] = GRAY;
            dfs(i);
            lowest[u] = min(lowest[u], lowest[i]);
        } else {
            lowest[u] = min(lowest[u], prenum[i]);
        }
    }
    colors[u] = BLACK;
}

void articulationPoint() {
    for(int i = 0; i < MAX; i++) colors[i] = WHITE;
    parent[0] = NIL;
    colors[0] = GRAY;

    dfs(0);

    int cnt = 0;
    for(int i = 1; i < N; i++) {
        if(parent[i] == 0) cnt++;
        else if(prenum[parent[i]] <= lowest[i]) st.insert(parent[i]);
    }
    if(cnt > 1) st.insert(0);
}

int main() {
    int M, s, t;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);

    }

    articulationPoint();
    
    for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << endl;
}


Measured memory_bytes: 7132
#include <stdio.h>
#include <math.h>

int main() {
	double a, b, c, d, e, f;
	double x, y;
	double A;
	while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF) {
		A = a * e - b * d;
		x = (c * e - b * f) / A;
		y = (a * f - c * d) / A;
		x *= 10000;
		x += (x >= 0)? 0.5 : -0.5;
		x *= 0.0001;
		y *= 10000;
		y += (y >= 0)? 0.5 : -0.5;
		y *= 0.0001;
		printf("%.3f %.3f\n", x, y);
	}

	return 0;
}

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

const int INF = 1001001001;

int main()
{
    ll n, W;
    cin >> n >> W;
    vector<ll> w(n), v(n);
    rep(i, 0, n) cin >> w[i] >> v[i];
    vector<vector<ll>> dp(n, vector<ll> (W+1, 0));
    dp[0][0] = 0;
    if(w[0] <= W) dp[0][w[0]] = v[0];
    rep(i, 0, n-1){
        rep(j, 0, W+1){
            if(j + w[i+1] <= W){
                dp[i+1][j+w[i+1]] = max(dp[i+1][j+w[i+1]], dp[i][j] + v[i+1]);
            }
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }
    ll mx = 0;
    rep(i, 0, W+1){
        mx = max(mx, dp[n-1][i]);
    }
    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 80624
#!ruby -nal
a=$F.sort
c||={a=>0}
q=c.keys
l=[[1],*[[1,-1]]*2,[-1]]*2
(l[t=(m=q.shift).index(?0)]+[-4]).map{|i|d=m.dup
d[t]=d[t+i]
d[t+i]=?0
c[d]||(c[d]=c[m]+1)&&q<<d
}until n=c[$F]
p n

Measured memory_bytes: 16084
//written by NewbieChd
#include <cstdio>
#include <cctype>
#include <algorithm>
using namespace std;

const int BUF = 1000000;
char buf[BUF], *p1, *p2;
inline char getChar() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BUF, stdin), p1 == p2) ? EOF : *p1++; }
inline int read() {
    register int f = 0;
    char c;
    while (!isdigit(c = getChar())) {}
    do
        f = f * 10 + (c ^ 48);
    while (isdigit(c = getChar()));
    return f;
}

const int maxN = 100003;
int l[maxN], r[maxN];

int main() {
    int n = read(), m = read(), i, L = 0, R = n;
    for (i = 1; i <= m; ++i)
        l[i] = read(), r[i] = read(), L = max(l[i], L), R = min(r[i], R);
    printf("%d\n", max(R - L + 1, 0));
    return 0;
}


Measured memory_bytes: 1920
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

void solve(){
	int n, m; scanf("%d%d", &n, &m);
	int A[100010] = {};
	rep(i, m) {
		int x, y; scanf("%d%d", &x, &y);
		A[x]++, A[y]++;
	}
	for(int i=1;i<=n;i++) if(A[i] & 1) {
		puts("NO");
		return;
	}
	puts("YES");
}

int main(){
	int Tc = 1; // scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		// printf("Case #%d\n", tc);
		solve();
	}
	return 0;
};

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int partition(int A[],int p,int r)
{
	int x,i,j;
	x = A[r];
	i = p-1;
	for(j=p;j<r;j++)
	{
		if(A[j]<=x)
		{
			i = i+1;
			swap(A[i],A[j]);
		}
	}
	swap(A[++i],A[r]);
	return i;
}
int main()
{
	int n,A[100005],r;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>A[i];
	}
	r =	partition(A,0,n-1);
	for(int i= 0;i<n;i++)
	{
		if(i)
		cout<<' ';
		if(i == r)
		{
			cout<<'['<<A[i]<<']';
		}
		else 
		cout<<A[i];
	}
	cout<<endl;
	return 0;
}






Measured memory_bytes: 3464
import math


def is_distance_int(D, y, z):
    sum_diff_squre = 0
    for i in range(D):
        sum_diff_squre += (y[i] - z[i]) * (y[i] - z[i])
    distance = int(math.sqrt(sum_diff_squre))

    if distance * distance == sum_diff_squre:
        return True
    else:
        return False


if __name__ == '__main__':
    N, D = map(int, input().split())
    X = [list(map(int, input().split())) for _ in range(N)]

    answer = 0
    for i in range(N):
        for j in range(0, i):
            # print(str(i+1) + ',' + str(j+1))
            if is_distance_int(D, X[i], X[j]):
                answer += 1

    print(answer)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
using namespace std;

int main() 
{
    string s,t;
    cin >> s;
    cin >> t;
    string u = s;
    int count = 0;
    vector<int> counts;
    for (int i = 0; i < (s.size()-t.size()+1); i++)
    {
        count = 0;
        u.replace(i,t.size(),t);
        for (int j = i; j < i+t.size(); j++)
        {
            if (s[j] != u[j])
            {
                count += 1;
            }
        }
        counts.push_back(count);
    }
    int min = counts[0];
    for (int i = 0; i < counts.size(); i++)
    {
        if (min > counts[i])
        {
            min = counts[i];
        }
        
    }
    cout << min << endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int table[] = new int[3];

		Scanner sc = new Scanner(System.in);

		table[0] = sc.nextInt();
		table[1] = sc.nextInt();
		table[2] = sc.nextInt();

		int work;

		for(int base_loc = 0; base_loc <= 1; base_loc++){
			for(int comp_loc = table.length-1;comp_loc >= base_loc+1; comp_loc--){
				if(table[comp_loc] < table[comp_loc-1]){
					work = table[comp_loc-1];
					table[comp_loc-1] = table[comp_loc];
					table[comp_loc] = work;
				}
			}
		}

		for(int i = 0; i < table.length; i++){
			if(i != 0)System.out.printf(" ");
			System.out.printf("%d", table[i]);
		}
		System.out.printf("\n");
	}
}


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

int main() {
  while (true) {
    int n, count = 0;
    cin >> n;
    if (n == 0) break;
    vector<int> f(n), ser(n);
    for (int i = 0; i < n; i++) {
      string a;
      cin >> a;
      if (a == "lu") f.at(i) = 1;
      else if (a == "ru") f.at(i) = 10;
      else if (a == "ld") f.at(i) = -1;
      else f.at(i) = -10;
    }
    ser.at(0) = f.at(0);
    for (int i = 1; i < n; i++) ser.at(i) = ser.at(i - 1) + f.at(i);
    for (int i = 0; i < n; i++) {
      if ((count % 2 == 0 && ser.at(i) == 11) || (count % 2 == 1 && ser.at(i) == 0)) count++;
    }
    cout << count << endl;
  }
}


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

#define fn "test"
#define fn1 ""

using namespace std;

const int mn = 1 * (int)(1e5) + 10;
const int mod = 1 * (int)(1e9) + 7;
const int mm = 1 * (int)(1e3) + 10;
const int base = 1 * (int)(1e9);
const bool aNs = 0;

int tt, ntest = 1;

void docfile()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    if (ifstream(fn".inp"))
    {
        freopen(fn".inp", "r", stdin);
        if (!aNs) freopen(fn".out", "w", stdout);
		else freopen (fn".ans", "w", stdout);
    }else if (ifstream(fn1".inp"))
    {
        freopen(fn1".inp", "r", stdin);
        freopen(fn1".out", "w", stdout);
    }
}

template <typename T>
void read(T& x)
{
    x = 0; T f = 1;
    char ch = getchar();
    while (!isdigit(ch)) f = ch == '-' ? - f : f, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
    x *= f;
}

template <typename T>
void write (T a)
{
    if (a < 0)
    {
        putchar ('-');
        write (-a);
        return;
    }
    if (a < 10)
    {
        putchar ('0' + a);
        return;
    }
    write (a / 10);
    putchar ((char)('0' + (a % 10)));
}

void enter()
{
    int n;
    cin >> n;
    vector<int> a (n + 2);
    int s = 0;
    for (int i = 1; i <= n; ++ i)
    {
        cin >> a[i];
        s += abs (a[i] - a[i - 1]);
    }
    s += abs (a[n]);
    for (int i = 1; i <= n; ++ i)
    {
        cout << s - abs (a[i] - a[i - 1]) - abs (a[i] - a[i + 1]) + abs (a[i - 1] - a[i + 1]) << "\n";
    }

}

void solve()
{

}

void print_result()
{

}

int main()
{
    docfile();
    //cin>>ntest;
    for (tt = 1; tt <= ntest; ++ tt)
    {
        enter();
        solve();
        print_result();
    }
}

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

signed main(){
  int n;cin>>n;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++)cin>>a[i]>>b[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  if(n&1)cout<<b[n/2]-a[n/2]+1<<endl;
  else cout<<b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1]+1<<endl;
}


Measured memory_bytes: 4788
#include <bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
  
	map<string, int> m;
	int q;
	cin >> q;
	while(q--){
		int op;
		cin >> op;
		string s;
		cin >> s;
		if(op)cout << m[s] << '\n';
		else{
			int x;
			cin >> x;
			m[s] = x;
		}
	}
    return 0;
}



Measured memory_bytes: 25868
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000000000001;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

int prod = 1;

long long long_pow(int n, int times) {
    long long sum = 1;
    while (times--) sum *= n;
    return sum;
}

int main() {
    long long n;
    cin >> n;
    long long sum = 0;
    int prod = 1;
    while (sum + long_pow(26, prod) < n) {
        sum += long_pow(26, prod);
        prod++;
    }
    n -= sum;

    string s = "";
    prod--;
    n--;
    while (prod >= 0) {
        s.push_back(n % 26 + 'a');
        n /= 26;
        prod--;
    }
    reverse(s.begin(), s.end());
    cout << s;

    return 0;
}

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

int main() {
  int K;
  string S;
  cin >> K >> S;
  if (S.size() <= K){
    cout << S;
  }
  else{
    string sum;
    for(int i=0;i<K;i++){
      sum += S.at(i);
    }
    cout << sum+"...";
  }
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main(){

	int a , b , c , d;
	int p;

	cin >> a >> b >> c >> d >> p;

	int A = a * p;
	int l = p - c;

	if(c > p){
		if(b < A){
			cout << b << endl;
		}
		else{
			cout << A << endl;
		}
	}
	else if(c < p){
		int ans = b + (d * l);
		if(ans < A) cout << ans << endl;
		else cout << A << endl;
	}

	return 0;
}

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 998244353
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define INF 1LL << 30
#define ll long long
#define ull unsigned long long
#define RNG mt19937
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
const int N = 4005;
ll fac[N], inv[N];

ll mod_pow(ll x, ll p){
	ll res = 1;
	while(p > 0){
		if(p&1)res = res * x % MOD;
		p>>=1;
		x = x * x % MOD;
	}
	return res;
}


inline ll mul(ll x, ll y){
	return x * y % MOD;
}

inline ll add(ll x, ll y){
	ll res = x + y;
	if(res >= MOD)res-=MOD;
	return res;
}

inline ll comb(ll n, ll k){
	if(n < k)return 0;
	return mul(mul(fac[n],inv[k]), inv[n-k]);
}

int main(){
	fast_io();
	int k,n;cin >> k >> n;
	fac[0] = inv[0] = 1;
	cu(i,1,N){
		fac[i] = mul(fac[i-1], i);		
		inv[i] = mod_pow(fac[i], MOD - 2);
	}
	fu(i,2,2*k){
		int ans = 0;
		int p = min(i/2, (2*k-i+2)/2);
		fu(j,0,p){
			ll cur = mul(comb(p,j), comb(n + k - 1 - 2*j, k - 1));
			if(j&1)cur = add(MOD,-cur);
			ans = add(ans, cur);	
		}
		cout << ans << '\n';
	}
}


Measured memory_bytes: 384
#include <iostream>
#define f(i,j,k) for(int i=j;i<k;i++)
#define MAX 2147483647
using namespace std;
int c[200000];
void update(int a,int b){
    c[a]=b;
    a=a/2;
    while(a!=0){
        c[a]=min(c[2*a],c[2*a+1]);
        a=a/2;
    }
    
}
int find(int d,int e){
    if(d==e){
        return c[d];
    }
    else if(d%2==1){
        return min(c[d],find(d+1,e));
    }
    else if(e%2==0){
        return min(find(d,e-1),c[e]);
    }
    else{
        return find(d/2,e/2);
    }
}
int main(){
    int n,q,com,x,y;
    cin>>n>>q;
    f(i,0,n*2){
        c[i]=MAX;
    }
    f(i,0,q){
        cin>>com>>x>>y;
        if(com==0){
            update(x+n,y);
        }
        else{
            cout<<find(x+n,y+n)<<endl;
        }
    }
    return 0;
}




Measured memory_bytes: 3784
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize
    };
    for i in 1..=100 {
        if a * i % b == c {
            println!("YES");
            return;
        }
    }
    println!("NO");
}


Measured memory_bytes: 2132
use std::vec::Vec;

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let wether = vec!["Sunny", "Cloudy", "Rainy"];
    let s: String = read();
    for (i, &str) in wether.iter().enumerate() {
        if str == s {
            print!("{}", wether[(i+1) % 3]);
            break
        }
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	static final int MAX = 2019;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();   // 駒の数
		int[] X = new int[N];   // 駒の位置（スタートに近い順から）
		for(int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
		}
		int M = sc.nextInt();   // 行う操作の回数
		for(int i = 0; i < M; i++) {
			int A = sc.nextInt();
			advancePiece(X, A);
		}

		// 結果出力
		for(int i = 0; i < N; i++) {
			System.out.println(X[i]);
		}

		sc.close();
	}

	static void advancePiece(int[] x, int a) {
		int work = x[a-1] + 1;
		if(work == MAX+1) {
			return;
		}
		for(int i = 0; i < x.length; i++) {
			if(work == x[i]) {
				return;
			}
		}
		x[a-1] = work;
	}
}


Measured memory_bytes: 26480
def f(A):
    s = sum(A)
    c = len(A)
    r = s / float(c)
    r = int(round(r))

    cost = 0
    for j in range(len(A)):
        diff = A[j] - r
        cost += (diff * diff)
    return cost

f([4, 2, 5]) == 5
f([1, 1, 3]) == 3

n = input()
A = list(map(int, input().split()))
ans = f(A)
print(ans)


Measured memory_bytes: 38256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 2019;

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    int r = x%y;
    if (r == 0) {
        return y;
    }
    return gcd(y, r);
}

ll mypow(ll x, ll n) {
    if (n == 0) return 1;
    if (n%2 == 0) return mypow(((x%mod)*(x%mod))%mod, n/2);
    else return ((x%mod) * mypow(((x%mod)*(x%mod))%mod, (n-1)/2))%mod;
}

int main(){
    string S;
    cin >> S;
    int N = S.size();
    reverse(S.begin(), S.end());
    map<int, int> hist;
    for (int i=0; i<2019; i++) hist[i] = 0;
    int val = 0;
    int ten = 1;
    ll ans = 0;
    for (int i=0; i<N; i++) {
        val += (S.at(i) - '0')*ten;
        val %= mod;
        ans += hist[val];
        hist[val]++;
        ten = (ten*10)%mod;
    }
    ans += hist[0];
    cout << ans << endl;
}

Measured memory_bytes: 3752
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")

#include <bits/stdc++.h>
using namespace std;
 
#define len(x) (int)((x).size())
#define endl '\n'
#define int long long
#define x first 
#define y second
#define dbg(x) cout << #x << " = " << x << endl;

void solve(); signed main() {
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(10);
    solve();
    return 0;
}
 
const int MOD = 998244353, MAXN = 1e6 + 10, INF = 1e18 + 10, BASE = 37;

void solve() {
    int n, m;
    cin >> n >> m;

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    int sum = accumulate(a.begin(), a.end(), 0ll);

    int k = (sum + 4 * m - 1) / (4 * m);

    if (a[n - m] >= k) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=924844033;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cout<<setprecision(20);
	cin.tie(0);
	ios::sync_with_stdio(false);
	llint n,i,K;cin>>n>>K;
	vector<llint>x(n);
	for(i=0;i<n;i++){cin>>x[i];}
	REV(x);
	llint ans=big;
	//なぜか三分探索ができる?
	llint bmin=0,bmax=n+1;
	while(bmax-bmin>1){
		llint bgen=(bmax+bmin)/2;
		//bgenとbgen+1回の差を見る
		llint hians=K*(n+bgen);
		for(i=0;i<n;i++){
			int suu=i/bgen;
			if(suu==0){suu=5;}
			else{suu=suu*2+3;}
			hians+=x[i]*suu;
		}
		mineq(ans,hians);
		
		llint mgans=K*(n+bgen+1);
		for(i=0;i<n;i++){
			int suu=i/(1+bgen);
			if(suu==0){suu=5;}
			else{suu=suu*2+3;}
			mgans+=x[i]*suu;
		}
		mineq(ans,mgans);
		if(hians<mgans){bmax=bgen;}
		else{bmin=bgen;}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
/*
	Failure is not the reason for you to stop trying 
	   it is actually a remainder that you should 
			KEEP GOING 
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	SaveTime;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n ;
		fn1{
			cin >> ar[i];
		}
		if(n==1){
			if(ar[1]==1)cout<<0<<endl;
			else
				cout<<-1;
			return 0;
		}
		int ans =0, cur =1;
		fn1{
			if(ar[i]==cur && cur <=n ){
				cur++;
			}
			else{
				ans++;
			}
		}
		if(ans>n-1)return cout<<-1,0;
		else
			cout<<ans<<endl;
		
	}
	
	cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}



Measured memory_bytes: 4352
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int n;
vector<int> v;
int ans;
int main(){
    scanf("%d",&n);
    int t;
    for (int x=0;x<n;x++){
        scanf("%d",&t);
        v.push_back(t);
    }
    sort(v.begin(),v.end());
    int z;
    for (int x=0;x<n;x++){
        z=0;
        for (int y=0;y<x;y++){
            while (z && v[z-1]+v[y]>v[x]) z--;
            if (z<y && v[z]+v[y]<=v[x]) z++;
            ans+=y-z;
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
As = gets.split.map(&:to_i).sort

$h = Hash.new
HONs = [-1, 2, 5, 5, 4, 5, 6, 3, 7, 6]
As.each{|a| $h[HONs[a]] = a}
hons = $h.keys.sort
rhons = hons.sort{|hon1, hon2| $h[hon2] <=> $h[hon1]}

#def p(str) end

lens = [0]
1.upto(N).each do |n|
  if hons.all?{|hon| n < hon}
    lens << nil
  elsif hons.any?{|hon| n < hon}
    lens << hons.find_all{|hon| hon <= n}.map{|hon| lens[n-hon].nil? ? nil : lens[n-hon] + 1}.compact.max
  else
    lens << hons.map{|hon| lens[n-hon].nil? ? nil : lens[n-hon] + 1}.compact.max
  end
end

digits = []
len = lens[-1]
n = N
#p [digits, len, n]

while len > 0
  rhons.each do |hon|
    if hon > n then next end
    if lens[n-hon] == len - 1
      digits << $h[hon]
      len -= 1
      n -= hon
      #p [digits, len, n]
      break
    end
  end
end

puts digits.join('')


Measured memory_bytes: 2044
/*
      author  : nishi5451
      created : 14.08.2020 15:49:06
*/

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


int main(){
    ll n;
    cin >> n;
    ll ans;
    for(int i=1; i*i<=n; i++){
        ans = i*i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
  string X,ans;
  cin >> X;
  if (X=="A"){
    ans = "T";
  }else if (X=="T"){
    ans = "A";
  }else if (X=="G"){
    ans = "C";
  }else if (X=="C"){
    ans = "G";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
use std::cmp;

struct Solver {
    w: i32,
    cells: Vec<Vec<i32>>,
}

impl Solver {
    fn new() -> Solver {
        let w = read();
        let h = 2;
        Solver {
            w: w,
            cells: read_lines(h),
        }
    }

    fn run(&self) {
        let mut best = 0;

        // 最も良いルートを探索
        for i in 0..self.w as usize {
            let mut value = 0;
            let mut y = 0;
            for x in 0..self.w as usize {
                if i == x {
                    y = 1;
                    value = value + self.cells[0][x];
                }
                value = value + self.cells[y][x];
            }
            best = cmp::max(best, value);
        }

        println!("{}", best);
    }

    fn show(&self) {
        for row in &self.cells {
            for i in row {
                print!("{} ", i);
            }
            println!("");
        }
    }
}

fn read() -> i32 {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_lines(h: i32) -> Vec<Vec<i32>> {
    let mut v2 = Vec::new();
    for _ in 0..h {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let v = s.trim()
            .split_whitespace()
            .map(|e| e.parse().ok().unwrap())
            .collect();
        v2.push(v);
    }
    v2
}

fn main() {
    let solver = Solver::new();
    // solver.show()
    solver.run();
}


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

int main()
{
    int n, r;
    cin >> n >> r;
    if (n < 10)
        cout << r + 100 * (10 - n) << endl;
    else
    {
        cout << r << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write = sys.stdout.write

N, T, Q = map(int, readline().split())
P = [list(map(int, readline().split())) for i in range(N)]
QS = [P[int(readline())-1] for i in range(Q)]
prv = 1
R = {}
A = []; B = []
for x, t in P:
    if prv == t:
        if t == 1:
            A.append(x)
        else:
            B.append(x)
    else:
        if prv == 2:
            y = ((A[-1] if A else -10**19) + (B[0] if B else 10**19)) >> 1
            for z in A:
                R[z] = min(z+T, y)
            for z in B:
                R[z] = max(z-T, y)
            A = [x]; B = []
        else:
            B.append(x)
    prv = t
if A or B:
    y = ((A[-1] if A else -10**19) + (B[0] if B else 10**19)) >> 1
    for z in A:
        R[z] = min(z+T, y)
    for z in B:
        R[z] = max(z-T, y)

for x in QS:
    write("%d\n" % R[x[0]])



Measured memory_bytes: 29228
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cstring>

#define int long long
//typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)

using namespace std;



signed main()
{
#ifdef LOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int N, A, B;

    cin >> N >> A >> B;

    if (A > B) {
        cout << 0 << endl;
        return 0;
    }

    if (A != B && N == 1) {
        cout << 0 << endl;
        return 0;
    }

    int mn = A + B;
    rep(i,N-2) mn += A;

    int mx = A + B;
    rep(i,N-2) mx += B;

    cout << mx - mn + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define RES REP(k, n){cout << A[k]; k != n-1 ? cout << " " : cout << endl;}
using namespace std;
typedef vector<int> vi;

void insertionSort(vi &A, size_t n){
    RES
    FOR(i, 1, n) {
        int v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;}
        A[j+1] = v;
        RES}
}

int main(){
    int n; cin >> n;
    vi A(n);
    REP(i, n) cin >> A[i];
    insertionSort(A, n);
}

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

int main()
{
	long long int i, j, k, l, m,flag,N;
	long long int sum;
	m = 0;
	sum = 1;
	flag = 0;
	cin >> N;
	long long int prime[300] = {};
	long long int jou[300] = {};
	prime[0] = 2;
	for (i = 3; i <= N; i+=2) {
		flag = 0;
		for (j = 2; j <=sqrt(i) ; j++) {
			if (i%j == 0) {
				flag = 1;
				break;
			}
		}
		if (flag == 0) {
			m++;
			prime[m] = i;
		}
	}
	k = 0;
	long long int cons = N;
	for (k = 0; prime[k] != 0; k++) {
		while (N) {
			N /= prime[k];
			jou[k] += N;
		}
		N = cons;
	}
	for (k = 0; jou[k] != 0; k++) {
		sum = sum*(jou[k]+1)%1000000007;
	}
	

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



Measured memory_bytes: 256
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:102400000,102400000")
#include<iostream>  
#include<cstdio>  
#include<fstream>  
#include<iomanip>
#include<algorithm>  
#include<cmath>  
#include<deque>  
#include<vector>  
#include<assert.h>
#include<bitset>
#include<queue>  
#include<string>  
#include<cstring>  
#include<map>  
#include<stack>  
#include<set>
#include<functional>
#define pii pair<int, int>
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define eps 0.00000001
#define mst(a,i) memset(a,i,sizeof(a))
#define all(n) n.begin(),n.end()
#define lson(x) ((x<<1))  
#define rson(x) ((x<<1)|1) 
#define inf 0x3f3f3f3f
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int maxn = 1e4 + 5;
int a[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int i, j, k, m, n, T;
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	sort(a + 1, a + 1 + n);
	cout << a[n] - a[1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
char a[2*Max],ch;
int b[26];
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	int i=0;
	scanf("%s",a);
	int len=strlen(a);
	for(int i=1;i<len;i++)
	{
		if(a[i]==a[i-1])
		{
			printf("%d %d\n",i,i+1);
			return 0;
		}
		if(i>2 && a[i]==a[i-2])
		{
			printf("%d %d\n",i-1,i+1);
			return 0;
		}
	}
	printf("-1 -1\n");
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll pow2i[64];

ll power(ll x, ll n){
    ll res = 1;
    for(ll i = 0; i < n; i++) res = (res * x) % MOD;
    return res;
}

ll foo(ll i, ll k){
    ll res = power(3, i);
    ll s = pow2i[i] - k - 1;
    ll t = 0;
    for(ll j = i + 1; j >= 0; j--){
        if(pow2i[j] & s){
            res = (res + MOD - power(3, j) * power(2, t) % MOD) % MOD;
            t++;
        }
    }
    return res;
}

ll foo2(ll i, ll j){
    ll res = 0;
    j++;
    ll t = 0;
    for(ll k = i + 1; k >= 0; k--){
        if(pow2i[k] & j){
            res = (res + power(3, k) * power(2, t) % MOD) % MOD;
            t++;
        }
    }
    return res;
}

ll rec(ll i, ll j, ll k){
    if(k < 0) return 0;
    if(i == 0) return 1;
    if(k > j) return rec(i, j, j);
    if(pow2i[i - 1] > k){
        if(pow2i[i - 1] > j) return rec(i - 1, j, k);
        else return (rec(i - 1, j - pow2i[i - 1], k) + foo(i - 1, k)) % MOD;
    }
    return (rec(i - 1, j - pow2i[i - 1], k - pow2i[i - 1]) +
            foo2(i - 1, j - pow2i[i - 1]) + 
            foo(i - 1, pow2i[i - 1] - 1)) % MOD;
}

ll count(ll l, ll r){
    ll res = 0;
    ll noise = 0;
    ll temp = 1;
    while(temp <= l + 1){
        temp *= 2;
        noise++;
    }
    noise--;
    for(ll i = 0; i < noise; i++) res = (res + power(3, i)) % MOD;
    l -= pow2i[noise];
    r -= pow2i[noise];
    r = min(r, pow2i[noise] - 1);
    res = (res + rec(noise + 1, r, l)) % MOD;
    return res;
}

int main()
{
    pow2i[0] = 1;
    for(ll i = 1; i < 64; i++){
        pow2i[i] = pow2i[i - 1] * 2;
    }
    ll l, r;
    cin >> l >> r;
    cout << (count(r, r) + MOD - count(l - 1, r)) % MOD << endl;
}

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

int main() {
  int n;
  long long c;
  scanf("%d %lld", &n, &c);
  vector<long long> x(n);
  vector<int> v(n);
  for (int i = 0; i < n; ++i)
    scanf("%lld %d", &x[i], &v[i]);

  vector<long long> suf(n, v.back());
  vector<long long> suf_max(n, v.back() - (c - x.back()));
  for (int i = n - 2; i >= 0; --i) {
    suf[i] = suf[i + 1] + v[i];
    suf_max[i] = max(suf[i] - (c - x[i]), suf_max[i + 1]);
  }

  vector<long long> pref(n, v[0]);
  vector<long long> pref_max(n, v[0] - x[0]);
  for (int i = 1; i < n; ++i) {
    pref[i] = pref[i - 1] + v[i];
    pref_max[i] = max(pref[i] - x[i], pref_max[i - 1]);
  }

  long long z = accumulate(v.begin(), v.end(), 0LL);
  long long ans = max({0LL, z - (c - x[0]), z - x[n - 1]});

  long long s = 0;
  for (int i = 0; i < n - 1; ++i) {
    s += v[i];
    ans = max(ans, s - x[i]);
    ans = max(ans, s - 2 * x[i] + suf_max[i + 1]);
  }

  s = 0;
  for (int i = n - 1; i >= 1; --i) {
    s += v[i];
    ans = max(ans, s - (c - x[i]));
    ans = max(ans, s - 2 * (c - x[i]) + pref_max[i - 1]);
  }

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

Measured memory_bytes: 4608
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
lis=[tuple(map(int,input().split()))for _ in range(n+m-1)]
node_in=[0]*n
node=[[]for i in range(n)]
for x,y in lis:
	node_in[y-1]+=1
	node[x-1].append(y-1)
for i in range(n):
	if node_in[i]==0:
		root=i
		break
ans=[-1]*n
ans[root]=0
stack=[root]
while stack:
	r=stack.pop()
	for x in node[r]:
		node_in[x]-=1
		if node_in[x]==0:
			stack.append(x)
			ans[x]=r+1
for x in ans:
	print(x)


Measured memory_bytes: 40684
N = int(input())
s = input()
#print(s)
d = ['S','W']
for i in d:
    for j in d:
        ans = [i,j]
        for k in range(2,N):
            if s[k-1] == 'o':
                if ans[-1] == ans[-2]:
                    ans.append('S')
                else:
                    ans.append('W')
            else:
                if ans[-1] == ans[-2]:
                    ans.append('W')
                else:
                    ans.append('S')

        #print(ans)

        cans = [ans[-2],ans[-1],ans[0],ans[1]]
        cs = [s[-2],s[-1],s[0],s[1]]
        # print(cans)
        # print(cs)
        flg = True
        for k in range(1,3):
            if (cans[k] == 'S' and cs[k] == 'o') or (cans[k] == 'W' and cs[k] == 'x'):
                if cans[k-1] != cans[k+1]:
                    flg = False
            else:
                if cans[k-1] == cans[k+1]:
                    flg = False
        if flg == True:
            print(''.join(ans))
            exit()



print(-1)


Measured memory_bytes: 93392
#include<iostream>
#include<string>

using namespace std;

int main() {
  long N;
  cin >> N;
  long H[N];
  for (long i=0; i<N; i++) {
    cin >> H[i];
  }
  /////////////////////////////////
  
  long max = 0;
  long count = 0;
  
  for (long i=0; i<N-1; i++) {
    if (H[i] >= H[i+1]) {
      count++;
    } else {
      if (max < count) max = count;
      count = 0;
    }
  }
  
  if (max < count) max = count;
  
  cout << max << endl;
  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}
 
bool ispossible(vector<int> &A, ll d) {
    int N = A.size();
    if (d == 1) {
        for(int i = 0; i + 1 < N; i++) {
            if (A[i + 1] <= A[i]) {
                return false;
            }
        }
        return true;
    }
    map<ll, ll> digit;
    for (int i = 1; i < N; i++) {
        if (A[i] <= A[i - 1]) {
            bool cont = true;
            int now = A[i];
            while(cont && now != 0) {
                cont = false;
                digit[now]++;
                if (digit[now] == d) {
                    digit.erase(now);
                    now--;
                    cont = true;
                }
            }
            if (now == 0) return false;
            for (auto it = digit.lower_bound(A[i] + 1); it != digit.end(); it = digit.erase(it));
        }
    }
    return true;
}
 
void solve() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
 
    ll ok = 200000;
    ll ng = 0;
 
    while(ok - ng > 1) {
        ll c = (ok + ng) / 2;
        if (ispossible(A, c)) {
            ok = c;
        } else {
            ng = c;
        }
    }
    cout << ok << endl;
}
 
 
int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>




typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)



ll fast_pow(ll x,ll n,ll mod){
    if (n==0) return 1;
    ll res=fast_pow(x*x %mod,n/2,mod);
    if (n&1) res=res*x%mod;
    return res;
}

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

vector<int> to[200005];
vector<int> ans;
void dfs(int v,int p=-1){
    for (int u: to[v]){
        if (u==p) continue;
        else{
            ans[u]+=ans[v];
            dfs(u,v);
        }
    }
}

int main(){
    int n,q;
    cin>>n>>q;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    rep(i,q){
        int p,x;
        cin>>p>>x;
        p--;
        ans[p]+=x;
    }
    dfs(0);
    rep(i,n){
        cout<<ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 23936
#include <iostream>
#include <iomanip>
#include <vector>
#include <complex>
#include <cmath>
#include <algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
int main(){
	int high;
	vector<int> tmp;
	for(int i=0;i<10;i++){
		cin>>high;
		tmp.push_back(high);
	}
	sort(tmp.begin(),tmp.end());
	for(int i=9;i>6;i--){
		cout<<tmp[i]<<endl;
	}
}

Measured memory_bytes: 1216
while True:
    try:
        N = int(input())
        SP = []
        for i in range(1, N+1):
            S, P = map(str, input().split())
            SP.append([S, int(P), i])
            
        for sp in sorted(SP, key=lambda x: (x[0], -x[1])):
            print(sp[2])
    except:
        break

Measured memory_bytes: 3060
import java.io.InputStream;
import java.util.Scanner;
import java.util.Arrays;
import java.util.stream.*;
import java.util.StringJoiner;
import java.util.HashSet;
import java.util.Set;
// https://atcoder.jp/contests/abs/tasks/abc081_b
public class Main {
  public static void main(String[] args){
    System.out.println(new Main().excute(System.in)); 
  }
  public String excute(InputStream f) {
    Scanner scan = new Scanner(f);
    int a = scan.nextInt();
    int b = scan.nextInt();
    
    int[] arr = {1, 2, 3};
    return  "" + Arrays.stream(arr)
            .filter(i ->  (i !=  a && i != b))
            .findFirst().getAsInt();
  }
}


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

using namespace std;


#ifdef zxc

#include <sys/resource.h>
#include "debug.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = int64_t;
using ld = long double;
const ld EPS = 1e-9;
//const ll MOD = 924844033;
const ld PI = 3.141592653589793;
const int maxn = 300001;
const ll MOD = 998244353;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

signed main() {
#ifdef zxc
    struct rlimit rl;
    const rlim_t kStackSize = 512L * 1024L * 1024L;
    assert(!getrlimit(RLIMIT_STACK, &rl));
    rl.rlim_cur = kStackSize;
    assert(!setrlimit(RLIMIT_STACK, &rl));
    freopen("../kolya_input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    //    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
    //            freopen("", "r", stdin);
    //        freopen("hack.out", "w", stdout);
#endif


    function<void(int)> solve = [](int t) {
        int n;
        cin >> n;
        vector<int> x(n);
        for (int i = 0; i < n; ++i) {
            cin >> x[i];
        }
        vector<int> diff(n);
        for (int i = 1; i < n; ++i) {
            diff[i] = x[i] - x[i - 1];
        }
        vector<int> p(n);
        iota(p.begin(), p.end(), 0);
        ll m, k;
        cin >> m >> k;
        for (int i = 0; i < m; ++i) {
            int a;
            cin >> a;
            --a;
            swap(p[a], p[a + 1]);
        }
        vector<int> used(n);
        vector<int> cmp;
        vector<int> res(n);
        function<void(int)> dfs = [&](int v) {
            used[v] = 1;
            cmp.push_back(v);
            if (!used[p[v]]) {
                dfs(p[v]);
            }
        };
        for (int i = 0; i < n; ++i) {
            if (!used[i]) {
                cmp.clear();
                dfs(i);
                for (int e = 0; e < cmp.size(); ++e) {
                    res[cmp[e]] = cmp[(k + e) % cmp.size()];
                }
            }
        }
        cout << x[0] << "\n";
        ll last = x[0];
        for (int i = 1; i < n; ++i) {
            last = last + diff[res[i]];
            cout << last << "\n";
        }
    };


    fast_io();
    cout.precision(9);
    cout << fixed;
    auto start = chrono::steady_clock::now();
    for (int i = 1; i <= 1; ++i)solve(i);
    auto end = chrono::steady_clock::now();

    debug("time", chrono::duration_cast<chrono::milliseconds>(end - start).count() / 1000.0);

}


Measured memory_bytes: 6904
N = int(input())
Blue = [input() for _ in range(N)]
M = int(input())
Red = [input() for _ in range(M)]
Blue_dic = {b: Blue.count(b) for b in Blue}
for k, v in Blue_dic.items():
  if(k in Red):
    Blue_dic[k] = v - Red.count(k)
print(max(max(Blue_dic.values()),0))

Measured memory_bytes: 3060
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	n := nextInt()
	a := nextInt()
	b := nextInt()
	fmt.Println(min(n*a, b))
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

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

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    int n, m;
    cin >> n >> m;
    --n;--m;
    cout << n*m << endl;
    return 0;
}

Measured memory_bytes: 3628