akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef int64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 10e16;
int inf = 10e8;
const ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

ll power(ll x, ll p) {
    x %= MOD;
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * x) % MOD;
        x = (x * x) % MOD;
        p >>= 1;
    }

    return res;
}

map<ll, ll> factorize(ll n, const vector<ll> &pr) {
    map<ll, ll> res;

    while(n > 1) {
        ++res[pr[n]];
        n /= pr[n];
    }

    return res;
}

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int N;
    cin >> N;

    // soe
    vector<ll> pr(1000005);
    REP(i, pr.size()) pr[i] = i;

    for (int i=2; i * i < pr.size(); ++i) {
        if(pr[i] != i) continue;
        for (int j=i*i; j < pr.size(); j+=i) {
            if (pr[j] == j) pr[j] = i;
        }
    }

    // get lcm as prior
    map<ll, ll> lcm;
    int a[N];
    REP(i, N) {
        cin >> a[i];

        map<ll, ll> fa;
        fa = factorize(a[i], pr);

        for(auto p: fa) {
            lcm[p.fi] = max(lcm[p.fi], p.se);
        }
    }

    // get remainder of lcm
    ll LCM = 1;
    for(auto p: lcm) {
        LCM = (LCM * power(p.fi, p.se)) % MOD;
    }
    ll res = 0;
    REP(i, N) {
        ll val = LCM * power(a[i], MOD-2);
        res = (res + val) % MOD;
    }

    cout << fixed << setprecision(20);
    cout << res << endl;
}


Measured memory_bytes: 8704
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
 
import bisect

N, H = mi()
A = [0]*N
B = [0]*N
for i in range(N):
    A[i], B[i] = mi()
 
B = sorted(B)
a = max(A)
m = bisect.bisect_left(B, a)
'''
s = 1
e = N
m = (s+e)//2
pre_m = 0
while True:
    m = (s+e)//2
    if B[m-1] > a:
        e = m
    elif B[m-1] <= a:
        s = m
    if s==e:
        m -= 1
        break
    #else:
        #break
    if e-s==1 and pre_m==m:
        break
    pre_m = m
'''
rem = H - sum(B[m:])
if rem > 0:
    print((N-m)+rem//a+(rem%a!=0))
else:
    for i in range(m, N):
        rem += B[i]
        if rem>0:
            print(N-i)
            exit()

Measured memory_bytes: 12080
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll r, g, b; cin >> r >> g >> b;
    if ((10 * g + b) % 4 == 0) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
const int man = 2e5+10;
#define IOS ios::sync_with_stdio(0)
template <typename T>
inline T read(){T sum=0,fl=1;int ch=getchar();
for(;!isdigit(ch);ch=getchar())if(ch=='-')fl=-1;
for(;isdigit(ch);ch=getchar())sum=sum*10+ch-'0';
return sum*fl;}
template <typename T>
inline void write(T x) {static int sta[35];int top=0;
do{sta[top++]= x % 10, x /= 10;}while(x);
while (top) putchar(sta[--top] + 48);}
template<typename T>T gcd(T a, T b) {return b==0?a:gcd(b, a%b);}
template<typename T>T exgcd(T a,T b,T &g,T &x,T &y){if(!b){g = a,x = 1,y = 0;}
else {exgcd(b,a%b,g,y,x);y -= x*(a/b);}}
#ifndef ONLINE_JUDGE
#define debug(fmt, ...) {printf("debug ");printf(fmt,##__VA_ARGS__);puts("");}
#else
#define debug(fmt, ...)
#endif
typedef long long ll;
const ll mod = 1e9+7;

int main() {
    #ifndef ONLINE_JUDGE
        //freopen("in.txt", "r", stdin);
        //freopen("out.txt","w",stdout);
    #endif
    int a[5];
    cin >> a[1] >> a[2] >> a[3];
    sort(a+1,a+4);
    if(a[1]==a[2]&&a[2]!=a[3]||a[2]==a[3]&&a[2]!=a[1])cout<<"Yes\n";
    else cout << "No\n";   
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[10];
int main(){
  int n; cin >> n;
  int count=0;
  for(int i=0;i<n;++i){
    int num; cin >> num;
    if(num<=3199) a[num/400]++;
    else count++;
  }
  int ans=0;
  for(int i=0;i<8;++i){
    if(a[i]!=0) ans++;
  }
  if(ans>=1){
    cout << ans << " " << ans+count << endl;
  }else{
    cout << 1 << " " << ans+count << endl;
  }
  return 0;
}

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


using namespace std;


using ll = long long;


const ll INF = 1e9;


int main() {
    ll N, M;

    cin >> N >> M;
    vector<ll> price(M);
    vector<vector<ll>> keys(M);

    ll size = 1;
    for (ll i = 0; i < N; i++) {
        size *= 2;
    }
    vector<ll> dp(size, INF);

    for (ll i = 0; i < M; i++) {
        ll a, b;
        cin >> a >> b;
        price[i] = a;
        for (ll j = 0; j < b; j++) {
            ll c;
            cin >> c;
            keys[i].push_back(c - 1);
        }
    }

    dp[0] = 0;
    for (ll i = 0; i < M; i++) {
        ll openable = 0;
        for (ll c : keys[i]) {
            openable |= (1LL << c);
        }

        for (ll bits = 0; bits < (1LL << N); bits++) {
            dp[bits | openable] = min(dp[bits | openable], dp[bits] + price[i]);
        }
    }

    if (dp[(1 << N) - 1] == INF) {
        dp[(1<< N) - 1] = -1;
    }
    cout << dp[(1 << N) - 1] << endl;
}


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

using namespace std;

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

  int n;
  cin >> n;

  vector<vector<int>> A(2, vector<int>(n));
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      cin >> A[i][j];
      // cerr << A[i][j] << " ";
    }
    cerr << '\n';
  }

  int maxa = 0;
  for (int i = 0; i < n; i++) {
    int sw = 0;
    int adda = 0;
    for (int j = 0; j < n; j++) {
      adda += A[sw][j];
      if (sw == 0 && j == i) {
        sw++;
        j--;
      }
    }
    maxa = max(maxa, adda);
  }

  cout << maxa << '\n';

  return 0;
}


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

int main(){
  int a, b;
  string s;
  cin >> a >> b >> s;
  bool clr = true;
  for(int i = 0; i < a + b + 1; i++){
    if(i == a) {
      if(s[i] != '-') clr = false;
    }else{
      if(s[i] == '-') clr = false;
    }
  }
  cout << (clr?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
    int n;
    string s;
    ll ans=1;
    int cnt=0;
    cin>>n>>s;
    vector<ll>num(n+1,1);
    for(int i=1;i<=n;++i){
        num[i]=num[i-1]*i;
        num[i]%=mod;
    }
    vector<int>r(2*n+5,0);
    for(int i=2*n;i>=1;--i){
        //if(i<2*n)if(s[i-1]!=s[i])++cnt;
        if(i%2==1){
            if(s[i-1]=='W')r[i]=r[i+1]+1;
            else {
                ans*=r[i+1];
                ans%=mod;
                r[i]=r[i+1]-1;
                ++cnt;
            }
        }
        else {
            if(s[i-1]=='B')r[i]=r[i+1]+1;
            else {
                ans*=r[i+1];
                ans%=mod;
                r[i]=r[i+1]-1;
                ++cnt;
            }
        }
    }
    if(cnt!=n)cout<<0<<endl;//左として選ぶものの数と右として選ぶものの数が合わない
    else cout<<(ans*num[n])%mod<<endl;
    return 0;
}

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

int main(){
  int n,k;
  cin>>n>>k;
  int kotae[n];
  for(int i=0;i<n;i++)kotae[i]=0;
  for(int i=0;i<k;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    kotae[a]++;
    kotae[b]++;
  }
  for(int i=0;i<n;i++){
    cout<<kotae[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3632
def main(A, B):
    if B == 1:
        return 0
    N = 1
    while A + (A-1)*(N-1) < B:
        N += 1
    return N


if __name__ == "__main__":
    A, B = map(int, input().split())
    ans = main(A, B)
    print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <stack>
#include <list>

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,b,n) for(int i=b;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

const float PI = 3.1415926;
static const int INFTY = (1<<30);

using namespace std;

typedef long long ll;
typedef long double ld;

ll ableg, score;
string inp;

int main() {
  cin >> inp;
  ableg=0;
  score=0;

  rep(i, inp.size()) {
    if(inp[i] == 'g') {
      if(ableg > 0) {
        score++;
        ableg--;
      } else {
        ableg++;
      }
    }
    if(inp[i] == 'p') {
      if(ableg > 0) {
        ableg--;
      } else {
        score--;
        ableg++;
      }
    }
  }

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

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  int n,a[200000],b[200000]={};
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    b[i]=a[i];
  }
  sort(a,a+n);
  for(int i=0; i<n; i++) {
    if(b[i]<=a[(n-1)/2]) {
      cout << a[(n-1)/2+1] << endl;
    }
    else {
      cout <<a[(n-1)/2] << endl;
    }
  }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
const int MAX_V=300000;  //変える
const int INF=10000000;  //変える
struct edge {int to, cost; };

int V;
vector <edge> G[MAX_V];
int d[MAX_V];

void dijkstra (int s){
    //小さい順に取り出す firstは最短距離、secondは頂点の番号
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d,d+V,INF);
    d[s]=0;
    que.push(P(0,s));
    
    while (!que.empty()) {
        P p=que.top();  que.pop();
        int v=p.second;
        if (d[v]<p.first) continue;
        rep(i,0,G[v].size()){
            edge e=G[v][i];
            if (d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}
int n,m;
int s,t;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    V=3*n;
    rep(i,0,m){
        int u,v;
        cin>>u>>v;
        u--; v--;
        G[u].pb(edge{v+n,1});
        G[u+n].pb(edge{v+2*n,1});
        G[u+2*n].pb(edge{v,1});
    }
    cin>>s>>t;
    s--; t--;
    dijkstra(s);
    cout <<(d[t]!=INF?d[t]/3:-1)<<"\n";
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int>> jobs(n);
    for (auto& job : jobs) {
        int a, b;
        cin >> a >> b;
        job.first = b;
        job.second = a;
    }
    sort(jobs.begin(), jobs.end());
    long long current_time = 0;
    for (auto& job : jobs) {
        current_time += job.second;
        if (current_time > job.first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   int N, K;
   cin >> N >> K;
   vector<int> A(N);
   K = min(K, 200);
   for (int i = 0; i < N; ++i) {
      cin >> A[i];
   }
   while (K--) {
      vector<int> cnts(N);
      for (int i = 0; i < N; ++i) {
         int low = max(0, i - A[i]);
         int high = min(i + A[i], N - 1);
         ++cnts[low];
         if (high + 1 < N) --cnts[high + 1];
      }
      for (int i = 1; i < N; ++i) {
         cnts[i] += cnts[i - 1];
      }
      A = cnts;
   }
   for (int i = 0; i < N; ++i) {
      cout << A[i] << " ";
   }
}


Measured memory_bytes: 4952
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var s = ReadLine();
        var t = ReadLine();
        var ssum = new int[s.Length + 1];
        for (var i = 1; i <= s.Length; i++)
            ssum[i] = ssum[i - 1] + s[i - 1] - 'A' + 1;
        var tsum = new int[t.Length + 1];
        for (var i = 1; i <= t.Length; i++)
            tsum[i] = tsum[i - 1] + t[i - 1] - 'A' + 1;
        var q = Input.num;
        var res = new List<string>();
        while (q-- > 0)
        {
            var abcd = Input.ar;
            var b = (ssum[abcd[1]] - ssum[abcd[0] - 1]) % 3 == (tsum[abcd[3]] - tsum[abcd[2] - 1])% 3;
            res.Add(b ? "YES" : "NO");
        }
        WriteLine(string.Join("\n", res));
    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(_ => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 22836
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, H, M = MAP()

h_rad = 360 * H / 12 + M / 60 * 360 / 12
m_rad = 360 * M / 60
# print(h_rad, m_rad)
h = radians(h_rad)
m = radians(m_rad)
c = A ** 2 + B ** 2 - 2 * B * A * cos(h - m)  
print(sqrt(c))
# rad = 2 * pi * H / 12

Measured memory_bytes: 10372
while 1:
    n = input()
    if n==0:
        break
    dic = {}
    for i, c in enumerate(raw_input().split()):
        dic[c] = dic.get(c, 0) + 1
        if dic[c] > n/2:
            print c, i+1
            break
        if len(dic) > 2:
            keys = sorted(dic, key=lambda x: dic[x])
            b, a = keys[-2:]
            if dic[a] > dic[b] + (n-1-i):
                print a, i+1
                break
    else:
        print "TIE"

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  long long int a;
  double b;
  cin >> a >> b;
  long long c = round(b*100);
  long long ans = a*c;
  cout << ans/100 << endl;
}

Measured memory_bytes: 3760
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# # input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
S = input()

ans = 0
for a,b,c in itertools.product(map(str,range(10)),repeat=3):
    aa = False
    bb = False
    for s in S:
        if aa == False and s == a:
            aa = True
            continue
        if bb == False and aa == True and s == b:
            bb = True
            continue
        if aa == True and bb == True and s == c:
            ans += 1
            break

print(ans)

Measured memory_bytes: 75956
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main(){
    int n = 0;
    std::vector<int> d;
    
    std::cin >> n;
    for(int i = 0; i < n; i++){
        int j = 0;
        std::cin >> j;
        d.push_back(j);
    }
    
    std::sort(d.begin(), d.end());
    
    int c = 0;
    for (int i = 0; i < d.size() - 1 ; i++) {
        if(d[i] == d[i + 1]) c++;
    }
    
    std::cout << (d.size() - c) << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL vector<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>u,v,w;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>o;
        u.PSB(o);
    }
    for(i=0; i<n; i++)
    {
        cin>>o;
        v.PSB(o);
    }
    for(i=0; i<n; i++)
    {
        cin>>o;
        w.PSB(o);
    }
    sort(v.B,v.E);
    sort(u.B,u.E);
    sort(w.B,w.E);
    k=0;
    for(i=0; i<n; i++)
    {
        o=v[i];
        if(o<=u[0] || o>=w[n-1])
        {
            z=0;
        }
        else
        {
            VL it=lower_bound(u.B,u.E,o);
            p=it-u.B;
            VL itt=upper_bound(w.B,w.E,o);
            q=itt-w.B;
            q=n-q;
            z=p*q;
        }
        k+=z;
    }
    cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 998244353;


int main() {
    int n; 
    cin >> n;
    n %= 10;
    string ret; 
    if (n == 3) ret = "bon";  
    else if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) ret = "hon";   
    else  ret = "pon";
    cout << ret << endl;   
    return 0;
}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static double[][] xy;
    static void Main()
    {
        int N = int.Parse(ReadLine());
        xy = new double[N][];
        for (int i = 0; i < N; i++)
        {
            xy[i] = ReadLine().Split().Select(double.Parse).ToArray();
        }

        int cntx = 300;
        double lowx = 0, highx = 1200;
        while (cntx-- > 0)
        {
            double c1 = (lowx* 2 + highx) / 3;
            double c2 = (lowx + highx * 2) / 3;

            if (termarySearchX(c1) > termarySearchX(c2)) lowx = c1;
            else highx = c2;
        }
        WriteLine(termarySearchX(highx));
    }
    static double termarySearchX(double x)
    {
        int cnty = 300;
        double lowy = 0, highy = 1200;
        while (cnty-- > 0)
        {
            double c1 = (lowy * 2 + highy) / 3;
            double c2 = (lowy + highy * 2) / 3;

            if (maxlength(x, c1) > maxlength(x, c2)) lowy = c1;
            else highy = c2;
        }
        return maxlength(x,highy);
    }
    static double maxlength(double x,double y)
    {
        double maxlen = 0;
        foreach (var i in xy)
        {
            maxlen = Max((x - i[0]) * (x - i[0]) + (y - i[1]) * (y - i[1]),maxlen);
        }
        return Sqrt(maxlen);
    }
}


Measured memory_bytes: 28252
<?php
    $N = intval(trim(fgets(STDIN)));
    
    $ans = array();
    
    for($i=1;$i<105;$i++){
        for($j=1;$j<105;$j++){
            for($k=1;$k<105;$k++){
                $v = $i**2 + $j**2 +$k**2 + $i*$j + $j*$k + $k*$i;
                if($v<=10000){
                    if(empty($ans[$v])){
                        $ans[$v]=1;
                    }else{
                        $ans[$v]++;
                    }
                }
            }
        }
    }
    
    for($i=1;$i<=$N;$i++){
        if(empty($ans[$i])){
            echo "0";
            echo "\n";
        }else{
            echo $ans[$i]."\n";
        }
    }
?>


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

internal static class CR
{
    public static string Get() { return Console.ReadLine(); }
    public static IEnumerable<string> GetTexts() { return Console.ReadLine().Split(' '); }
    public static int GetInteger() { return int.Parse(Console.ReadLine()); }
    public static IEnumerable<int> GetIntegers() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)); }
}

namespace AtCoderBeginnerContest
{
    internal class Program
    {
        public static int N { get; private set; }
        public static int K { get; private set; }
        public static int R { get; private set; }
        public static int S { get; private set; }
        public static int P { get; private set; }
        public static string T { get; private set; }

        private static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.WriteLine(r); }

        private static object GetResult()
        {
            var i1 = CR.GetIntegers().ToList();
            N = i1[0];
            K = i1[1];
            var i2 = CR.GetIntegers().ToList();
            R = i2[0];
            S = i2[1];
            P = i2[2];
            T = CR.Get();

            var bestHands = T.Select(x =>
            {
                switch (x)
                {
                    case 's': return 'r';
                    case 'p': return 's';
                    default: return 'p';
                }
            }).ToList();

            var score = 0;
            for (int i = 0; i < bestHands.Count; i++)
            {
                var hand = bestHands[i];
                var beforeKIndex = i - K;
                if (beforeKIndex < 0)
                {
                    score += GetScore(hand);
                    continue;
                }

                if (hand == bestHands[beforeKIndex])
                {
                    bestHands[i] = 'x';
                }
                else
                {
                    score += GetScore(hand);
                }
            }

            return score;
        }

        private static int GetScore(char v)
        {
            switch (v)
            {
                case 's': return S;
                case 'p': return P;
                default: return R;
            }
        }
    }
}


Measured memory_bytes: 14292
#include <stdio.h>

#define NUMBERS 3

int main(void){
    int num[NUMBERS];
    int i;
    int flag;
    int temp;
    
    for(i=0;i<NUMBERS;i++){
        scanf("%d", &num[i]);
    }
    
    do{
        flag=0;
        for(i=0;i<NUMBERS-1;i++){
             if (num[i]>num[i+1]){
                 temp = num[i];
                 num[i] = num[i+1];
                 num[i+1] = temp;
                 flag++;
             }  
        }
    } while(flag!=0);
    
    for(i=0;i<NUMBERS;i++){
        printf("%d", num[i]);
        if(i<NUMBERS-1){printf(" ");}
    }

    printf("\n");
    return 0;
}



Measured memory_bytes: 2032
import collections
n, k = [int(w) for w in input().split()]
r, s, p = [int(w) for w in input().split()]
score = {"s": r, "p": s, "r": p}

t = input()

cnt = collections.Counter(t)

ans = 0
ans += cnt["s"] * r
ans += cnt["p"] * s
ans += cnt["r"]*p

for i in range(k):
    sp_t = t[i:n: k]
    is_prev_lose = False
    for j in range(1, len(sp_t)):
        if sp_t[j - 1] == sp_t[j]:
            if is_prev_lose:
                is_prev_lose = False
            else:
                is_prev_lose = True
                ans -= score[sp_t[j]]
        else:
            is_prev_lose = False
print(ans)


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	vector<int> v(3);
	cin >> v[0] >>v[1] >> v[2];
	sort(BE(v));

	cout << ((v[0] + v[1]) == v[2] ? "Yes" : "No") << endl;

	return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> vi(n);
	for(int i=0;i<n;i++)
	{
		cin >> vi[i];
	}
	long long int val =0;
	long long int ans = 1e9+7;
	for(int i=-100;i<=100;i++)
	{
		for(int j=0;j<n;j++)
		{
			val+=(abs(vi[j]-i) * abs(vi[j]-i));
		}
		ans=min(val,ans);
		val=0;
	}
	cout<< ans <<endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

inf = 10**9+7
def ng(key, c=None):
    if c is None:
        return key == "agc" or key == "gac" or key == "acg"
    if key[0] == 'a' and key[1] == 'g' and c == 'c':
        "ag.c"
        return True
    if key[0] == 'a' and key[2] == 'g' and c == 'c':
        "a.gc"
        return True
    if key[1] == 'a' and key[2] == 'g' and c == 'c':
        "agc"
        return True
    if key[1] == 'g' and key[2] == 'a' and c == 'c':
        "gac"
        return True
    if key[1] == 'a' and key[2] == 'c' and c == 'g':
        "acg"
        return True
    return False


def init():
    ret = {}
    for c1 in list('acgt'):
        for c2 in list('acgt'):
            for c3 in list('acgt'):
                key = c1+c2+c3
                if ng(key):
                    continue
                ret[key] = 1
    return ret


def next(dp):
    ndp = {}
    for key in dp:
        for c in list('atcg'):
            if ng(key, c):
                continue
            nkey = key[1:] + c
            ndp.setdefault(nkey, 0)
            ndp[nkey] += dp[key] % inf
    return ndp


def main():
    N = int(input())
    dp = init()
    for i in range(N-3):
        dp = next(dp)
    print(sum(dp.values()) % inf)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end


n = inp[0]
a = inp
ans = 1e20
lsum = sum(a)
now = 0
a.each do |d|
  now += d
  ans = small((lsum-now-now).abs,ans)
end
p ans








# make space for editer

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

int main(){
    int n;
    cin >> n;
    vector<int> a(13, 0);   a[0]++;
    for(int i = 0; i < n; i++){
        int d;  cin >> d;
        a[d]++;
        if((n == 1 && d == 0) || a[d] > 2){
            cout << 0 << endl;
            return 0;
        }
    }
    if(a[0] == 2){
        cout << 0 << endl;
        return 0;
    }
    int ans = 0;
    for(int i = 0; i < 1<<11; i++){
        vector<int> tim;
        tim.push_back(0);
        if(a[12])   tim.push_back(12);
        for(int j = 0; j < 11; j++){
            if(a[j+1] == 0)   continue;
            if(a[j+1] == 2)   tim.push_back(j+1), tim.push_back(24-j-1);
            else if((i>>j)&1) tim.push_back(j+1);
            else              tim.push_back(24-j-1);
        }
        sort(tim.begin(), tim.end());
        int gap = 24-tim[tim.size()-1];
        for(int j = 1; j < tim.size(); j++) gap = min(gap, tim[j]-tim[j-1]);
        ans = max(ans, gap);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,i,j,k;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    k=n-2;
    ll s=a[n-1];
    for(i=n-2;i>=0 && k;i--){
        if(k==1) s+=a[i],k--;
        else{
            s+=2*a[i];
            k-=2;
        }
    }
    cout<<s<<endl;


}


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

namespace AtCoderMake.ABC171
{
    class ABC171A
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine();
            string ret;
            if (char.IsUpper(a[0]))
            {
                ret = "A";
            }
            else
            {
                ret = "a";
            }
            Console.WriteLine(ret);
        }
    }
}


Measured memory_bytes: 25792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >>N;
    vector<int>vec(N);
    for(int i=0;i<N;i++){
        cin>>vec.at(i);
    }
  long long sum=1;
  for(int i=0;i<N;i++){
      sum*=3;
  }
  long long kake=1;
  for(int i=0;i<N;i++){
      if(vec.at(i)%2==0){
          kake*=2;
      }
      else{
          kake*=1;
      }
  }
  cout <<sum-kake<<endl;

}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int s;
    cin >> s;
    
    int s1, s2, s3;
    s1 = s % 10;
    s2 = s % 100 / 10;
    s3 = s / 100;
    
    cout << s1 + s2 + s3 << endl;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

const int D = 60;
const int MAX_N = 200005;
int to[D][MAX_N]; // to[i][j] => 地点jから2^i個先の地点

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) {
        cin >> to[0][i];
        to[0][i]--;
    }

    rep(i, D - 1) {
        rep(j, N) {
            to[i + 1][j] = to[i][to[i][j]];
        }
    }

    int v = 0;
    for (int i = D - 1; i >= 0; i--) {
        ll l = 1ll << i;
        if (l <= K) {
            v = to[i][v];
            K -= l;
        }
    }
    cout << v + 1 << endl;
}


Measured memory_bytes: 51832
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int N = s[0];
            int X = s[1];
            int ans = 1; int tmp = 0;
            int[] input = ReadLine().Split(' ').Select(int.Parse).ToArray();
            for (int i = 0; i < N; i++)
            {
                tmp = tmp + input[i];
                if (tmp <= X)
                {
                    ans++;
                }
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl;
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;


//最大公約数
ll gcd(ll a, ll b){
  if (a%b == 0) {
    return(b);
  } else {
    return(gcd(b, a%b));
  }
}

//最小公倍数
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}

int main() {
  ll n, m; cin >> n >> m;
  string s, t; cin >> s >> t;
  ll a = lcm(n, m);
  vector<char> v = {}, w = {};
  for(int i = 0; i < n; i += a/m){
    v.push_back(s[i]);
  }
  for(int i = 0; i < m; i += a/n){
    w.push_back(t[i]);
  }
  rep(i, 0, v.size()){
    if(v[i] != w[i]){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << a << endl;
  


  return 0;
}

Measured memory_bytes: 512
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]


class Combinations:
    def __init__(self, max_num, mod):
        self.mod = mod
        self.factorials = [1]
        for i in range(1, max_num + 1):
            self.factorials.append((self.factorials[-1] * i) % mod)
        self.invs = [pow(self.factorials[-1], mod - 2, mod)]
        for i in reversed(range(1, max_num + 1)):
            self.invs.append(self.invs[-1] * i % mod)
        self.invs = self.invs[::-1]

    def __call__(self, n, k):
        if n < 0 or k < 0 or k > n:
            return 0
        return self.factorials[n] * self.invs[k] * self.invs[n - k] % self.mod


MOD = 10**9 + 7

n, k = ril()
ls = sorted(ril())

combinations = Combinations(n, MOD)
combs = [combinations(i, k - 2) for i in range(k - 2, n - 1)]

accs = [combs[0]]
for x in combs[1:]:
    accs.append(accs[-1] + x)

res = 0
for x, y in zip(ls, reversed(accs)):
    res -= x * y
    res %= MOD
for x, y in zip(reversed(ls), reversed(accs)):
    res += x * y
    res %= MOD
print(res)

Measured memory_bytes: 19864
#include <stdio.h>
#include <math.h>

int main(){

	long x;
	int i, flag, count;

	count = 0;

	while( scanf("%ld", &x) != EOF ){
		flag = 0;

		if( x == 2 ){
			//none
		}
		else if( (x < 2) || (( x % 2) == 0 )){
			flag = 1;	//Not prime number
		}
		else{
			i=3;
			while( i <= sqrt(x) ){
				if( x % i == 0 ){
					flag = 1;	//Not prime number
					break;
				}
				i += 2;
			}
		}

		if( flag == 1 ){
			//none
		}
		else{
			count++;
		}
	}

	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 596
// no proof is included. may have unused libraries. may have unused variables. possibly dirty code - contest mode

#include <iostream> // std::cin, std::cout
#include <cstring> // std::memset()
#include <algorithm> // std::max_element(), std::min_element(), std::reverse(), std::sort(), std::__gcd()

using namespace std;

bool debug = true;

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

    string s;
    int n;
    cin >> n >> s;

    int abc = 0;
    for (int i = 0; i < n - 2; i++) {
        if (s[i] == 'A' and s[i + 1] == 'B' and s[i + 2] == 'C') {
            abc++;
        }
    }

    cout << abc << endl;

    return 0;
}


Measured memory_bytes: 256
#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>;

int main(){
	int N,A,B;
	cin>>N>>A>>B;
	int x=0;
	for(int i=1;i<=N;i++){
		int n=i;
		int mod=0;
		while(n){
			mod+=n%10;
			n=n/10;
		}
		if(A<=mod&&mod<=B){
			x+=i;
			//cout<<i<<endl;
		}
	}
	cout<<x;
return 0;}

/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
#define INF (1<<28)

struct edge{int to,cost;};
struct state{
  int pos,pos2,cost;
  bool operator < (const state &p)const{
    return cost > p.cost;
  }
};

vector<edge> G[1005];
int T[1005][1005];
int n,m,k,p;
vector<int> cpoint;

int di[1005][(1<<13)];

void solve(){
  for(int i=0;i<1005;i++)
    for(int j=0;j<(1<<13);j++)
	di[i][j]=INF;

  di[p][0]=0;
  priority_queue<state> Q;
  Q.push((state){p,0,0});
  while(!Q.empty()){
    state s=Q.top();Q.pop();
    if(s.pos2+1==(1<<(k+k))){
      cout<<s.cost<<endl;
      return;
    }
    if(s.cost>di[s.pos][s.pos2])continue;
    for(int i=1;i<(int)cpoint.size();i++){
      int to=cpoint[i];
      int ncost=s.cost+T[s.pos][to];
      int npos2=s.pos2;
      int a=(i-1)/2,b=a+k;
      if(i%2){
	npos2|=(1<<a);
      }else if(i%2==0&&(s.pos2>>a)&1){
	npos2|=(1<<b);
      }
      if(ncost>=di[to][npos2])continue;
      di[to][npos2]=ncost;
      Q.push((state){to,npos2,ncost});
    }
  }
  cout<<"Cannot deliver"<<endl;
}

void dijkstra(int si){
  int d[1005];
  for(int i=0;i<1005;i++)d[i]=INF;
  d[si]=0;
  priority_queue<state> Q;
  Q.push((state){si,si,0});
  while(!Q.empty()){
    state s=Q.top();Q.pop();
    if(s.cost>d[s.pos])continue;
    for(int i=0;i<(int)G[s.pos].size();i++){
      edge e=G[s.pos][i];
      int ncost=s.cost+e.cost;
      if(ncost<d[e.to]){
	d[e.to]=ncost;
	Q.push((state){e.to,e.to,ncost});
      }
    }
  }

  for(int i=0;i<n;i++)T[si][i]=d[i];
}

void init(){
  cpoint.clear();
  for(int i=0;i<1005;i++){
    G[i].clear();
    for(int j=0;j<1005;j++){
      T[i][j]=INF;
    }
  }
}


int main(){
  while(cin>>n>>m>>k>>p){
    init();
    p--;
    cpoint.push_back(p);
    for(int i=0;i<m;i++){
      int x,y,z;
      cin>>x>>y>>z;
      x--,y--;
      G[x].push_back( (edge){y,z} );
      G[y].push_back( (edge){x,z} );
    }
    for(int i=0;i<k;i++){
      int a,b;
      cin>>a>>b;
      a--,b--;
      cpoint.push_back(a);
      cpoint.push_back(b);
    }
    for(int i=0;i<(int)cpoint.size();i++)
      dijkstra(cpoint[i]);

    //    for(int i=0;i<n;i++)      for(int j=0;j<n;j++)	cout<<i<<" "<<j<<" "<<T[i][j]<<endl;


    solve();
  }
  return 0;
}

Measured memory_bytes: 37500
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ABC102A - Multiple of 2 and N
  ll N; cin >> N;
  if(N % 2 == 0){
    cout << N << endl;
  }else{
    cout << N * 2 << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  int a;
  vector<int> X(9, 0);
  for (int i = 0; i < N; i++) {
    cin >> a;
    if (a < 400) X[0]++;
    else if (a < 800) X[1]++;
    else if (a < 1200) X[2]++;
    else if (a < 1600) X[3]++;
    else if (a < 2000) X[4]++;
    else if (a < 2400) X[5]++;
    else if (a < 2800) X[6]++;
    else if (a < 3200) X[7]++;
    else X[8]++;
  }

  int ansmin = 0;
  for (int i = 0; i < 8; i++) {
    ansmin += 0 < X[i];
  }
  ansmin = max(ansmin, 1);

  int ansmax = 0;
  for (int i = 0; i < 8; i++) {
    ansmax += 0 < X[i];
  }
  ansmax += X[8];

  cout << ansmin << ' ' << ansmax << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    ll n,e[300010]={},w[300010]={};
    cin>>n>>s;
    ll E=0,W=0;
    rep(i,n){
        if(s[i]=='E'){
            e[i+1]+=e[i]+1;
            w[i+1]+=w[i];
            E++;
        }
        else{
            e[i+1]+=e[i];
            w[i+1]+=w[i]+1;
            W++;
        }
    }
    ll ans=LLINF;
    // rep(i,n+1){
    //     cout<<e[i]<<" ";
    // }
    // cout<<endl;
    // cout<<E<<" "<<W<<endl;
    cout<<endl;
    rep(i,n){
        ans=min(ans,w[i]+e[n]-e[i+1]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5456
n,m=map(int,input().split())
k=[0]*m
s=[[0 for j in range(n)] for i in range(m)]
for i in range(m):
  x = list(map(int,input().split()))
  k = x[0]
  for j in range(1, k+1):
    s[i][x[j]-1] = 1
p=list(map(int,input().split()))

ans = 0
for x in range(2**n):
  for i in range(m):
    cnt = 0
    for j in range(n):
      if (x >> j & 1) and s[i][j]:
        cnt += 1
    if cnt % 2 != p[i]:
      break
  else:  # breakしなかった=すべて一致した場合のみ
    ans += 1
print(ans)

Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main(){
  int p, q;
  while(cin >> p >> q, p){
    vector<string> P(p), Q(q);
    for(int i = 0; i < p; ++i) cin >> P[i];
    for(int i = 0; i < q; ++i) cin >> Q[i];
    vector<int> I(p,0), r(p+1,0), c(p+1,0), s(p+1,0);
    for(int i = 0; i < p; ++i){
      int t = 0;
      r[i+1] += r[i];
      c[i+1] += c[i];
      s[i+1] += s[i];
      for(int j = 0; j < P[i].size(); ++j){
        if(P[i][j] == '.') ++t;
        if(P[i][j] != '.'){
          I[i] = max(t,I[i]);
          t = -2000000;
        }
        if(P[i][j] == '(') ++r[i+1];
        if(P[i][j] == ')') --r[i+1];
        if(P[i][j] == '{') ++c[i+1];
        if(P[i][j] == '}') --c[i+1];
        if(P[i][j] == '[') ++s[i+1];
        if(P[i][j] == ']') --s[i+1];
      }
    }
    
    vector< vector<int> > rcs;
    for(int i = 1; i < 21; ++i){
      for(int j = 1; j < 21; ++j){
        for(int k = 1; k < 21; ++k){
          bool f = true;
          for(int l = 0; l < p; ++l){
            if(r[l]*i + c[l]*j + s[l]*k != I[l]){
              f = false;
              break;
            }
          }
          if(f){
            rcs.push_back({i,j,k});
          }
        }
      }
    }
    
    vector<int> r_(q+1,0), c_(q+1,0), s_(q+1,0);
    for(int i = 0; i < q; ++i){
      r_[i+1] += r_[i];
      c_[i+1] += c_[i];
      s_[i+1] += s_[i];
      for(int j = 0; j < Q[i].size(); ++j){
        if(Q[i][j] == '(') ++r_[i+1];
        if(Q[i][j] == ')') --r_[i+1];
        if(Q[i][j] == '{') ++c_[i+1];
        if(Q[i][j] == '}') --c_[i+1];
        if(Q[i][j] == '[') ++s_[i+1];
        if(Q[i][j] == ']') --s_[i+1];
      }
    }
    vector<int> ans(q);
    for(int i = 0; i < q; ++i){
      set<int> t;
      for(int j = 0; j < rcs.size(); ++j){
        int x = rcs[j][0], y = rcs[j][1], z = rcs[j][2];
        t.insert(x*r_[i] + y*c_[i] + z*s_[i]);
      }
      if(t.size() == 1) ans[i] = *t.begin();
      else ans[i] = -1;
    }
    for(int i = 0; i < q; ++i){
      cout << ans[i];
      if(i < q-1) cout << " ";
      else cout << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3268
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
string s; cin>>s;
lint cnt = 0;
REP(i, s.size()) if(s[i]=='o') cnt++;
if(15-s.size()+cnt>=8) cout << "YES" << endl;
else cout << "NO" << endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <numeric>
#include <algorithm>
#include <stdio.h>

int main(void){
  int n,k;
  std::cin >> n >> k;
  std::vector<int> a(n);
  for(int i=0;i<n;i++){
    std::cin >> a.at(i);
  }

  for(int i=0;i<n-k;i++){
    if(a.at(i)<a.at(i+k)){
      std::cout << "Yes" << std::endl;
    }else{
      std::cout << "No" << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3984