akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a))
#define RSort(a) reverse(All(Sort(a)))
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibutan(auto a,auto b);
class Modulo{
public:
    int val;
    static const int mod = 1e9+7;
    vector<int> factable = {1};
    vector<int> invtable = {1};
    int pro(int x,int y){return ((x%mod)*(y%mod))%mod;}
    int sum(int x,int y){return ((x%mod)+(y%mod))%mod;}
    int dif(int x,int y){int d =((x%mod)-(y%mod))%mod;if(d>=0){return d;}else{return d+mod;}}
    int quo(int x, int y){return pro(x,pow(y,mod-2));}
    int pow(int x,int y){
        if(y<=0){return 1;}
        if(y%2==0){int d = pow(x,y/2);return ((d%mod)*(d%mod))%mod;}
        else{return (x*pow(x,y-1))%mod;}
    }
    void operator=(int n){this->val = n%mod;}
    int operator+(int n){return sum(this->val,n);}
    int operator-(int n){return dif(this->val,n);}
    int operator*(int n){return pro(this->val,n);}
    int operator/(int n){return quo(this->val,n);}
    void operator+=(int n){this->val = sum(this->val,n);}
    void operator-=(int n){this->val = dif(this->val,n);}
    void operator*=(int n){this->val = pro(this->val,n);}
    void operator/=(int n){this->val = quo(this->val,n);}
    int fac(int x){
        //x! mod mod
        if(factable.size()<=x){
            int s = factable.size();
            FOR(i,s,x+1){
                factable.push_back(pro(i,factable.back()));
                invtable.push_back(quo(1,factable.back()));
            }
        }
        if(x<0) return 1;
        else return factable[x];
    }
    int facinv(int x){
        if(invtable.size()<=x){
            int s = invtable.size();
            FOR(i,s,x+1){
                factable.push_back(pro(i,factable.back()));
                invtable.push_back(quo(1,factable.back()));
            }
        }
        if(x<0) return 1;
        else return invtable[x];
    }
    int com(int x,int y){
        //xCy mod mod = x!/((x-y)!*y!) mod mod
        if(x-y<y)return com(x,x-y);
        return pro(fac(x),pro(facinv(x-y),facinv(y)));
    }
};


signed main(){
    int n,m;
    cin >> n >> m;
    Modulo o;
    o.val = 0;
    int ans = 1;
    for(int i = 2; i <= m;i++){
        int count = 0;
        while(m%i==0){
            count++;
            m/=i;
        }
        if(count!=0) ans *= o.com(n+count-1,count);
        ans %= max_int;
    }
    cout << ans << endl;

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibutan(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    return x-1;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,k;
char s[125252];

const int B = 10007;
// hash[i] := [0,i)
int hsh[125252];
int bpow[125252];
// subhash(l,r) := [l,r) = [0,r) - [0,l) * bpow[r-l]
inline int subhash(int l,int r){
  return (hsh[r] - (ll)hsh[l]*bpow[r-l]%MOD + MOD)%MOD;
}
int rolcmp(int al,int ar,int bl,int br){
  int alen = ar-al;
  int blen = br-bl;
  int len = min(alen,blen);
  int low = 0, high = len+1;
  while(low+1<high){
    int mid = (low+high)/2;
    if(subhash(al,al+mid)==subhash(bl,bl+mid)){
      low = mid;
    }else{
      high = mid;
    }
  }
  if(low < len){
    char a = s[al+low];
    char b = s[bl+low];
    return a-b;
  }else{
    return alen-blen;
  }
}

int sa[125252];

bool check(int x,int n,int k,int l){
  int head = 0;
  REP(_,k){
    // compare head~head+l, x~x+l
    if(head+l>n)return true;
    bool le = true;
    REP(j,l){
      char a = s[head+j];
      char b = s[x+j];
      if(a!=b){
        if(a<b)le=true;
        else le=false;
        break;
      }
    }
    if(le)head += l;
    else head += l-1;
  }
  return head>=n;
}

int main(){
  scanf("%d",&k);
  scanf("%s",s);
  n = strlen(s);
  // rolling hash
  hsh[0] = 0;
  REP(i,n)hsh[i+1] = ((ll)B*hsh[i] + s[i])%MOD;
  bpow[0] = 1;
  REP(i,n)bpow[i+1] = (ll)bpow[i]*B%MOD;

  // // suffix array
  // REP(i,n)sa[i]=i;
  // sort(sa,sa+n,[&](int x,int y){
  //   int cmp = rolcmp(x,n,y,n);
  //   return cmp<0;
  // });

  k++;
  int l = (n+k-1)/k;
  vi cand(n-l+1,0);
  REP(i,n-l+1)cand[i]=i;
  sort(ALL(cand),[&](int x,int y){
    int cmp = rolcmp(x,x+l,y,y+l);
    return cmp<0;
  });
  int low = -1, high = n-l+1-1;
  while(low+1<high){
    int mid = (low+high)/2;
    if(check(cand[mid],n,k,l)){
      high = mid;
    }else{
      low = mid;
    }
  }
  int ans = cand[high];
  REP(i,l)putchar(s[ans+i]);
  putchar('\n');
  return 0;
}


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

int n,cnt=0;
int a[200005];

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i];
	for (int i=1;i<=n-1;i++)
	{
		if (a[i]==i)
		{
			swap(a[i],a[i+1]);
			cnt++;
		}
	}
	if (a[n]==n)  swap(a[1],a[n]),cnt++;
	cout<<cnt<<endl;
	
	return 0;
}

Measured memory_bytes: 4416
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

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

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    int cnt = 0;
    bool flag = false;
    rep(i, N)
    {
        if (A[i] < 0)
            cnt++;
        if (A[i] == 0)
            flag = true;
    }
    ll ans = 0;
    if (cnt % 2 == 0)
    {
        rep(i, N) ans += abs(A[i]);
    }
    else
    {
        if (flag)
        {
            rep(i, N) ans += abs(A[i]);
        }
        else
        {
            rep(i, N) ans += abs(A[i]);
            ll x = INF;
            rep(i, N) x = min(abs(A[i]), x);
            ans -= x * 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n;
    vi s(n);
    rep(i, n) {
        cin >> s[i];
    }
    cin >> q;
    vi t(q);
    rep(i, q) {
        cin >> t[i];
    }

    sort(all(s));
    sort(all(t));
    int ans = 0;
    rep(i, q) {
        if(binary_search(all(s), t[i])) {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3388
#include <stdio.h>
int main(void){
    int n,i,j,k,a[100],v;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    for(i=1;i<n;i++){
    	printf("%d",a[0]);
    	for(k=1;k<n;k++){
    		printf(" %d",a[k]);
    		//if(k<=n-1) printf(" *");
    	}
    	printf("\n");
    	v=a[i];
    	j=i-1;
    	while(j>=0&&a[j]>v){
    		a[j+1]=a[j];
    		j--;
    	}
    	a[j+1]=v;
    	
    }
    printf("%d",a[0]);
    for(k=1;k<n;k++){
    		printf(" %d",a[k]);
    		//if(k<=n-1) printf(" *");
    	}
    	printf("\n");
    return 0;
}


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

int main(void){
    long long N;
    bool s[40];
    int cnt = 0;
    long long base = 1;
    int sign = 1;
    
    cin >> N;
    
    if(N == 0){
        cout << '0' << endl;
        return 0;
    }
    
    while(N){
        if(abs(N) % (base * 2)){
            s[cnt] = true;
            N -= base * sign;
        }else{
            s[cnt] = false;
        }
        cnt++;
        base *= 2;
        sign *= -1;
    }
    
    while(--cnt >= 0){
        if(s[cnt]){
            cout << '1';
        }else{
            cout << '0';
        }
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main( ) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,n,i;
    double a;
    t = 1;
    while(t--) {
     a = 0;
     cin >> n;
     int arr[n];
     for(i = 0; i < n; i++)
      cin >> arr[i];
     sort(arr, arr + n);
     a = (double) (arr[0] + arr[1]) / 2;
     for(i = 2; i < n; i++) {
      a = (double) (a + arr[i]) / 2;
	 }
	 cout << fixed << setprecision(16);
     cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ans = [-1] * N
flag = False
for i in range(M):
    s, c = map(int, input().split())
    if ans[s-1] == -1 or ans[s-1] == c:
        ans[s-1] = c
    else:
        flag = True
        break
if flag:
    print(-1)
else:
    for i in range(1, N):
        if ans[i] == -1:
            ans[i] = 0
    if len(ans) == 1:
        if ans[0] == -1:
            print(0)
        else:
            print(ans[0])
    elif ans[0] == 0:
        print(-1)
    elif ans[0] == -1:
        ans[0] = 1
        print(''.join(list(map(str, ans))))
    else:
        print(''.join(list(map(str, ans))))







Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N, K;

int main() {
  scanf("%d%d", &N, &K);
  int t = 1 + (K-1) * 2;
  if (t <= N) puts("YES");
  else puts("NO");
}


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

using namespace std;
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PI; 
typedef pair<LL,LL> PLL;
typedef unsigned long long ULL;

#define IOSWORK ios::sync_with_stdio(0); cin.tie(0)
#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())
#define VAR(v, n) typeof(n) v = (n)
#define FOREACH(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)

#define SCAN_INT(n) scanf("%i",&n)
#define SCAN_P_INT(n,m) scanf("%i %i",&n,&m)
#define PRINT_P_INT(n,m) printf("%i %i\n",n,m);
#define PRINT_INT(n) printf("%i\n",n)


#define PB push_back
#define IN insert
#define ST first
#define ND second
#define INF 1000000007


#define MAXSIZE 

int n;
int main(){
	SCAN_INT(n);
	
	if(n==1)
		PRINT_INT(1);
	else if(n==2)
		PRINT_INT(3);
	else{
		LL l =1;
		LL p =3;
		
		FOR(i,3,n){
			LL k = l+p;
			l=p;
			p=k;
		}
		printf("%lld\n",p);
	}
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
int main(){  
    int n;
    cin>>n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];

    }
    int count=0;

    for (int i = 0; i < n; i++)
    {
        if(a[i]!=i+1){
            count++;
        }
        if (count>2){
            cout<<"NO"<<endl;
            break;
        }    
    }
    if(count<=2)  cout<<"YES";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define decToBin(name, num) string name = bitset<8>(num).to_string();
#define binToDec(name, binary) unsigned long name = bitset<8>(binary).to_ulong();
#define radToDeg(name, radians) double name = radians * 180 / M_PI;
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define arrfind(arr, x) (find(all(arr), x) != arr.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define printMat(mat) for (auto &x : mat) { for (auto &y : x) cout << y << " "; cout << '\n'; }
#define printArr(arr) for (auto &x : arr) cout << x << " "; cout << '\n';
#define int ll
#define double ld
#define INF 987654321
#define M_PI 3.14159265358979323846
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
void str_replaceAll(string& str, const string& from, const string& to) { if(from.empty()) return; size_t start_pos = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); } }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    vector<int> arr(3);
    for (auto &x : arr) cin >> x;
    removeDuplicates(arr);
    if (arr.size() == 2) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

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

int main() {

    char n[2];

    cin >> n[0] >> n[1];

    if(n[0] == '9' || n[1] == '9'){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

void solve()
{
    ll n;
    cin >> n;
    ll ans = 1;
    for(ll i = 1; i * i <= n; i++)
    {
        ans = i;
    }
    cout << ans * ans;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if (u == s)
    a--;
  if (u == t)
    b--;
  cout << a << ' ' << b << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    int[] ls = new int[5];
    int[] rs = new int[5];
    while (scanner.hasNext()) {
      ls[aaaa(scanner.nextDouble())]++;
      rs[aaaa(scanner.nextDouble())]++;
    }
    for (int ii = 1; ii < 5; ii++) {
      System.out.printf("%d %d\n", ls[ii], rs[ii]);
    }
  }

  private static int aaaa (double e) {
    if (1.1 <= e) {
      return 1;
    } if (0.6 <= e && e < 1.1) {
      return 2;
    } if (0.2 <= e && e < 0.6) {
      return 3;
    } if (e < 0.2) {
      return 4;
    }
    return 0;
  }
}

Measured memory_bytes: 20324
#include<iostream>
#include<math.h>
#include<map>
using namespace std;

int main()
{
    // 整数の入力                                                                                                      
    string WEATHER;
    cin >> WEATHER;

    map<string, string> PREDICTION;

    PREDICTION["Sunny"] = "Cloudy";
    PREDICTION["Cloudy"] = "Rainy";
    PREDICTION["Rainy"] = "Sunny";

    // 出力                                                                                                            
    cout << PREDICTION[WEATHER] << endl;
    return 0;
}


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

int main()
{
    int n,m;
    cin >> n >> m;
    bool ac[1000050];
    int wa[1000050];
    if( m == 0 )
    {
       cout << 0 << " " << 0  << endl;
       return 0;
    }
    
    int ac_count = 0;
    int wa_c = 0;
    for( int i = 0; i < m; i++ )
    {
        int p;
        string s;
        cin >> p >> s;
        if( ac[p] == true )
        {
            continue;
        }

        if( s == "WA" )
        {
            wa[p] = wa[p] + 1;
        }
        else if( s == "AC" )
        {
            ac[p] = true;
            ac_count = ac_count + 1;
            wa_c = wa_c + wa[p];
        }

    }
    cout << ac_count << " " << wa_c << endl;
    return 0;
}



Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    string s;
    cin >> n >> s;
    vi w(n + 1);
    vi e(n + 1);
    REP(i, n) {
        if (s[i] == 'W') {
            w[i + 1] = w[i] + 1;
            e[i + 1] = e[i];
        } else {
            w[i + 1] = w[i];
            e[i + 1] = e[i] + 1;
        }
    }
    int ans = n;
    REP(i, n) {
        chmin(ans, w[i] - w[0] + e[n] - e[i + 1]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2964
#include <iostream>
#include<vector>
#include <algorithm>
using namespace std;
int main(void)
{
	long A;
	cin >> A;
	vector<long> data(A);
	vector<long>yobi(A);
	for (int i = 0; i < A; i++)
	{
		cin >> data[i];
		yobi[i] = data[i];
	}
	sort(data.begin(), data.end());
	long max = data[A-1];
	long second = data[A - 2];
	

	for (int i = 0; i < A; i++)
	{
		if (yobi[i] == max)
		{
			cout << second << endl;
		}
		else if(yobi[i] < max)
		{
			cout << max << endl;
		}
	}
}

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

using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef long int li;
const int MAX_N=100;
string s[MAX_N];
int div(int n){
    int ans=0;
    for(int i=1;i*i<=n;i++){
        if(n%i==0)
            ans+=2;
    }
    int u=sqrt(n);
    if(u*u==n)
        ans--;
    return ans;
    
}

int main() {
    IOS;
    string s;
    cin>>s;
    int r=0;
    if(s[0]=='R')
        r=1;
    if(s[1]=='R')
        r=1;
        if(s[2]=='R')
            r=1;
    if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')
        r=3;
    else if(s[0]=='R'&&s[1]=='R')
        r=2;
    else if(s[1]=='R'&&s[2]=='R')
        r=2;
    cout<<r<<endl;
         
    return 0;
    
}


Measured memory_bytes: 3636
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        mut s: Chars,
    }

    s[3] = '8';
    for i in s {
        print!("{}",i);
    }

    print!("\n");

}


Measured memory_bytes: 2180
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String line = in.nextLine();
		in.close();
		if (line.contains("a") && line.contains("b") && line.contains("c")) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 21588
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <string>


#define rep(i,n) for(int i = 0;i < n;i++)
#define Rep(i,m,M) for(int i = m;i < M;i++)
#define print(var) cout<<#var" = "<<var<<endl;

typedef long long ll;

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;


int main()
{
	int N,ans = -1;
	cin >> N;
	double tax = 1.08;
	for (int i = 0.9 * N;i<=N; i++)
	{
		if ((int)(i * tax) == N)
		{
			ans = i;
			break;
		}
	}
	if (ans != -1)
		cout << ans;
	else cout << ":(";
}


Measured memory_bytes: 256
use proconio::*;
use proconio::marker::*;

#[fastout]
#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
    }
    // let ans = (1..N + 1).filter(|&x| x % 5 != 0 && x & 3 != 0).sum::<usize>();
    let mut ans: usize = 0;
    for i in 1..N + 1 {
        if i % 3 == 0 || i % 5 == 0 {
            continue;
        }
        ans += i;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;


int main(){
  rep(i,5){
    int g;
    cin >>g;
    if(g==0){cout << i+1 << endl; return 0;} 
  }
}

Measured memory_bytes: 3528
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, n) for (int i = 1; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    rep(i, K) {
        bool judge = true;
        rep(i, N) {
            if (A[i] != N) judge = false;
        }
        if (judge) break;
        vector<int> B(N + 1, 0);
        rep(i, N) {
            ++B[max(0, i - A[i])];
            --B[min(N, i + A[i] + 1)];
        }
        A[0] = B[0];
        REP(i, N) A[i] = A[i - 1] + B[i];
    }
    rep(i, N) cout << A[i] << "\n";
    return 0;
}


Measured memory_bytes: 4840
#include <stdio.h>

int main(){
    int s, high, low;

    scanf("%d", &s);

    high = s / 100;
    low = s % 100;

    if(high == 0){
        if(low == 0 || 12 < low)
            printf("NA\n");
        else
            printf("YYMM\n");
    }

    else if(high <= 12){
        if(low == 0 || 12 < low)
            printf("MMYY\n");
        else
            printf("AMBIGUOUS\n");
    }

    else{
        if(low == 0 || 12 < low)
            printf("NA\n");
        else
            printf("YYMM\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <math.h>
#include <map>
#include <set>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
using namespace std;

const int MOD = 1000000007;



int main(){
    int n;
    cin >> n;
    string res = "YES";
    map <int, int> m;
    REP(i,n)
    {
        int d;
        cin >> d;
        m[d] = m[d] + 1;
    }
    int M;
    cin >> M;
    REP(i,M)
    {
        int t;
        cin >> t;
        
        decltype(m)::iterator it = m.find(t);
        if(it == m.end() || m[t] == 0)
        {
            res = "NO";
            break;
        }
        m[t]--;    
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    ll n; cin >> n;
    if(n & 1 == 1){ cout << 0 << endl; return 0; }
    ll ans = 0;
    ll num = 10;
    while(n >= num){ ans += n/num; num *= 5; }
    cout << ans << endl; return 0;
}

Measured memory_bytes: 3616
import scala.io.StdIn._
object Main extends App {
  val mod = 1000000007L
  val Array(n, m, d) = readLine.trim.split(' ').map(_.toLong)
  val initialSalary = readLine.trim.split(' ').map(_.toLong)
  val jobs = readLine.trim.split(' ').map(_.toLong)
  val increase = readLine.trim.split(' ').map(_.toLong)
  val pay = (0 until n.toInt).map{id ⇒
    val diff = calStateDiff(n, m, id, jobs, increase).repeat(d / (n * m)) + calStateDiff(n, m, id, jobs, increase, d % (n * m))
    (diff.time * initialSalary(id) + diff.payForIncrease) % mod
  }
  println(pay.sum % mod)
  case class EmployeeStateDiff(time: Long, salary: Long, payForIncrease: Long) {
    def +(that: EmployeeStateDiff): EmployeeStateDiff = {
      EmployeeStateDiff((time + that.time) % mod, (salary + that.salary) % mod, (salary * that.time % mod + payForIncrease + that.payForIncrease) % mod)
    }
    def repeat(n: Long): EmployeeStateDiff = {
      n match {
        case 0L ⇒ EmployeeStateDiff(0, 0, 0)
        case 1L ⇒ this
        case _ if n % 2 == 1 ⇒ (this + this).repeat(n / 2) + this
        case _ ⇒ (this + this).repeat(n / 2)
      }
    }
  }
  def calStateDiff(n: Long, m: Long, id: Int, jobs: Array[Long], increase: Array[Long], day: Long = -1): EmployeeStateDiff = {
    var additionalTime = 0L
    var additionalPayForIncrease = 0L
    var additionalSalary = 0L
    for (d ← 0L until (if (day == -1) n * m else day)) {
      val t = jobs((((id - d) % n + n) % n).toInt)
      additionalTime += t
      additionalPayForIncrease += additionalSalary * t
      if (d % n == id) {
        additionalSalary += increase((d % m).toInt)
      }
      additionalTime %= mod
      additionalPayForIncrease %= mod
      additionalSalary %= mod
    }
    EmployeeStateDiff(additionalTime, additionalSalary, additionalPayForIncrease)
  }
}



Measured memory_bytes: 54300
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

//つねに10億7などの剰余をとる構造体
//参考: https://www.youtube.com/watch?v=L8grWxBlIZ4&t=9858
//参考: https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#4-%E7%B4%AF%E4%B9%97-an
int mod  = MODA;
struct modint {
	ll x;
	modint (ll x):x(x%mod){}
	modint& operator+=(const modint a){
		(x += a.x ) %= mod;
		return *this;
	}
	modint& operator-=(const modint a){
		(x -= a.x ) %= mod;
		if (x < 0) x += mod;
		return *this;
	}
	modint& operator*=(const modint a){
		(x *= a.x ) %= mod;
		return *this;
	}
	modint& operator/=(modint a){
		ll exp = mod - 2;
		while(exp > 0){
			if(exp & 1) *this *= a.x;
			a *= a.x;
			exp >>= 1;
		}
		return *this;
	}
	modint operator+(const modint a) const{
		modint res(*this);
		return res+=a;
	}
	modint operator-(const modint a) const{
		modint res(*this);
		return res-=a;
	}
	modint operator*(const modint a) const{
		modint res(*this);
		return res*=a;
	}
	modint operator/(const modint a) const{
		modint res(*this);
		return res/=a;
	}
};
modint modpow(modint x, ll n){
	modint res=1;
	while(n > 0){
		if(n & 1) res = res * x.x;
		x = x * x;
		n >>= 1;
	}
	return res;
}

int main() {
	//素数列挙
	bool *pr;
	int P_max = 1000000; //10^6くらいまでが現実的か
	pr = (bool*)malloc(sizeof(bool) * P_max);
	REP(i, P_max) {
		pr[i] = i;
	}
	REP(i, P_max + 1) pr[i] = true;
	pr[0] = false;
	pr[1] = false;
	for(int i = 2; i * i <= P_max; i++){ 
		if(pr[i] == true){
			for(int j = 2 * i; j <= P_max; j+=i){
				pr[j] = false;
			}
		}
	}
	vector<int> prime;
	for(int i = 2; i <= P_max; i++){
		if(pr[i]) prime.push_back(i);
	}

	
	modint ans = 0;
	int tmp;
	
	int n;
	cin >> n;
	vector<int> a;
	REP(i, n){
		cin >> tmp;
		a.push_back(tmp);
	}

	map<int, int> lcm, prf;
	REP(i, n){
		prf.clear();
		tmp = a[i];
		//cout << tmp << endl;
		for(int j = 0; tmp > 1 && prime[j] * prime[j] <= a[i]; j++){
			while (tmp % prime[j] == 0)
			{
				tmp /= prime[j];
				prf[prime[j]]++;
			}
			lcm[prime[j]] = max(lcm[prime[j]], prf[prime[j]]);
		}
		prf[tmp]++;
		lcm[tmp] = max(lcm[tmp], prf[tmp]);
		prf.erase(1);
		//for(auto j = prf.begin(); j!= prf.end(); j++) cout << j->first << "," << j->second << " ";
		//cout << endl;
	}

	modint lcmall = 1;
	for(auto i = lcm.begin(); i!= lcm.end(); i++){
		lcmall *= modpow((modint) i->first, (ll) i->second);
	}

	REP(i, n){
		tmp = a[i];
		ans += lcmall / (modint) tmp ;
	}
	
	cout << ans.x << endl;
}

Measured memory_bytes: 2040
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	ll ans = 1;
	int n;
	cin>>n;
	vector<ll> cnt(n+1);
	cnt[0]=3;
	rep(i,n){
		int x;cin>>x;
		ans = ans*cnt[x]%mod;
		if(ans==0){
			cout<<0<<endl;
			return 0;
		}
		--cnt[x];
		++cnt[x+1];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long fib[233],x,y,ans;
int now;long long all;
void dfs(long long u,long long v,int c,int err)
{
	//cout<<u<<' '<<v<<' '<<c<<' '<<err<<' '<<(((u>=fib[c+2])&&(v>=fib[c+3]))||(u>x)||(v>y))<<endl;
	if (((u>=fib[c+2])&&(v>=fib[c+3]))||(u>x)||(v>y)) return;
	//if (c==now) {ans+=(int)((u<=x)&&(v<=y))+(int)((v<=x)&&(u<=y));return;}
	if (c==now-1)
	{
		ans+=max(0ll,(y-u)/v)*(v<=x)+max(0ll,(x-u)/v)*(v<=y);
		return;
	}
	if (!err)
	{
		dfs(v,u+v,c+1,0);
		dfs(v,u+v+v,c+1,1);
		//v,u+kv
		//p=fib[now-c-2]*v+fib[now-c-1]*(u+kv)
		//q=fib[now-c-1]*v+fib[now-c]*(u+kv)
		//p<=x q<=y
	}
	else if (err==1)
	{
		if ((double)u*fib[now-2-c]+(double)v*fib[now-1-c]>1.1e18) return;
		if ((double)u*fib[now-1-c]+(double)v*fib[now-0-c]>1.1e18) return;
		long long uu=u*fib[now-2-c]+v*fib[now-1-c],vv=u*fib[now-1-c]+v*fib[now-0-c];
		dfs(uu,vv,now-1,1);
	}
}
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	fib[0]=0;fib[1]=1;for (int i=2;i<=90;i++) fib[i]=fib[i-1]+fib[i-2];
	int q;scanf("%d",&q);
	while (q--)
	{//if (q%1000==0) cerr<<q<<endl;
		scanf("%lld%lld",&x,&y);if (x>y) swap(x,y);
		if (x==1) {printf("1 %lld\n",y%1000000007);continue;}
		if (y==2) {printf("1 4\n");continue;}
		now=0;while ((fib[now+2]<=x)&&(fib[now+3]<=y)) now++;
		printf("%d ",now);
		ans=0;dfs(1,1,0,0);
		printf("%lld\n",ans%1000000007);
	}
	cerr<<all<<endl;
}

Measured memory_bytes: 3968
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>

using namespace std;

int main()
{
	int n,k;
	cin >> n >>k;
	vector<int> v(n);
	for(int i=0;i<n;i++)
		cin >> v[i];
	
	if(k>=n*2)
	{
		int ans=0;
		for(int i=0;i<n;i++)
			if(v[i]>0)ans+=v[i];
		cout << ans << endl;
		return 0;
	}

	int ans=0;
	for(int a=0;a<=k;a++)
		for(int b=0;b<=k-a;b++)
		{
			int c=k-a-b;
			int tmp=0;
			vector<int> have;
			for(int i=0;i<a;i++)
				have.push_back(v[i]);
			for(int i=0;i<b;i++)
				have.push_back(v[n-1-i]);
			sort(have.begin(),have.end());
			for(int i=0;i<have.size();i++)
				if(!(have[i]<0 and i<c))tmp+=have[i];
			ans=max(tmp,ans);
		}
	
	cout << ans << endl;


}


Measured memory_bytes: 256
#include<iostream>;

using namespace std;

int main(void) {
	int R; cin >> R;
	if (R < 1200) {
		cout << "ABC" << endl;
		return(0);
	}
	else if (R < 2800) {
		cout << "ARC" << endl;
		return(0);

	}
		cout << "AGC" << endl;
		return(0);


}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
 
using namespace std;

typedef long long ll;
const int mod=1e9+7;
const int INF=1<<30;

ll f(ll b,ll n){//nをb進数表記した時の各桁の和
  ll res=0;
  if(n<b) return n;
  else res=n%b+f(b,n/b);
  return res;
}

int main(){
  ll n,s;
  cin >> n >> s ;
  if(s==n){
    cout << n+1 << endl;
    return 0;
  }
  if( s > (ll)((2*n-1)/2) ) {//n=1,s>nの場合を除く
    cout << "-1" << endl;
    return 0;
  }
  for(ll b=2; b*b<=n; b++){
    ll temp=f(b,n);
    if(temp==s){
      cout << b << endl;
      return 0;
    }
  }
  ll ans=-1;
  for(ll p=1; p*p<=n; p++){
    ll q=s-p;
    if(q<0) continue;
    if((n-q)%p) continue;
    ll b=(n-q)/p;
    if(f(b,n)==s){
      if(ans==-1) ans=b;
      else ans=min(ans,b);
    }
  }
  cout << ans << endl;
  return 0;
}

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

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for (int i = 0 ; i < n ; i++) {
            if (x >= a[i]) {
                x -= a[i];
            } else {
                System.out.println(i);
                return;
            }
        }
        if (x == 0) {
            System.out.println(n);
        } else {
            System.out.println(n - 1);
        }

    }

}

Measured memory_bytes: 21972
#include<stdio.h>
int main()
{
	int a[10],i,s=0;
	for(i=1;i<=9;i++)
	scanf("%d",&a[i]); 
	if((a[2]-a[1])==(a[5]-a[4])&&(a[2]-a[1])==(a[8]-a[7]))
	s++;
	if((a[3]-a[2])==(a[6]-a[5])&&(a[3]-a[2])==(a[9]-a[8]))
	s++;
		if((a[4]-a[1])==(a[5]-a[2])&&(a[6]-a[3])==(a[4]-a[1]))
		s++;
			if((a[7]-a[4])==(a[8]-a[5])&&(a[7]-a[4])==(a[9]-a[6]))
		s++;
		if(s==4)
		printf("Yes\n");
		else
		printf("No\n");
		return 0;
}

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

int main () {
  long long n;
  cin >> n;
  n = n % 10;
  if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) cout << "hon";
  else if (n == 0 || n == 1 || n == 6 || n == 8) cout << "pon";
  else cout << "bon";
  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>

int main() {
  int N;
  std::cin >> N;
  std::vector<long long> a(3 * N);
  for (int i = 0; i < 3 * N; ++i) {
    std::cin >> a[i];
  }

  std::priority_queue<long long, std::vector<long long>, std::greater<long long>> pq;
  std::vector<long long> max(3 * N);
  max[0] = 0;
  for (int i = 0; i < N; ++i) {
    max[i] = max[i > 0 ? i - 1 : 0] + a[i];
    pq.push(a[i]);
  }
  for (int i = 0; i <= N; ++i) {
    pq.push(a[N + i]);
    max[N + i] = max[N + i - 1] + a[N + i] - pq.top();
    pq.pop();
  }

  std::priority_queue<long long, std::vector<long long>, std::greater<long long>> pq2;
  std::vector<long long> max2(3 * N);
  max2[0] = 0;
  for (int i = 0; i < N; ++i) {
    max2[i] = max2[i > 0 ? i - 1 : 0] - a[3 * N - 1 - i];
    pq2.push(-a[3 * N - i - 1]);
  }
  for (int i = 0; i <= N; ++i) {
    pq2.push(-a[2 * N - i - 1]);
    max2[N + i] = max2[N + i - 1] + (-a[2 * N - i - 1]) - pq2.top();
    pq2.pop();
  }

  long long ans = std::numeric_limits<long long>::min();
  for (int i = 0; i <= N; ++i) {
    ans = std::max(ans, max[N - 1 + i] + max2[2 * N - i - 1]);
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 9588
n,c,k = map(int,input().split())
t = [int(input()) for nesya in range(n)]
t.sort()
bus = 0
wait = []
for i in range(n):
  wait.append(t[i])
  if wait[0] + k < t[i]:
    bus += 1
    wait = [t[i]]
  elif len(wait) == c:
    bus += 1
    wait = []
  elif wait[0] + k == t[i]:
    bus += 1
    wait = []
  if i == n-1 and len(wait) > 0:
    bus += 1
print(bus)

Measured memory_bytes: 7384
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#define debug(x) cout<<"***"<<x<<"***"<<endl;
using namespace std;

int main()
{
	int d[101],n,i,j,sum=0;
	cin>>n;
	for(i=1;i<=n;i++) cin>>d[i];
	for(i=1;i<=n-1;i++)
		for (j=i+1;j<=n;j++)
			{sum=sum+d[i]*d[j];
			}
	cout<<sum;
	return 0;
}


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

using namespace std;

int const size = 100006;
int arr[size];
long long int dp[size];

long long int getans(int n, int k, int i){
	if(i == n-1) return 0;
	if(i > n-1) return INT_MAX;
	if(dp[i] != -1) return dp[i];
	long long int ans = INT_MAX;
	for(int x = i+1;x<n;x++){
		if(x>i+k) break;
		ans = min(ans, getans(n, k, x) + abs(arr[i] - arr[x]));
	}
	dp[i] = ans;
	return ans;
}

int main(){
	int n, h, k;
	scanf("%d %d",&n,&k);
	for(int x=0;x<=n;x++){
		dp[x] = -1;
	}
	for(int x=0;x<n;x++){
		scanf("%d",&arr[x]);
	}
	cout<<getans(n,k,0);
	return 0;
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, 0, n)
    {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int sum = 0;
    rep(i, 0, k)
    {
        sum += p[i];
    }
    cout << sum << endl;
    return 0;
}


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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}

int main() {
    int i,n,m,c=0,k,sum=0;
    c_p_c();
    string s;
    cin>>s;
    n = (int)s.size();

    for (int i = n-1; i>0; --i)
    {
    	/* code */
    	if(i%2==0){
    		// watch(i);
    		string a,b;
    		a=s.substr(0,i/2);
    		b=s.substr(i/2,i/2);
    		// watch2(a,b);

    		if(a==b){
    			cout<<2*a.size()<<endl;
    			break;
    		}

    	}
    }
 
  	
 	return 0;

   }

Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
using namespace std;

#define MAX 100002
int n;
int c;

long long int sc[MAX];

vector<pair<long long int, int> > v;
vector<int> bit;

struct st {
    int ty;
    int t;
    long long int p;
    st(int a, int b, int c) {
        ty = a;
        t = b;
        p = c;
    }
};
vector<st> vv;
void add(int pos, int x) {
    pos++;
    while (pos < bit.size()) {
        bit[pos] += x;
        pos += pos & -pos;
    }
}
long long int sum(int pos) {
    pos++;
    long long int res = 0;
    while (pos) {
        res += bit[pos];
        pos -= pos & -pos;
    }
    return res;
}
int get_id(int team) {
    return lower_bound(v.begin(), v.end(), make_pair(-sc[team], team))-v.begin();
}
int main() {
    cin >> n >> c;
    for (int i = 0; i < n; i++) {
        v.push_back(make_pair(0, i));
    }
    for (int i = 0; i < c; i++) {
        int ty;
        scanf("%d", &ty);
        if (ty == 0) {
            long long int t, p;
            scanf("%lld%lld", &t, &p);
            t--;
            sc[t] += p;
            v.push_back(make_pair(-sc[t], t));
            vv.push_back(st(ty, t, p));
        }
        else {
            int m;
            scanf("%d", &m);
            vv.push_back(st(ty, m,-1));
        }
    }
    sort(v.begin(), v.end());
    bit.assign(v.size() + 100,0);
    memset(sc, 0, sizeof(sc));
    for (int i = 0; i < n; i++)add(get_id(i), 1);
    for (int i = 0; i < vv.size(); i++) {
        if (vv[i].ty == 0) {
            add(get_id(vv[i].t), -1);
            sc[vv[i].t] += vv[i].p;
            add(get_id(vv[i].t), 1);
        }
        else {
            int want = vv[i].t;
            int mint = 0;
            int maxt = v.size() - 1;
            while (mint + 1 < maxt) {
                int mid = (mint + maxt) / 2;
                if (sum(mid) >= want) {
                    maxt = mid;
                }
                else {
                    mint = mid;
                }
            }
            if (sum(mint) >= want) {
                maxt = mint;
            }
            else {
                mint = maxt;
            }
            printf("%d %lld\n", v[mint].second+1,-v[mint].first);
        }
    }
    return 0;
}


Measured memory_bytes: 10444
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, alice, bod int
	fmt.Scan(&n)
	cards := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&cards[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(cards)))
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			alice += cards[i]
		} else {
			bod += cards[i]
		}
	}
	fmt.Println(alice - bod)
}


Measured memory_bytes: 512
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  N,M=LI()
  l1=[]
  l2=[]
  l3=[]
  l4=[]
  l5=[]
  l6=[]
  l7=[]
  l8=[]
  for _ in range(N):
    _l=LI()

    l1.append(sum([_l[0],_l[1],_l[2]]))
    l2.append(sum([_l[0],_l[1],-_l[2]]))
    l3.append(sum([_l[0],-_l[1],_l[2]]))
    l4.append(sum([_l[0],-_l[1],-_l[2]]))
    l5.append(sum([-_l[0],_l[1],_l[2]]))
    l6.append(sum([-_l[0],_l[1],-_l[2]]))
    l7.append(sum([-_l[0],-_l[1],_l[2]]))
    l8.append(sum([-_l[0],-_l[1],-_l[2]]))

  l1=sorted(l1,key=lambda x:x,reverse=True)
  l2=sorted(l2,key=lambda x:x,reverse=True)
  l3=sorted(l3,key=lambda x:x,reverse=True)
  l4=sorted(l4,key=lambda x:x,reverse=True)
  l5=sorted(l5,key=lambda x:x,reverse=True)
  l6=sorted(l6,key=lambda x:x,reverse=True)
  l7=sorted(l7,key=lambda x:x,reverse=True)
  l8=sorted(l8,key=lambda x:x,reverse=True)

  x1=sum(l1[:M])
  x2=sum(l2[:M])
  x3=sum(l3[:M])
  x4=sum(l4[:M])
  x5=sum(l5[:M])
  x6=sum(l6[:M])
  x7=sum(l7[:M])
  x8=sum(l8[:M])

  return max(x1,x2,x3,x4,x5,x6,x7,x8)

# main()
print(main())


Measured memory_bytes: 6992