akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    ll n = s.size();
    // 始点を0～n-2までずらす
    for(ll i=0; i<=n-2; i++){
        if(s[i] == s[i+1]){
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
        if(i <= n-3 && s[i] == s[i+2]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
}

Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>

using namespace std;
int main() 
{
	int A, B;
	cin >> A >> B;

	if (A > 9 or B > 9) cout << "-1" << endl;
  else cout << A * B << endl;
}


Measured memory_bytes: 256
n = int(input())
F = [0]*n
P = [0]*n
for i in range(n):
    F[i] = list(map(int,input().split()))
for i in range(n):
    P[i] = list(map(int,input().split()))
 
ans = -float("Inf")
for i in range(1,2**10):
    L = []
    b = 0
    for j in range(10):
        if (i>>j)&1:
            L.append(j)
    for j in range(n):
        c = 0
        for x in L:
            if F[j][x] == 1:
                c += 1
        b += P[j][c]
        
    ans = max(ans, b)
 
 
print(ans)

Measured memory_bytes: 9164
N = int(input())
INF = 10**5 + 10
dp = [INF]*(N+1)

dp[0] = 0
dp[1] = 1

for j in range(2, N+1):
  k = 1
  while k <= N:
    dp[j] = min(dp[j], dp[j-k]+1)
    k *= 6
  k = 1
  while k <= N:
    dp[j] = min(dp[j], dp[j-k]+1)
    k *= 9
print(dp[N])

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef long long ll;

int main(){
    int n,m;
    cin >> n >> m;
    vi num(n);
    for(int i=0;i<m;i++){
        int s,c;
        cin >> s >> c;
        if(num[s-1]!=0){
            if(num[s-1]!=c){
                cout << "-1" << endl;
                return 0;
            }
        }
        if(s-1==0&&c==0&&n>=2){
            cout << "-1" << endl;
            return 0;
        }
        num[s-1]=c;
    }
    if(num[0]==0&&n>=2) num[0]=1;
    for(int x:num){
        cout << x;
    }
    puts("");
    return 0;
}

Measured memory_bytes: 3564
import math
while True:
    n = int(input())
    if n == 0:
        break
    s = input().split(" ")
    t = list(map(int,s))
    goukei = 0
    for i in range(n):
        goukei += t[i]
    m = goukei / n
    sagoukei = 0
    for i in range(n):
        sagoukei += (t[i]-m)**2
    a = math.sqrt(sagoukei/n)
    print(a)

Measured memory_bytes: 7656
#include <bits/stdc++.h>
using namespace std;
const int N = 100;
int f[N][N];
#define LL long long
int main()
{
    LL x, y;
    cin >> x >> y;
    if (abs(x - y) <= 1) puts("Brown");
    else puts("Alice");
    return 0;
    int n;
    cin >> n;
    for (int i = 0; i <= n * 2; ++ i)
        for (int j = 0; j <= i; ++ j)
        {
            int k = i - j;
            for (int p = 1; p + p <= j; ++ p) if (!f[j - p * 2][k + p]) f[j][k] = 1;
            for (int p = 1; p + p <= k; ++ p) if (!f[j + p][k - p * 2]) f[j][k] = 1;
        }
    for (int i = 0; i <= n; ++ i)
    {
        for (int j = 0; j <= n; ++ j)
            cout << f[i][j];
        cout << "\n";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 2019;
const ll  maxn = 1e6 + 5;
const int N = 2e5 + 5;

char s[N];
int a[N],suf[N],n;
map<ll,ll>M;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>s+1;
	int n=strlen(s+1);
	for(int i=1;i<=n;i++){
		a[i]=s[i]-'0';
	}
	int cnt=0;int base=1;
	M[0]++;
	for(int i=n;i>=1;i--){
		suf[i]=(suf[i+1]+a[i]*base)%mod;
		M[suf[i]]++;
		base=base*10%mod;
	}
	for(int i=0;i<2019;i++){
		if(M[i]>=2) cnt+=M[i]*(M[i]-1)/2;
	}
	cout<<cnt<<'\n';
	return 0;
}

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

int main(){
  int N;
  string S;
  cin>>N>>S;
  int i=0,j=0;
  for(char &c:S)
    if(c=='I'){
      i++;
      j=max(j,i);
    }
    else
      i--;
  cout<<j<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int mount[10], i, j, t;
	for (i = 0; i < 10; ++i)
	{
		scanf("%d", &mount[i]);
		j = i;
		while (j > 0 && mount[j] > mount[j - 1])
		{
			t = mount[j - 1];
			mount[j - 1] = mount[j];
			mount[j] = t;
			--j;
		}
	}
	for (i = 0; i < 3; ++i)
		printf("%d\n", mount[i]);
	return 0;
}

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

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

    ll N;
    cin >> N;

    ll ans = 0;
    for (ll i = 1; i <= N; ++i) {
        if (i % 3 == 0 && i % 5 == 0) continue;
        else if (i % 5 == 0) continue;
        else if (i % 3 == 0) continue;
        else ans += i;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3624
n, m, q = (int(i) for i in input().split())
city = [[0 for i in range(n+1)] for j in range(n+1)]

for i in range(m):
    l, r = (int(i) for i in input().split())
    city[l][r] += 1
for i in range(1, n+1):
    for j in range(1, n+1):
        city[i][j] += city[i][j-1]
for i in range(1, n+1):
    for j in range(1, n+1):
        city[i][j] += city[i-1][j]


for i in range(q):
    a, b = (int(i) for i in input().split())
    print(city[b][b] - city[a-1][b] - city[b][a-1] + city[a-1][a-1])


Measured memory_bytes: 13400
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		for (int i=0; i<3;i++) {
			a[i] = sc.nextInt();
		}

		Arrays.sort(a);

		int sum = 0;

		sum = (a[1] - a[0]) + (a[2] - a[1]);
		System.out.println(sum);
	}
}

Measured memory_bytes: 23764
<?php
//$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
list($N,$K) = array_map('intval',explode(" ",trim(fgets(STDIN))));
$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

sort($A);

$tot=0;
for($i=0;$i<$K;$i++) {
  $tot+=$A[$i];
}
printf("%d\n",$tot);


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

int max(int a,int b){
	if(a>b)return a;
	else return b;
}

int main(void) {
	int n,ans=0;
	scanf("%d",&n);
	int dp[n][3];
	int a[n][3];
	for(int i=0;i<n;i++){
		scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
		dp[i][0]=0,dp[i][1]=0,dp[i][2]=0;//総和の初期化
	}
	dp[0][0]=a[0][0],dp[0][1]=a[0][1],dp[0][2]=a[0][2];//1日目のパターン入力
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(j!=k){
					//漸化式
					dp[i+1][j] = max(dp[i][k]+a[i+1][j],dp[i+1][j]);
				}
			}
		}
	}
	for(int i=0;i<3;i++){
		ans = max(ans,dp[n-1][i]);
	}
	printf("%d\n",ans);
}


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

int main()
{
    string s;
    cin >> s;
    string t = "CODEFESTIVAL2016";
    int ans = 0;
    for(int i = 0; i < 16; i++) if(s[i] != t[i]) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

# b,r = map(str, readline().split())
# A,B = map(int, readline().split())
N = I()
A = LI()

def main():
    judge=False
    if len(set(A))==N:
        judge=True
    if judge:
        return 'YES'
    else:
        return 'NO'
print(main())


Measured memory_bytes: 49100
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int n;
string s[101];
bool f = true;

int main() {
	cin >> n;
	rep(i, n) {
		string t;
		cin >> t;
		s[i] = t;

		for (int j = 0; j < i; j++) {
			if (s[j] == t) {
				f = false;
			}
		}

		if (i == 0) continue;
		if (s[i - 1][s[i - 1].size() - 1] != t[0]) {
			f = false;
		}
	}

	if(f) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,sse")
using namespace std;

int n, k, ans = 0;
vector<int> arr;

int ind(int x, vector<int> &arr) {
    if (arr.empty() || arr[0] >= x) {
        return 0;
    } else if (arr.back() < x) {
        return arr.size();
    } else {
        int l = 0;
        int r = arr.size() - 1;
        while (r - l > 1) {
            int m = (l + r) >> 1;
            if (arr[m] < x) {
                l = m;
            } else {
                r = m;
            }
        }
        return r;
    }
}

void go(int l, int r) {
    if (l == r) {
        if (arr[l] == 1) {
            ans++;
        }
    } else {
        int m = (l + r) >> 1;
        map<int, vector<int>> delta;
        for (int i = m + 1, curr = 0, len = 1; i <= r; i++, len++) {
            curr = (curr + arr[i]) % k;
            int d = (curr - len + k) % k;
            delta[d].push_back(len);
        }
        for (pair<int, vector<int>> pr : delta) {
            int x = pr.first;
            sort(delta[x].begin(), delta[x].end());
        }
        for (int i = m, curr = 0, len = 1; i >= l; i--, len++) {
            curr = (curr + arr[i] % k);
            int d = (curr - len + k) % k;
            ans += ind(k - len, delta[(k - d) % k]);
        }
        go(l, m);
        go(m + 1, r);
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> k;
    arr.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        arr[i] %= k;
    }
    go(0, n - 1);
    cout << ans << '\n';

    fflush(stdout);
    return 0;
}


Measured memory_bytes: 42256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

// #define ANS  //for answer
#define CMP  //for compe
#ifdef CMP
using namespace std;
#else
#endif

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define nv(x) #x, (x)
#define ncv(x) #x, ":", (x)
#define ncvc(x) #x, ":", (x), ","
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
void pPRINT(std::ostream& ost) {}
template <class T, class... U>
void pPRINT(std::ostream& ost, const T t, const U... u) {
  ost << t << " ";
  pPRINT(ost, u...);
}
template <class... T>
void PRINT(const T... t) { pPRINT(std::cout, t...); }
template <class... T>
void PRINTl(const T... t) {
  pPRINT(std::cout, t...);
  std::cout << "\n";
}
template <class T>
void PRINTa(const T* const t, const ll size) {
  REP(i, size)
  PRINT(t[i]);
  PRINTl();
}
template <class T>
void PRINTal(const T* const t, const ll size) {
  REP(i, size)
  PRINTl(i, ":", t[i]);
}
#ifndef DBG
#define DEBUG(...)
void init() {}
#else
#define DEBUG(...)                                                     \
  {                                                                    \
    PRINT("##DEBUG##", "file :", __FILE__, ", line :", __LINE__, "["); \
    PRINT(__VA_ARGS__);                                                \
    PRINTl("]");                                                       \
  }
void init() {
  DEBUG("INIT");
  cin.tie(0);
  ios::sync_with_stdio(false);
}
#endif
#ifdef ANS
#else
#endif

void solve();

int main(int argc, char* argv[]) {
  DEBUG("MAIN");
  init();
  solve();

  return 0;
}

void solve() {
  DEBUG("SOLVE START");

  int a, b;
  cin >> a >> b;
  PRINT(a ^ b);

  return;
}

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

int  a, b;
int main() {
	cin >> a >> b;
	if (a==b){
		cout << a << endl;
	} else if (a>b) {
		cout << a-1 << endl;
	} else if (a<b) {
		cout << a << endl;
	}
	}
	



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

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


int main() {
        ll N, K;
        cin >> N >> K;

        vector<ll> A(N+1, 0);
        FOR(i, 1, N+1) cin >> A[i];

        // before loop
        vector<ll> label(N+1, 0);
        ll n = 1;
        ll cnt = 0;
        while (K > 0) {
                if (label[n] != 0) {
                        break;
                }
                label[n] = cnt++;
                n = A[n];
		--K;
        }

	if (K == 0) {
		cout << n << endl;
		return 0;
	}

	// after loop
        ll loop_size = cnt - label[n];

	K %= loop_size;
	while (K) {
		n = A[n];
		--K;
	}

	cout << n << endl;
        return 0;
}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
	int n;
	cin >> n;
	map<int,int> mp;
	for(int i=2;i<=n;i++) {
		int k=i;
		for(int j=2; j<i;j++) {
			while(k % j == 0) {
				//cout << k << " " << j << " ";
				mp[j]++;
				k /= j;
			}
		}
		if(k == i) mp[i]++;
	}
	ll ans=1;
	//for(int i=1; i<=n; i++) cout << i << " " << mp[i] << endl;
	for(int i=1; i<=n; i++) {
		ans *= mp[i]+1;
		ans %= 1000000007;
	}
	cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,a[100005],b,c,q,sum=0,cnt[100005];
int main(){
  cin>>n;
  for(ll i=1;i<=n;i++){
    cin>>a[i];
    sum+=a[i];
    cnt[a[i]]++;
  }
  cin>>q;
  for(ll i=1;i<=q;i++){
    cin>>b>>c;
    sum+=(c-b)*cnt[b];
    cnt[c]+=cnt[b];
    cnt[b]=0;
    cout<<sum<<endl;
  }
  return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define INF 1000000000

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef long double ld;

//ある値がvector内の要素に含まれているか否か判定する
int vector_finder(std::vector<int> vec, int number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance(vec.begin(), itr);
    if (index != vec.size()) { // 発見できたとき
        return 1;
    } else { // 発見できなかったとき
        return 0;
    }
}

////////////////////////// let's code! /////////////////////////////

int i, j, k;

///// variables frequent to use /////

struct node {
    vector<int> childs;
    int count = 0;
};

void dfs(vector<node> &nodes, int label, int addcount) {

    nodes[label].count += addcount;
    for (int child : nodes[label].childs) {
        dfs(nodes, child, nodes[label].count);
    }
}

int main() {

    int N;
    cin >> N;
    vi H(N);

    REP(i, N) {
        cin >> H[i];
    }

    int max = 0, count = 0;
    for (i = 1; i < N; i++) {
        if (H[i - 1] >= H[i]) {
            count++;
        } else {
            if (max < count) {
                max = count;
            }
            count = 0;
        }
    }

    if (max < count) {
        max = count;
    }

    cout << max << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

int main() {
    int w, c;
    while (cin >> w >> c) {
        if (w <= c) cout << "unsafe" << endl;
        else cout << "safe" << endl;
    }
}

















Measured memory_bytes: 3636
# AGC014
A, B, C = map(int, input().split())
ans = 1
if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
    print(0)
    exit()

if A == B == C:
    print(-1)
    exit()

ans = 1
while 1:
    a = B // 2 + C // 2
    b = C // 2 + A // 2
    c = A // 2 + B // 2
    if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
        break
    else:
        A = a
        B = b
        C = c
        ans += 1
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  
  cout << max({10*A+B+C, A+10*B+C, A+B+10*C}) << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace A_Still_TBD
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().Split('/').ToArray();
            
            if (int.Parse(string.Join("", S)) <= 20190430)
            {
                Console.WriteLine("Heisei");
            }
            else
            {
                Console.WriteLine("TBD");
            }
        }
    }
}

Measured memory_bytes: 13268
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] kuku = new int[9] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            int ans = 0;
            string mes = "No";
            for(int i = 0; i < 9; i++)
            {
                for(int j = 0; j < 9; j++)
                {
                    ans = kuku[i] * kuku[j];
                    if(ans == N)
                    {
                        mes = "Yes";
                    }
                }
            }
            Console.WriteLine(mes);
        }
    }
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int H, W, M;
int cntH[int(3e5+5)], cntW[int(3e5+5)];
Pii PH[int(3e5+5)], PW[int(3e5+5)];
map <Pii, bool> mp;

int main(){
  cin >> H >> W >> M;
  for (int i = 0; i < M; i++){
    int h, w; cin >> h >> w;
    cntH[h]++; cntW[w]++;
    mp[{h, w}] = true;
  }

  for (int i = 0; i <= H; i++) PH[i] = {cntH[i], i};
  sort(PH, PH + H + 1, greater<Pii>()); 
  for (int i = 0; i <= W; i++) PW[i] = {cntW[i], i};
  sort(PW, PW + W + 1, greater<Pii>());

  int h = 0, w = 0;
  while (PH[0].fi == PH[h].fi) h++;
  while (PW[0].fi == PW[w].fi) w++;

  int ans = PH[0].fi + PW[0].fi;
  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      if (!mp[{PH[i].se, PW[j].se}]){
        cout << ans << endl;
        return 0;
      }
    }
  }
  cout << ans - 1 << endl;

  return 0;
}


Measured memory_bytes: 29404
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int d,g,p[15]={},c[15]={},ans=inf,M,cnt,sum,x;
  cin >> d >> g;
  for(int i=0; i<d; i++) {
    cin >> p[i] >> c[i];
  }
  for(int i=0; i<(1<<d); i++) {
    cnt=0,M=0,sum=0;
    for(int j=0; j<d; j++) {
      if(i&(1<<j)) {
        sum+=100*(j+1)*p[j]+c[j];
        cnt+=p[j];
      }
      else {
        M=j+1;
      }
    }
    if(sum<g) {
      x=(g-sum-1)/(100*M)+1;
      if(x>=p[M-1]) {
        continue;
      }
      cnt+=x;
    }
    ans=min(ans,cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF INT_MIN 
#define INF INT_MAX 
#define int ll int
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/
//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{//cout<<"Case #"<<T1<<":"<<' '; 
   int n,m;
   cin>>n>>m;
   cout<<max((int)0,(n*(n-1))/2)+max((int)0,(m*(m-1))/2)<<endl;
}


return 0;
}





Measured memory_bytes: 256
/* C++ */
// ?????¢????´¢???P121

#include <stdio.h>


int main(void)
{
	int n = 0; int S[10001];		// ????´¢????±?
	int q = 0; int T;			// ????´¢??????
	int C = 0;						// ?????´??°

	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		scanf("%d", &S[i]);
//		printf("%d\n", S[i] );
	}

	scanf("%d", &q);

//	printf("q=%d\n", q);

	for (int i = 0; i < q; i++)
	{
//		printf("----\n");
		scanf("%d", &T);
//		printf("T=%d\n", T);
		for(int j = 0; j < n; j++){
//			printf("%d", j);
			if(S[j] == T){
				C++;
				break;
			}
		}
	}

	printf("%d\n", C );

	return 0;
}

Measured memory_bytes: 1068
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 1010101;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[8] = { 1,-1,0,0,1,1,-1,-1 };
ll dy[8] = { 0,0,1,-1,1,-1,1,-1 };
ll dp[2010][2010];

//union-find木について
ll par[101010];
ll rank2[101010];
ll usize[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
		usize[i] = 1;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (usize[x] < usize[y]) {
		par[x] = y;
		usize[y] += usize[x];
	}
	else {
		par[y] = x;
		usize[x] += usize[y];
	}
}


//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n, m;
	cin >> n >> m;
	vector<ll>a(m), b(m), ans(m);
	init(n);
	ans[m - 1] = n * (n - 1) / 2;
	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
	}
	for (ll i = m - 1;i > 0;--i) {
		if (find(a[i]) != find(b[i])) {
			ans[i - 1] = ans[i] - usize[find(a[i])] * usize[find(b[i])];
			unite(a[i], b[i]);
		}
		else {
			ans[i - 1] = ans[i];
		}
	}
	rep(i, m) {
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 7968
let rec make_xy ?(l=[0]) = function
  | 0 -> l
  | n ->
    let t = Scanf.scanf "%d\n" (fun x -> x) in
    make_xy ~l:((List.hd l + t) :: l) (pred n)

let rec t2 t y = function
  | [] -> t
  | h :: l' ->
    let n = Array.get t (y-h) in
    Array.set t (y-h) (succ n);
    t2 t y l'

let rec t1 t = function
  | [] -> t
  | h :: l' -> t1 (t2 t h l') l'

let rec u2 t y cnt = function
  | [] -> cnt
  | h :: l' ->
    let n = Array.get t (y-h) in
    u2 t y (cnt+n) l'

let rec u1 t ?(cnt=0) = function
  | [] -> cnt
  | h :: l' -> u1 t ~cnt:(u2 t h cnt l') l'

let rec solve () =
  let nm = Scanf.scanf "%d %d\n" (fun i j -> (i, j)) in
  match nm with
  | (0, 0) -> exit 0
  | (n, m) ->
    let y = make_xy n in
    let x = make_xy m in
    let t = Array.make ((max m n)*1000) 0 in
    let cnt = u1 (t1 t y) x in
    Printf.printf "%d\n" cnt;
    solve ()

let () = solve ()

Measured memory_bytes: 60900
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


/*
vvl comb(int n, int r) {
vvl v(n + 1,vl(n + 1, 0));
for (int i = 0; i < v.size(); i++) {
v[i][0] = 1;
v[i][i] = 1;
}
for (int j = 1; j < v.size(); j++) {
for (int k = 1; k < j; k++) {
v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
}
}
return v;
}
*/

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}


int main(){
	int n;cin>>n;
	int c[10][10]={};
	rep(i,1,n+1){
		int a=i;
		while(a>=10)
			a/=10;
		c[a][i%10]++;
	}
	ll ans=0;
	rep(i,1,n+1){
		int a=i;
		while(a>=10)
			a/=10;
		ans+=c[i%10][a];
	}
	print(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

ll calc(ll a, ll b, ll x) {
    ll ret = (a*x/b) - a*(x/b);
    return ret;
}

int main(int argc, char const *argv[]) {
    ll a,b,n; cin>>a>>b>>n;
    if (b==1) {
        cout << 0 << '\n';
        return 0;
    }

    ll x = min(n,b-1);
    cout << calc(a,b,x) << '\n';
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    ll ans_m = 100 * a, ans_s = 0;
    for(int na = 0; (100 * a * na) <= f; ++na){
        for(int nb = 0;
            100 * (a * na + b * nb) <= f; ++nb){
            const ll water = 100 * (a * na + b * nb);
            for(int nc = 0;
                (water + c * nc <= f) &&
                (100 * c * nc <= e * water);
                ++nc){
                for(int nd = 0;
                    (water + c * nc + d * nd <= f) &&
                    (100 * (c * nc + d * nd) <= e * water);
                    ++nd){
                    const ll sugar = c * nc + d * nd;
                    if(ans_s * (water + sugar) < ans_m * sugar){
                        ans_m = water + sugar;
                        ans_s = sugar;
                    }
                }
            }
        }
    }
    cout << ans_m << ' ' << ans_s << endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////////////////
int n,a=0,ans=0;
cin >> n;
int h[n];
for(int i=0;i<n;i++){
   cin >> h[i];
}
for(int i=0;i<n-1;i++){
   if(h[i]>=h[i+1]){
      a++;
      ans=max(ans,a);
   }
   else{
      a=0;
   }

}
cout << ans << endl;


////////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 640
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
C = Counter(S)
C0 = C["AC"]
C1 = C["WA"]
C2 = C["TLE"]
C3 = C["RE"]
print(f"AC x {C0}")
print(f"WA x {C1}")
print(f"TLE x {C2}")
print(f"RE x {C3}")

Measured memory_bytes: 16632
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using ll = long long;

string s;
ll memo[200020];
map<string, ll> mp;

int main()
{
	int n; cin >> n;
	
	REP(i, n) {
		cin >> s;
		mp[s]++;
	}
	ll ans = 0;
	for (auto a : mp) {
		ans++;
	}
	cout << ans;
	return 0;
}

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,bottom,ceiling) for(auto (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(auto (i) = (ceiling); (i) >= (bottom); --(i))
#define repV(i,v) for(auto (i) = begin(v); (i) < end(v); ++(i))
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define divceil(n,d) ((n)/(d) + ((n)%(d) > 0))
#define parity(a,b) (((a) & 1LL)^((b) & 1LL)^1LL)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = (int)1e9 + 7;

ull next_subset(ull subset){
	ull tem = subset + (subset & -subset);
	ull btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}


void solve(){
	
	
	int a,b; cin>>a>>b;
	if(a + b == 15) cout<<"+\n";
	else if(a * b == 15) cout<<"*\n";
	else cout<<"x\n";
	return;
}

void input(){
	
	
	
	return;
}

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





Measured memory_bytes: 256
N, M = gets.split().map(&:to_i)
array = []
N.times do
	array << [:price, :bottle].zip(gets.split().map(&:to_i)).to_h
end

array.sort! {|p,n| p[:price] <=> n[:price]}
cost = 0
bought_bottle = 0

until array.empty?
	if bought_bottle + array.first[:bottle] >= M
		cost += (M - bought_bottle) * array.first[:price]
		break
	else
		bought_bottle += array.first[:bottle]
		cost += array.first[:price] * array.first[:bottle]
		array.shift(1)
	end
end

p cost

Measured memory_bytes: 32376
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for i in range(A+1):
    if (X-500*i) < 0:
        continue
    for j in range(B+1):
        if (X-500*i-100*j) < 0:
            continue
        elif (X-500*i-100*j)//50 <= C and (X-500*i-100*j)%50 == 0:
            cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;
using ll = long long;

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

	vector<ll> a(3*N);
	for (int i = 0; i < 3*N; i++)
		cin >> a[i];

	priority_queue<ll,vector<ll>,greater<ll>> q1;
	vector<ll> total1(N+1);
	for (int i = 0; i < N; i++) {
		total1[0] += a[i];
		q1.push(a[i]);
	}

	for (int i = 1; i <= N; i++) {
		total1[i] = total1[i - 1];
		if (a[N-1+i] > q1.top()) {
			total1[i] += (a[N - 1 + i] - q1.top());
			q1.pop();
			q1.push(a[N - 1 + i]);
		}
	}

	priority_queue<ll> q2;
	vector<ll> total2(N + 1);
	for (int i = 0; i < N; i++) {
		total2[0] += a[3 * N - 1 - i];
		q2.push(a[3 * N - 1 - i]);
	}

	for (int i = 1; i <= N; i++) {
		total2[i] = total2[i - 1];
		if (a[2*N - i] < q2.top()) {
			total2[i] += (a[2*N - i] - q2.top());
			q2.pop();
			q2.push(a[2 * N - i]);
		}
	}

	ll ans = LLONG_MIN;
	for (int i = 0; i <= N; i++) {
		ans = max(ans, total1[i] - total2[N - i]);
	}

	cout << ans << endl;

}

Measured memory_bytes: 6516
#include <bits/stdc++.h>
using namespace std;
int main (){
 int a;
  cin >>a;
  if((a/10)%111==0){
  cout << "Yes" << endl;
  }
  else if((a%1000)%111==0){
  cout << "Yes" << endl;
  }
  else {
  cout << "No" <<endl;
  }
  
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
typedef pair<ll, int> PLI;

const ll inf = 5e18;

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VL x(n), y(n);
  REP(i, 0, n) {
    ll p, q;
    cin >> p >> q;
    if (p > q) {
      x[i] = q;
      y[i] = p;
    } else {
      x[i] = p;
      y[i] = q;
    }
  }
  ll mi = inf;
  // Suppose min is taken by red, max is taken by blue.
  {
    ll red_mi = inf;
    ll red_ma = -inf;
    ll blue_mi = inf;
    ll blue_ma = -inf;
    REP(i, 0, n) {
      red_mi = min(red_mi, x[i]);
      red_ma = max(red_ma, x[i]);
      blue_mi = min(blue_mi, y[i]);
      blue_ma = max(blue_ma, y[i]);
    }
    mi = min(mi, (red_ma - red_mi) * (blue_ma - blue_mi));
  }
  // Suppose that min and max are both taken by red
  {
    PLI rmi(inf, -1);
    PLI rma(-inf, -1);
    REP(i, 0, n) {
      rmi = min(rmi, PLI(x[i], i));
      rma = max(rma, PLI(y[i], i));
    }
    ll bl = y[rmi.second];
    ll bh = x[rma.second];
    // if rmi.second == rma.second, we need to select n-1 elements, and bl, bh are ignored.
    if (bl > bh) {
      swap(bl, bh);
    }
    if (rmi.second == rma.second) {
      bl = inf;
      bh = -inf;
    }
    vector<PLI> pool;
    REP(i, 0, n) {
      if (i != rmi.second && i != rma.second) {
	pool.push_back(PLI(x[i], i));
	pool.push_back(PLI(y[i], i));
      }
    }
    sort(pool.begin(), pool.end());
    int kind = rmi.second == rma.second ? n - 1 : n - 2;
    if (kind > 0) {
      int pos = 0;
      VI tbl(n, 0);
      int cur = 0;
      ll bdiff = inf;
      REP(i, 0, pool.size()) {
	while (cur < kind && pos < (int) pool.size()) {
	  PLI c = pool[pos];
	  tbl[c.second] += 1;
	  if (tbl[c.second] == 1) {
	    cur += 1;
	  }
	  pos++;
	}
	if (cur == kind) {
	  ll diff = max(pool[pos - 1].first, bh)
	    - min(pool[i].first , bl);
	  
	  bdiff = min(bdiff, diff);
	}
	PLI c = pool[i];
	tbl[c.second] -= 1;
	if (tbl[c.second] == 0) {
	  cur -= 1;
	}
      }
      mi = min(mi, (rma.first - rmi.first) * bdiff);
    }
  }
  cout << mi << "\n";
}


Measured memory_bytes: 13676
#include <cstdio>
#include <algorithm>
using namespace std;
long long a,b,c;
int main()
{
    scanf("%lld%lld%lld",&a,&b,&c);
    if (a%2==0||b%2==0||c%2==0)
        puts("0");
    else
        printf("%lld\n",min(a*b,min(a*c,b*c)));
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
  int H;
  int A;
  int N;
  int c=1;
  cin >> H;
  cin >> A;
  N=H-A;
  while(N>0){
    N-=A;
    c++
;}
 cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 


int main(void){
    ll n,k;
    cin>>n>>k;
    ll t = n/k;
    ll ans = n;
    ans = min(ans,n-t*k);
    ans = min(ans,(t+1)*k-n);
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>

auto& in = std::cin;
auto& out = std::cout;

int32_t N;
int32_t A[110001];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (size_t i = 0; i < N; i++)
	{
		in >> A[i];
	}

	int32_t count = 0;
	for (size_t i = 0; i < N; i++)
	{
		if (A[i] == (i+1)) {
			std::swap(A[i], A[i + 1]);
			++count;
		}
	}
	out << count << endl;
	return 0;
}
#endif

#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>

auto& in = std::cin;
auto& out = std::cout;

int32_t N;
int32_t A[110001];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (size_t i = 0; i < N; i++)
	{
		int a;
		in >> a; A[a]++;
	}

	int32_t max = 0;
	for (int32_t  i = 1; i < 100010; i++)
	{
		max = std::max(max, A[i - 1] + A[i] + A[i + 1]);
	}
	out << max << endl;

	return 0;
}
#endif


Measured memory_bytes: 888
var n = Int(readLine()!)!
let abc = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
           "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y","z"]
var ans = ""
func sol(_ num: Int) {
  guard num > 0 else { return }
  var next = num / 26
  let i = num % 26 - 1
  if i == -1 { next -= 1 }
  ans += abc[i == -1 ? 25 : i]
  sol(next)
}
sol(n)
print(String(ans.reversed()))

Measured memory_bytes: 7740
A, B, C, X, Y = gets.split(' ').map(&:to_i)
x, y, z = X, Y, 0

def change?(x, y)
  return false if x <= 0 && y <= 0
  return C * 2 < B if x <= 0
  return C * 2 < A if y <= 0
  return C * 2 < (A + B)
end

while change?(x, y)
  x -= 1
  y -= 1
  z += 2
end
puts [0, x].max * A + [0, y].max * B + z * C


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int p[200009];
int main(){
	int n, k;
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> p[i];
	}
	long long num = 0;
	for(int i=0;i<k;i++){
		num += p[i];
	}
	long long int m = num;
	for(int i=1;i<n-k+1;i++){
		num -= p[i-1];
		num += p[i+k-1];
		m = max(m,num);
	}
	double ans = (m+k)/2.0;
	cout<<fixed<<setprecision(12);
	cout <<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
// Date: 2020-03-19

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define D(x) cerr<<#x<<" = "<<x<<endl;
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

LL cal(LL x, LL y) {
    LL ans = 0;
    while(x) {
        ans += x % y;
        x /= y;
    }
    return ans;
}

int main() {
    FIO;
    LL n, s;
    cin >> n >> s;
    if(s > n) {
        cout << -1;
        return 0;
    }
    if(s == n) {
        cout << n+1;
        return 0;
    }
    LL ans = INF;
    int q = sqrt(n)+1;
    rep(i, 2, q) {
        if(cal(n, i) == s) {
            chkmin(ans, 1LL*i);
        }
    }
    LL m = n-s;
    for(int i = sqrt(m); i >= 1; --i) if(m % i == 0) {
        LL b = m/i+1, y = n-b*i;
        if(y >= 0 && y < b && 1LL*i+y == s && b >= 2 && i < b) {
            chkmin(ans, b);
        }
    }
    if(ans == INF) ans = -1;
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;cin>>h>>w;
  string s[2*h];
  for(int i=0;i<2*h;i+=2){
    cin>>s[i];
    s[i+1]=s[i];
    cout<<s[i]<<endl;
    cout<<s[i+1]<<endl;
  }
}
  

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int N;
int main(){
  int i;
  long long res = 0;
  rd(N);
  for(i=(1);i<(N+1);i++){
    int k = N / i;
    res += (long long) k * (k+1) / 2 * i;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// int N;
// {
//   ll res = 0;
//   rd(N);
//   rep(i,1,N+1){
//     int k = N / i;
//     res += (ll) k * (k+1) / 2 * i;
//   }
//   wt(res);
// }


Measured memory_bytes: 3648