akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <vector> // vectors
#include <string> // string
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <unordered_map> // hashed by keys
#define _for(i,n) for(int i = 0; i < n; i++)

typedef long long ll; // at least int64 > 9*10^18
typedef unsigned long long ull; // at least uint64

std::vector<int> par;
int root(int i) {
  if(par[i]==i) return i;
  return par[i] = root(par[i]);
}

void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if(x==y)return;
  par[x] = y;
}

int main() {
  int n,m;
  std::cin >> n >> m;
  par.resize(n);
  std::iota(par.begin(),par.end(),0);
  int x;
  int y;
  int z;
  _for(i,m) {
    std::cin >> x >> y >> z;
    x--;y--;
    unite(x,y);
  }
  int count = 0;
  _for(i,n) {
    if(par[i]==i) {
      count++;
    }
  }
  std::cout << count << std::endl;

  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#define MAXN 3500
using namespace std;
int n;
double answer;
double p[MAXN];
double ans[MAXN][MAXN];
int main(){
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> p[i];
    }
    ans[1][1] = 1 - p[1];
    ans[1][2] = p[1];
    for (int i = 2; i <= n; i++){
        for (int j = 1; j <= n+1; j++){
            ans[i][j] = ans[i - 1][j] * (1 - p[i]) + ans[i - 1][j - 1] * p[i];
        }
    }
    /*for (int i = 1; i <= n+1; i++){
        for (int j = 1; j <= n+1; j++){
            cout << ans[j][i] << ' ';
        }
        cout << endl;
    }*/
    answer = 0;
    for (int i = n/2 + 1; i <= n; i++){
        answer += ans[n][i+1];
        //cout << ans[n][i+1] << ' ' << i+1 << ' ' << n << endl;
    }
    cout.fixed;
    cout.precision(12);
    cout << answer << endl;
}

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

int main(){
  int n; cin >> n;
  vector<long long> a(n + 1), b(n);
  for(int i = 0; i <= n; i++){
    cin >> a.at(i);
  }
  for(int i = 0; i < n; i++){
    cin >> b.at(i);
  }
  long long ans = 0;
  for(int i = 0; i < n; i++){
    if(a.at(i) + a.at(i + 1) <= b.at(i)){
      ans += a.at(i) + a.at(i + 1);
      a.at(i + 1) = 0;
    }
    else if(a.at(i) <= b.at(i)){
      ans += b.at(i);
      a.at(i + 1) -= (b.at(i) - a.at(i));
    }
    else{
      ans += b.at(i);
    }
  }
  cout << ans << endl;
}

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

int main()
{
    long long int x,y;
    cin>>x>>y;
    if(y==0)
    {
        if(x<=0)
        {
            cout<<abs(x)<<endl;
        }
        else
        {
            cout<<1+x<<endl;
        }
    }
    else if(x==0)
    {
        if(y>=0)
        {
            cout<<y<<endl;
        }
        else
        {
            cout<<1+abs(y)<<endl;
        }
    }
    else if(x<0&&y>=0||(x>=0&&y<0))
    {
        cout<<abs(abs(y)-abs(x))+1<<endl;
        return 0;
    }
    else if(y>=x&&y>=0&&x>=0)
    {
        cout<<y-x<<endl;
    }
    else if(y>=x&&y>=0&&x<0)
    {
        if(-x<=y)
        {
            int min1=min(1+y+x,y-x);
            cout<<abs(min1)<<endl;
        }
        else
        {
            cout<<abs(y-x)<<endl;
        }
    }
    else if(y>=x&&y<0&&x<0)
    {
        cout<<abs(y-x)<<endl;
    }
    else if(y<x&&x>=0&&y>=0)
    {
        cout<<2+abs(-y+x)<<endl;
    }
    else if(y<x&&x>=0&&y<0)
    {
        cout<<1+abs(y+x)<<endl;
    }
    else if(y<x&&y<0&&x<0)
    {
        cout<<2+abs(y)-abs(x)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{

    int d;

    scanf("%d", &d);

    if(d == 25){
        printf("Christmas\n");
    }

    else if(d == 24){
        printf("Christmas Eve\n");
    }

    else if(d == 23){
        printf("Christmas Eve Eve\n");
}

    else
        printf("Christmas Eve Eve Eve\n");


    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    li n, l, t;
    cin >> n >> l >> t;

    vector<li> xs(n), vs(n);
    for (int i = 0; i < n; ++i) {
        cin >> xs[i] >> vs[i];
        if (vs[i] == 2) {
            vs[i] = -1;
        }
    }

    li swaps = 0;
    for (int i = 0; i < n; ++i) {
        if (vs[i] == vs[0]) {
            continue;
        }
        li offset;
        if (vs[0] == 1) {
            offset = xs[i] - xs[0];
        } else {
            offset = xs[0] + (l - xs[i]);
        }

        swaps += (2 * t + l - offset) / l;
    }
    swaps %= n;

    li zero_owner;
    if (vs[0] == 1) {
        zero_owner = swaps;
    } else {
        zero_owner = (n - swaps) % n;
    }

    vector<li> results(n);
    for (int i = 0; i < n; ++i) {
        results[i] = ((xs[i] + t * vs[i]) % l + l) % l;
    }

    li zero_pos = results[0];
    sort(results.begin(), results.end());

    li owner_index;
    if (vs[0] == 1) {
        owner_index = (upper_bound(results.begin(), results.end(), zero_pos) - results.begin()) - 1;
    } else {
        owner_index = lower_bound(results.begin(), results.end(), zero_pos) - results.begin();
    }
    // results[owner_index] = ans[zero_owner]

    for (int i = 0; i < n; ++i) {
        int j = (i + owner_index - zero_owner + n) % n;
        cout << results[j] << endl;
    }

    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

template <ll Mod>
struct ModInt {
  ll n;
  ModInt(const ll x = 0) : n(x) { while (n < 0) n += Mod; n %= Mod; }
  ModInt operator+(const ModInt r) const { return ModInt(*this) += r; }
  ModInt operator-(const ModInt r) const { return ModInt(*this) -= r; }
  ModInt operator*(const ModInt r) const { return ModInt(*this) *= r; }
  ModInt operator/(const ModInt r) const { return ModInt(*this) /= r; }
  ModInt &operator+=(const ModInt r) { n += r.n; if (n >= Mod) n -= Mod; return *this; }
  ModInt &operator-=(const ModInt r) { if (n < r.n) n += Mod; n -= r.n; return *this; }
  ModInt &operator*=(const ModInt r) { n = n * r.n % Mod; return *this; }
  ModInt &operator/=(const ModInt r) { return *this *= r.inv(); }
  ModInt pow(ll x) const { ModInt<Mod> ret(1), tmp(*this); while (x) { if (x&1) ret *= tmp; tmp *= tmp; x >>= 1; } return ret; }
  ModInt inv() const { return pow(Mod-2); }
  friend ostream& operator<<(ostream& os, const ModInt& obj) { return os << obj.n; }
  friend istream& operator>>(istream& is, ModInt& obj) { ll t; is >> t; obj = ModInt(t); return is; }
};
constexpr ll mod = 1000000007;
using mint = ModInt<mod>;
mint operator"" _mi(unsigned long long n) { return mint(n); }

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

  ll n;
  cin >> n;
  vl c(n);
  rep(i, n) {
    cin >> c[i];
  }

  c.erase(unique(all(c)), c.end());
  n = c.size();

  constexpr ll maxi = 200'000;
  vector<mint> sum(maxi+1);
  vector<mint> dp(n+1);
  dp[0] = 1_mi;

  rep(i, n) {
    dp[i+1] = dp[i] + sum[c[i]];
    sum[c[i]] = dp[i+1];
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 4992
from collections import Counter
n = int(input())
l = list(map(int,input().split()))
c = Counter(l)
mod = 998244353
if l.count(0) != 1 or l[0] != 0:
    print(0)
    exit()
ans = 1
for i in l[1:]:
    ans *= c[i-1]
    ans %= mod
print(ans%mod)


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

int main(){
  int n;
  cin >> n;
  if(n%2==0)
    cout << 0.5000000000;
  else
    cout << std::setprecision(10) << (double)(n/2+1)/n;
}

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

int main () {

    int N;
    string A, B, C;
    cin >> N >> A >> B >> C;

    int ans = 0;

    for (int i = 0; i < N; i++) {
        if (A[i] != B[i] && B[i] != C[i] && C[i] != A[i]) {
            ans += 2;
        }
        else if (A[i] == B[i] && B[i] != C[i] && C[i] != A[i]) {
            ans += 1;
        }
        else if (A[i] != B[i] && B[i] == C[i] && C[i] != A[i]) {
            ans += 1;
        }
        else if (A[i] != B[i] && B[i] != C[i] && C[i] == A[i]) {
            ans += 1;
        }

    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 100005

int main(){

    string s;
    cin >> s;
    int count = 0;
    for(int i = 0;i < 3;i++){
        if(s[i] == 'o'){
            count++;
        }
    }
    cout << 700+count*100 << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input()) 
A = [int(x) for x in input().split()]

L = {}
for i in A:
    if i in L:
        L[i] += 1
    else:
        L[i]= 1

L2 = []
for i in L:
    L2.append(L[i]*(L[i]-1)/2)
    
res = sum(L2)
for i in A:
    print(int(res - L[i] + 1))
    



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

#define M_PI 3.14159265358979323846

using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a) * (a))
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

//repetition
//------------------------------------------
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
//#define MOD 1000000007

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-8;

#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

#define MOD 1000000007
class UnionFind
{
public:
    vector<int> par;
    vector<int> siz;

    UnionFind(int sz_) : par(sz_), siz(sz_, 1)
    {
        for (int i = 0; i < sz_; ++i)
            par[i] = i;
    }
    void init(int sz_)
    {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i)
            par[i] = i;
    }

    int root(int x)
    {
        while (par[x] != x)
        {
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool merge(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (siz[x] < siz[y])
            swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(int x, int y)
    {
        return root(x) == root(y);
    }

    int size(int x)
    {
        return siz[root(x)];
    }
};

ll modPow(ll x, ll n, ll mod = MOD)
{
    if (n == 0)
        return 1;
    ll res = 1;
    while (n)
    {
        if (n & 1)
            res = (res * x) % mod;

        res %= mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

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

    int N, K;
    cin >> N >> K;
    vector<double> p(N);

    double ans = 0.0;

    double tmp = 0.0;
    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
    }

    for (int i = 0; i < K; i++)
    {
        tmp += p[i] * (p[i] + 1) / 2 / p[i];
    }

    ans = tmp;
    for (int i = K; i < N; i++)
    {
        tmp -= p[i - K] * (p[i - K] + 1) / 2 / p[i - K];
        tmp += p[i] * (p[i] + 1) / 2 / p[i];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  LLI n,k;
  while(cin >> n >> k){
    vector<LLI> a(n); cin >> a;


    vector<LLI> b;
    REP(i,n) b.push_back(a[i]);
    REP(i,n) b.push_back(a[i]);

    vector<vector<LLI>> poss(400000);
    REP(i,2*n){
      poss[b[i]].push_back(i);
    }
    
    vector<LLI> next(n);
    REP(i,n){
      next[i] = *upper_bound(ALL(poss[a[i]]), i);
      if(next[i] >= n) next[i] -= n;
    }

    // join(cerr, ALL(next));

    LLI cycle = 1;

    LLI j = 0;
    vector<LLI> last;
    
    REP(i,n){
      if(next[j] <= j){
        ++cycle;
        last.push_back(j);
      }

      (j = next[j]+1) %= n;

      if(j==0) break;
    }

    //join(cerr, ALL(last));

    //cerr << cycle << endl;

    k %= cycle;

    //  cerr << k << endl;

    vector<LLI> ans;

    if(k!=0){
      FOR(i,last[k-1],n){
        if(next[i] > i and next[i] < n){
          //cerr  << i << " : " << next[i] << endl;
          i = next[i];
        }else{
          ans.push_back(a[i]);
        }
      }
    }

    

    
    
    join(cout, ALL(ans));
  }
  
  return 0;
}


Measured memory_bytes: 29036
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        for(int i = 0; i < h; i++){
            String s = sc.next();
            System.out.println(s);
            System.out.println(s);
        }
    }
}

Measured memory_bytes: 23892
//Leonidas
#pragma GCC optimize("Ofast")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container'.',hpp>
//#include <ext/pb_ds/tree_policy'.',hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define pll pair<ll,ll>
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define M_PI 3.14159265358979323846
//#define int long long
const int mod=1000000007;
//const int mod=1009;
//const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.000000000000000000001;
using namespace std;
int T[200005];
int32_t main()
{
    speed
    int n;
    cin>>n;
    int ksor=0;
    for(int i=1;i<=n;i++)
    {
        cin>>T[i];
        ksor^=T[i];
    }
    for(int i=1;i<=n;i++)
    {
        cout<<(ksor^T[i])<<" ";
    }
    return 0;
}


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

using namespace std;


int main() {
	string s;
	cin >> s;
	
	string res = "";

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0') res += "0";
		else if (s[i] == '1') res += "1";
		else {
			if (res.size() > 0) {
				res.erase(res.size() - 1);
			}
		}
	}

	cout << res;
}


Measured memory_bytes: 256
#include <stdio.h>
int main () {
	
	char s[10];
	for(int i=0; i<10; i++){
		scanf("%c", &s[i]);
	}
	
	printf("2018");
	for (int i=4; i<10; i++){
		printf("%c", s[i]);
	}
	
	return 0;
}

Measured memory_bytes: 1668
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MOD = 1000000007;

long exp_mod(long long a, long long b, long m) {
	long long res = 1;
	while (b > 0) {
		if (b&1)
			res = (res * a)%m;
		a = (a * a)%m;
		b >>= 1;
	}
	return (long)res;
}

long fact_mod(long n, long m) {
	long long res = 1;
	for (long i=n; i>0; --i)
		res = (res * i)%m;
	return (long)res;
}

long comb_mod(long n, long r) {
	long long res = 1;
	for (long i=0; i<r; ++i)
		res = (res * (n - i) )%MOD;
	return ( res * exp_mod(fact_mod(r, MOD), MOD-2, MOD) ) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

struct Pony
{
    int x,y;

    Pony(int x_, int y_)
    {
        x = x_;
        y = y_;
    }

    bool operator<(const Pony &another) const
    {
        return x < another.x;
    };
};

long modinv(long a, long m) {
    long b = m, u = 1, v = 0;
    while (b) {
        long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

  long n,x;
  cin >> n>>x;

  vector<long> l(n);
  fillLong(l, n);

  long cnt = 1;
  long d = 0;
  
  rep(i, n) {
    d = d + l[i];
    if (d <= x) cnt++;
    else break;
  }

  cout << cnt << endl;
}



Measured memory_bytes: 888
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int main()
{
    long long int n,i,minn=0,t;
    char s[300005];
    scanf("%lld",&n);
    scanf("%s",s);
    for(i=1;i<n;i++)
    {
        if(s[i]=='E')
            minn++;
    }
    t=minn;
    for(i=1;i<n;i++)
    {
        if(s[i]=='E'&&s[i-1]=='E')
            t--;
        if(s[i]=='W'&&s[i-1]=='W')
            t++;
        if(t<minn)
            minn=t;
    }
    printf("%lld\n",minn);
    return 0;
}


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

namespace CF2017qA
{
    class C
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int H = input[0];
            int W = input[1];

            char[,] HW = new char[H, W];
            int[] cCount = new int[26];
            for (int h = 0; h < H; h++)
            {
                string a = Console.ReadLine();
                for (int w = 0; w < W; w++)
                {
                    HW[h, w] = a[w];
                    cCount[a[w] - 'a']++;
                }
            }

            if (H % 2 == 0 && W % 2 == 0)
            {
                for (int i = 0; i < cCount.Length; i++)
                {
                    if (cCount[i] % 4 != 0) { Console.WriteLine("No"); return; }
                }
                Console.WriteLine("Yes"); return;
            }

            if (H % 2 != 0 && W % 2 != 0)
            {
                for (int i = 0; i < cCount.Length; i++)
                {
                    cCount[i] %= 4;
                }

                int ecount = 0;
                int ocount = 0;
                for (int i = 0; i < cCount.Length; i++)
                {
                    if (cCount[i] != 0 && cCount[i] % 2 == 0) ecount++;
                    else if (cCount[i] % 2 != 0) ocount++;
                }

                if (ecount < (W + H) / 2 && ocount == 1)
                {
                    Console.WriteLine("Yes"); return;
                }
                else
                {
                    Console.WriteLine("No"); return;
                }
            }

            if (H % 2 == 0 || W % 2 == 0)
            {
                for (int i = 0; i < cCount.Length; i++)
                {
                    cCount[i] %= 4;
                }

                int count = 0;
                for (int i = 0; i < cCount.Length; i++)
                {
                    if (cCount[i] != 0 && cCount[i] % 2 == 0) count++;
                    else if (cCount[i] % 2 != 0) { Console.WriteLine("No"); return; }
                }

                if (H % 2 == 0 && count <= H / 2)
                {
                    Console.WriteLine("Yes"); return;
                }
                else if (W % 2 == 0 && count <= W / 2)
                {
                    Console.WriteLine("Yes"); return;
                }
                else
                {
                    Console.WriteLine("No"); return;
                }
            }
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <math.h>
#include<iomanip>
using namespace std;

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

  int X = ceil(N / 1.08);
  
  if(floor(X*1.08)!=N){
    cout << ":(";
  }
  else{
    cout << X;
  }
  
  return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

ll n, a[100005], dp[100005];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i=1; i<=n; i++)
        cin >> a[i];
    dp[0]=1e9;
    for(int i=2; i<=n; i++)
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
    cout << dp[n];
    return 0;
}


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

namespace ABC113_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var TA = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var T = TA[0];
            var A = TA[1];
            var H = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var tl = H.Select(x => T - x * 0.006).ToArray();

            var min = 100000000.0;
            var a = 0;
            for (int i = 0; i < tl.Length; i++)
            {
                if (Math.Abs(A-tl[i]) < min)
                {
                    min = Math.Abs(A - tl[i]);
                    a = i + 1;
                }
            }
            Console.WriteLine(a);
        }
    }
}


Measured memory_bytes: 13312
import java.util.Scanner;
import java.lang.Math;
import java.math.BigInteger;

public class Main{
    public static void main(String args[]){
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        BigInteger nk = BigInteger.valueOf(n / k);
        BigInteger nk2 = BigInteger.valueOf(n / 2);
        BigInteger nk3 = BigInteger.valueOf((n / 2) + 1);
        BigInteger nk4 = BigInteger.valueOf((n / k) + 1);
        if(k % 2 != 0){
            System.out.println(nk.pow(3));
        }else{
            if(k - (k / 2) == 1){
                if(n % 2 == 0){
                    System.out.println(nk.pow(3).add(nk2.pow(3)));
                }else{
                    System.out.println(nk.pow(3).add(nk3.pow(3)));
                }
            }else{
                if(n - ((n / k) * k) >= k / 2){
                    System.out.println(nk.pow(3).add(nk4.pow(3)));
                }else{
                    System.out.println(nk.pow(3).add(nk.pow(3)));
                }
            }
        }
    }
}

Measured memory_bytes: 23508
package main

import (
	"fmt"
)

func main() {
	var x int
	fmt.Scanf("%d", &x)

	fmt.Println(answer(x))
}

func answer(x int) int {
	var fiveHundred = x / 500
	var five = (x % 500) / 5
	return fiveHundred*1000 + five*5
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

using ll = long long;

ll factorial(ll x) {
    if (x==0 || x==1) return 1;
    return ((x % 1000000007) * factorial(x-1)) % 1000000007;
}

int main() {
    ll n, m;
    cin >> n >> m;
    ll a = max(n, m);
    ll b = min(n, m);
    if ( a > b+1 ) {
        cout << 0 << endl;
    } else if ( a == b+1 ) {
        ll temp = factorial(b);
        cout << (temp*factorial(a)) % 1000000007 << endl;
    } else if(a == b) {
        ll temp = factorial(b);
        cout << (temp*temp*2)% 1000000007 << endl;
    }
}

Measured memory_bytes: 1792
#include <cstdio>
using namespace std;
int main()
{
	int n,m,i,j=0;
	scanf("%d",&n);
	for(i=0;i<3;i++)
	{
		m=n%10;
		n/=10;
		if(m==1)
		{
			j+=1;
		}
	}
	printf("%d",j);
        return 0;
} 

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;
#define LL long long
const int N = 1e5+5;
int x[N];

int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	int ans=0x3f3f3f3f;
	for(int i=1;i<=n;i++)
		scanf("%d",&x[i]);

	for(int i=1;i<=n-k+1;i++){
		int l=i,r=i+k-1;
		if(x[l]<=0&&x[r]<=0){
			ans=min(ans,-x[l]);
		}
		else if(x[l]<=0&&x[r]>=0){
			ans=min(ans,-2*x[l]+x[r]);
			ans=min(ans,-x[l]+2*x[r]);
		}else{
			ans=min(ans,x[r]);
		}
	}
	printf("%d\n",ans);



	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main()
{
    ll N;
    cin >> N;
    vector<string> S(N);
    rep(i, N)
    {
        cin >> S[i];
    }
    sort(all(S));
    vector<ll> cnt(0);      //文字列カウンタ。もともと1入れとく
    vector<string> memo(0); //文字列メモ
    int j = 0;
    cnt.pb(1);
    memo.pb(S[0]);
    rep1(i, N)
    {
        if (S[i] == S[i - 1])
        {
            cnt[j]++;
        }
        else //いきなり切り替わってもカウンタは1入る
        {
            cnt.pb(1);
            memo.pb(S[i]); //切り替わったら文字列追加
            j++;
        }
    }
    ll mxcnt = *max_element(all(cnt));
    rep(i, cnt.size())
    {
        if (cnt[i] == mxcnt)
        {
            cout << memo[i] << endl;
        }
    }
    return 0;
}


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

int d[10];
int main() {
    ios::sync_with_stdio(false);
    int n, k;

    cin >> n >> k;

    for (int i = 0; i < k; i++) {
        int t;
        cin >> t;
        d[t]++;
    }

    for (int i = n; ; i++) {
       int t = i;
       bool isValid = true;
       while (t) {
            int num = t % 10;
            if (d[num] != 0) {
                isValid = false;
                break;
            }
            t /= 10;
       }
       if (isValid) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


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

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

  vector<int> vec(num);
  for(int i = 0; i < num; ++i) cin >> vec.at(i);

  int counter = 0;
  for(int i = 0; i <= num - 3; ++i){
    int maxi = max(max(vec.at(i), vec.at(i + 1)), vec.at(i + 2));
    int mini = min(min(vec.at(i), vec.at(i + 1)), vec.at(i + 2));
    bool one = (maxi == vec.at(i) && mini == vec.at(i + 2));
    bool two = (maxi == vec.at(i + 2) && mini == vec.at(i));
    if(one || two) ++counter;
    else continue;
    }

  cout << counter << endl;

  return 0;
  
}


Measured memory_bytes: 256
INF = 1000000007


def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30\
            if 0 < min(a, b, c) else INF

    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    ret4 = dfs(cur + 1, a, b, c)

    return min(ret1, ret2, ret3, ret4)


N, A, B, C = map(int, input().split())

l = [int(input()) for i in range(N)]

print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 

const int mod = 1000000007;
const int inf = 1e9;

int main(){
    int n, m;
    cin >> n >> m;
    cout << n*(n-1)/2+m*(m-1)/2;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<string>
#include<utility>
#include<iomanip>
#include<bitset>
#include<math.h>
using namespace std;
 
 
int main(){
 
	long long a,b;
	cin >> a >> b;
	if(b > a){
		swap(a,b);
	}
	if((b-a)%2 == 0){
		cout << a+((b-a)/2) << endl;
	}else{
		cout << "IMPOSSIBLE" << endl;
	}
	
}

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


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

ll c,k,a[100005],dp[100005];

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n>>c>>k;

rep(i,1,n)cin>>a[i];

sort(a+1,a+n+1);

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

rep(i,2,n)
{
	int id=lower_bound(a+1,a+n+1,a[i]-k)-a;
	id--;
	if(i-id>c)id=i-c;
	dp[i]=dp[id]+1;
}
ol(dp[n]);

return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;

    vector<int> A(N, 0);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }

    vector<int> indices(N);
    iota(indices.begin(), indices.end(), 0);

    sort(indices.begin(), indices.end(), [&A](size_t i1, size_t i2){
        return A[i1] < A[i2];
    });
    
    for(auto v : indices){
        cout << v+1 << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;

const int N = 1e5 + 5;
int n , A[N],B[N],C[N],DP[N][101];
int calc(int idx , char pre_value){
    if (idx == n)return 0;
    if (DP[idx][pre_value] != -1)return DP[idx][pre_value];
    int a = 0 , b = 0 , c = 0;
    if (pre_value == 'X'){
        a = calc(idx + 1 , 'a') + A[idx];
        b = calc(idx + 1 , 'b') + B[idx];
        c = calc(idx + 1 , 'c') + C[idx];
        return DP[idx][pre_value] = max(a , max(b,c));
    }
    if (pre_value == 'a'){
        b = calc(idx + 1 , 'b') + B[idx];
        c = calc(idx + 1 , 'c') + C[idx];
        return DP[idx][pre_value] = max(b , c);
    }
    if (pre_value == 'b'){
        a = calc(idx + 1 , 'a') + A[idx];
        c = calc(idx + 1 , 'c') + C[idx];
        return DP[idx][pre_value] = max(a,c);
    }
    if (pre_value == 'c'){
        b = calc(idx + 1 , 'b') + B[idx];
        a = calc(idx + 1 , 'a') + A[idx];
        return DP[idx][pre_value] = max(a , b);
    }
}

int main(){
    fastIO;
    cin>>n;
    memset(DP,-1,sizeof DP);
    for(int i = 0 ; i<n ; i++){
        cin>>A[i]>>B[i]>>C[i];
    }
    cout<<calc(0,'X');
}


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

using namespace std;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int maximum = max(a, b);
    maximum = max(maximum, c);
    int sum = a + b + c - maximum;
    for(int i = 1; i <= k; ++i) maximum = 2 * maximum;
    sum += maximum;
    cout << sum << endl;
    return 0;
}


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

int main()
{
  ll n;
  cin>>n;
  vector<ll>a(n);
  for(ll i=0;i<n;i++)
    cin>>a[i];
  ll mx=a[0],mn=a[0];
  ll count=1;
  for(ll i=1;i<n;i++)
  {
    if(a[i]<mn)
      count++;
    mn=min(a[i],mn);
    mx=max(a[i],mx);
    //cout<<mx<<" ";
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
int h,w;
int map[1001][1001];
int dx[9]={1,1,1,0,0,0,-1,-1,-1},dy[9]={1,0,-1,1,0,-1,1,0,-1};
int qx[1000001],qy[1000001],ql[1000001];
int head=0,tail=0;
void BFS(int y,int x,int len){
	map[y][x]--;
	for(int i=0;i<9;i++){
		if(x+dx[i]>=0&&x+dx[i]<w&&y+dy[i]>=0&&y+dy[i]<h){
			map[y+dy[i]][x+dx[i]]--;
			if(map[y+dy[i]][x+dx[i]]==0){
				qx[tail]=x+dx[i],qy[tail]=y+dy[i];
				ql[tail]=len+1;
				tail++;
			}
		}
	}
}
int main(){
	cin>>h>>w;
	char z;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>z;
			if(z=='.'){
				map[i][j]=0;
				qy[tail]=i,qx[tail]=j;
				ql[tail]=0;
				tail++;
			}
			else map[i][j]=z-'0';
		}
	}
	int ans=0;
	while(true){
		if(head==tail)break;
		ans=max(ans,ql[head]);
		BFS(qy[head],qx[head],ql[head]);
		head++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 16792
#!/usr/bin/env python3
#AGC12 A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
a.sort(reverse = True)
ans = 0
for i in range(1,2*n,2):
    ans += a[i]
print(ans)


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



int main(){
  int a,b = 0;
  cin >> a >> b;

  if(a > b){
    rep(i,a){
      cout << b;
    }
    return 0;
  }
  else{
    rep(i,b){
      cout << a;
    }
    return 0;
  }
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

static const int MAX = 100010;

int n, m, k;
vector<pair<int, int>> G[MAX];
bool used[MAX];

int prim() {
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
    memset(used, 0, sizeof(used));
    que.push(make_pair(0, 0));
    int ret = 0;
    while(!que.empty()) {
        int cst = que.top().first;
        int v = que.top().second;
        que.pop();
        if (used[v]) continue;
        used[v] = 1;
        ret += cst;
        for (int i = 0; i < G[v].size(); i++) {
            que.push(make_pair(G[v][i].first, G[v][i].second));
        }
    }
    return ret;
}

int main()
{
    int n;
    cin >> n;
    vector<ll> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];

    using pint = pair<int, int>;
    using Edge = pair<ll, pint>;
    vector<Edge> edges;

    vector<int> ids(n);
    iota(ids.begin(), ids.end(), 0);
    sort(ids.begin(), ids.end(), [&](int i, int j) {return x[i] < x[j];});
    rep(i, ids.size()-1) {
        int u = ids[i], v = ids[i+1];
        G[u].push_back(make_pair(x[v] - x[u], v));
        G[v].push_back(make_pair(x[v] - x[u], u));
    }

    sort(ids.begin(), ids.end(), [&](int i, int j) {return y[i] < y[j];});
    rep(i, ids.size()-1) {
        int u = ids[i], v = ids[i+1];
        G[u].push_back(make_pair(y[v] - y[u], v));
        G[v].push_back(make_pair(y[v] - y[u], u));
    }

    cout << prim() << endl;

    return 0;
}

Measured memory_bytes: 12408
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;

int w,h;
int s[50][50];

void dfs(int y,int x){
	s[y][x] = 0;
	for(int i = y-1; i <= y+1; i++) for(int j = x-1; j <= x+1; j++){
		if(0 <= i && i < h && 0 <= j && j < w){
			if(s[i][j]){
				dfs(i,j);
			}
		}
	}
}

int main(){
 
	while(cin>>w>>h,w||h){
		 FOR(i,h) FOR(j,w) cin>>s[i][j];
		 int ans = 0;
		 FOR(i,h) FOR(j,w){
			 if(s[i][j]){
				 dfs(i,j);
				 ans++;
			 }
		 }
		 cout << ans << endl;
	}
    return 0;
}

Measured memory_bytes: 1352
#include<bits/stdc++.h>
using namespace std;
map<int,int>mp;
int a[100005];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		mp[a[i]]++;
	}
	sort(a,a+n);
	long long x=0;
	for(int i=n;i>=0;i--)if(mp[a[i]]>=2){x=a[i];break;}
	mp[x]-=2;
	long long y=0;
	for(int i=n;i>=0;i--)if(mp[a[i]]>=2){y=a[i];break;}
	printf("%lld\n",x*y);
	return 0;
}

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

int main(int argc, char const *argv[])
{
    int X, A, B;
    cin>>X>>A>>B;
    bool flag = 0;
    for(int i=A;i<=B;i++){
        if(i%X==0){
            flag = 1;
            break;
        }
    }
    if (flag)
        cout<<"OK\n";
    else
    {
        cout<<"NG\n";
    }
    
    return 0;
}


Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 


#x,y = [int(i) for i in readline().split()]
#n = int(input())

n,t = [int(i) for i in readline().split()]
ab = [[int(i) for i in readline().split()] for i in range(n)]

from operator import itemgetter


ab.sort(key = itemgetter(1), reverse = True)
ab.sort(key = itemgetter(0))

dp = [0]*(t)
val = 0

#print(ab)

for a,b in ab:
    for i in range(max(0,t-a),t):
        val = max(val,dp[i]+b)
    
    for i in range(t-1,-1,-1):
        if i-a >= 0:
            if dp[i-a] != 0 or i==a:
                dp[i] = max(dp[i], dp[i-a] + b)
        else:
            break
    #print(dp,val)

print(max(max(dp),val))



Measured memory_bytes: 44524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    ll n, k, q;
    cin >> n >> k >> q;
    vector<ll> A(n, k);
    repi(i, q, 0)
    {
        ll tmp;
        cin >> tmp;
        A.at(tmp-1)++;
    }
    repi(i,n,0){
        cout << (A.at(i)-q>0?"Yes":"No") << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
def main():
    n = int(input())
    pt = []
    for _ in range(n):
        x,y = map(int,input().split())
        pt.append([x,y])
    a,b,c = [],[],[]
    for p in pt:
        a.append(p[0]+p[1])
        b.append(p[0]-p[1])
        c.append(p[1]-p[0])
    ans = 0
    if max(a)-min(a)>ans:
        ans = max(a)-min(a)
    if max(b)-min(b)>ans:
        ans = max(b)-min(b)
    if max(c)-min(c)>ans:
        ans = max(c)-min(c)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 63056
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <map>
using namespace std;
#define REP(n) for(int i=0;i<n;i++)
long long al[51] = { 0 };
long long pans[51] = { 0 };

int type_cnt[100001] = { 0 };
long long func(long long N, long long X) {
	if (N == 0) {
		if (X >= 1) {
			return 1;
		}
		else {
			return 0;
		}
	}

	if (X <= 1 + al[N - 1]) {
		return func(N - 1, X - 1);
	}
	else if (X <= 2 + al[N - 1]) {
		return pans[N-1]+1;
	}
	else{
		return pans[N - 1] + 1 + func(N-1,X-al[N-1]-2);
	}
}



int main() {
	long long N,X;
	long long ans = 0;
	cin >> N >> X;
	al[0] = 1;
	pans[0] = 1;
	for (int i = 1; i < N;i++) {
		al[i] = al[i - 1] * 2 + 3;
		pans[i] = 2 * pans[i - 1] + 1;
	}


	ans = func(N, X);

	cout << ans << endl;
	return 0;
}

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

int main(){
    ll N;
    cin >> N;
    set<ll> A;
    while(N--){
        ll a; cin >> a;
        A.insert(a);
    }

    ll M;
    cin >> M;
    set<ll> B;
    while(M--){
        ll b; cin >> b;
        B.insert(b);
    }

    vector<ll> C;
    set_symmetric_difference(ALL(A), ALL(B), back_inserter(C));

    for(ll c : C){
        p(c);
    }

    return 0;
}


Measured memory_bytes: 25800
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 998244353;

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

  int n; cin >> n;
  vector<int> pos(n);
  rep(i, n) {
    int a; cin >> a;
    a--;
    pos.at(a) = i;
  }

  set<int> st;
  st.insert(-1);
  st.insert(n);

  ll ans = 0;
  rep(i, n) {
    int p = pos.at(i);
    st.insert(p);
    auto it = st.find(p);
    ll e = p - *prev(it, 1);
    ll f = *next(it, 1) - p;
    //debug(e); debugln(f);
    ans += e*f*(i+1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
using namespace std;


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

	int min = abs(l) + n;
	int min_v = 0;
	int ans = 0;
	for(int i=0;i<n;i++){
		ans += l+i;
		if(min > abs(l+i)){
			min = abs(l+i);
			min_v = l+i;
		}
	}
	cout << ans - min_v << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x,y;
		while (scan.hasNextInt()) {
			x=scan.nextInt();
			y=scan.nextInt();
			System.out.println(String.valueOf(x+y).length());
		}
	}
}

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

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

  string s;
  cin >> s;
  int n = s.size(), count = 1;
  vector<int> r(n, 0), l(n, 0);

  r[0] = 1, l[n - 1] = 1;
  rep(i, 1, n) {
    if (s[i] == 'R') r[i] = r[i - 1] + 1;
  }
  repr(i, 0, n - 1) {
    if (s[i] == 'L') l[i] = l[i + 1] + 1;
  }

  vector<int> ans(n, 0);
  rep(i, 0, n - 1) {
    if (r[i] != 0 && r[i + 1] == 0) {
      int a = r[i], b = l[i + 1];
      ans[i] = (a - 1) / 2 + b /2 + 1;
      ans[i + 1] = (b - 1) / 2 + a /2 + 1;
      i++;
    }
  }

  rep(i, 0, n) {
    if (i != 0) cout << " ";
    cout << ans[i];
  }
  cout << endl;
}


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


int main()
{
	
	int n ; 
	 cin>>n;
	 vector<int> h ;
	 for(int i  =0;i<n;i++)
	 {
	 	int a;
	 	cin>>a;
	 	h.push_back(a);
	 	
	 }
	 
	 
	 vector<int>dp(n+1,0);
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i =2;i<n;i++)
	{
		dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
	}
	
	cout<<dp[n-1];
	 return 0 ;
}


Measured memory_bytes: 1144