akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

vector<set<char>> st;
int n, q; string s;

void build(int id=1, int l=0, int r=n) {
  if (r-l < 2) {
    st[id] = set<char>();
    st[id].insert(s[l]);
    return ;
  }
  int mid = (l+r)/2;
  build(2*id, l, mid);
  build(2*id+1, mid, r);
  st[id] = set<char>();
  for (char c : st[2*id]) st[id].insert(c);
  for (char c : st[2*id+1]) st[id].insert(c);
}

set<char> query(int x, int y, int id=1, int l=0, int r=n) {
  if (l >= x && r <= y) return st[id];
  if (l >= y || r <= x) return set<char>();
  int mid = (l+r)/2;
  set<char> ans, ls = query(x,y,2*id,l,mid), rs = query(x,y,2*id+1,mid,r);
  for (char c : ls) ans.insert(c);
  for (char c : rs) ans.insert(c);
  return ans;
}

void update(int p, char c, int id=1, int l=0, int r=n) {
  if (r-l < 2) {
    st[id] = set<char>();
    st[id].insert(c);
    return ;
  }
  int mid = (l+r)/2;
  if (p < mid)
    update(p, c, 2*id, l, mid);
  else
    update(p, c, 2*id+1, mid, r);

  st[id] = set<char>();
  for (char c : st[2*id]) st[id].insert(c);
  for (char c : st[2*id+1]) st[id].insert(c);
}

int main() {
  cin >> n >> s >> q;
  st.resize(4*n);
  build();
  while (q--) {
    int t; cin >> t;
    if (t==1) {
      int i; char c; cin >> i >> c;
      i--;
      update(i, c);
    }
    else {
      int l, r; cin >> l >> r;
      l--, r--;
      cout << query(l, r+1).size() << endl;
    }
  } 
  return 0;
}


Measured memory_bytes: 233732
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint H; cin >> H;
    function<lint(lint)> num_attacks_to_repel = [&](lint X) {
        if (X == 1) return 1LL;
        return 2LL * num_attacks_to_repel(X / 2) + 1;
    };
    cout << num_attacks_to_repel(H) << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define FOREQ(i,k,n) for(int i=(k); i<=(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int m, n, p;
  while(cin>>n>>m>>p && m){
    int ans = -1;
    string winner = "Draw";
    int height[10][10] = {};
    bool ball[20][20][20][2]= {};
    string name[2] = {"Black", "White"};
    REP(i, p){
      int x, y; cin>>x>>y;
      x--; y--;
      if(ans != -1) continue;
      int h = height[y][x];
      height[y][x]++;
      int t = i % 2;
      ball[h][y][x][t] = true;
      //printf("%d %d %d\n", x, y, t);
      REP(z, n)REP(y, n)REP(x, n){
        FOREQ(dz, -1, 1) FOREQ(dy, -1, 1) FOREQ(dx, -1, 1) {
          if(dx == 0 && dy == 0 && dz == 0) continue;
          bool ok = true;
          REP(k, m){
            ok = ok && (z+k*dz >= 0 && y+k*dy >=0 && x+k*dx >= 0) && ball[z+k*dz][y+k*dy][x+k*dx][t];
          }
          if(ok){
            ans = i + 1;
            winner = name[t];
          }
        }
      }
    }
    if(ans == -1) cout<<winner<<endl;
    else printf("%s %d\n", winner.c_str(), ans);
  }

  return 0;
}

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

using namespace std;
int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int k;
    cin >> k;
    int sum = 0;
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            for (int l = 1; l <= k; l++) {
                sum += gcd(i,gcd(j,l));
            }
        }
    }
    cout << sum;
}


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

#define FILE_IN freopen("kotlin.in", "r", stdin);
#define FILE_OUT freopen("kotlin.out", "w", stdout);

#define fr(i,n) for(int i=0;i<n;i++)
#define frr(i,a,b) for(int i =a;i<=b;i++)
// for(auto it : g[i].nb)

typedef long long ll;
typedef long double ld;

#define pb push_back

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

#define fi first
#define se second
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const long double PI = acos(-1.0l);
const ll MOD = 1e9+7;

//LLONG_MAX
//-DBL_MAX
//__builtin_popcountll(ll x) - __builtin_popcount(int x)

bool debug = 1;
#define printa(a) cout << #a << " = " << (a) << endl
#define prin(a) if(debug) cout << #a << " = " << (a) << endl
#define soprin(a) if(debug) cout << (a)
#define ppal(a)  if(debug) cout << #a << endl
#define prinsep if(debug) cout << "------" << endl
#define cendl if(debug) cout << endl
#define prinpar(p) if(debug) cout << #p << ".fi=" << (p).fi << " " << #p << ".se=" << (p).se << endl
#define print(tup) if(debug) cout << #tup << " = {" << get(tup,0) << ", " << get(tup,1) << ", " << get(tup,2) << "}\n"
#define prinv(v) if(debug){ cout << #v << ":" << endl; for(auto it = (v).begin(); it!=(v).end();it++){ cout << *it << " ";} cout << endl;}

const int N = 110;

int v[N];

int main(){
	//FILE_IN FILE_OUT
	int n;
	cin >> n;
	
	fr(i,n){
		scanf("%d", v+i);
	}
	
	ll ans = INT_MAX;
	frr(pivo,-100,100){
		ll cur = 0;
		fr(i,n){
			cur+=1ll*(pivo-v[i])*(pivo-v[i]);
		}
		ans = min(ans,cur);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
from functools import reduce


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def gcd_n(numbers):
    return reduce(gcd, numbers)


def main():
    N, X = map(int, input().split())
    x = [abs(X - int(i)) for i in input().split()]
    print(gcd_n(x))
    return


main()


Measured memory_bytes: 14680
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        System.out.println(6-s.nextInt()-s.nextInt());


    }




}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

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

int main() {
  int n, k, ans = 0;
  cin >> n >> k;
  int l[n];

  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }

  sort(l, l + n);

  for (int i = 1; i <= k; i++) {
    ans += l[n - i];
  }

  cout << ans << endl;
}


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

struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

signed main() {
	int H, W, sh, sw;

	cin >> H >> W;
	cin >> sh >> sw;

	cout << H*W - (H * sw + W * sh - sh * sw) << endl;

	#ifdef _DEBUG
		system("pause");
	#endif
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int[] flag = new int[101];
		Arrays.fill(flag, 0);
		
		for(int i = 0; i < N; i++) {
			int d = stdIn.nextInt();
			flag[d] = 1;
		}
		
		int ans = 0;
		for(int i = 0; i < 101; i++) {
			ans += flag[i];
		}
		
		System.out.println(ans);

	}

}

Measured memory_bytes: 21844
#include<stdio.h>
long so2(long a, long b, long c)
{
  if ( (a<b && c<a) || (a<c && b<a) ) return a;
  if ( (b<c && a<b) || (b>c && a>b) ) return b;
  if ( (c<b && a<c) || (c>b && a>c) ) return c;
}
int main()
{
  long p[20],n,i,check[100],kqua=0;
  scanf("%ld", &n);
  for (i=0; i<n; i++) 
    {
      scanf("%ld", &p[i]);
      check[i+1]=0;
    }
  for (i=1; i<n-1; i++)
   {
     //printf("%d\n", second(p[i-1],p[i],p[i+1]));
     if (so2(p[i-1],p[i],p[i+1])==p[i])
     check[p[i]]++;
   }
  for (i=0; i<n; i++)
    {
      if (check[i+1]!=0) kqua++;
    }
  printf("%ld", kqua);
  return 0;
}


Measured memory_bytes: 128
n=int(input())
a=[[0]*9 for i in range(9)]
for i in range(1,n+1):
    x,y =int(str(i)[0]), int(str(i)[-1])
    if y>0:
        a[x-1][y-1]+=1
count=0
for i in range(9):
    for j in range(9):
        if i>j:
            continue
        if i==j:
            count+=a[i][j]**2
        else:
            count+=a[i][j]*a[j][i]*2
print(count)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String input = br.readLine();

        for(int i = input.length() - 1;i >= 0; i--)
        	System.out.print(input.charAt(i));

        System.out.println("");
	}


}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N+1);
    vector<int> B(N+1);
    vector<int> C(N+1);
    for(int i=1;i<=N;i++) cin >> A[i];
    for(int i=1;i<=N;i++) cin >> B[i];
    for(int i=1;i<N;i++) cin >> C[i];
    int ans=0;
    for(int i=1;i<=N;i++) {
        ans += B[A[i]];
        if(i>=2) {
            if(A[i]==(A[i-1]+1)) ans += C[A[i]-1];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math as m
N = int(input())
prime = []
# 素数->True, 合成数->False
def check(n):
    sup = m.floor(pow(n,1/2))
    for i in range(2,sup+1):
        if n % i == 0:
            return False
    return True

for i in range(2,11112,2):
    if len(prime) == N:
        break
    p = 5*i + 1
    # 素数ならprimeに追加
    if check(p) is True:
        prime.append(p)

for i in range(N):
    if i == N-1:
        print(prime[i])
    else:
        print(prime[i],end = " ")


def debug():
    import itertools
    for e in itertools.combinations(prime,5):
        # 素数ならreturn
        if check(sum(e)) is True:
            print("No")
            return
    print("Yes")

#debug()

Measured memory_bytes: 3064
#include<iostream>
#include <vector>

int main() {
  std::string s, t;
  std::cin >> s >> t;
  std::vector<unsigned> s_cnt(s.size() + 1);
  std::vector<unsigned> t_cnt(t.size() + 1);
  s_cnt[0] = 0;
  for (unsigned i = 1; i <= s.size(); ++i) {
    s_cnt[i] = s_cnt[i - 1] + (s[i - 1] == 'A' ? 1 : 2);
  }
  t_cnt[0] = 0;
  for (unsigned i = 1; i <= t.size(); ++i) {
    t_cnt[i] = t_cnt[i - 1] + (t[i - 1] == 'A' ? 1 : 2);
  }
  unsigned q;
  std::cin >> q;
  for (unsigned i = 0; i < q; ++i) {
    unsigned a, b, c, d;
    std::cin >> a >> b >> c >> d;
    std::cout << (((s_cnt[b] - s_cnt[a-1]) % 3 == (t_cnt[d] - t_cnt[c-1]) % 3) ? "YES" : "NO") << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222



ll p[22], x[22];


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

  

  cin >> n >> m;
  vll sw[22];
  rep(i, m) {
    ll k;
    cin >> k;
    rep(j, k) {
      cin >> tmp;
      sw[tmp - 1].pb(i);
    }
  }
  rep(i, m) cin >> p[i];
  
  rep(bit, (1LL << n)) {
    ll cnt = 0;
    rep(i, n) x[i] = 0;
    rep(i, n) {
      if (bit >> i & 1) {
        rep(j, sw[i].size()) x[sw[i][j]]++;
      }
    }
    rep(i, m) if (p[i] == x[i] % 2) cnt++;
    if (cnt == m) ans++;
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
#define print(a) cout << a << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  lvector A(n+1,0);
  rep(i,n) cin>>A[i+1];
  vector<lvector> dp(3,lvector(n+2,-1e14));
  dp[0][0]=0;
  rep(i,n+1) {
    rep(j,3) if(i) dp[j][i+1]=max(dp[j][i+1],dp[j][i-1]+A[i]);
    rep(j,2) dp[j+1][i+1]=max(dp[j+1][i+1],dp[j][i]);
  }
  print(dp[1+n%2].back());
  return 0;
}


Measured memory_bytes: 11064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

ll C[55][55];

void comInit(){
    C[0][0] = 1;
    for(int i=1; i<=50; i++){
        for(int j=0; j<=i; j++){
            if(j == 0 || j == i) C[i][j] = 1;
            else if(j < i) C[i][j] = C[i-1][j-1] + C[i-1][j];
            else C[i][j] = 0;
        }
    }
}

int main(){
    int N, A, B; cin >> N >> A >> B;

    vector<ll> v(N);
    for(int i=0; i<N; i++) cin >> v[i];
    sort(v.begin(), v.end(), greater<ll>());

    double sum = 0;
    for(int i=0; i<A; i++) sum += v[i];
    double ave = sum/A;
    printf("%.8lf\n", ave);

    comInit();

    ll ans = 0;
    if(v[0] == ave){
        int cnt = 0;
        for(auto u:v) if(u == ave) cnt++;
        for(int i=A; i<=min(cnt, B); i++) ans += C[cnt][i];
        cout << ans << endl;
        return 0;
    } else {
        int a = 0, b = 0;
        for(int i=0; i<N; i++){
            if(v[i] == v[A-1]){
                if(i <= A-1){ a++; b++; }
                else b++;
            }
        }

        ll ans = C[b][a];
        cout << ans << endl;
        return 0;
    }

}

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

int N,A,ans,c;

int main(){
    ans = 1000000000;
    scanf("%d",&N);
    for (int i=0;i<N;i++){
        c=0;
        scanf("%d",&A);
        while(A%2==0){
            A/=2;
            c++;
        }
        if (ans>c){
            ans =c;
        }
    }
    printf("%d\n",ans);
}


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

int main() {
    int X;
    cin >> X;
    int maxValue = 1;
    for (int i = 2; i <= X; i++) {  // O(N^2) -> 1000 * 1000 = 10^6
        int tmp = i * i;
        while(tmp <= X) {
            maxValue = max(maxValue, tmp);
            tmp *= i;
        }
    }

    cout << maxValue << endl;

    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  cout << ( 60*H2+M2 - 60*H1-M1 - K ) << endl;
}

Measured memory_bytes: 3624
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

unordered_set<ll> s;

int main() {
    fast_io; cout_precision;
    for (ll i = 0, c; i < 3; i++) {
        cin >> c;
        s.insert(c);
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 256
import numpy as np
N, K, *H = map(int, open(0).read().split())
dp = np.zeros(N, dtype=int)
heights = np.array(H)
for i in range(1, N):
    start = max(0, i - K)
    dp[i] = (dp[start:i] + np.abs(heights[i] - heights[start:i])).min()
print(dp[-1])

Measured memory_bytes: 22924
n = int(input())
s = input()

ans = s.count('R') * s.count('G') * s.count('B')

for i in range(n):
    for j in range(i + 1, n):
        k = 2 * j - i
        # 三個目が範囲内 かつ 三文字違う かつ 距離が同じはダメ
        if k < n and (s[i] != s[j] and s[j] != s[k]
                      and s[i] != s[k]) and j - i == k - j:
            ans -= 1

print(ans)


Measured memory_bytes: 9136
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = [ni() for _ in range(n)]

isodd = False
for ai in a:
    if ai%2:
        isodd = True
        break

print("first") if isodd else print("second")

Measured memory_bytes: 7096
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

int n, w, s, e;
 

int main() {
	string p;
	cin >> p;
	for (int i = 0; i < p.length(); i++) {
		if (p[i] == 'N')n=1;
		if (p[i] == 'W')w=1;
		if (p[i] == 'S')s=1;
		if (p[i] == 'E')e=1;
	}
	if (n==s&&w==e)print("Yes"); else print("No");




	return 0;
}

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

long long int dp[10][101][1001];
int n,s;
int maxs;
using namespace std;

long long int check(int i,int cnt,int sum)
{
  if(sum==s && cnt==n)
    {
      //    cout<<i<<" "<<cnt<<" "<<sum<<endl;
      return 1;
    }
  if(sum>=s || cnt>=n || i>=100)
    return 0;
  if(dp[cnt][i][sum]!=-1)
    return dp[cnt][i][sum];
  long long int ans=0;
  for(int j=i+1;j<=maxs;j++)
    ans+=check(j,cnt+1,sum+j);
  
  dp[cnt][i][sum]=ans;
  return ans;
}
int main()
{

  for(;cin>>n>>s,n;)
    { 
      memset(dp,-1,sizeof(dp));
      long long int ans=0;
      maxs=min(s,100);
      for(int i=0;i<=maxs;i++)
	ans+=check(i,1,i);
      
      cout<<ans<<endl;
    }

}

Measured memory_bytes: 9060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();
		int x = scan.nextInt();
		
		if (500 * k >= x) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		scan.close();
	}
}

Measured memory_bytes: 21844
k = 10000
c = [0] * (k + 1)


def countingSort(a, b):
    global k
    n = len(a) - 1
    for i in range(k + 1):
        c[i] = 0
    for j in range(n):
        c[a[j + 1]] += 1

    #print(c)

    for i in range(1, k + 1):
        c[i] = c[i] + c[i - 1]

    #print(c)
    for j in range(n):
        #print(a[j], c[a[j]])
        b[c[a[j + 1]]] = a[j + 1]
        c[a[j + 1]] -= 1


n = int(input())
*a, = map(int, input().split())
a.insert(0, 0)
b = [0] * (n + 1)

countingSort(a, b)
b.pop(0)
print(" ".join([str(v) for v in b]))


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

int main() {
  string n;
  cin >> n;
  if(n[0]=='1') n[0]='9';
  else n[0]='1';
  if(n[1]=='1') n[1]='9';
  else n[1]='1';
  if(n[2]=='1') n[2]='9';
  else n[2]='1';
  cout << n << endl;
}

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

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define int long long
#define endl '\n'

using namespace std;

const int N = 2e5 + 77;
int A[N];
int32_t main(){
    fast;
    int n ; cin >> n ;
    string s; cin >> s;
    int ans = 0;
    for(int i = 0; i < 1000 ; ++i){
        int a = i/100 , b = (i/10)%10 , c = i%10;
        int C[3] = {a,b,c};
        int idx = 0;
        for(int j = 0 ; j < n ; ++j){
            if(s[j]==(C[idx] +'0')) idx++;
            if(idx==3) break;
        }
        if(idx==3) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

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

    if((n-1)*(n-2)/2<k){
        cout << "-1" << endl;
        return 0;
    }

    int ans = n-1 + (n-1)*(n-2)/2 - k;
    cout << ans << endl;

    rep(i,n-1){
        cout << '1' << ' ' << i+2 << endl;
    }

    int count = 0;
    srep(i,2,n){
        srep(j,i+1,n+1){
            if(count == (n-1)*(n-2)/2-k){
                return 0;
            }
            cout << i << ' ' << j << endl;
            count++;
        }
    }

    return 0;
}
 
 


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] arr = sc.next().toCharArray();
		int count = 0;
		for (int i = 0; i < n; i++) {
		    if (arr[i] == '1') {
		        count++;
		    }
		}
		StringBuilder sb = new StringBuilder();
		if (count == 0) {
		    for (int i = 0; i < n; i++) {
		        sb.append(1).append("\n");
		    }
		} else if (count == 1) {
		    for (int i = 0; i < n; i++) {
		        if (arr[i] == '1') {
		            sb.append(0).append("\n");
		        } else {
		            if (arr[n - 1] == '1' || i == n - 1) {
		                sb.append(2).append("\n");
		            } else {
		                sb.append(1).append("\n");
		            }
		        }
		    }
		} else {
		    int plus = count + 1;
		    int minus = count - 1;
		    int[] plusMods = new int[n];
		    int[] minusMods = new int[n];
		    int plusValue = 0;
		    int minusValue = 0;
		    plusMods[0] = 1 % plus;
		    minusMods[0] = 1 % minus;
		    if (arr[n - 1] == '1') {
		        plusValue += plusMods[0];
		        minusValue += minusMods[0];
		    }
		    for (int i = 1; i < n; i++) {
		        plusMods[i] = (plusMods[i - 1] << 1) % plus;
		        minusMods[i] = (minusMods[i - 1] << 1) % minus;
		        if (arr[n - 1 - i] == '1') {
		            plusValue = (plusValue + plusMods[i]) % plus;
		            minusValue = (minusValue + minusMods[i]) % minus;
		        }
		    }
		    for (int i = 0; i < n; i++) {
		        int ans;
		        if (arr[i] == '1') {
		            ans = get((minusValue - minusMods[n - 1 - i] + minus) % minus);
		        } else {
		            ans = get((plusValue + plusMods[n - 1 - i]) % plus);
		        }
		        sb.append(ans).append("\n");
		    }
		}
		System.out.print(sb);
	}
	
	static HashMap<Integer, Integer> set = new HashMap<>();
	
	static int get(int value) {
	    if (!set.containsKey(value)) {
	        if (value == 0) {
	            set.put(value, 1);
	        } else {
	            int count = 0;
	            int x = value;
	            while (x > 0) {
	                count += x % 2;
	                x >>= 1;
	            }
	            set.put(value, get(value % count) + 1);
	        }
	    }
        return set.get(value);
	}
}


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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    int top1 = 0;
    int top2 = 0;
    int top1num = -1;
    rep(i, N){
        cin >> A[i];
        if(A[i] >= top1){
            top2 = top1;
            top1 = A[i];
            top1num = i;
        } else if(A[i] >= top2){
            top2 = A[i];
        }
    }

    rep(i, N){
        if(i == top1num){
            cout << top2 << endl;
        } else {
            cout << top1 << endl;
        }
    }

    return 0;
}

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

using namespace std;

typedef long long ll;

int n, m, v, w;
vector<int> a, p;

bool chk(int x){
        if (x + w >= n) return true;
        int r = v - w - x;
        if (r < 0) {
            for (int i = x + 1; i + w <= n; ++i)
                if (a[p[x]] + m < a[p[i]]) return false;
            return true;
        }
        else {
            ll s = 1ll * r * m;
            for (int i = x + 1; i + w <= n; ++i) {
                int y = a[p[x]] + m - a[p[i]];
                if (y > 0)
                    s -= a[p[x]] + m - a[p[i]];
                else if (y < 0)
                    return false;
            }
            return s <= 0;
        }
    }

int main(void) {
    scanf("%d%d%d%d", &n, &m, &v, &w);
    a.resize(n, 0);
    p.resize(n, 0);
    for (int& i : a) scanf("%d", &i);
    iota(p.begin(), p.end(), 0);
    sort(p.begin(), p.end(), [&](int i, int j) { return a[i] < a[j]; });

    int l = 0, r = n - 1;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (chk(mid)) r = mid - 1;
        else l = mid + 1;
    }


    printf("%d\n", n - l);
    return 0;
}

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

using namespace std;

typedef long long int LL;

#define st first
#define nd second
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 1e6 + 7;
const int MX = 1e9 + 7;
const LL INF = 1LL * MX * MX;

int n;
char in[N];
int to_solve[N];

int get_2(int x){
	int ans = 0;
	while(x){
		x /= 2;
		ans += x;
	}
	
	return ans;
}

int solve(){
	int ans = 0;
	int ile_n = get_2(n - 1);
	for(int i = 1; i <= n; ++i){
		int ile_nk = get_2(i - 1) + get_2(n - i);
		if(ile_nk == ile_n)
			ans ^= to_solve[i];
	}
	
	return ans;
}

int main(){
	scanf("%d", &n);
	scanf("%s", in + 1);
	
	int cnt1 = 0;
	for(int i = 1; i <= n; ++i){
		cnt1 += in[i] == '2';
		to_solve[i] = (in[i] - '1') % 2;
	}
	
	if(cnt1 == 0){
		for(int i = 1; i <= n; ++i)
			to_solve[i] = (in[i] - '1') / 2;

		printf("%d\n", 2 * solve());
		return 0;
	}
	
	int t = solve();
	if(t == 1){
		puts("1");
		return 0;
	}
	
	puts("0");
	return 0;
}

Measured memory_bytes: 5120
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

int N, A;
int x[55];

LL dp[55][2505];

int main() {
    cin >> N >> A;
    for (int j = 0; j < N; ++j) {
        cin >> x[j];
    }

    for (int j = 0; j <= N; ++j) {
        fill(dp[j], dp[j] + 2505, 0);
    }

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

    dp[0][0] = 1;
    dp[1][x[0]] = 1;

    for (int j = 1; j < N; ++j) {
        for (int k = N; k >= 1; --k) {
            for (int l = x[j]; l <= 50 * N; ++l) {
                dp[k][l] += dp[k-1][l-x[j]];
            }
        }
    }

    LL ans = 0LL;
    for (int j = 1; j <= N; ++j) {
        ans += dp[j][j*A];
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
struct segtree{
private:
  ll siz;
  vector<ll> node;
public:
  segtree(ll n){
    siz=1;
    while(siz<=n) siz*=2;
    node.resize(siz*2+1,0);
  }
  void upd(int p,int x){
    p+=siz-1;
    node[p]=x;
    while(p>0){
      p=(p-1)/2;
      node[p]=max(node[2*p+1],node[2*p+2]);
    }
  }
  ll max_v(ll a,ll b,ll p,ll l,ll r){
    if(a<=l&&r<=b) return node[p];
    if(r<=a||b<=l) return 0;
    ll mid=(l+r)/2;
    return max(max_v(a,b,2*p+1,l,mid),max_v(a,b,2*p+2,mid,r));
  }
  ll max_q(ll a){
    return max_v(a,siz,0,0,siz);
  }
};
int main(){
  vector<ll> vec;
  vector<P> points;
  ll h,w,n;
  cin>>h>>w>>n;
  for(int i=0;i<n;i++){
    ll x,y;
    cin>>x>>y;
    points.push_back(P(x,y));
    vec.push_back(x);
  }
  vec.push_back(0);
  points.push_back(P(0,0));
  sort(vec.begin(),vec.end());
  sort(points.begin(),points.end());
// cout<<0<<" "<<points[0].first<<" "<<points[0].second<<endl;
  segtree seg=segtree(n+5);
  for(int i=1;i<=n;i++){
    seg.upd(i,points[i].second);
  //  c//out<<i<<" "<<points[i].first<<" "<<points[i].second<<endl;
  }
  ll ans=17441744174417;
  for(int i=0;i<vec.size();i++){
    ll kans=vec[i];
    ll p=lower_bound(points.begin(),points.end(),P(kans+1,0))-points.begin();
  //  cout<<i<<" "<<kans<<" "<<p<<" "<<seg.max_q(p)<<endl;
    kans+=seg.max_q(p);
    ans=min(ans,kans);
  }
//  ans=min(ans,vec[])
  cout<<ans<<endl;
}



Measured memory_bytes: 8216
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int n,a[2000500],b[2000005],r,l;
void work(int x,int y){
	//cout<<x<<" "<<y<<endl;
	if((y-x)&1){
		if(n>=(y-x+1)/2){//cout<<"z"<<endl;
		    rep(i,x,(y+x)/2) b[i]=b[x];
		    rep(i,(y+x)/2+1,y) b[i]=b[y];
		}
		else{
			rep(i,x,x+n-1) b[i]=b[x];
			rep(i,x+n,y-n) if((i-x-n)%2==0) b[i]=b[x]; else b[i]=b[y];
			rep(i,y-n+1,y) b[i]=b[y];
		}
	}
	else{//cout<<"h";
	    rep(i,x,y) b[i]=b[x];
		if(n<=(y-x)/2) rep(i,x+n,y-n) if((i-x-n)%2==0) b[i]=1-b[x];else b[i]=b[x];
	}
}
bool check(int x){
//	cout<<x<<endl;
	rep(i,1,2*n-1) if(a[i]>=x) b[i]=1;else b[i]=0;
//	rep(i,1,2*n-1) cout<<b[i];cout<<endl;
	b[2*n]=2;
	int st=-1;
	rep(i,1,2*n-1){
		if(st!=-1 && b[i]==b[i+1]) work(st,i),st=-1;
		if(st==-1 && b[i]!=b[i+1]) st=i;
	}
	if(st!=-1) work(st,2*n-1);
//	rep(i,1,2*n-1) cout<<b[i];cout<<endl;
	return b[n];
}
int main(){
	scanf("%d",&n);
	rep(i,1,2*n-1) scanf("%d",&a[i]),r=max(r,a[i]);
    l=1;
    while(l<r){
    	int mid=(l+r+1)>>1;
    	if(check(mid)) l=mid;
    	else r=mid-1;
	}
	printf("%d",l);
	return 0;
}

Measured memory_bytes: 5120
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll n, m;
    cin >> n >> m;
    ll ans = 1;
    for (ll i = 1; i * i <= m; i++) {
        if (m % i == 0) {
            ll temp = m / i;
            if (temp >= n) {
               ans = max(ans, i);
            }
            if (i >= n) {
                ans = max(ans, temp);
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

template<typename edgeT>
struct normalMST {
	struct UnionFind {
		vector<int> data;
		UnionFind(int n) { data.assign(n, -1); }
		bool unionSet(int x, int y) {
			x = root(x); y = root(y);
			if (x != y) {
				if (data[y] < data[x]) swap(x, y);
				data[x] += data[y]; data[y] = x;
			}
			return x != y;
		}
		bool same(int x, int y) { return root(x) == root(y); }
		int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
		int size(int x) { return -data[root(x)]; }
	};
	int n;
	using edgetp = tuple<edgeT, int, int>;
	vector<edgetp>edges;
	UnionFind uf;
	normalMST(int n) :n(n), uf(n) {}
	void add_edge(int a, int b, edgeT c) {
		edges.emplace_back(c, a, b);
	}
	edgeT build() {
		sort(edges.begin(), edges.end());
		edgeT sum = 0;
		for (auto &it : edges) {
			edgeT c; int a, b;
			tie(c, a, b) = it;
			if (uf.same(a, b))continue;
			sum += c;
			uf.unionSet(a, b);
		}

		return sum;
	}
};
inline int in() { int in; scanf("%d", &in); return in; }
inline void outint(int out, bool endl = 1) { printf("%d%c", out, " \n"[endl]); }

int main() {
	int N = in();
	using tp = tuple<int, int, int>;
	vector<tp>edge(N);
	FOR(i, 0, N) {
		int x = in(), y = in();
		edge[i] = tp(x, y, i);
	}
	sort(ALL(edge), [](const tp&L, const tp&R) {
		if (get<0>(L) == get<0>(R))return get<1>(L) < get<1>(R);
		return get<0>(L) < get<0>(R);
	});
	normalMST<LL> mst(N);
	FOR(i, 0, N - 1) {
		int a = get<2>(edge[i]);
		int b = get<2>(edge[i + 1]);
		LL c = abs(get<0>(edge[i]) - get<0>(edge[i + 1]));
		mst.add_edge(a, b, c);
	}


	sort(ALL(edge), [](const tp&L, const tp&R) {
		if (get<1>(L) == get<1>(R))return get<0>(L) < get<0>(R);
		return get<1>(L) < get<1>(R);
	});

	FOR(i, 0, N - 1) {
		int a = get<2>(edge[i]);
		int b = get<2>(edge[i + 1]);
		LL c = abs(get<1>(edge[i]) - get<1>(edge[i + 1]));
		mst.add_edge(a, b, c);
	}

	cout << mst.build() << "\n";


}

Measured memory_bytes: 7792
#include <cstdio>
using namespace std;
int N;
int F [100][14];
int P [100][15];
int main ()
{
	scanf ("%d",&N);
	for ( int i=0;i<N;i++)
		for ( int j =0;j<10;j++)
			scanf ("%d",&F[i][j]);
	for ( int i =0; i <N;i++) 
		for ( int j =0; j <11; j ++) 
			scanf ("%d",&P[i][j]);
	int res = -(1<<30);
	for ( int b =1; b <(1<<10); b ++)
	{
		int cc =0;
		for ( int i =0; i <N;i ++)
		{
			int c =0;
			for ( int j =0; j <10; j ++) 
				if ((b >>j &1)&& F[i ][ j ])
					c ++;
			cc += P[i ][ c ];
		}
		if ( res < cc ) 
			res = cc ;
	}
	printf ("%d\n", res );
}

Measured memory_bytes: 128
def chmin(a, b):
  if a > b:
    return b
  else:
    return a

def main():
  dp = [1e12]*100010
  hs = [0]*100010
  
  N = int(input())
  hs[:N] = map(int, input().split())
  
  dp[0] = 0
  for i in range(N):
    dp[i+1] = chmin(dp[i+1], dp[i]+abs(hs[i+1]-hs[i]))
    dp[i+2] = chmin(dp[i+2], dp[i]+abs(hs[i+2]-hs[i]))
  print(dp[N-1])
  return

if __name__ == '__main__':
  main()

Measured memory_bytes: 15440
///CCCC
/*
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int mp[1010][1010];
int sum[1010][1010];
int main()
{
    int t,p=1;
    scanf("%d",&t);
    while(t--)
    {
        int r,c;
        scanf("%d %d",&r,&c);
        memset(mp,0,sizeof(mp));
        memset(sum,0,sizeof(sum));
        for(int i=1; i<=r; i++)
        {
            for(int j=1; j<=c; j++)
            {
                scanf("%d",&mp[i][j]);
            }
        }
        for(int i=1; i<=r; i++)
        {
            for(int j=1; j<=c; j++)
            {
                int max1;
                max1=max(mp[i+1][j],mp[i][j+1]);
                sum[r][c]+=max(mp[i+1][j+1],max1);
                 printf("%d***\n",sum[r][c]);
            }
        }
        printf("Scenario #%d:\n",p++);
        printf("%d\n",sum[r][c]);
        printf("\n");
    }
    return 0;
}*/
///EEE
/*
#define MAX_INT 0x3f3f3f3f
#define MIN_INT -MAX_INT
int v[4100],w[4100];
int dp[13000];
int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++)
    scanf("%d %d",&v[i],&w[i]);
    for(int i=0;i<n;i++)
    {
        for(int j=m;j>=v[i];j--)
        {
            dp[j]=max(dp[j],dp[j-v[i]]+w[i]);///啥意思？
        }
    }
    printf("%d\n",dp[m]);
    return 0;
}
*/

///FFFF
/*
int main()
{
    for(int j=m;j>=v[i];j--)
        {
            dp[j]=max( dp[j],dp[ j-v[i] ]+w[i] );
        }
    for(int j=v[i];j<=m;j++)
    {
        dp[i][j]=max( dp[j],dp[ j-v[i] ]+w[i] );
    }
    return 0;
}

*/
///DDDD
/*int a[41000];
int dp[41000];
int main()
{

    int T;
    scanf("%d",&T);
    while(T--)
    {
        int n;
        scanf("%d",&n);
        memset(a,0,sizeof(a));
        memset(dp,0,sizeof(dp));
        for(int i=0;i<n;i++)
            scanf("%d",&a[i]);
        int j=0;
        dp[0]=a[0];

        for(int i=1;i<n;i++)
        {
            if(a[i]>dp[j])
            {
                j++;
                dp[j]=a[i];
            }
            else
            {
                int pow=lower_bound( dp,dp+j,a[i] )-dp;
                dp[pow]=a[i];
                //printf("%d&&\n",pow);
            }
        }
        printf("%d\n",j+1);
    }
    return 0;
}*/
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
ll n,a[100100],sum=1,k=0;
int main()
{
    scanf("%lld",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a+1,a+1+n);
    for(int i=n; i>=2; i--)
    {
        if(a[i]==a[i-1])
        {
            sum*=a[i];
            i-=1;
            k++;
            //printf("%d***\n",k);
            if(k==2) break;
        }
    }
    if(k<2) printf("0\n");
    else  printf("%lld\n",sum);
    return 0;
}



Measured memory_bytes: 1024
/*  
    |\_/|
    |* *|
    \_+_/
*/
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int a,c;
  char b;

  cin>>a>>b>>c;

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

}


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

int main() {
  int n, a, max = 0, min = 0;

  cin >> n;
  cin >> min;
  max = min;
  for(int i = 1; i < n; i++) {
    cin >> a;
    if(a > max)
      max = a;
    else if(a < min)
      min = a;
  }

  cout << max - min << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a,b;
  cin >> a >> b;
  if(a==b){
    cout << "Draw" << endl;
  }else{
    if(a==1){
      a=14;
    }
    if(b==1){
      b=14;
    }
    if(a>b){
      cout << "Alice" << endl;
    }else{
      cout << "Bob" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;public class Main{static{Scanner s=new Scanner(System.in);while(s.hasNext()){double x=s.nextDouble();System.out.println(x<=48?"light fly":x<=51?"fly":x<=54?"bantam":x<=57?"feather":x<=60?"light":x<=64?"light welter":x<=69?"welter":x<=75?"light middle":x<=81?"middle":x<=91?"light heavy":"heavy");}System.exit(0);}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std; 
int main() 
{
	long long n;
	cin>>n;
	long long res=floor(log10(n)+1);
	for(long long i=sqrt(n);i>=2;i--)
	{
		if(n%i==0)
		{
			long long d1=floor(log10(i)+1);
			long long d2=floor(log10(n/i)+1);
			res=min(res,max(d1,d2));
			break;
		}
	}
	cout<<res;
}

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

const int maxn = 2e5 + 5;
int h[maxn];
ll dp[maxn];
int tree[4*maxn];
int trstp = 1;
int n;
ll c;

ll eval(int f, int x) {
  if (f == 0) return 1e18;
  return dp[f] + ll(h[x] - h[f])*(h[x] - h[f]) + c;
}

void update(int f, int root = 1, int s = 1, int e = n) {
  int mid = (s + e)/2;
  bool lless = eval(f, s) < eval(tree[root], s);
  bool rless = eval(f, mid) < eval(tree[root], mid);
  if (rless) {
    swap(f, tree[root]);
  }
  if (s == e) {
    return;
  } else if (lless != rless) {
    update(f, 2*root, s, mid);
  } else {
    update(f, 2*root + 1, mid + 1, e);
  }
}

ll query(int x, int root = 1, int s = 1, int e = n) {
  int mid = (s + e)/2;
  ll ans = eval(tree[root], x);
  if (s == e) {
    return ans;
  } else if (x <= mid) {
    return min(query(x, 2*root, s, mid), ans);
  } else {
    return min(query(x, 2*root + 1, mid + 1, e), ans);
  }
}

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

  while (trstp < n) trstp *= 2;
  for (int i = 1; i <= n; i++) {
    cin >> h[i];
  }

  dp[n] = 0;
  update(n);
  for (int i = n - 1; i >= 1; i--) {
    dp[i] = query(i);
    update(i);
  }

  cout << dp[1] << '\n';

  return 0;
}


Measured memory_bytes: 5760
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;
long long mod = 1000000000 + 7;




int main()
{
	int n;
	cin >> n ;
	vector<long long> x;
	vector<long long> y;
	for (int i = 0; i < n; i++) {
		long long xin, yin;
		cin >> xin >> yin;
		x.push_back(xin);
		y.push_back(yin);
	}

	int ans = 999999;
	int con = 0;
	for (int i1 = 0; i1 < n; i1++) {
		for (int i2 = 0; i2 < n; i2++) {
			long long p = x[i1] - x[i2];
			long long q = y[i1] - y[i2];
			if (p == 0 && q == 0) continue;
			for (int i3 = 0; i3 < n; i3++) {
				for (int i4 = 0; i4 < n; i4++) {
					if (x[i3] - x[i4] == p && y[i3] - y[i4] == q) {
						con++;
					}
					else {
					
					}

				}
			}
			ans = min(ans, n - con );
			con = 0;
		}
	}
	if (ans == 999999) {
		ans = 1;
	}
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

 int H, W, i, j;

 while(1)
 {
     scanf("%d %d", &H, &W);
     if(H == 0 && W == 0) break;
     for(i = 0; i < H; i++)
     {
         for(j = 0; j < W; j++)
         {
             if((i + j) % 2 == 0)
             {
                 printf("#");
             }
             else
             {
                 printf(".");
             }
         }
         printf("\n");
     }
     printf("\n");
 } 

 return 0;
}

Measured memory_bytes: 572
/**Hey, What's up?*/

#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<long long>v;
int main()
{
    fastio;
    long long a=0,b=0,c,d,e,f=0,l,g,m,n,k,i,j,t,p,q;
    cin>>n>>m;
    if(n<=m){
        for(i=0;i<m;i++)cout<<n;
    }
    else for(i=0;i<n;i++)cout<<m;
    return 0;
}


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = 1e9+7; typedef vector<ll> VL;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, m;
	cin >>n >>m;
	VL a(n), sm(n+1);
	rep(i, n) cin >>a[i];
	
	rep(i,n) sm[i+1] = (sm[i] + a[i])%m;
	ll ans =0;
	sort(all(sm));
	sm.push_back(-1);
	ll wa = 1;
	rep2(i, 1, sz(sm)){
		if(sm[i-1] == sm[i]) wa++;
		else{
			ans += wa * (wa -1) / 2;
			wa = 1;
		}
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
typedef unsigned long long ull;
#define MAX (ull)1000000000000000000
inline ull gcd(ull a, ull b){
	return b ? gcd(b, a%b) : a;
}
int main(){
	ull x, y, z, i;
	scanf("%llu %llu", &x, &y);
	z = gcd(x, y);
	if (z == y){
		puts("-1");
		return 0;
	}
	else {
		for (i = 2;x*i<=MAX; i++){
			if (x*i%y != 0){
				printf("%llu", x*i);
				return 0;
			}
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
LL N,M,K;
int main(){
    cin>>N>>M>>K;
    REP(i,N+1){
        REP(j,M+1){
            if(i*M+N*j-2*(i*j)==K){
               cout<<"Yes"<<endl;
               return 0;
            }
        }
    }
    cout<<"No"<<endl;
	return(0);
}

Measured memory_bytes: 256
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define MOD 1000000007;//1e9+7

void solve() {
    int a, b;
    cin >> a >> b;
    if (a > b)swap(a, b);
    for (int i = 0; i < b; i++)cout << a;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256