akhauriyash/Code-Regression huggingface dataset:
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func main() {
	defer stdout.Flush()
	n := readInt()
	a := make([]int64, n)
	for i := range a {
		a[i] = readInt64()
	}

	dp := make([][2]int64, n)
	dp[0][0] = a[0]
	dp[0][1] = a[1]
	for i := 1; i < n; i++ {
		dp[i][0] = gcd(dp[i-1][0], a[i])
		dp[i][1] = gcd(dp[i-1][1], a[i])
		if i > 1 {
			dp[i][1] = max(dp[i][1], gcd(dp[i-2][0], a[i]))
		}
	}
	println(max(dp[n-2][0], dp[n-1][1]))
}

func gcd(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 4736
#include <iostream>
#include <set>
using namespace std;
int main(void) {
	string s;
	int k;
	cin >> s >> k;
	set<string> st;
	for (int i = 0; i < s.size(); ++i) {
		string subs;
		for (int j = i; j < s.size(); ++j) {
			subs += s[j];
			if (subs.size() > k) break;
			st.insert(subs);
		}
	}
	int cnt = 0;
	for (auto x : st) {
		++cnt;
		if (cnt == k) {
			cout << x << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<int> IntegerToVector(int bit, int N) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
            S.push_back(i);
        }
    }
    return S;
}

int main()
{
    IO;

    ll N; cin >> N;
    vl L(N);
    rep(i, N) cin >> L[i];

    sort(all(L));

    ll ans = 0, M=L.size();

    rep(i, M - 2) {
        rpt(j, i+1, M - 1) {
            rpt(k, j+1, M) {
                if (L[i] + L[j] > L[k] & (L[i]-L[j])*(L[j]-L[k])*(L[k]-L[i])!=0) {
                    ++ans;
                }
            }
        }
    }

    cout << ans << endl;

}

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

int n,v[16][16];
int honest[16],unkind[16],vis[16];

bool dfs(int u)
{
	if(vis[u] == 2) return true;
	vis[u]++;
	for(int i = 1; i <= n; i++) {
		//if(vis[i]) continue;
		if(v[u][i] == 1) {
			if(unkind[i] == 1) return false;
			else {
				honest[i] = 1;
				if(dfs(i) == false) return false;
			}
		}  
		else if(v[u][i] == 0) {
			if(honest[i]) return false; 
			else unkind[i] = 1;
		}
	}
	return true;
}

int main()
{
	
	std::ios::sync_with_stdio(false);cin.tie(0);
	cin >> n;
	memset(v,-1,sizeof(v));
	for(int i = 1; i <= n; ++i){
		int t; cin >> t;
		for(int j = 0; j < t; ++j){
			int x,y;  cin >> x >> y;
			v[i][x] = y;
		}
	}
	int ans = 0;
	for(int i = 0; i < (1 << n); ++i){
		int flag = 1;
		for(int j = 0; j < n; j++){
			if(i & (1 << j)){
				if(unkind[j + 1]){
					flag = 0;
					break;
				}
				honest[j + 1] = 1;
				if(dfs(j + 1) == false) {
					flag = 0;
					break;
				}
			}
		}
		if(flag) {
			int tmp = 0;
			for(int j = 1; j <= n; j++) if(honest[j]) tmp++;
			//cout << i << " " << tmp << endl;
			ans = max(ans,tmp);
		}
		memset(honest,0,sizeof(honest));
		memset(unkind,0,sizeof(unkind));
		memset(vis,0,sizeof(vis));
	}	
	cout << ans << endl;	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define sz(x) (int)(x.size())
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;


bool check(int N){
    int dig=0;
    while(N>0){
        N=N/10;
        dig++;
    }
    if((dig%2)==0){
        return false;
    }
    else{
        return true;
    }
}
int32_t main(){
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        if(check(i)){
            ans++;
        }
    }
    cout<<ans<<"\n";



    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

bool f(string s)
{
    ll n=s.length();
    for(ll i=0;i<n;++i){
        if(s[i]!=s[n-i-1]){return 0;}
    }
    return 1;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	string s;
	cin>>s;
	string a="";
	string b="";
	ll n=s.length();
	for(ll i=0;i<n;++i){
        if(i<n/2){a+=s[i];}
        else if(i>n/2){b+=s[i];}
	}
	if(f(a)&&f(b)&&f(s)){cout<<"Yes";}
	else{cout<<"No";}

	return(0);
}


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

int N;
const int MAX_N = 8;
vector<int> rows(MAX_N, -1);

bool check(int row, int col)
{
    for (int k = 0; k < MAX_N; k++)
    {
        if (rows[k] == -1)
            continue;
        // 列方向のチェック
        if (col == rows[k])
            return false;
        // 対角線のチェック
        if (row + col == rows[k] + k || row - col == k - rows[k])
            return false;
    }

    return true;
}

bool dfs(int row)
{
    if (row == 8)
    {
        for (int i = 0; i < MAX_N; i++)
        {
            for (int j = 0; j < MAX_N; j++)
            {
                cout << (rows[i] == j ? 'Q' : '.');
            }
            cout << endl;
        }
        return true;
    }

    if (rows[row] == -1)
    {
        for (int col = 0; col < MAX_N; col++)
        {
            if (check(row, col))
            {
                rows[row] = col;
                if (dfs(row + 1))
                    return true;
                rows[row] = -1;
            }
        }
    }
    else
    {
        if (dfs(row + 1))
            return true;
    }
    return false;
}

int main()
{

    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int row, col;
        cin >> row >> col;
        rows[row] = col;
    }

    dfs(0);

    return 0;
}


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

#define INF 1e9
#define PI 3.141592653589793238
typedef long long ll;

int main() {
    ll n,d,x,y; cin>>n>>d;
    int ans=0;
    for(int i=0; i<n; i++){
        cin>>x>>y;
        if(x*x+y*y<=d*d)ans++;
    }
    cout<<ans<<endl;


    return 0;
}

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

int main()
{
    ll a, b, x;
    cin >> a >> b >> x;

    ll upper, lower = 0;
    ll ans = 0;

    if (a == 0)
    {
        ans = b / x + 1;
    }
    else
    {
        upper = b / x + 1;
        lower = (a - 1) / x + 1;

        ans = upper - lower;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)

string S, T;

bool solve(){
	// cout<<S<<" "<<T<<"\n";//

	vvi ss(26, vi()), tt(26, vi());//[char-'a']<index>

	rp(i, 0, S.size()){
		ss[S[i]-'a'].push_back(i);
	}

	rp(i, 0, T.size()){
		tt[T[i]-'a'].push_back(i);
	}

	// rp(i,0,26){if(ss[i].size()<=1)continue;printf("%2d %c: ",i,char(i+'a'));rp(j,0,ss[i].size()){cout<<ss[i][j]<<" ";}puts("");}///
	// puts("---");///
	// rp(i,0,26){if(tt[i].size()<=1)continue;printf("%2d %c: ",i,char(i+'a'));rp(j,0,tt[i].size()){cout<<tt[i][j]<<" ";}puts("");}///
	// puts("===");///

	vi cs(200000+1, 0), ct(200000+1, 0);//[count]<count_num> 1_origin

	rp(i, 0, ss.size()){
		cs[ss[i].size()]++;
	}

	rp(i, 0, tt.size()){
		ct[tt[i].size()]++;
	}

	// rp(i,1,26){if(cs[i]==0)continue;cout<<i<<" "<<cs[i]<<"\n";}///
	// puts("----");///
	// rp(i,1,26){if(ct[i]==0)continue;cout<<i<<" "<<ct[i]<<"\n";}///
	// puts("====");///

	rp(i, 1, 200000+1){
		if(cs[i] != ct[i]){
			return false;
		}
	}

	return true;
}

int main(){
	cin>>S>>T;
	cout<< (solve()? "Yes":"No") <<endl;
}


Measured memory_bytes: 4488
/*
                                        //     //     //\\\\\\\\\
                                        \\    //      \\        \\
                                        //   //       //         \\
                                        \\  //        \\          \\
                                        // //         //           \\
                                        \\//          \\            \\       
                                        //\\          //            //
                                        \\ \\         \\           //
                                        //  \\        //          //
                                        \\   \\       \\         //
                                        //    \\      //        //
                                        \\     \\     \\/////////
*/

#include <bits/stdc++.h>
//#include <boost/math/common_factor.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vint vector <int>
#define vll vector <long long int>
#define endl cout<<'\n'
#define fre(i,l,n) for(long long int i=l;i<n;++i)
#define fr(i,l,n) for(long long int i=l;i<=n;i++)
#define rfre(i,n,l) for(long long int i=n-1;i>=l;i--)
#define rfr(i,n,l) for(long long int i=n;i>=l;--i)
#define tab '\t'
#define debug cout<<'*';
#define s(a) cin>>a
#define p(a) cout<<a
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> pll;
typedef pair<int,pair<int,int> > tii;
typedef vector<int> vec;
typedef vector<long long> vecll;
typedef vector<pair<int,int> > vec_pii;
typedef vector<pair<long long int,long long int> > vec_pll;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvll;
typedef vector<vector<pair<int,int> > > vvpii;
typedef vector<vector<pair<ll,ll> > > vvpll;
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define Pi 3.14159265358979
#define gcd(a,b) __gcd(a,b)
#define sf(n) scanf("%lld",&(n))
#define pf(n) printf("%lld\n",(n))
#define min3(a,b,c) (min((c),min((a),(b))))
#define max3(a,b,c) (max((a),max((b),(c))))
#define w(t) while(t--)
#define flt(a) cout<<fixed<<setprecision(a)
#define cntSetBits(n) __builtin_popcountll(n)
/*****************************
*****************************/

const ll MAXN = 1000000000000001;


void solve()
{
    ll n;
    s(n);
    string res = "";
    while(n--)
    {
        res = char('a' + n%26) + res;
        n /= 26;
    }
    p(res);endl;
}



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll t=1;
    // s(t);
    w(t)
    {
        solve();
    }
    return 0;
}









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

vector<int> Adjlist[100001];
vector<pair<int, int> > maxmin(100001);
int d[100001];

void dfs(int u, int v){
    for(int i = 0; i < Adjlist[u].size(); i++){
        if(Adjlist[u][i] != v){
            d[Adjlist[u][i]] = d[u] + 1;
            dfs(Adjlist[u][i], u);
        }
    }
}

int main(){
    int n, k, u, v;
    cin >> n;
    for(int i = 1; i <= n; i++){
        maxmin[i] = make_pair(-1000000, 1000000);
    }
    for(int i = 0; i < n - 1; i++){
        cin >> u >> v;
        Adjlist[u].push_back(v);
        Adjlist[v].push_back(u);
    }
    cin >> k;
    int m = -1;
    d[1] = 0;
    dfs(1, 0);
    queue <int> q;
    for(int i = 0; i < k; i++){
        cin >> u >> v;
        maxmin[u] = make_pair(v, v);
        q.push(u);
        int c = (v + d[u]) % 2;
		if (m == -1){
			m = c;
		}
		if (m != c){
			cout << "No";
			return 0;
        }
    }
    while(q.size()){
	    int u = q.front();
	    q.pop();
	    for (int v : Adjlist[u]){
			pair<int, int> temp = maxmin[v];
			temp.first = max(temp.first, maxmin[u].first - 1);
			temp.second = min(temp.second, maxmin[u].second + 1);
			if (temp.first > temp.second){
				cout << "No";
				return 0;
			}
			if (temp != maxmin[v]){
				maxmin[v] = temp;
				q.push(v);
			}
		}
	}
	cout << "Yes" << endl;
	for(int i = 1; i <= n; i++){
		cout << maxmin[i].first << endl;
		for (int u : Adjlist[i]){
			maxmin[u] = make_pair(max(maxmin[u].first, maxmin[i].first - 1), min(maxmin[u].second, maxmin[i].first + 1));
		}
	}
}

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

using namespace std;

int main(void)
{
	string a;
	cin>>a;
	for(int i=0;i<a.size()/2;i++){
		char tmp=a.at(i);
		a.at(i)=a.at(a.size()-i-1);
		a.at(a.size()-i-1)=tmp;
	}
	cout<<a<<endl;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#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
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

struct UnionFind {
  vector<int> par; // par[i]が親を表す
  vector<int> _size; // _size[i]でそのノードの属しているサイズを返す

  // コンストラクタ
  UnionFind(int n) {
    _size = vector<int>(n);
    par = vector<int>(n);
    for (int i = 0; i < n; i++) {
      par[i] = i;
      _size[i] = 1;
    }
  }

  // データxの根を求める
  int root(int x) {
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]); // 木構造の縮約を行っている
  }

  // xとyの親が違うとき、マージする。そのときyの根がxの根の子になる
  void merge(int x, int y) {
    int rootx = root(x);
    int rooty = root(y);
    if (rootx == rooty)
      return;
    par[rooty] = rootx;
    int s = _size[rooty] + _size[rootx];
    _size[rooty] = s;
    _size[rootx] = s;
  }

  // xの属している集団のサイズ
  int size(int x) { return _size[x]; }

  // 同じグループに属しているか
  bool isSame(int x, int y) { return root(x) == root(y); }
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(n);
  REP(i, n) {
    cin >> p[i];
    p[i]--;
  }

  UnionFind uf(n);
  REP(i, m) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    uf.merge(x, y);
  }

  int ans = 0;
  REP(i, n) {
    if (uf.root(i) == uf.root(p[i])) {
      ans++;
    }
  }
  cout << ans << endl;
}


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

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

  int ans = 0;
  for(int i=1; i<=n; i++) {
    int y = 0;
    for(int j=1; j<=i; j++) {
      if(i%j == 0) y++;
    }
    if(i % 2 != 0 && y == 8) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int L, sz = 0;
struct edge{ int u,v,w; };
vector<edge>e;

int main() {
	cin >> L; L--;
	if (L == 1) {
		cout << "2 2" << endl << "1 2 1" << endl << "1 2 0" << endl;
		return 0;
	}
	while ((1 << sz) <= L)sz++;
	int s = 1, t = sz;
	for (int i = 1; i < sz; i++) {
		e.push_back({ i,i + 1,1 << (sz - i - 1) });
		e.push_back({ i,i + 1,0 });
	}
	int w = 1 << (sz - 1);
	for (int p = sz - 2, i = 1; p >= 0; p--, i++) {
		if (L >> p & 1) {
			e.push_back({ s,i + 1,w });
			w += 1 << p;
		}
	}
	e.push_back({ s,t,L });
	cout << sz << ' ' << e.size() << endl;
	for (auto&& x : e)cout << x.u << ' ' << x.v << ' ' << x.w << endl;
	return 0;
}

Measured memory_bytes: 256
mod = 1000000007


def fexp(x, y):
    ans = 1
    while y > 0:
        if y % 2 == 1:
            ans = ans * x % mod
        x = x * x % mod
        y //= 2
    return ans


n = int(input())
ans = fexp(10, n) - 2 * fexp(9, n) + fexp(8, n)
ans %= mod
if ans < 0:
    ans += mod
print(ans)


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vs= vector<string>;
using vb= vector<bool>;
using vl= vector<ll>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

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

  if(r<1200){
    cout << "ABC";
  }else if(r<2800){
    cout << "ARC";
  }else{
    cout << "AGC";
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

vector<int>v[maxn];

int visited[maxn];

void dfs(int st){
	visited[st] = 1;
	for(auto i:v[st]){
		if(!visited[i]){
			dfs(i);
		}
	}
}

int32_t main(){
	fastio();
	int n,m;
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int a,b;
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(!visited[i]){
			dfs(i);
			ans++;
		}
	}
	cout << ans - 1;
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  int N = s.size();

  if(s.back() == '1') s += '0';
  else s += '1';

  int ans = 0;
  int cnt = 1;
  FOR(i, 1, N+1){
    if(s[i] != s[i-1]){
      chmax(ans, min(i, N-i+cnt));
      cnt = 1;
    }else cnt++;
  }

  cout << ans << "\n";

  return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

const int MAX_N = 2020;

int w[MAX_N][MAX_N];
int dp[MAX_N][MAX_N];
int minima[MAX_N];
int f(int d, int i, int j) {
  return dp[d][j] + w[i][j+1];
}
void rowMinima(int d, int ib, int ie, int jb, int je) {
  if(ib > ie) return;
  if(ib == ie) {
    int jm = jb;
    int fm = f(d, ib, jm), fj;
    for(int j = jb+1; j <= je; ++j) {
      if(fm > (fj = f(d, ib, j))) fm = fj, jm = j;
    }
    minima[ib] = jm;
    return;
  }
  int im = (ib+ie)/2;
  rowMinima(d, im, im, jb, je);
  rowMinima(d, ib, im-1, jb, minima[im]);
  rowMinima(d, im+1, ie, minima[im], je);
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int s, n, m;
  cin >> s >> n >> m;
  vint x(s);
  rep(i, s) cin >> x[i];
  vint a(n);
  rep(i, n) {
    int t, p;
    cin >> t >> p; --p;
    a[i] = t-x[p];
  }
  sort(all(a));
  rep(i, n) {
    for(int j = i-1; j >= 0; --j) w[i][j] = w[i][j+1]+a[i]-a[j];
  }
  /*
  rep(i, n) {
    rep(j, n) cout << w[i][j] << " \n"[j==n-1];
  }
  */
  fill(dp[0], dp[MAX_N], inf);
  //dp[0][0] = 0;
  rep(i, n) dp[0][i] = w[i][0];
  reps(i, 1, m+1) {
    rowMinima(i-1, 0, n-1, 0, n-1);
    rep(j, n+1) chmin(dp[i][j], dp[i-1][minima[j]]+w[j][minima[j]+1]);
  }
  /*
  rep(i, m) {
    rep(j, n) cout << dp[i][j] << " \n"[j==n-1];
  }
  */
  cout << dp[m-1][n-1] << endl;

  return 0;
}



Measured memory_bytes: 57728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int c[3][3];
	rep(i,3) rep(j,3) cin >> c[i][j];
	for(int a1=-100;a1<=100;++a1){
		int a2,a3,b1,b2,b3;
		if(c[0][0]<a1 || c[0][1]<a1 || c[0][2]<a1) break;
		b1=c[0][0]-a1;
		b2=c[0][1]-a1;
		b3=c[0][2]-a1;
		a2=c[1][0]-b1;
		a3=c[2][0]-b1;
		if(c[1][1]==a2+b2 && c[1][2]==a2+b3 && c[2][1]==a3+b2 && c[2][2]==a3+b3){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long A, B;
    scan(A, B);
    auto S = sread();
    bool a = S[A] == '-';
    bool b = (S[0 .. A] ~ S[A + 1 .. $]).all!(c => '0' <= c && c <= '9');
    writeln((a && b) ? "Yes" : "No");
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  while(1){
    int d[17][17] ={};
    int n;
    int a,b;
    int x,y;
    d[1][1] = 1;
    cin >>a >>b;
    if(a==0 && b==0) break;
    cin >> n;
    for (int i=0; i<n; i++){
      cin >>x >>y;
      d[x][y] = -1;
    }
    
    for(int i =1; i<=a ;i++){
      for(int j= 1; j<= b ;j++){
	if(x==1 && y==1) continue;
	if(d[i][j] < 0) continue;
	if(d[i][j-1] >=0) d[i][j] += d[i][j-1];
	if(d[i-1][j] >= 0) d[i][j] += d[i-1][j];
      }
    }
    cout << d[a][b] <<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

string S;
int N;

bool C(int K){
    int parity = S[N-K];
    for(int i=N-K; i<K; i++) if(S[i] != parity) return false;
    return true;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> S;
    N = S.size();
    bool flag = true;
    for(int i=0; i<N-1; i++){
        if(S[i] != S[i+1]){
            flag = false;
            break;
        }
    }
    if(flag){
        cout << N << endl;
        return 0;
    }
    int ub = N;
    int lb = 1;
    while(ub - lb > 1){
        int mid = (ub+lb) / 2;
        if(C(mid)) lb = mid;
        else ub = mid;
    }
    cout << lb << endl;
    return 0;
}

Measured memory_bytes: 512
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

// #include <bits/extc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp> // tree
// #include <ext/pb_ds/hash_policy.hpp> // hash
// #include <ext/pb_ds/trie_policy.hpp> // trie
// #include <ext/pb_ds/priority_queue.hpp> // priority_queue
// using namespace __gnu_pbds;

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

#define X first
#define Y second
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define Push push_back

using lli = long long;
using pll = pair<lli, lli>;
using Double = long double;
template<typename T>
using priority = priority_queue<T>;

const lli mod = 998244353;
const Double PI = 3.1415926535846;
const Double eps = 1e-8;

lli fastPow(lli base, lli exp, lli module = mod) {
	lli ans = 1;
	base %= module;
	while (exp) {
		if (exp & 1) ans = ans * base % module;
		base = base * base % module;
		exp >>= 1;
	}
	return ans;
}

bool millerRabin(lli n, lli a) {
	if (n < 2 or n % 2 == 0) return n == 2;
	lli u, t;
	for (u = n-1, t = 0; u & 1; u >>= 1, ++t);
	a = fastPow(a, u, n);
	if (a == 1 or a == n - 1) return true;
	for (int i = 0; i < t; ++i) {
		a = a * a % n;
		if (a == 1) return false;
		if (a == n - 1) return true;
	}
	return false;
}

void solve() {
	int n, tmp;
	cin >> n;
	
	vector<lli> cnt(n, 0);
	for (int i = 0; i < n; ++i) {
		cin >> tmp;
		if (i == 0 and tmp != 0) {
			cout << 0 << "\n";
			return;
		}
		++cnt[tmp];
	}
	
	if (cnt[0] != 1) {
		cout << 0 << "\n";
		return;
	}
	
	for (int i = 1; i < n-1; ++i) {
		if (!cnt[i] and cnt[i + 1]) {
			cout << 0 << "\n";
			return;
		}
	}
	
	lli ans = 1;
	for (int i = 2; i < n; ++i) {
		if (cnt[i] == 0) break;
		ans = ans * fastPow(cnt[i - 1], cnt[i]) % mod;
	}
	
	cout << ans << "\n";
}

int main() {
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 1024
def resolve():
    N, M = list(map(int, input().split()))
    A = list(map(int, input().split()))
    required = [None]+[2,5,5,4,5,6,3,7,6]
    dp = [0 for _ in range(max(10, N+1))]
    candidates = {}
    for a in A:
        req = required[a]
        if dp[req] < a:
            dp[req] = a
            candidates[req] = a
    #print(dp)
    #print(candidates)
    for i in range(N+1):
        for n_match, num in candidates.items():
            if i - n_match >= 0 and dp[i-n_match] != 0:
                dp[i] = max(dp[i], dp[i-n_match]*10+num)
    #print(dp)
    print(dp[N])

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 14412
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int64_t X;
cin >> X;
int64_t a = 100;
for (int i = 1;i < INF;i++) {
    a += a*0.01;
    if (a >=X) {
        cout << i << endl; 
        return 0;
    }
}



return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
 
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    int n,  ans = 0, prev = -1;
    cin >> n;
    vector<int> v(n);
    rep(n) cin >> v[i];
    sort(all(v));
    rep(n){
        if(prev < v[i]){
            ans++;
            prev = v[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
s = input()

x = s[0]
ans = s[0]
cnt = 0
for i in range(1,len(s)):
    if s[i] == ans[i-1]:
        if s[i] == '0':
            ans += '1'
        else:
            ans += '0'
        cnt += 1
    else:
        ans += s[i]
print(cnt)


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

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, k;
  cin >> n >> k;
  ll tmp1 = n%k;
  if (tmp1) {
    ll tmp2 = k-tmp1;
    cout << min(tmp1, tmp2) << endl;
  } else cout << tmp1 << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int MOD2 = 998244353;

ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

ll modinv(ll x, ll n){
    return modpow(x, n - 2);
}

int main(){
    int n;
    cin >> n;
    ll tot = modpow(10, n);
    ll a = modpow(9, n);
    ll b = modpow(8, n);

    cout << (tot - (2*a - b) + 10*MOD)%MOD << endl;

    return 0;
}


Measured memory_bytes: 3612
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n=int(input())
    s=input()
    now=0
    l=0
    for c in s:
        if c=="(":
            now+=1
        else:
            now-=1
        if now==-1:
            l+=1
            now=0
    ans="("*l+s+")"*now
    print(ans)
main()

Measured memory_bytes: 3064
from collections import deque
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

H,W=LI()

MP=[input() for _ in range(H)]
MEMO=[[(-1,0)]*W for _ in range(H)]
MEMO[0][0] = (0,1)
QU=deque([])

QU.append((0,0,0))
IT=[(1,0),(0,1)]
while QU:
    i,j,cost = QU.popleft()
    cost+=1
    pat = MEMO[i][j][1]
    for dy, dx in IT:
        ny, nx = i+dy, j+dx
        if ny < H and ny >= 0 and nx < W and nx >= 0 and MP[ny][nx] == '.':
            cost2, pat2 = MEMO[ny][nx]
            if cost2 == -1:
                # print('i:{},j:{},ny:{},nx:{},cost:{},pat:{}'.format(i,j,ny,nx,cost,pat))
                MEMO[ny][nx] = (cost, pat)
                QU.append((ny,nx,cost))
            elif cost2 == cost:
                _pat = (pat+pat2)%DVSR
                MEMO[ny][nx] = (cost,_pat)
                # print('i:{},j:{},ny:{},nx:{},cost:{},pat:{}'.format(i,j,ny,nx,cost,_pat))
                # QU.append((ny,nx,cost,pat))
# for li in MEMO:
    # print(li)
print(MEMO[H-1][W-1][1])

Measured memory_bytes: 89180
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

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

Measured memory_bytes: 384
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define each(i, ctn) for (auto &&i : (ctn))
#define all(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(12);*/ } } pre__;


int main() {
	string S;
	int A, B;
	cin >> A >> B >> S;
	if (S[A] != '-') {
		OUT("No");
		return 0;
	}
	if (S.size() != A + B + 1) {
		OUT("No");
		return 0;
	}
	REP(i, S.size()) {
		if (i == A)continue;
		if (S[i] < '0' || S[i] > '9') {
			OUT("No");
			return 0;
		}
	}
	OUT("Yes");
	return 0;
}

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

int main() {
  int w, h, x, y, r;
  cin >> w >> h >> x >> y >> r;
  int left = x - r;
  int right = x + r;
  int lower = y - r;
  int upper = y + r;

  if (left < 0 || right > w || lower < 0 || upper > h) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3112
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<time.h>
using namespace std;
#define ll long long
#define re register
#define mp make_pair
typedef pair<int,int> pii;
inline int gi()
{
	int sum=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=1000010;
int n,a[N];
int main()
{
	n=gi();for(int i=1;i<=n;i++)scanf("%1d",&a[i]),a[i]--;
	int fl=0;
	for(int i=1;i<=n;i++)if(a[i]==1)fl=1;
	if(fl)for(int i=1;i<=n;i++)a[i]%=2;
	int ans=0;
	for(int i=1;i<=n;i++)
		if(((n-1)&(i-1))==i-1)ans^=a[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4096
/*
 * Main.cpp
 *
 *  Created on:
 *      Author: KC
 */
/*
 ID: chancha4
 PROG: packrec
 LANG: C++
 */
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <sstream>
#include <math.h>
#include <vector>
#include <time.h>
#include<stack>
#include <set>
#include <limits>
#include<map>
#include<utility>

using namespace std;

int res = 0;
int w, h;
char s[130][130];
char cursign = '0';
void bfs(int x, int y){
    s[x][y] = '0';
    for(int i = -1; i<= 1; i++){
        if(x + i >= 0 && x + i < h &&  s[x + i][y] == cursign) bfs(x + i, y);
    }
    for(int i = -1; i<= 1; i++){
        if(y + i >= 0 && y + i < w &&  s[x][y + i] == cursign) bfs(x, y + i);
    }

}
int main(){
    int count = 0;
    while(true){

        scanf("%d %d", &h, &w);
        if(w == 0 && h == 0) break;
        count++;
        for(int i = 0; i < h; i++) scanf("%s", s + i);
        int x, y;
        res = 0;
        for(int i = 0; i < h; i++)
            for(int j = 0; j < w; j++){
                if(s[i][j] == '@' || s[i][j] == '#' || s[i][j] == '*'){
                    cursign = s[i][j];
                    bfs(i, j);
                    res++;
                }
            }
        printf("%d\n", res);
    }

    return 0;
}

Measured memory_bytes: 1828
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>











ll n,c,c2,d,d2,a;
map<ll,ll>m;
map<ll,ll>::reverse_iterator rit;



void solve()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		m[a]++;
	}
	c2=0;
	for(rit=m.rbegin();rit!=m.rend();rit++)
	{
		a=rit->st;
		c=rit->nd;
		if(c2==0)
		{
			if(c>=4)
			{
				c2=2;
				d=a;
				d2=a;
			}
			else if(c>=2)
			{
				c2=1;
				d=a;
			}
		}
		else if(c2==1)
		{
			if(c>=2)
			{
				c2=2;
				d2=a;
			}
		}
		if(c2==2)
		{
			cout<<d*d2<<"\n";
			return;
		}
	}
	cout<<"0\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 6528
// D - Banned K
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int N;
vl A;

vl solve(){
	vl m(N+1), csum(N+1), del(N+1);

	rp(i,0,N) m[A[i]]++;//ai ごとの計数

	rp(a, 1, N+1){
		ll c = m[a];
		if(c>=2) csum[a] = c*(c-1)/2;//組み合わせ
		c--;
		if(c>=2) del[a] = c*(c-1)/2;//１減の組み合わせ
	}

	rp(i, 1, N+1) csum[i] += csum[i-1];//累積和: Cumulative sum

	vl ans(N, 0);
	rp(k, 0, N){
		int ak = A[k];
		ll m = del[ak];// ak の組み合わせ
		ll f = csum[ak-1];// ak より前の組み合わせの和
		ll b = csum[N] - csum[ak];// ak より後の組み合わせの和
		ans[k] = f + m + b;
	}

	return ans;
}

int main(){
	cin>>N;
	A.resize(N);
	rp(i, 0, N) cin>>A[i];
	for(auto x:solve()) cout<< x <<endl;
}

Measured memory_bytes: 8064
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
int ans;
signed main(){
  int n,x;
  int l[200];
  cin >> n >> x;
  REP(i,n) cin >> l[i];
  int now = 0;
  REP(i,n) {
    if(now<=x) ans ++;
    now += l[i];
  }
  if(now<=x) ans ++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
	char s[100001];
	scanf("%s",s);
	long i,l=strlen(s),ans=0;
	for(i=0;i<l;i++){
		if(s[i]!=s[i+1])ans++;
	}
	
	printf("%lld",ans-1);
	return 0;
}

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)9e18);
const int ninf=((int)-9e18);
const int mod=1000000007;

using namespace std;

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);


    int n,m;
    cin>>n>>m;

    set <int> ac;
    vector <string> s(n+1,"WA");
    int pen=0,cnt=0;
    map <int,int> cntd;
    loop(i,0,m)
    {
        int x;
        cin>>x;
        string a;
        cin>>a;

        if(a=="AC")
        {
            s[x]=a;
            ac.insert(x);
        }
        else if(s[x]=="WA")
        {
            cntd[x]++;
        }

    }

    for(auto p:cntd)
    {
        if(s[p.first]=="AC")
        {
            pen+=p.second;
        }
    }

    cnt=ac.size();

    cout<<cnt<< " "<<pen;


    return 0;
}


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

int d[111111] = {1};
int main() {
    int x;
    cin >> x;
    for(int i = 0; i < x; i++)
        if(d[i])
            for(int j = 0; j < 6; j++)
                d[i + 100 + j] = 1;
    cout << d[x] << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const int N=(int)2e5+10;
int P[N],R[N];

int find(int x)
{
	if(x==P[x])return x;
	return P[x]=find(P[x]);
}
void join(int a,int b)
{
	a=find(a);
	b=find(b);
	if(R[a]<R[b])
	{
		P[a]=b;
	}
	else
	{
		P[b]=a;
		if(R[a]==R[b])
		{
			R[a]++;
		}
	}
}
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		P[i]=i;
		R[i]=0;
	}
	map<int,int>mp;
	int mx=0;
	while(m--)
	{
		int a,b;
		cin>>a>>b;
		int fa=find(a);
		int fb=find(b);
		if(fa==fb)
		{
			continue;
		}
		else
		{
			join(a,b);
		}
	}
	for(int i=1;i<=n;i++)
	{
		int a=find(i);
		mp[a]++;
	}
	for(auto x:mp)
	{
		mx=max(mx,x.second);
	}
	cout<<mx<<endl;
	return 0;
	
}
		


Measured memory_bytes: 14412
#pragma GCC optimize("O2")
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <functional>
#include <numeric>
#include <algorithm>
// #include <queue>
using namespace std;
const long long INF = 1000000000;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n , m , x ;
	cin >> n >> m >> x ;
	vector<vector<int>> a(n , vector<int>(m)) ;
	vector<int> c(n) ;
	for (int i = 0 ; i < n ; i++) {
		cin >> c[i] ;
		for (int j = 0 ; j < m ; j++) {
			cin >> a[i][j] ;
		}
	}
	int ans = INF ;
	for (int i = 0 ; i < (int) 1 << n ; i++) {
		vector<int> b(m);
		int res = 0;
		for (int j = 0 ; j < n ; j++) {
			if (i & (1 << j)) {
				res += c[j];
				for (int k = 0 ; k < m ; k++) {
					b[k] += a[j][k];
				}
			}
		}
		bool flag = true;
		for (int k = 0 ; k < m ; k++) {
			if (b[k] < x) flag = false;
		}

		if (flag) ans = min(ans, res);
	}

	if (ans == INF) cout << -1 << "\n";
	else cout << ans << "\n";







	return 0 ;

}


Measured memory_bytes: 3660
N = int(input())
digit = len(str(N))

ans = 0
for a in range(1, 10):
    for b in range(1, 10):
        x, y = 0, 0
        if a == b:
            if a <= N:
                x += 1
                y += 1

        if a*10+b <= N:
            x += 1

        if b*10+a <= N:
            y += 1

        if digit <= 2:
            ans += x*y
            continue

        d = 3
        while d < digit:
            x += 10**(d-2)
            y += 10**(d-2)
            d += 1

        for i in range(10**(digit-2)):
            if int(str(a)+str(i).zfill(digit-2)+str(b)) <= N:
                x += 1
            if int(str(b)+str(i).zfill(digit-2)+str(a)) <= N:
                y += 1
        ans += x*y

print(ans)


Measured memory_bytes: 44376
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll D;
    cin >> D;

    vector<ll> c(26);
    ll sum_c = 0;
    rep(0, i, 26)
    {
        cin >> c.at(i);
        sum_c += c.at(i);
    }

    vector<vector<ll>> s(D, vector<ll>(26, 0));
    rep(0, i, D)
    {
        rep(0, j, 26)
        {
            cin >> s.at(i).at(j);
        }
    }

    ll score = 0, dec = 0; // i日目のスコア、スコアの減少量
    vector<ll> t(D), last(26, 0), ans(D, 0);
    rep(0, i, D)
    {
        // 今日開くコンテストと得られる満足度
        ll today_i = 0, today_score = -10000000000;
        // i日目に各コンテストを開催したと仮定して満足度を求める
        rep(0, j, 26)
        {
            ll sum = s.at(i).at(j);
            sum = sum - (dec + sum_c - (c.at(j) * (last.at(j) + 1)));
            if (today_score < sum)
            {
                today_i = j;
                today_score = sum;
            }
        }

        // ループが終了したら今日開くコンテストが決まるので、last(d,i)を更新する
        rep(0, j, 26)
        {
            last.at(j) += 1;
        }
        last.at(today_i) = 0;

        // decの更新
        dec = 0;
        rep(0, j, 26)
        {
            dec += c.at(j) * last.at(j);
        }

        // scoreの更新
        score += today_score;

        // 答え
        t.at(i) = today_i + 1;
        ans.at(i) = score;
    }

    rep(0, i, D)
    {
        cout << t.at(i) << endl;
    }
}

Measured memory_bytes: 3656