akhauriyash/Code-Regression huggingface dataset:
void main() {
	auto S = rs;
	ulong[] arr = new ulong[](S.length);
	arr[0] = S[0] == 'B' ? 1 : 0;
	foreach(i, v; S[1..$]) arr[i+1] = arr[i] + (v == 'B' ? 1 : 0);
	ulong res;
	foreach(i, v; S[1..$]) {
		if(v == 'W') res += arr[i];
	}
	// arr.writeln;
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

// main.cpp

int main() {
  std::int_fast64_t N;
  std::cin >> N;
  std::vector<std::int_fast64_t> A;
  A.reserve(N);
  std::copy_n(std::istream_iterator<std::int_fast64_t>(std::cin), N, std::back_inserter(A));

  std::vector<std::int_fast64_t> cumsum({0});
  cumsum.reserve(N + 1);
  for (const std::int_fast64_t& A_i : A) {
    cumsum.push_back(cumsum.back() + A_i);
  }

  std::unordered_map<std::int_fast64_t, std::int_fast64_t> counts;
  for (const std::int_fast64_t& cumsum_i : cumsum) {
    counts.insert(std::make_pair(cumsum_i, 0));
    ++counts[cumsum_i];
  }

  std::cout << std::accumulate(counts.begin(), counts.end(), static_cast<std::int_fast64_t>(0), [](const std::int_fast64_t sum, const std::pair<std::int_fast64_t, std::int_fast64_t>& p) {
    return sum + p.second * (p.second - 1) / 2;
  }) << std::endl;
  return 0;
}

Measured memory_bytes: 11592
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

#define FOR(i, b, e) for(int i=(b);i<(e);i++)
#define REP(i, n) FOR(i,0,n)

#define ALL(v) (v).begin(),(v).end()

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000007;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }

int N, H[100001];

int main() {
    cin >> N;
    REP (i, N) {
        cin >> H[i];
    }
    H[0]--;
    FOR (i, 1, N) {
        if (H[i - 1] < H[i]) {
            H[i]--;
        }
        if (H[i - 1] > H[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int main() {
  int a,b,c;
  cin >> a >>b >>c;
  vector<int>s(3);
  s.at(0)=a;
  s.at(1)=b;
  s.at(2)=c;
  sort(s.begin(), s.end());
  cout << s.at(2)*10 + s.at(1) + s.at(0) <<endl;    
}


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

ll a,b,c;

int main(void){
	scanf("%lld%lld%lld",&a,&b,&c);
	if(c<a+b)
		puts("No");
	else if((c-a-b)*(c-a-b)<=4*a*b)
		puts("No");
	else
		puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
    int a, b, c, d, e;
    int x, y;
    scanf("%d%d%d%d%d", &a, &b, &c, &d, &e);
    x = a * e;
    y = (e > c) ?
                (b + d*(e - c)): b;
    int n = x < y ? x : y;
    printf("%d\n", n);
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);cout<<"\n";};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
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); }
template<typename T> vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts){   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value!=0>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value==0>::type fill_v(U &u,const V... v){ for(auto &e:u) fill_v<T>(e,v...);}
//FUNCTION  


void solve(void)
{ 
  int N,M;
  cin>>N>>M;
  vector<int> vec(N);
  int SUM = 0;
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
    SUM += vec[i];
  }
  double B = double(SUM) / 4 /(double)(M);
  int COUNT = 0;
  for (int i = 0; i < N; i++)
  {
    if(double(vec[i] >= B))COUNT++;
  }
  if(COUNT >= M)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  
  
  
  
  return;
}
  
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
def fact(n)
    n10 = 0
    n5 = 0
    n2 = 0
    for ans in 1..n do
        #10**4
        for i in 0..4-1 do 
            pow=10**(4-i)
            ans,n10=ans/pow,n10+(4-i) if ans%pow==0
        end
        #5**6
        for i in 0..6-1 do 
            pow=5**(6-i)
            ans,n5=ans/pow,n5+(6-i) if ans%pow==0
        end
        #2**14
        for i in 0..14-1 do 
            pow=2**(14-i)
            ans,n2=ans/pow,n2+(14-i) if ans%pow==0
        end
    end
    n10 + [n2,n5].min
end

while true
    n = STDIN.gets.to_i
    exit 0 if n==0
    print fact(n),"\n"
end

Measured memory_bytes: 6092
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0544

"""
import sys
from sys import stdin
input = stdin.readline




def move(pos, result):
    pos = pos + result
    try:
        if squares[pos] != 0:
            pos += squares[pos]
        return pos
    except:
        return float('inf')


squares = []
def main(args):
    global squares
    while True:
        N, M = map(int, input().split())
        if N == 0 and M == 0:
            break

        squares = [int(input()) for _ in range(N)]
        dice = [int(input()) for _ in range(M)]

        turn = 0
        pos = 0
        for d in dice:
            turn += 1
            pos = move(pos, d)
            if pos >= (N - 1):
                break
        print(turn)


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7820
// Last Change: 06/10/2019 19:50:51.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  ll H, W;
  cin >> H >> W;

  vector<string> S(H);
  string ipt;
  for (ll i = 0; i < H; ++i) {
    cin >> ipt;
    S[i] = ipt;
  }

  vector<vector<ll>> imosH(H, vector<ll>(W));
  vector<vector<ll>> imosV(H, vector<ll>(W));
  for (ll i = 0; i < H; ++i) {
    ll tmp = 0;
    ll j = 0;
    while (j < W) {
      if (S[i][j] == '.') {
        ++tmp;
      } else {
        tmp = 0;
      }
      imosH[i][j] = tmp;
      ++j;
    }
    --j;
    tmp = 0;
    while (j >= 0) {
      if (imosH[i][j] == 0) {
        tmp = 0;
      } else {
        tmp = max(tmp, imosH[i][j]);
      }
      imosH[i][j] = tmp;
      --j;
    }
  }
  for (ll i = 0; i < W; ++i) {
    ll tmp = 0;
    ll j = 0;
    while (j < H) {
      if (S[j][i] == '.') {
        ++tmp;
      } else {
        tmp = 0;
      }
      imosV[j][i] = tmp;
      ++j;
    }
    --j;
    tmp = 0;
    while (j >= 0) {
      if (imosV[j][i] == 0) {
        tmp = 0;
      } else {
        tmp = max(tmp, imosV[j][i]);
      }
      imosV[j][i] = tmp;
      --j;
    }
  }

  ll ans = 0;
  for (ll i = 0; i < H; ++i) {
    for (ll j = 0; j < W; ++j) {
      ans = max(ans, imosH[i][j] + imosV[i][j] - 1);
    }
  }

  cout << ans << endl;

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 68992
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int INF = 100000000;

class Edge{
public:
  int u, v, cost;
  Edge(int u, int v, int cost) : u(u), v(v), cost(cost) {}
  bool operator < (const Edge& s) const {
    return cost < s.cost;
  }
};

vector<Edge> es;
int V, E;
int par[101];
int rank[101];

void init(int n){
  for(int i=0;i<=n;i++){
    par[i] = i;
    rank[i] = 0;
  }
}

int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x == y) return;
  
  if(rank[x] < rank[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rank[x] == rank[y]) rank[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

int kruskal(){
  init(V);
  int tmp = (int)es.size()-1;
  int cnt = 0;
  for(int i=0;i<es.size();i++){
    Edge e = es[i];
    if(!same(e.u, e.v)){
      unite(e.u, e.v);
      tmp = i;
      cnt++;
    }
  }
  return (cnt != V-1 ? INF : es[tmp].cost - es[0].cost);
}

main(){
  while(cin >> V >> E && (V|E)){
    es.clear();
    for(int i=0;i<E;i++){
      int a, b, c;
      cin >> a >> b >> c;
      es.push_back(Edge(a, b, c));
    }
    int ans = INF;
    sort(es.begin(), es.end());
    while(es.size() >= V-1){
      int tmp = kruskal();
      if(tmp == INF) break;
      ans = min(ans, tmp);
      es.erase(es.begin());
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
  }
}

Measured memory_bytes: 1068
/* 未完成 */
#include <iostream>
#include <stdlib.h>
#include <iomanip>
using namespace std;

int main(void){
    int h,w,i,j,k;    

    while (1){
        cin >> h >> w;
        if (h == 0 && w == 0) break;

    for (int i = 0; i < w; ++i)
    {
        cout << "#";
    }

    cout << endl;
    
    for (int i = 0; i < h-2; ++i)
    {
        cout << "#";
        for (int j = 0; j < w-2; ++j)
        {
            cout << ".";
        }
        cout << "#" << endl;
    }
    for (int k = 0; k < w; ++k)
    {
        cout << "#";
    }

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

}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i<=i##end;++i)
#define DREP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i>=i##end;--i)
template<typename T>bool chkmin(T &x,const T &y){return x>y?x=y,1:0;}
template<typename T>bool chkmax(T &x,const T &y){return x<y?x=y,1:0;}
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
template<typename T>T read(){
	T x=0,f=1;
	char c=getchar();
	while((c<'0')||(c>'9')){if(c=='-')f=-1;c=getchar();}
	while((c>='0')&&(c<='9'))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
#define read() read<int>()
template<typename T>void write(T x,char c){
	static char t[25];
	static int tlen;
	t[tlen=1]=c;
	if(x<0)putchar('-'),x=-x;
	do t[++tlen]=(x%10)^48;
	while(x/=10);
	while(tlen)putchar(t[tlen--]);
}
#define pb push_back
typedef long long ll;
typedef double lf;
const int maxn=100005;
int n,m,dis[maxn];
bool vis[maxn],res=1;
struct edge{int to,cost;};
vector<edge>E[maxn];
void dfs(int u){
	vis[u]=1;
	REP(i,0,E[u].size()-1){
		int v=E[u][i].to;
		if(!vis[v])dis[v]=dis[u]+E[u][i].cost,dfs(v);
		else if(dis[v]!=dis[u]+E[u][i].cost)res=0;
	}
}
int main(){
	n=read(),m=read();
	REP(i,1,m){
		int u=read(),v=read(),w=read();
		E[u].pb((edge){v,w});
		E[v].pb((edge){u,-w});
	}
	REP(i,1,n)if(!vis[i])dfs(i);
	puts(res?"Yes":"No");
	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int gcd(int a, int b) {
  return b ? gcd(b, a % b) : a;
}


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

  vector<int> left(N+1, 0), right(N+1, 0);
  for(int i = 0; i < N; ++i) left[i+1] = gcd(left[i], A[i]);
  for(int i = N-1; i >= 0; --i) right[i] = gcd(right[i+1], A[i]);

  int ans = 0;
  for(int i = 0; i < N; ++i) {
    int l = left[i];
    int r = right[i+1];
    chmax(ans, gcd(l, r));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#define N 2000000
int n,A[N+1];
void maxHeapify(int);
int main(){
  int i;
  scanf("%d", &n);
  for(i = 1; i <= n; i++)
    scanf("%d", &A[i]);
  for(i = n/2; i >= 1; i--)
    maxHeapify(i);
  for(i = 1; i <= n; i++)
    printf(" %d", A[i]);
  printf("\n");

  return 0;
}

void maxHeapify(int i){
  int left,right,largest,t;
  left = 2*i;
  right = 2*i+1;
  if(left <= n && A[left] > A[i])
    largest = left;
  else
    largest = i;

  if(right <= n && A[right] > A[largest])
    largest = right;

  if(largest != i){
    t = A[i];
    A[i] = A[largest];
    A[largest] = t;
    maxHeapify(largest);
  }
}




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

int main(){
    int n;
    cin >> n;
    vector<int> A;
    A.push_back(0);
    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
    }
    A.push_back(0);

    int total = 0, s = 0;
    for(int i = 0; i < A.size(); i++){
        total += abs(s - A[i]);
        s = A[i];
        if(i == A.size() - 1) total += s;
    }
    
    for(int i = 1; i <= n; i++){
        int x = total;
        if(i < n){
            x -= (abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i]));
            x += abs(A[i + 1] - A[i - 1]);
        }else{
            x -= (abs(A[i]) + abs(A[i] - A[i - 1]));
            x += abs(A[i - 1]);
        }
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 1784
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

int main()
{
    int n;
    cin>>n;
    int ans=0;
    if(n%2==0)
    {
        ans=n/2.0;
    }
    else
    {
        ans=n/2.0+1.0;
    }
    cout<<setprecision(6)<<(double)ans/(double)n;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
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); }
template< typename T > using matrix = vector< vector< T > >;

//FUNCTION  
void solve(void)
{
  int N;
  cin>>N;
  vector<pair<int,int> > vec;
  for (int i = 0; i < N; i++)
  {
    int A,B;
    cin>>A>>B;
    vec.emplace_back(B+A,A-B);

  }
  sort(ALL(vec));
  for (int i = 0; i < N; i++)
  {
    // DEBUG(vec[i].first,vec[i].second);
  }
  int R = -1*INF;
  int ANS = 0;
  for (int i = 0; i < N; i++)
  {
    if(R <= vec[i].second)
    {
      R = vec[i].first;
      ANS++;
    }
  }
  cout<<ANS<<endl;
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

template<typename T>
class BIT {
public:
    int n;
    vector<T> nodes;
    BIT(int _n): n(_n), nodes(_n+1,0) {}
    void add(int i, T v) {
        for (++i; i<=n; i+=i&(-i)) nodes[i] += v;
    }
    T sum(int i) {
        T res = 0;
        for (++i; i>0; i-=i&(-i)) res += nodes[i];
        return res;
    }
};

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<int> c(N);
    for (int i=0; i<N; ++i) cin >> c[i];
    vector<tuple<int,int,int,int>> lr; // (l, r, index, answer)
    for (int i=0; i<Q; ++i) {
        int l, r;
        cin >> l >> r;
        lr.emplace_back(l, r, i, 0);
    }

    sort(lr.begin(), lr.end(), [](auto a, auto b){ return get<1>(a) < get<1>(b); });

    map<int,int> last; // (color, index)
    BIT<int> indices(N + 10);

    int k = 0;
    for (int i=0; i<Q; ++i) {
        while (k < get<1>(lr[i])) {
            if (last.count(c[k])) {
                indices.add(last[c[k]], -1);
            }
            last[c[k]] = k + 1;
            indices.add(last[c[k]], 1);
            k ++;
        }
        get<3>(lr[i]) = indices.sum(get<1>(lr[i])) - indices.sum(get<0>(lr[i]) - 1);
    }

    sort(lr.begin(), lr.end(), [](auto a, auto b){ return get<2>(a) < get<2>(b); });

    for (int i=0; i<Q; ++i) {
        cout << get<3>(lr[i]) << endl;
    }

    return 0;
}

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

int main(){
    
    while(1){
        int H,W;
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if(i >= 1 && i <= H-2 && j >= 1 && j <= W-2){
                    cout << '.';
                }else{
                    cout << '#';
                }
                if(j == W-1){
                    cout << endl;
                }
            }
        }
        printf("\n");
    }
}


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

int main()
{
	int a, b, x;
	cin >> a >> b >> x;
	if (a > x || a + b < x)
	{
		cout << "NO" << endl;
	}
	else
	{
		cout << "YES" << endl;
	}

	return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, A[105], a, b;

int main(){
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A, A + N, greater<int>());

  for (int i = 0; i < N; i++){
    if (i % 2 == 0) a += A[i];
    else b += A[i];
  }
  cout << a- b << endl;

  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll par[200010];
ll len[200010];
void init(ll n){
    for(int i=0;i<n;i++){
        par[i]=i;
        len[i]=0;
    }
}
ll root(ll n){
    if(par[n]==n)return n;
    return par[n]=root(par[n]);
}
void unit(ll a,ll b){
    a=root(a);
    b=root(b);
    if(a==b)return;
    if(len[a]<len[b]){
        par[a]=b;
    }
    else{
        par[b]=a;
        if(len[a]==len[b])len[a]++;
    }
}
int main(){
    int m;cin>>m;
    int k;cin>>k;
    int u=pow(2,m);
    if(k>=u){
        cout<<-1<<endl;
        return 0;
    }
    if(m==1){
        if(k==0)cout<<0<<" "<<0<<" "<<1<<" "<<1<<endl;
        else cout<<-1<<endl;
        return 0;
    }
    int a[2*u];
    a[0]=k;
    a[u]=k;
    vector<int> v;
    rep(i,0,u){
        if(i==k)continue;
        v.push_back(i);
    }
    rep(i,0,v.size()){
        a[i+1]=v[i];
        a[2*u-1-i]=v[i];
    }
    rep(i,0,2*u-1)cout<<a[i]<<" ";
    cout<<a[2*u-1]<<endl;
}


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

int main(){
  
  int H,W;
  cin >> H >> W;
  vector<string> a(H);
  
  for(int i = 0; i < H; ++i){
  
    cin >> a.at(i);
  
  }
  
  for(int i = 0; i < W+2; ++i){
  
    cout << "#";
  
  }
  
  cout << endl;
  
  for(int i = 0; i < H; ++i){
  
    cout << "#" << a.at(i) << "#" << endl;
  
  }
  
  for(int i = 0; i < W+2; ++i){
  
    cout << "#";
  
  }
  
  cout << endl;

  return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;
/*int main()
{
	int n; cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
//	for(int i=0;i<n;i++) cout<<a[i];
	int sum=0;
	for(int i=n-1;i>1;i--)
	{
		for(int j=i-1;j>0;j--)
		{
			if(a[i]==a[j]) continue;
			for(int k=j-1;k>=0;k--)
			{
				if(a[k]!=a[i] and a[k]!=a[j] and a[i] < (a[k] + a[j])) 
				{
					sum++;
				}
				
				if(a[k]!=a[i] and a[k]!=a[j] and a[i] >= (a[k] + a[j])) 
				{
					break;
				}
				
			}
		}
	}
	
	cout<<sum;
}

int main()
{
	int n,d,ans=0;
	cin>>n>>d;
	while(n--)
	{
		int a,b; cin>>a>>b;
		long long int fl=a*a + b*b;
		float sum=sqrt(fl);
		if(sum<=d) ans++;
		
	}
	cout<<ans;
}
int main()
{
	int n,k; cin>>n>>k;
	int a[n],sum=0;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<k;i++) sum+=a[i];
	cout<<sum; 
}
*/
int main()
{
	int n,k; cin>>n>>k;
	k%2==0 and k>=2*n and k<=4*n ? cout<<"Yes" : cout<<"No";
}


Measured memory_bytes: 3128
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
int x[100006];
int cnt[100006];
int modcnt[100006];
vector<int>modlst[100006];
int par[100006], notpar[100006];
signed main() {
	int n, m; cin >> n >> m;
	rep(i, n) {
		cin >> x[i]; cnt[x[i]]++; modcnt[x[i] % m]++;
		modlst[x[i] % m].push_back(x[i]);
	}
	rep(i, m) {
		sort(modlst[i].begin(), modlst[i].end());
		modlst[i].push_back(inf);
	}
	rep(i, m) {
		int now = modlst[i][0],c=0;
		rep(j, modlst[i].size()) {
			if (modlst[i][j] == now)c++;
			else {
				par[i] += c/2;
				notpar[i] += c%2;
				c = 1;
				now = modlst[i][j];
			}
		}
	}
	
//	rep(i, m)cout << par[i] << ' ' << notpar[i] << endl;

	int ans = 0;
	rep(i, m/2+1) {
		if (!i||i*2==m) {
			int x = modcnt[i] / 2;
			ans += x;
		}
		else {
			int x = min(modcnt[i], modcnt[(m - i) % m]);
			if (modcnt[i] > modcnt[(m - i) % m]) {
				x += min(par[i], par[i]-(modcnt[(m - i) % m] - notpar[i]+1)/2);
			}
			else {
				x += min(par[(m-i)%m], par[(m-i)%m] - (modcnt[i] - notpar[(m-i)%m] + 1) / 2);
			}
			ans += x;
		}
//		cout<<ans<<endl;
	}
	cout << ans << endl;
}

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


int main(){
    ios::sync_with_stdio(0);
    string s, t, u;
    int a,b;
    cin >> s >> t >> a >> b >> u;
    if (u == s)
        cout << a-1 << " " << b;
    else
        cout << a << " " << b-1;
    return 0;
}


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

int main(){
    int S,h,m,s;
    scanf("%d",&S);
    h = floor(S/3600);
    m = floor(S/60)-h*60;
    s = S - m*60 - h*3600;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<pair<int, int>, int> ppi;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef bitset<60> Bitset;
const ll INFL = 1LL << 60;
const int INF = 1000000005;
const int MAX = 300000;
const int MOD = 1000000007;
struct Graph{int to,coin; ll cost;};
struct Edge{int from,to,coin; ll cost;};
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
//------------------------------------------------------------------------------------------------------------------------------

int main(void) {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    ll n;cin>>n;
    cout<<n*(n-1)/2<<endl;
}


Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		StringBuilder result = new StringBuilder();

		while(true){

			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();

			if(op.equals("?"))break;

			int ans = 0;

			switch(op){
			case "+":
				ans = a+b;
				break;
			case "-":
				ans = a-b;
				break;
			case "*":
				ans = a*b;
				break;
			case "/":
				ans = a/b;
				break;
			}
			result.append(Integer.toString(ans)).append("\n");
		}
		System.out.print(result.toString());
	}
}




Measured memory_bytes: 26356
#include <bits/stdc++.h> //H - Grid 1
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
const int maxn = 1100;
const int mod = 1e9 + 7;
typedef long long int ll;


int dp[maxn][maxn];
bool mm[maxn][maxn];
int n,m,ans;



int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	cin>>n>>m;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
		{
			char c;
			cin>>c;
			if(c == '.') mm[i][j] = true;
			else mm[i][j] = false;
		}

	dp[1][1] = 1;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
		{
			dp[i][j] = (dp[i][j] + (mm[i-1][j] == true ? dp[i-1][j] : 0))%mod;
			dp[i][j] = (dp[i][j] + (mm[i][j-1] == true ? dp[i][j-1] : 0))%mod;
		}

	cout<<dp[n][m]<<'\n';
}

Measured memory_bytes: 8992
// Name: Kanisht Agarwal Copyright Think before u copy //
//Connect with me at LinkedIn

#include <bits/stdc++.h>
#define mod 1000000007
#define ull unsigned ll
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.1415926535897932
#define nui 100
#define INF 100000000000
using namespace std;

ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
        {
            res *= a;
        }
        a *= a;
        b >>= 1;
    }
    return res;
}

ll fermat_inv(ll y) {return binpow(y, mod - 2);}

clock_t time_p = clock();

void TLE()
{
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}

struct point
{
    int x; int y;
};
bool segment(point p, point q, point r)
{
    if (q.x <= max(p.x, r.x) && q.y <= max(p.y, r.y) && q.x >= min(p.x, r.x) && q.y >= min(p.y, r.y))
        return true;

    return false;
}
int orientation(point p, point q, point r)
{
    int o = (r.x - q.x) * (q.y - p.y) - (r.y - q.y) * (q.x - p.x);
    if (o == 0)return 0;
    return (o > 0) ? 1 : 2;
}
bool intersection(point p, point q, point r, point s)
{
    int o1 = orientation(p, q, r);
    int o2 = orientation(p, q, s);
    int o3 = orientation(r, s, p);
    int o4 = orientation(r, s, q);
    if (o1 != o2 && o3 != o4)return true;
    if (o1 == 0 && segment(p, r, q))return true;
    if (o2 == 0 && segment(p, s, q))return true;
    if (o3 == 0 && segment(r, p, s))return true;
    if (o4 == 0 && segment(r, q, s))return true;

    return false;
}

bool prime[10000001];
vector<ll>v;
void seive()
{
    memset(prime, 1, sizeof(prime));
    for (ll i = 2; i * i <= 10000001; i++)
    {
        if (prime[i] == 1)
        {
            for (ll j = i * i; j <= 10000001; j += i)
            {
                prime[j] = 0;
            }
        }
    }
    for (ll i = 2; i <= 10000001; i++)
    {
        if (prime[i])
        {
            v.pb(i);
        }
    }

}



int main()
{

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll n;
    cin >> n;
    ll W;
    cin >> W;
    ll V = 0;
    ll v[n], w[n];

    vector<pair<ll, ll> >ve;


    for (ll i = 0; i < n; i++)
    {
        cin >> w[i] >> v[i];
        V += v[i];
        ve.pb(mp(w[i], v[i]));
    }
    vector<ll>dp(V + 1, INF);
    dp[0] = 0;
    for (ll i = 0; i < n; i++)
    {
        for (ll j = V - ve[i].ss; j >= 0; j--)
        {
            dp[j + ve[i].ss] = min(dp[j + ve[i].ss], dp[j] + ve[i].ff);
        }
    }
    ll ans = 0;
    for (ll i = 1; i <= V; i++)
    {
        if (dp[i] <= W)
        {
            ans = max(ans, i);
        }
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 4048
import collections
from functools import lru_cache


def read():
    return input().strip()


def readInt():
    return int(input().strip())


def readList():
    return list(map(int, input().strip().split()))


def solve(s):
    i = 0
    N = len(s)
    ans = 0

    while i < N:
        while i < N and s[i] == "S":
            i += 1

        if i >= N:
            break

        j = i+1

        while j < N and s[j] == "R":
            j += 1

        ans = max(ans, j-i)
        i = j

    return ans


s = read()
print(solve(s))


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

using namespace std;

typedef long long ll;
typedef pair <ll, ll> point;

#define x first
#define y second

const int N = 200010;

point p[N];
ll t[2][N << 1];
int n, id[N], rev[N];

void update (int id, int p, ll v) {
  for (t[id][p += n] = v; p > 1; p >>= 1) {
    t[id][p >> 1] = min(t[id][p], t[id][p ^ 1]);
  }
}

ll get (int id, int l, int r) {
  ll ret = LLONG_MAX / 69;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) ret = min(ret, t[id][l++]);
    if (r & 1) ret = min(ret, t[id][--r]);
  }
  return ret;
}

int main() {
  cin >> n;
  vector <ll> ys;
  for (int i = 0; i < n; ++i) {
    scanf("%lld %lld", &p[i].x, &p[i].y);
    id[i] = i, ys.emplace_back(p[i].y);
  }
  sort(p, p + n);
  sort(id, id + n, [] (int i, int j) {
    return p[i].y < p[j].y;
  });
  for (int i = 0; i < n; ++i) {
    rev[id[i]] = i;
  }
  for (int i = 0; i < n + n; ++i) {
    t[0][i] = t[1][i] = LLONG_MAX / 69;
  }
  sort(ys.begin(), ys.end());
  ll ans = LLONG_MIN / 69;
  for (int i = 0, pos; i < n; ++i) {
    pos = upper_bound(ys.begin(), ys.end(), p[i].y) - ys.begin();
    ans = max(ans, p[i].x + p[i].y - get(0, 0, pos));
    update(0, rev[i], p[i].x + p[i].y);
    pos = lower_bound(ys.begin(), ys.end(), p[i].y) - ys.begin();
    ans = max(ans, p[i].x - p[i].y - get(1, pos, n));
    update(1, rev[i], p[i].x - p[i].y);
  }
  cout << ans << '\n';
  return 0;
}



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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define for_each(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = __INT_MAX__;               // 2^31 - 1
const long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    string s;
    int q;
    cin >> s >> q;
    bool r = false;
    deque<char> dq;
    rep(i, s.size()) {
        dq.push_back(s[i]);
    }
    rep(i, q) {
        int x;
        cin >> x;
        if (x == 1) {
            if (r)
                r = false;
            else
                r = true;
        } else {
            int t;
            char c;
            cin >> t >> c;
            if (t == 1) {
                if (r)
                    dq.push_back(c);
                else
                    dq.push_front(c);
            } else {
                if (r)
                    dq.push_front(c);
                else
                    dq.push_back(c);
            }
        }
    }
    string ans = "";
    while (!dq.empty()) {
        ans += dq.front();
        dq.pop_front();
    }
    if (r) reverse(all(ans));
    out(ans);
    return 0;
}


Measured memory_bytes: 1412
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


int main(){
	char ss[120];
	int i,c;
	c=0;
	while(0<=scanf("%s",ss)){
		for(i=0;i<=strlen(ss)-1;i++){
			if(ss[i]!=ss[strlen(ss)-i-1])break;
		}
		
		if(i==strlen(ss))++c;
	}
	printf("%d\n",c);
	return 0;
}

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

int main() {
    string S;
    cin >> S;
    bool a, b, c;
    a = b = c = false;
    for (int i=0; i < 3; i++) {
        if (S[i] == 'a') {
            a = true;
        } else if (S[i] == 'b') {
            b = true;
        } else if (S[i] == 'c') {
            c = true;
        }
    }

    if (a && b && c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

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

    vector<pair<int, int>> ab(n);

    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        ab[i] = make_pair(a, b);
    }

    sort(ab.begin(), ab.end(), [](pair<int, int> lhs, pair<int, int> rhs) {
        return lhs.first < rhs.first;
    });

    vector<vector<int>> dp(n, vector<int>(t+10, 0));

    dp[0][ab[0].first] = ab[0].second;
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = 0; j < t; j++)
        {
            dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]);
            if (j + ab[i + 1].first < t)
            {
                int aip1 = ab[i + 1].first;
                int bip1 = ab[i + 1].second;
                dp[i + 1][j + aip1] = max(dp[i][j] + bip1, dp[i + 1][j + aip1]);
            }
        }
    }

    int max_b = 0;
    for (int i = 0; i < n - 1; i++)
    {
        int max_dp = 0;
        for (int j = 0; j < t; j++)
        {
            max_dp = max(max_dp, dp[i][j]);
        }
        max_dp += ab[i + 1].second;
        max_b = max(max_b, max_dp);
    }

    cout << max_b << endl;

    return 0;
}

Measured memory_bytes: 35712
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

int main() {
  ll k;
  cin >> k;
  vector<ll> v(k,-1);
  priority_queue<P,vector<P>,greater<P>> q;
  auto push = [&](ll nk,ll d){
    nk %= k;
    if(0<v[nk] && v[nk]<=d) return;
    v[nk]=d;
    q.emplace(d,nk);
  };
  push(1,1);
  while(!q.empty()){
    P p = q.top(); q.pop();
    ll d = p.first, k = p.second;
    if(k%10<9) push(k+1,d+1);
    push(k*10,d);
  }
  cout << v[0] << endl;
}

Measured memory_bytes: 2168
// Try Hitachi Hokudai Labo & Hokkaido University Contest 2019-1
// author: Leonardone @ NEETSDKASU

fn main() {
    let io = StandardIO::new();
    let mut io = io.get_io();

    let (_, e): (usize, usize) = io.get2();

    for _ in 0..e {
        io.get_line();
    }

    let freqs = io.get_vec::<usize>();

    let t_max = if freqs[0] != 0 {
        freqs[0]
    } else {
        io.get()
    };

    if freqs[0] != 0 {
        for _ in 0..t_max {
            let n_new = io.get();
            for _ in 0..n_new {
                io.get_line();
            }
        }
        for _ in 0..t_max {
            io.println(-1);
        }
    } else {
        for _ in 0..t_max {
            let n_new = io.get();
            for _ in 0..n_new {
                io.get_line();
            }

            let n_put = io.get();
            for _ in 0..n_put {
                io.get_line();
            }

            io.println(-1);

            if io.gets() != "OK" {
                break;
            }

            let n_ach = io.get();
            for _ in 0..n_ach {
                io.get_line();
            }
        }
    }
}

struct StandardIO {
    stdin: std::io::Stdin,
    stdout: std::io::Stdout,
}

struct IO<'a> {
    stdin: std::io::StdinLock<'a>,
    stdout: std::io::StdoutLock<'a>,
}

impl StandardIO {
    fn new() -> Self {
        StandardIO {
            stdin: std::io::stdin(),
            stdout: std::io::stdout()
        }
    }
    fn get_io(&self) -> IO {
        IO {
            stdin: self.stdin.lock(),
            stdout: self.stdout.lock()
        }
    }
}

impl<'a> IO<'a> {
    fn get_line(&mut self) -> String {
        let mut line = String::new();
        std::io::BufRead::read_line(&mut self.stdin, &mut line).unwrap();
        line
    }
    fn gets(&mut self) -> String {
        self.get_line().trim().to_string()
    }
    fn get<A>(&mut self) -> A
        where
            A: std::str::FromStr,
            <A as std::str::FromStr>::Err: std::fmt::Debug {
        self.get_line().trim().parse().unwrap()
    }
    fn get2<A,B>(&mut self) -> (A,B)
        where
            A: std::str::FromStr,
            B: std::str::FromStr,
            <A as std::str::FromStr>::Err: std::fmt::Debug,
            <B as std::str::FromStr>::Err: std::fmt::Debug {
        let line = self.get_line();
        let mut tokens = line.split_whitespace();
        let a: A = tokens.next().unwrap().parse().unwrap();
        let b: B = tokens.next().unwrap().parse().unwrap();
        (a, b)
    }
    fn get_vec<A>(&mut self) -> Vec<A>
        where
            A: std::str::FromStr,
            <A as std::str::FromStr>::Err: std::fmt::Debug {
        self
            .get_line()
            .split_whitespace()
            .map(|v| v.parse().unwrap())
            .collect()
    }
    fn println(&mut self, v: i32) {
        use std::io::Write;
        writeln!(&mut self.stdout, "{}", v).unwrap();
        self.stdout.flush().unwrap();
    }
}

Measured memory_bytes: 5456
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;

using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007

ll mod_pow(ll a,ll b) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2);
}

void solve() 
{
	ll n;
	
	map<ll , ll> mp1;
	
	cin >> n;
	
	for(ll i = 2; i*i <= n; ++i) {
		int cn = 0;
		
		while(n % i == 0) {
			cn++;
			
			n = n/i;
		}
		
		if(cn > 0) {
			mp1[i] = cn;
		}
	}
	
	if(n > 1) {
		mp1[n] = 1;
	}
	
	int tot = 0;
	
	for(auto u : mp1) {
		int cur = 1;
		
		int req = u.S;
		
		while(req >= cur) {
			req -= cur;
			cur++;
			tot++;
		}
	}
	
	cout << tot ;
}

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


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if (e - a <= k)
    cout << "Yay!" << endl;
  else
    cout << ":(" << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
        long num = 100;
        long index = 1;
        while (true) {
        	long r = num/100;
        	num += r;
        	if (X <= num) {
        		break;
        	}
        	index++;
        }
        System.out.println(index);
    }
}

Measured memory_bytes: 35880
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define Num 1000000007
// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    if(a<=8 && b<=8){
        cout<<"Yay!"<<endl;
    }
    else {
        cout<<":("<<endl;
    }
    return 0;
}

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

int mod = 1e9+7;

void solve()
{
    int n; cin >> n;
    vector<int> v(n);
    vector<ll> suffix(n + 1);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    for (int i = n - 1; i >= 0; --i) {
        suffix[i] = (v[i] + suffix[i + 1]) % mod;
    }
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ans = (ans + (v[i] * suffix[i + 1] % mod)) % mod;
    }
    cout << ans << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 5564
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
signed main()
{
    IOS
    string str; cin>>str;
    for(int i=0;i<str.length();i++)
    {
        if((i%2 == 0 && str[i] == 'L') || (i%2 == 1 && str[i] == 'R'))
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

"""
左端の順番を固定して考えた.(A,B,Cの順とする)
n : Aの長さ, m : Bの長さ, l : Cの長さ
AB : Aを固定した時のBが一致する先頭位置
    ⇒ Aの先頭からAの末尾+1の位置までn+1箇所考える
AC : Aを固定した時のCが一致する先頭位置
    ⇒ Aの先頭からAの末尾+1の位置までn+1箇所考える
BC : Bを固定した時のCが一致する先頭位置
　　⇒ Bの先頭からBの末尾+1の位置までm+1箇所考える + nがmより大きい場合はBとCが離れているかもしれないので, Aの末尾+1まで考える
"""

def compare(a, b):
    return a == '?' or b == '?' or a == b

def solve(A, B, C):
    n, m, l = len(A), len(B), len(C)
    AB, AC, BC = [True]*(n+1), [True]*(n+1), []
    for i in range(n):
        for j in range(m):
            if i + j >= n:
                continue
            if not compare(A[i + j], B[j]):
                AB[i] = False
                break
    
    for i in range(n):
        for j in range(l):
            if i + j >= n:
                continue
            if not compare(A[i + j], C[j]):
                AC[i] = False
                break

    for i in range(n):
        for j in range(l):
            if i + j >= m:
                continue
            if compare(B[i + j], C[j]):
                continue
            break
        else:
            BC.append(i)
    for i in range(max(0,n-m)):
        BC.append(m+i)

    res = n + m + l
    for i in range(n+1):
        if AB[i]:
            for j in BC:
                if i + j >= n:
                    res = min(res, max(n, i + m, i + j + l))
                elif AC[i + j]:
                    res = min(res, max(n, i + m, i + j + l))
    return res

def main():
    a = input()
    b = input()
    c = input()
    ans = min(solve(a,b,c),solve(a,c,b),solve(b,a,c),solve(b,c,a),solve(c,a,b),solve(c,b,a))
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 49884