akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  ldouble a, b, h, m, r, ax, ay, bx, by, pi = 3.14159265358979;
  cin >> a >> b >> h >> m;
  ax = a * cos(pi / 180 * (30 * h + 0.5 * m));
  ay = a * sin(pi / 180 * (30 * h + 0.5 * m));
  bx = b * cos(pi / 30 * m);
  by = b * sin(pi / 30 * m);
  r = sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by));
  cout << fixed << setprecision(10) << r << "\n";
  return 0;
}

Measured memory_bytes: 4168
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
//#define DEBUG
//#define RANDOM
typedef long long ll;
typedef long double ld;
using namespace std;

// Myslienka: Ak by sme pre kazdu query vedeli povedat, na aky stlpec/riadok narazime
// vedeli by sme efektivne vediet odcitat pocet ciernych kamienkov. Na to potrebujeme
// datovu strukturu, ktora efektivne zvlada dva typy operacii:
// - Povedz, ake cislo je na policku x.
// - Zmen vsetky cisla na polickach l az r na min(cislo_i, x).
// To znie ako nejaky upraveny intervalac.
// Kazdy vrchol si pamata lazy hodnotu, kazdy list si pamata svoju hodnotu
class intervalac
{
    int N;
    vector<int> l, r;
    vector<int> val;
    void unlazy(int vr)
    {
        val[vr * 2 + 1] = min(val[vr * 2 + 1], val[vr]);
        val[vr * 2 + 2] = min(val[vr * 2 + 2], val[vr]);
    }
public:
    intervalac(int n): N(n)
    {
        int n2 = 1;
        while (n2 < n)
        {
            n2 <<= 1;
        }
        l.resize(n2 * 2);
        r.resize(n2 * 2);
        val.resize(n2 * 2, n);
        for (int i = n2 - 1; i < n2 * 2; i++)
        {
            l[i] = i - (n2 - 1);
            r[i] = i - (n2 - 1);
        }
        for (int i = n2 - 2; i >= 0; i--)
        {
            l[i] = l[i * 2 + 1];
            r[i] = r[i * 2 + 2];
        }
    }
    void update(int li, int ri, int x, int vr = 0)
    {
        if (li > r[vr] || ri < l[vr])
        {
            return;
        }
        if (li <= l[vr] && r[vr] <= ri)
        {
            val[vr] = min(val[vr], x);
            return;
        }
        unlazy(vr);
        update(li, ri, x, vr * 2 + 1);
        update(li, ri, x, vr * 2 + 2);
    }
    int value(int i, int vr = 0)
    {
        if (l[vr] > i || r[vr] < i)
        {
            return -1;
        }
        if (l[vr] == i && r[vr] == i)
        {
            return val[vr];
        }
        unlazy(vr);
        return max(value(i, vr * 2 + 1), value(i, vr * 2 + 2));
    }
};
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, q;
    cin >> n >> q;
    ll ans = (n - 2ll) * (n - 2ll);
    intervalac i1(n), i2(n);
    for (int i = 0; i < q; i++)
    {
        int typ, x;
        cin >> typ >> x;
        if (typ == 1)
        {
            // i1, ktory narazi na i2
            int zastavi = i2.value(x);
            zastavi--;
            ans -= ll(zastavi-1);
            i1.update(0, zastavi, x);
            //cout << x << " zastavi sa na " << zastavi + 1 << "\n";
        }
        else
        {
            int zastavi = i1.value(x);
            zastavi--;
            ans -= ll(zastavi-1);
            i2.update(0, zastavi, x);
            //cout << x << " zastavi sa na " << zastavi + 1 << "\n";
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 15616
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<60
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;

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

  int n,a,b;
  cin >> n >> a >> b;

  cout << min(a,b) << " " << max(n-(n-a)-(n-b),0LL) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define max(v) *max_element(v.begin(), v.end())
#define min(v) *min_element(v.begin(), v.end())
using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin>>n>>k;
    int x[1000000];
    rep(i, n){
        cin>>x[i];
    }
    int xl, xr, min = 1000000000;
    for(int i = 0; i < n-k+1; i++){
        xl = x[i];
        xr = x[i+k-1];
        if(min > abs(xl) + abs(xr-xl)){
            min = abs(xl) + abs(xr-xl);
        }
        if(min > abs(xr) + abs(xl-xr)){
            min = abs(xr) + abs(xl-xr);
        }
    }
    cout<<min<<endl;    
    return 0;
}

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

using ll = long long;

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)

using namespace std;

//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);



void solve()
{
    int n, k;
    cin >> n >> k;
    map<int, int> m;
    REP(i, n) {
        int a;
        cin >> a;
        if(m.find(a) == m.end()) m[a] = 0;
        m[a]++;
    }
    int mlen = m.size();
    priority_queue<int, vector<int>, greater<int>> pq;
    for(auto &x : m) {
        pq.push(x.second);
    }
    int ans = 0;
    for(int i = 0; i < mlen - k; i++){
        ans += pq.top();
        pq.pop();
    }
    cout << ans << "\n";
}

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

Measured memory_bytes: 10748
/*  Success may not come to me immediately,
 *  but it will come definitely....
 */
#include <bits/stdc++.h>
//=====================================================================
using namespace std;
//=====================================================================
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//=====================================================================
#define li      int64_t
#define ld      double_t
#define ulli    uint64_t
//=====================================================================
#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define repi(i,v)   for(i=v.begin();i!=v.end();i++)
#define repir(i,v)  for(i=v.rbegin();i!=v.rend();i++)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))
#define nl          cout<<'\n'
//=====================================================================
typedef vector<li>       vli;
typedef vector<string>   vstr;
typedef pair<li,li>      pli;
typedef pair<li,pli >    ppli;
typedef pair<li,ppli >   pppli;
typedef vector<pli >     vpli;
typedef vector<ppli >    vppli;
typedef vector<pppli >   vpppli;
//=====================================================================
#define pb  push_back
#define pob pop_back
#define pf  push_front
#define pof pop_front
#define all(v)  v.begin(),v.end()
#define itr iterator
#define rtr reverse_iterator
#define sz  size()
#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define mp  make_pair
#define F   first
#define S   second
//=====================================================================
#define mod (li)(1e9+7)
#define inf (li)(1e18)
#define MX1 (li)(1e5+5)
#define MX2 (li)(1e6+5)
#define pi  acos(-1)
//=====================================================================
li power(li a,li b){li ans=1;while(b){if(b&1){ans=(ans*a)%mod;}
a=(a*a)%mod;b>>=1;}return ans;}
//=====================================================================
li mmi(li n){return power(n,mod-2);}
//=====================================================================
li two(li n){return (1LL<<n);}
//=====================================================================
void onbit(li &n,li x){n|=two(x);}
//=====================================================================
void offbit(li &n,li x){n&=~two(x);}
//=====================================================================
li cntbit(li n){li res=0;while(n and ++res)n-=n&-n;return res;}
//=====================================================================
li dx[]={-1,0,1,0},dy[]={0,-1,0,1};
//=====================================================================
/*------------------------MAIN CODE BEGINS NOW!------------------------*/

multiset<li> ms;
li n;

void solve(){
  li i;cin>>n;
  rep(i,0,n){
    li x;cin>>x;
    if(ms.find(x)!=ms.end()){
      ms.erase(x);
    }else ms.insert(x);
  }
  li ans=ms.sz;
  cout<<ans;
}
  
int main(){
  opt
  #ifndef ONLINE_JUDGE
  #endif
  li t=1;
  //cin>>t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 4992
//raja1999

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define int ll

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


//std::ios::sync_with_stdio(false);

main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	string s;
	cin>>s;
	if(s=="ABC"){
		cout<<"ARC"<<endl;
	}
	else{
		cout<<"ABC"<<endl;
	}
	return 0;
} 


Measured memory_bytes: 3640
#python2.7

A=raw_input().split()
B=[]
for i in A:
	if i.isdigit():
		B.append(i)
	else:
		if i=="+":
			B[-1]=str(int(B[-1])+int(B[-2]))
			del B[-2]
		elif i=="-":
			B[-1]=str(int(B[-2])-int(B[-1]))
			del B[-2]
		elif i=="*":
			B[-1]=str(int(B[-1])*int(B[-2]))
			del B[-2]
print B[0]

Measured memory_bytes: 6432
N = int(input())
ListN=[0]
List = []
res =0
flag = True
mid =0
n =0
for i in range(N):
  k = int(input())
  n += k
  ListN.append(n)
  for j in range(k):
    List.append(list(map(int, input().split())))
#print(List)
for bits in range(2**N):
  mid=0
  flag= True
  for j in range(N):
    #print(bits,j,((bits>>j) & 1))
    if((bits>>j) & 1): 
      mid+= 1
      #print(ListN[j],ListN[j+1])
      for k in range(ListN[j],ListN[j+1]):
        mynum = bits
        #print(bits,List[k][0],(mynum>>List[k][0])&1, List[k][1])
        if ((mynum>>List[k][0]-1)&1) != List[k][1]:
          flag = False
          break
  #print(bits,flag,mid)
  if flag:
    res = max(res,mid)
print(res)

Measured memory_bytes: 9200
#include <iostream>
#include <string>
#include <cmath>
#include <fstream>
#include <chrono>
#include <iomanip>
#include <vector>
#include <utility>
#include <time.h>
#include <set>
#include <unordered_set>
#include <list>
#include <iterator>
#include <time.h>
#include <chrono>
#include <deque>
#include <cstdio>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <climits>
#include <tuple>
#include <map>
using namespace std;

#define ll long long
#define ldb long double

ll mod(ll a, ll b)
{
	return (b + (a % b)) % b;
}

ll subMod(ll a, ll b, ll M)
{
	return mod((mod(a, M) - mod(b, M)), M);
}

ll dayofweek(ll d, ll m, ll y)
{
	static ll t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 };
	y -= m < 3;
	return (y + y / 4 - y / 100 +
		y / 400 + t[m - 1] + d) % 7;
}

void test()
{

}


void solve()
{
	ll n, k;
	cin >> n >> k;

	int count = 0;

	while (n != 0)
	{
		n /= k;
		count++;
	}

	cout << count;
}

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

	//test();

	solve();

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,max,min,i,a;
  long int sum=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%",&a);
    if(i==0){ max=a; min=a; }
    if(max<a) max = a;
    if(min>a) min = a;
    sum+=a;
  }
  printf("%d %d %ld\n",min,max,sum);

  return 0;
}


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

#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int   mod   = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 10){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solver() {
  int H = input(), W = input();
  vector< string > s(H);
  for (auto &i : s) cin >> i;

  vector< bool > noh(H), pw(W);
  range(i, 0, H) {
    bool f = false;
    range(j, 0, W) {
      if (s[i][j] == '#') f = true;
    }

    if (!f) noh[i] = true;
  }

  range(j, 0, W) {
    bool f = false;
    range(i, 0, H) {
      if (s[i][j] == '#') f = true;
    }

    if (f) pw[j] = true;
  }

  range(i, 0, H) {
    if (noh[i]) continue;
    range(j, 0, W) if (pw[j]) cout << s[i][j];
    cout << endl;
  }
}

signed main(int argc, char *argv[]) {
  solver();
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  string s; cin >> s;
  vector<int> west(N + 5, 0), east(N + 5, 0);
  for (int i = 0; i < N; ++i) {
    if (s[i] == 'W') { west[i + 1] = 1; }
    else { east[i + 1] = 1; }
  }
  for (int i = 1; i <= N; ++i) {
    west[i] += west[i - 1];
    east[i] += east[i - 1];
  }
  int ans = INF;
  for (int i = 1; i <= N; ++i) {
    int cnt = west[i - 1] + (east[N] - east[i]);
    ans = min(ans, cnt);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2948
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll powmod(ll n, ll k, ll m) {
ll r=1;
 for(; k>0; k >>=1) {
   if(k&1) r=(r*n)%m;
   n=(n*n)%m;
 }
  return r;
}

ll fact(ll n) {
ll a=1;
rep(i,n) {
a=a*(n-i);
}
return a;
}

ll pow(ll a, ll b) {
ll x=1;
rep(i,b) {
x=x*a;
}
return x;
}



int main() {


ll N;
  cin >>N;
 if(N==1) {
   cout<<0<<endl;
 }
else if(N==2) {
cout<<2<<endl;
}
else {
ll a=powmod(10,N,MOD);
  ll b=powmod(9,N,MOD);
  ll c=powmod(8,N,MOD);

  
  cout<<((a-2*b)%MOD+c+MOD)%MOD<<endl;
  
  
  
  
  
}
  
  
}
  

Measured memory_bytes: 3644
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()
import fractions
gcd=fractions.gcd
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

n,m=LI()
b=[int(i)//2 for i in input().split()]
#a=LI()

'''
s=time.time()
n=10**4
b=[random.randint(10,10**8) for i in range(n)]
t=time.time()
show(t-s)
'''

lcm=b[0]
for i in range(1,n):
    lcm=(lcm//gcd(b[i],lcm))*b[i]
    if lcm>3*m:
      break

ans=(1+m//lcm)//2

fl=False
for i in b:
    t=lcm//i
    if t%2==0:
        fl=True
    
if lcm%2==0 and fl:
    ans=0
    
    
print(ans)



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

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; }
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

int N;
ll a,b;

// *********************************************************
int main(){

    cin >> N ;

    cin >>a;
    ll fumi=0;
    ll fumiall=0;
    rep(i, N-1){
        cin >>b;
        if(a+fumi >b){
            fumi = a+fumi-b;
        }else{
            fumi = 0;
        }
        fumiall += fumi;
        a=b;
    }
    
    cout <<fumiall<<endl;


    return 0;
}

Measured memory_bytes: 3608
a , b , c , d = input().split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)

a_hp = a
b_hp = c

result = ""
while True :
	b_hp -= b
	if b_hp <= 0 :
		result ="Yes"
		break
		
	a_hp -= d
	if a_hp <= 0 :
		result = "No"
		break
print(result)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll gcd(int a,int b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(int a,int b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll INFS=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);

int main() {
  double l;
  cin>>l;
  double cnt=l/3;
  double ans=cnt*cnt*cnt;
  printf("%.10f\n",ans);
  
}

Measured memory_bytes: 3712
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int64_t gcd(int64_t x, int64_t y)
{
    if (x == 0) {
        return y;
    }
    return gcd(y % x, x);
}

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

    int64_t m = 0;
    int64_t d;
    rep(i, n)
    {
        int64_t a;
        cin >> a;
        if (i == 0) {
            d = a;
        } else {
            d = gcd(d, a);
        }
        m = max(m, a);
    }

    cout << (k % d == 0 && k <= m ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin >> n;
    vector<vector<string>> ans(11);
    string zero = "`";
    ans[0].push_back(zero);
    rep(i, 10) {
        for (auto s : ans[i]) {
            char c = 0;
            for (char x : s) chmax(c, x);
            for (char x = 'a'; x <= c + 1; x++) {
                ans[i + 1].push_back(s + x);
            }
        }
    }
    sort(all(ans[n]));
    for (string s : ans[n]) cout << s.substr(1, n) << endl;
}


Measured memory_bytes: 11508
H, W = map(int, raw_input().split())
sky = []
for i in range(0, H):
	sky.append(raw_input())
answer = []
for i in range(0, H):
	lst = []
	tmp = -1
	for j in range(0, W):
		if sky[i][j] == 'c':
			tmp = 0
		elif tmp != -1:
			tmp += 1
		lst.append(tmp)
	answer.append(lst)
for i in range(0, H):
	ans = str(answer[i][0])
	for j in range(1, W):
		ans = ans + ' ' + str(answer[i][j])
	print ans


Measured memory_bytes: 4712
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

string calc(string a, string b, int n)
{
	string ret = "";

	int back = 0;
	rrep(i, n - 1, 0)
	{
		int aa = a[i] - '0';
		int bb = b[i] - '0';

		int cc = aa - bb - back;
		if (cc < 0)
		{
			back = 1;
			cc += 10;
		}
		else
			back = 0;

		string c = "0";
		c[0] += cc;

		ret = c + ret;
	}

	return ret;
}

int main()
{
	while (1)
	{
		string s; cin >> s;
		int n; cin >> n;
		if (n == 0) return 0;

		rep(i, 0, s.length() - n) s = "0" + s;

		map<string, int> m;
		int i = 0;
		while (m.find(s) == m.end())
		{
			m[s] = i; i++;

			string a = s; sort(a.begin(), a.end(), greater<char>());
			string b = s; sort(b.begin(), b.end());

			s = calc(a, b, n);
		}

		cout << m[s] << " ";
		int ans = 0;
		rep(i, 0, n) ans = ans * 10 + s[i] - '0';
		cout << ans << " ";
		cout << i - m[s] << endl;
	}
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,j,i;
    cin>>n;
    long long a[n],b[n],p=0;
    for(i=0;i<n;i++)
    cin>>a[i]>>b[i];
    for(i=0;i<n-2;i++){
        if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2])
        p=1;
    }if(p==1)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}


Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int a, b; char c;

	int sum1 = 0, sum2 = 0, num = 0;
	while (cin >> a >> c >> b) {
		//if (!a && !b)break;

		sum1 += a * b;
		sum2 += b;
		num++;
	}

	int ans1 = sum1;
	int ans2 = round((double)sum2 / num);

	cout << ans1 << endl << ans2 << endl;
}


Measured memory_bytes: 3180
/*
AizuOnline A1501
Title　Grid
*/
#include <stdio.h>
#define min(x,y) (((x)<(y))?(x):(y))
int number[2000];
int primes[]={2,3,5,7,11,13,17,19,23,29,31};
//
long long combi(int n,int r)
{
  int i,j,k,q;
  long long product;
  
  for(i=n;i>n-r;i--)
    number[i]=i;
  
  for(i=r;i>=2;i--)
    {
      q=i;
      for(k=0;k<sizeof(primes)/sizeof(int);k++)
	{
	  if((q % primes[k])==0)
	    {
	      for(j=n;j>n-r;j--)
		{
		  if((number[j] % primes[k])==0)
		    {
		      number[j]/=primes[k];
		      goto NEXT;
		    }
		}
	    NEXT:
	      q /= primes[k];
	    }
	}
      if(q>1)
	for(j=n;j>n-r;j--)
	  {
	    if((number[j] % q)==0)
	      {
		number[j]/=q;
		break;
	      }
	  }
    }  
  
  product=1LL;
  
  for(i=n;i>n-r;i--)
    {
    product *= number[i];
    //printf("%d:",number[i]);
    product = product % 100000007;
    }
    
  return(product);
}
main()
{
  int r,c,a1,a2,b1,b2,x,y,x1,y1,x2,y2,k;


  while(EOF!=scanf("%d %d %d %d %d %d",&r,&c,&a1,&a2,&b1,&b2))
    {
      x=abs(a1-b1);
      y=abs(a2-b2);
      x1=r-x;        // wrap around
      y1=c-y;        // "    "
      k=((x==x1)?2:1)*((y==y1)?2:1);
      x2=min(x,x1);
      y2=min(y,y1);
      //printf("%d %d %d\n",x2,y2,k);
      printf("%lld\n",(combi(x2+y2,x2)*k)%100000007);
    }
return(0);
}

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

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

  vector<int> a(n);
  for (auto &i : a) {
    cin >> i;
    --i;
  }

  int idx = 0;
  int ans = 0;
  while (idx != 1) {
    ans++;
    idx = a[idx];

    if (ans > n + 2) {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

typedef pair<int, int> P;

int main() {
  int n, q, a, v, f[1000001] = {};
  
  priority_queue<P> pq;

  cin >> n >> q;
  
  for(int i=0; i<q; i++) {
    if(cin >> a >> v); else break;
    f[a] += v;
    pq.push(P(f[a], -a));
    for(;;) {
      int A = pq.top().first;
      int B = -pq.top().second;

      if(f[B] == A) {
	cout << B << " " << A << endl;
	break;
      } else {
	pq.pop();
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 6016
n = int(input())

point_t = 0
point_h = 0
for i in range(n):
    taro, hanako = input().split()
    if taro > hanako:
        point_t += 3
    elif taro < hanako:
        point_h += 3
    elif taro == hanako:
        point_t += 1
        point_h += 1
print(point_t,point_h)


Measured memory_bytes: 5596
n,*d=map(int,open(0).read().split())
f=[d[i]-d[n+i]for i in range(n)]
m=[v for v in f if v<0];p=sorted(v for v in f if v>0)
c=len(m);s=sum(m)
while s<0and p:s+=p.pop();c+=1
print([c,-1][s<0])

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

def solve():
    right_E=0
    left_W=0
    ans=10**7

    for i in range(len(s)):
        if s[i]=="E":
            right_E+=1
     
    for i in range(len(s)):
        if s[i]=="E":right_E-=1
        cnt=left_W+right_E
        ans=min(ans,cnt)
        if s[i]=="W":left_W+=1
    
    print(ans)
    
if __name__ == "__main__":
    solve()

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

int main(void) {

	std::vector<std::vector<int>> card(3, std::vector<int>(3));
	
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			std::cin >> card.at(i).at(j);
		}
	}

	int N = 0;
	std::cin >> N;
	std::vector<int> number(N);

	for (int i = 0; i < N; i++) {
		std::cin >> number[i];
	}


	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < N; k++) {
				if (number[k] == card.at(i).at(j)){
					card.at(i).at(j) = 0;
				}
			}
		}
	}

	// 確認用
	//for (int i = 0; i < 3; i++) {
	//	for (int j = 0; j < 3; j++) {
	//		std::cout << card.at(i).at(j);
	//	}
	//	std::cout << std::endl;
	//}

	bool answer = false;

	// Bingo判定
	for (int i = 0; i < 3; i++) {
		if (card.at(i).at(0) == 0 && card.at(i).at(1) == 0 && card.at(i).at(2) == 0) {
			answer = true;
		}
		if (card.at(0).at(i) == 0 && card.at(1).at(i) == 0 && card.at(2).at(i) == 0) {
			answer = true;
		}
		if (card.at(0).at(0) == 0 && card.at(1).at(1) == 0 && card.at(2).at(2) == 0) {
			answer = true;
		}
		if (card.at(2).at(0) == 0 && card.at(1).at(1) == 0 && card.at(0).at(2) == 0) {
			answer = true;
		}
	}

	if (answer == true) {
		std::cout << "Yes";
	}
	else {
		std::cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    double a,b,x;
    cin >> a >> b >> x;
    double v = a*a*b;
    double angle;
    double height = x/(a*a);
    double A = b;
    double B = 2*height-b;
    if(B < 0){
        height = x/(a*b);
        angle = atan2(2*height,b);
        angle = angle * 180/M_PI;
        printf("%.8f\n",90-angle);
    }
    else{
        angle = atan2(a,A-B);
        angle = angle * 180/M_PI;
        printf("%.8f\n",90-angle);
    }
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())

a = []
for i in range(n):
    a.append(int(input()))

max_value = max(a)
max_value_index = a.index(max(a))

a.pop(max_value_index)
second_max_value = max(a)
a.insert(max_value_index,max_value)

#print("======")
#print(max_value)
#print(max_value_index)
#print(second_max_value)
#print("======")

for i in a:
    if i != max_value:
        print(max_value)
    else:
        print(second_max_value)



Measured memory_bytes: 12660
#include <iostream>

int main() {
    std::cin.tie(0);
   	std::ios::sync_with_stdio(false);
    
    int n,r,p[20];
    r = 0 ;

    std::cin >> n;
    for (int i = 0; i < n; i++)
        std::cin >> p[i];

    for (int i=1; i<n-1;i++)
        if ((p[i-1]<p[i]&&p[i]<p[i+1])||(p[i-1]>p[i]&&p[i]>p[i+1])) r++;
	
    std::cout << r << "\n";
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	T := make([]byte, N)
	S := make([]byte, N)
	fmt.Scan(&S)
	fmt.Scan(&T)
	result := Combine(N, S, T)
	fmt.Println(string(result))
}

func Combine(N int, S, T []byte) []byte {
	result := make([]byte, 0, len(S)+len(T))
	for i := 0; i < N; i++ {
		result = append(result, S[i])
		result = append(result, T[i])
	}
	return result
}


Measured memory_bytes: 512
n1 = int(input())
nums1 = list(map(int, input().split()))
n2 = int(input())
nums2 = list(map(int, input().split()))

def linear_search(nums1, n1, key):
    nums1[n1] = key
    index = 0
    while nums1[index] != key:
        index += 1
    return index != n1

output = 0
nums1.append(None)
for key in nums2:
    if linear_search(nums1, n1, key):
        output += 1

print(output)


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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && b != c || a != b && b == c || a != b && a == c) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define vi vector <ll>
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define INF 1000000000

using namespace std;

int n;
vi tomados(3,0);
vector<vi> h,dp;

ll solve(int i,int ant){
	if(i < 0){
		return 0;
	}
	if(dp[i][ant] != -INF) return dp[i][ant];

	for (int j = 0; j < 3; ++j){
		if(ant == j) continue;
		tomados[j] = 1;
		dp[i][ant] = max(solve(i-1,j)+h[i][j],dp[i][ant]);
		tomados[j] = 0;
	}
	return dp[i][ant];
}

int main() {
	cin >> n;
    vi e(3,-INF);
    dp.assign(n,e);
    h.assign(n,e);
    for (int i = 0; i < n; ++i){
    	for (int j = 0; j < 3; ++j){
    		cin >> h[i][j];
    	}
    }
    ll ans = -INF;
    for (int i = 0; i < 3; ++i){
    	ans = max(solve(n-2,i)+h[n-1][i],ans);
    }
    cout << ans << endl;
   return 0;
}

Measured memory_bytes: 18944
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int main()
{
    int n;
    scanf(" %d", &n);

    vector<int> a(n);
    vector<int> f(n+1);
    rep(i,n)
    {
        scanf(" %d", &a[i]);
        f[a[i]]=i;
    }

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

    ll ans=0;

    for(int i=1; i<=n; ++i)
    {
        auto l = ids.lower_bound(f[i]);
        auto r = ids.lower_bound(f[i]);
        --l;

        ans += (ll)(f[i] - *l)*(*r - f[i])*i;
        ids.insert(f[i]);
    }

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


Measured memory_bytes: 11136
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var a = ReadLongs();

            var count = 0L;
            for (int i = 0; i < N; i++)
            {
                if (i % 2 == 0 && a[i] % 2 == 1)
                {
                    count++;
                }
            }
            return count;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28228
n = int(input())
L = list(map(int,input().split()))
L.sort(reverse=True)

# print(L)
ans = 0
for i in range(n):
    # print(i)
    a = L[i]
    ci = n-1
    for j in range(i+1,n-1):
        b = L[j]
        ci = max(ci,j)
        # print("ci",ci)
        while ci > j and b+L[ci] <= a:
            ci -= 1
        ans += ci-j
print(ans)



Measured memory_bytes: 43996
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append((i,n//i))
    return divisors
    
n = I()
p = make_divisors(n)
ans = n
for i in range(len(p)):
    ans = min(ans, p[i][0] + p[i][1] -2)
print(ans)


Measured memory_bytes: 4592
//B - Picture Frame
#include <bits/stdc++.h>
using namespace std;
char a[100][101];
char b[102][102];
int main(){
    //H:縦,W:横
    int H,W; cin >> H >> W;
    for(int i = 0;i < H;i++)
           scanf("%s",a[i]);

    for(int i = 0;i < H + 2;i++)
        for(int j = 0;j < W + 2;j++)
            b[i][j] = '#';
    
    for(int i = 0;i < H;i++)
        for(int j = 0;j < W;j++)
            b[i + 1][j + 1] = a[i][j];
    
    for(int i = 0;i < H + 2;i++){
        for(int j = 0;j < W + 2;j++){
            cout << b[i][j];
            }
            cout << endl;
    }
}

Measured memory_bytes: 256
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n,k;
    cin>>n>>k;
    int ar[n];
    for(int i=0;i<n;i++)
    cin>>ar[i];
    sort(ar, ar+n);
    int ans=0;
    for(int i=0;i<k;i++)
    ans+=ar[i];
    cout<<ans;
}

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

int main(){
  ll a, b, c, d; cin >> a >> b >> c >> d;
  string res =
    (c+b-1)/b > (a+d-1)/d
    ? "No" : "Yes";
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using  unll = unsigned long long;


int main() {
  int n,m;
  cin >> n >> m;
  vector<pair<int,string>> ps(m);
  vector<bool> id(n);
  vector<int> iniac(n);
  for(int i=0;i<m;i++){
    cin >> ps.at(i).first;
    cin >> ps.at(i).second;
  }
  
  
  int ac=0;
  for(int i=0;i<m;i++){
    if( !id.at( ps.at(i).first-1 ) && ps.at(i).second == "AC" ){
      ac++; //正答数
      id.at( ps.at(i).first-1 ) = true;
      iniac.at( ps.at(i).first-1 ) = i;
    }
  }
  int wa=0;
  for(int i=0;i<m;i++){
    if( id.at( ps.at(i).first-1 ) && ps.at(i).second == "WA" && i < iniac.at( ps.at(i).first-1 ) ){
      wa++;
    }
  }
  
  cout << ac << " " << wa << endl;
       

  
  
  return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;

int main(){
   int n;
   cin>>n;
   int f=0;
   int m=n;
   while(m>0){
      f+=m%10;
      m/=10;
   }
   if(n%f==0)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   

}

Measured memory_bytes: 256
def inlt():
    return(list(map(int, input().split())))


def inp():
    return(int(input()))


A = []
for t in range(3):
    A.append(inlt())

n = inp()
for t in range(n):
    b = inp()
    # mark the position of b
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                A[i][j] = 0
res = "No"
# see row wise:
for i in range(3):
    s = 0
    for j in range(3):
        s += A[i][j]
    if s == 0:
        res = "Yes"
        break
# see column wise
for i in range(3):
    s = 0
    for j in range(3):
        s += A[j][i]
    if s == 0:
        res = "Yes"
        break
# see diagonal
s = 0
for i in range(3):
    for j in range(3):
        if i == j:
            s += A[j][i]
if s == 0:
    res = "Yes"

s = 0
for i in range(3):
    for j in range(3):
        if i == j:
            s += A[j][i]
if s == 0:
    res = "Yes"

if A[0][2] == A[1][1] == A[2][0]:
    res = "Yes"

print(res)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 10000000007; //10^9+7

int main(){
  int x,y,z;
  cin>>x>>y>>z;
  int ans=(x-z)/(y+z);
  print(ans);
}

Measured memory_bytes: 256
# include<iostream>
# include<cstring>
# include<cstdio>
# include<algorithm>
# include<cmath>
using namespace std;
const int MAX=1e3+4;
int n;
double a[MAX];
int main()
{
	double s;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	  scanf("%lf",&a[i]),s+=a[i];
	s=s/n;
	double minn=1e18,k=0;
	for(int i=1;i<=n;++i)
	  if(abs(a[i]-s)<minn) k=i-1,minn=abs(a[i]-s);
	printf("%d",int(k));
}

Measured memory_bytes: 256