akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N; cin >> N;
  string S; cin >> S;
  vector<int> W(N), E(N);
  if (S.at(0) == 'W') W.at(0) = 1;
  for (int i = 1; i < N; i++) {
    W.at(i) = W.at(i-1);
    if (S.at(i) == 'W') W.at(i)++;
  }
  if (S.at(N-1) == 'E') E.at(N-1) = 1;
  for (int i = N-2; i >= 0; i--) {
    E.at(i) = E.at(i+1);
    if (S.at(i) == 'E') E.at(i)++;
  }
  int ans = 10000000;
  ans = min(ans, E.at(1));
  ans = min(ans, W.at(N-2));
  for (int i = 1; i < N-1; i++) {
    ans = min(ans, W.at(i-1) + E.at(i+1));
  }
  cout << ans << endl;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define INF 1145141919
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long int ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
////////////////////////////////////////////////////////////////////
int main()
{
    int N,K;
    string S;

    cin >> N >> S >> K;

    char res = S[K-1];

    REP(i,S.size()){
        if(S[i]!=res){
            S[i]='*';
        }
    }

    cout << S << endl;

    return 0;
}


Measured memory_bytes: 256
a, b, c, x = 4.times.map{ gets.to_i }
cnt = 0
(0..a).each do |i|
  (0..b).each do |k|
    (0..c).each do |m|
      cnt += 1 if 500*i + k*100 + m*50 == x
    end
  end
end
puts cnt

Measured memory_bytes: 1788
#include <bits/stdc++.h>
   using namespace std;
   int main(){
   	int n, k;
   	cin >> n >> k;
   	vector<int> h(n);
   	for(int i = 0; i < n; i++){
   		cin >> h[i];
   	}
   	int ans = 0;
   	for(int i = 0; i < n; i++) if(h[i] >= k) ans++;
   	cout << ans << endl;
   }

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<set>
#include<sstream>
#include<cstring>
#include<cmath>
#include<map>
using namespace std;
typedef  long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ull t,tot = 0;
	cin>>t;
	for(ll k = 1;k<=t;k++){
		if(k%3 && k % 5) tot += k;
	}
	cout<<tot;
	return 0;
}

Measured memory_bytes: 3640
import sys
import math

input = sys.stdin.readline

a, b, c = map(int, input().split())

right = (c - b - a)**2
left = 4 * a * b


if c - a - b <= 0:
    print('No')
    exit()
if left < right:
    print('Yes')
else:
    print('No')

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

template<class T> inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
struct Unionfind {
    vector<int> par;
    vector<int> sizes;

    Unionfind(int n) : par(n), sizes(n, 1) {
        for(int i = 0; i < n; ++i) par[i] = i;
    }

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

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        if(sizes[x] < sizes[y]) swap(x, y);
        par[ry] = rx;
        sizes[rx] += sizes[ry];
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

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

};

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

    int n;
    cin >> n;

    int flag = 0;
    rep(i, n) {
        int d1, d2;
        cin >> d1 >> d2;

        if(d1 == d2) ++flag;
        else flag = 0;
        

        if(flag == 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr,0,sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        int n;
        cin >> n;
        cout << a[n - 1] << '\n';
    } 
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    string s;
    cin >> s;
    int z = 0;
    int o = 0;
    for (i = 0; i < s.size(); i++) {
        if (s[i] == '0')
            z++;
        else
            o++;
    }
    cout << 2 * min(z, o) << endl;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
//const int mod = 1000000007;
const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int n, l;
  cin >> n >> l;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  sort(ALL(s));
  string ans = "";
  rep(i, n) ans += s[i];
  cout << ans << endl;
}

Measured memory_bytes: 3636
N, M = map(int, input().split())
A = list(map(int, input().split()))

acc_A = [0]
d = dict()
for i in range(N):
    acc_A.append((acc_A[i] + A[i]) % M)
    if acc_A[i + 1] in d:
        d[acc_A[i + 1]] += 1
    else:
        d[acc_A[i + 1]] = 1

result = 0
for i in range(N):
    if acc_A[i] in d:
        result += d[acc_A[i]]
    d[acc_A[i + 1]] -= 1
print(result)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

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; }
const int INF = 1e9;
const long long INFLL = 1LL<<60;

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

  string s, t;
  cin >> s >> t;
  if (s.size() < t.size()) {
    puts("UNRESTORABLE");
    return 0;
  }

  int idx = -1;
  for (int i = s.size() - t.size(); i >= 0; i--) {
    bool flag = true;
    for (int j = 0; j < t.size(); j++) {
      if (s[i+j] != t[j] && s[i+j] != '?') {
        flag = false;
        break;
      }
    }
    if (flag) chmax(idx, i);
  }

  if (idx == -1) {
    puts("UNRESTORABLE");
    return 0;
  }

  rep(i, t.size()) {
    s[idx+i] = t[i];
  }

  rep(i, s.size()) {
    if (s[i] == '?') s[i] = 'a';
  }

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String strNum = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
        String[] num_Array = strNum.split(", ");
        int k = sc.nextInt();
        System.out.println(num_Array[k-1]);
    }
}

Measured memory_bytes: 22228
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string>
using namespace std;

int main(){
    long long int n, k;
    cin >> n >> k;

    vector<long long int> num(100001, 0);
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        num[a] += b;
    }

    for(int i = 1; i <= 100001; i++){
        k -= num[i];
        if(k <= 0){
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
//小さい順にソート
int c[100002];
void merge(int i,int j,int *s){
  if(i!=j){
    merge(i,(i+j)/2,s);
    merge((i+j)/2+1,j,s);
    int a=i,b=(i+j)/2+1;
    int d;
    for(d=i;d<=j;d++){
      if((i+j)/2<a){
        c[d]=s[b];
        b++;
      }
      else if(j<b){
        c[d]=s[a];
        a++;
      }
      else if(s[a]<s[b]){
        c[d]=s[a];
        a++;
      }
      else{
        c[d]=s[b];
        b++;
      }
    }
    for(d=i;d<=j;d++)
      s[d]=c[d];
  }
}

int main(){
  int n,i;
  scanf("%d",&n);
  int a[n+1];
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  merge(0,n-1,a);
  int count=1;
  for(i=1;i<n;i++)
    if(a[i]!=a[i-1])
      count++;
  printf("%d\n",count%2==0?count-1:count);
  return 0;
}

Measured memory_bytes: 2452
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int t8, tA;
    cin >> t8 >>  tA;
    
    int o = tA * 10 + 9;
    
    bool exist = false;
    while(0 <= o){
    	int o8 = (int)(o * 0.08);
    	int oA = (int)(o * 0.10);
        if(o8 == t8 && oA == tA) exist = true;
        if((o8 != t8 || oA != tA) && exist) break;
        o--;
    }
    
    if(!exist){
	    cout << -1 << endl;
    }else{
	    cout << o + 1 << endl;
    }
  
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

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

  char a, b;
  cin >> a >> b;

  if (a == 'D') b = (b=='H' ? 'D' : 'H');
  cout << b << LF;

  return 0;
}



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

int binarySearch(int A[], int n, int key){
    int left = 0;
    int right = n;
    int m;
    
    if(key < A[0] || key > A[n-1]) return 0;
    while(left < right){
        m = (left+right)/2;
        if(A[m] > key){
            right = m;
        }
        else if(A[m] < key){
            left = m+1;
        }
        else{
            return 1;
        }
    }
    return 0;
}

int main(){
    int n, q, sum=0;
    int S[100000], T[100000];
    
    cin >> n;
    for(int i=0; i<n; i++) scanf("%d", &S[i]);
    cin >> q;
    for(int i=0; i<q; i++) scanf("%d", &T[i]);
    
    for(int i=0; i<q; i++){
        if(binarySearch(S, n, T[i])) sum++;
    }
    cout << sum << endl;
}


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


int getDigitSum(int N) { // 各位の桁の和を返す
	int ans = 0;
	while (N != 0) {
		ans += N % 10;
		N /= 10;
	}
	return ans;
}
int main() {
	int N;
	cin >> N;
	int ans = 100000;
	for (int i = 1;i < N;i ++) {
		ans = min(ans, getDigitSum(i) + getDigitSum(N - i));
	}
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

計算量に余裕があるので愚直コード
*/

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

    if(x-r<0 || x+r>W || y-r<0 || y+r>H)
      {
	printf("No\n");
      }
    else
      {
	printf("Yes\n");
      }

  return 0;
}

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

#define ll long long
#define lli long long int
#define loop(i,x,n) for(lli i=x; i<=n; i++)
#define rloop(i,n,x) for(lli i=n; i>=x; i--)

typedef vector<ll> v64;
typedef vector<pair<ll,ll>> vp64;
typedef vector<bool> vbo;
typedef set<ll> s64;
typedef set<bool> sbo;
typedef unordered_set<ll> us64;
typedef map<ll,ll> m64;
typedef unordered_map<ll,ll> um64;

int main(){
    string s,t;
    cin>>s>>t;
    int ans = 0;
    for(int i=0; i<s.length(); i++){
        if(s[i]==t[i]) ans++;
    }   
    cout<<ans;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define all(x) (x).begin(), (x).end()
#define fap(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

const int inf = 0x3f3f3f3f;
const ll INF = 2e18;

int main() {
	FastIO;

	int n;
	cin >> n;

	vector<int> a(n);
	for(int &x : a) cin >> x;

	ll res = 0;
	for(int i=0; i<n; ) {
		if(a[i] % 2 == 0) {
			res += a[i] / 2;
			++i;
		}
		else {
			ll sum = 0;
			for( ; i<n and a[i]; ++i) {
				sum += a[i];
			}
			res += sum / 2;
		}
	}
	cout << res << "\n";
	
	return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
class Main
{
	static void merge(int arr[], int l, int m, int r) 
    { 
        int n1 = m - l + 1; 
        int n2 = r - m; 
        int L[] = new int [n1]; 
        int R[] = new int [n2]; 
        for (int i=0; i<n1; ++i) 
            L[i] = arr[l + i]; 
        for (int j=0; j<n2; ++j) 
            R[j] = arr[m + 1+ j]; 
        int i = 0, j = 0; 
        int k = l; 
        while (i < n1 && j < n2) 
        { 
            if (L[i] <= R[j]) 
            { 
                arr[k] = L[i]; 
                i++; 
            } 
            else
            { 
                arr[k] = R[j]; 
                j++; 
            } 
            k++; 
        } 
        while (i < n1) 
        { 
            arr[k] = L[i]; 
            i++; 
            k++; 
        } 
        while (j < n2) 
        { 
            arr[k] = R[j]; 
            j++; 
            k++; 
        } 
    } 
    static void sort(int arr[], int l, int r) 
    { 
        if (l < r) 
        { 
            int m = (l+r)/2; 
            sort(arr, l, m); 
            sort(arr , m+1, r); 
            merge(arr, l, m, r); 
        } 
    } 
    static int gcd(int a, int b) 
    { 
      if (b == 0) 
        return a; 
      return gcd(b, a % b);  
    } 
    static long power(long n,long m)
    {
    	if(m==0)
    		return 1;
    	long ans=1;
    	while(m>0)
    	{
    		ans=ans*n;
    		m--;
    	}
    	return ans;
    }
	static int binarySearch(ArrayList<Integer> arr, int x) 
    { 
        int l = 0, r = arr.size() - 1,m=l + (r - l) / 2; 
        while (l <= r) { 
            m = l + (r - l) / 2; 
            if (arr.get(m) == x) 
                return m; 
            if (arr.get(m) < x) 
                l = m + 1; 
            else
                r = m - 1; 
        } 
        return (int)Math.max(l, m); 
    } 
	public static void main(String args[])throws Exception
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int t=1;//Integer.parseInt(br.readLine());
	    outer:for(int i=1;i<=t;i++)
	    {
	        double n=Double.parseDouble(br.readLine());//,k;
	        double ans=n*44/7;
	        System.out.println(ans);
	    }
	}
}


Measured memory_bytes: 33044
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vl a(n);
    ll sumA = 0;
    rep(i, n) {
        cin >> a[i];
        sumA += a[i];
    }

    vl b(n);
    ll sumB = 0;
    rep(i, n) {
        cin >> b[i];
        sumB += b[i];
    }

    if(sumA < sumB) {
        out(-1);
        re0;
    }

    ll u = 0;
    ll ans = 0;
    rep(i, n) {
        if(a[i] < b[i]) {
            u += b[i] - a[i];
            ans++;
        }
    }

    vl c(n);
    rep(i, n) {
        c[i] = a[i] - b[i];
    }
    sort(rall(c));

    ll cnt = 0;
    rep(i, n) {
        if(u <= cnt) {
            out(ans);
            re0;
        }
        cnt += c[i];
        ans++;
    }



    re0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;

typedef long long ll;
const ll MAXN=1e5+5;

int a[MAXN],b[MAXN],c[MAXN];
int n;
ll up_mid(int left,int right,int i){
	//upper && mid 
	ll ans2=0;
	int mid;
	while(left<=right){
		mid=(left+right)/2;
		if(a[mid]<b[i])	
			left=mid+1;
		else if(a[mid]>b[i]||a[mid]==b[i])
			right=mid-1;
	}
	if(left<=n&&a[left]<b[i]){
		ans2+=left;
	}
	else if(right>=1&&a[right]<b[i]){
		ans2+=right;
	}
	return ans2;
}

ll mid_down(int left,int right,int i){
	ll ans1=0;
	//down && mid 
	int mid;
	while(left<=right){
		mid=(left+right)/2;
		if(c[mid]<b[i]||c[mid]==b[i])	
			left=mid+1;
		else if(c[mid]>b[i])
			right=mid-1;
	}
	if(right>=1&&c[right]>b[i]){
		ans1+=n-right+1;
	}
	else if(left<=n&&c[left]>b[i]){
		ans1+=n-left+1;
	}
	return ans1;
}

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&b[i]);
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&c[i]);
	}
	sort(a+1,a+1+n);
	sort(c+1,c+1+n);
	ll ans=0;
	for(int j=1;j<=n;j++){
		ans+=mid_down(1,n,j)*up_mid(1,n,j);
	}
	
	printf("%lld",ans);
	return 0;
} 
	
	
	

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

#define el '\n'

const int MOD = 1e9+7;
const int MAXN = 1005;

int dp[MAXN][MAXN];
char grid[MAXN][MAXN];

int plmod(int a, int b){
  return (a%MOD+b%MOD)%MOD;
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int h, w;
  cin >> h >> w; 
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> grid[i][j];
    }
  }

  dp[0][0] = 1;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(i+1 < h && grid[i+1][j] == '.') dp[i+1][j] = plmod(dp[i+1][j], dp[i][j]) ;
      if(j+1 < w && grid[i][j+1] == '.') dp[i][j+1] = plmod(dp[i][j+1], dp[i][j]); 
    }
  }
  cout << dp[h-1][w-1] << el;

  return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
int getDate(int y,int m,int d){
	int res=0;
	int a = (y-1)/3;
	int b = (y-1) - a;
	res += 200*a + 195*b;
	res += 20*(m-1) - (y%3 == 0 ? 0 : (m-1)/2);
	res += d;
	return res;
}
int main(){
	int y,m,d,n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>y>>m>>d;
		cout<<getDate(1000,1,1)-getDate(y,m,d)<<endl;
	}
}

Measured memory_bytes: 1160
n = int(input())
s = [input() for i in range(n)]

march = [0] * 5

for i in range(n):
    if s[i][0] == 'M':
        march[0] += 1
    elif s[i][0] == 'A':
        march[1] += 1
    elif s[i][0] == 'R':
        march[2] += 1
    elif s[i][0] == 'C':
        march[3] += 1
    elif s[i][0] == 'H':
        march[4] += 1
        
ans = 0

for i in range(5):
    for j in range(5):
        for k in range(5):
            if i >= j or i >= k or j >= k:
                continue
            ans += march[i] * march[j] * march[k]
            
print(ans)

Measured memory_bytes: 9776
"use strict";

function Main(input) {
    input = input.split("\n");

    input[0] = input[0].split(" ");
    const n = parseInt(input[0][0], 10);
    const m = parseInt(input[0][1], 10);

    let stores = input.slice(1, -1).map(x => x.split(" ").map(x => parseInt(x, 10)));

    stores.sort(function(a, b) {
        return a[0] - b[0];
    });

    let numDrink = 0;
    let totalPrice = 0;
    for (let i = 0; i < n; i++) {
        const store = stores[i];
        for (let j = 0; j < store[1]; j++) {
            numDrink++;
            totalPrice += store[0];

            if (numDrink === m) {
                console.log(totalPrice);
                return;
            }
        }
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 52876
// vim: tabstop=2 softtabstop=2 shiftwidth=2
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

void solve() {
  int x, y, z;
  cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  printf("%d %d %d\n", x, y, z);
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,rec[200];
signed main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int a,b;cin>>a>>b;if(a==b){rec[i]=1;
		}
	}int cnt=0;
	for(int i=0;i<n;i++){
		if(rec[i]==1)cnt++;
		if(cnt==3){cout<<"Yes"<<endl;return 0;
		}
		if(rec[i]==0)cnt=0;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3628
import sys
input = sys.stdin.readline

def main():
    n, k = map(int, input().split())
    mod = 998244353

    dp = [0]*(n)

    zone = [tuple(map(int, input().split())) for i in range(k)]
    zone.sort()

    dp[0] = 1
    count = 0
    bit = [0]*k

    for i in range(1, n):
        for j in range(k):
            l, r = zone[j]
            if i-l >= 0:
                bit[j] += dp[i-l]
            if i-r-1 >= 0:
                bit[j] -= dp[i-r-1]
        dp[i] += sum(bit)%mod
        dp[i] %= mod
    ans = dp[n-1]
    print(ans)

if __name__ == "__main__":
    main()





Measured memory_bytes: 75488
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var A = Sarray()[0];
            var B = Sarray()[0];
            var C = Sarray()[0];
            var D = Sarray()[0];
            var E = Sarray()[0];
            var min = Min(E, Min(D, Min(C, Min(A, B))));
            WriteLine((N + min - 1) / min + 4);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
S = input()
N = len(S) 
ans = 0
for i in range(2**(N-1)):
    f = S[0]
    for j in range(N-1):
        if ( i >> j ) & 1 :
            f += '+'
        f += S[j+1]
    ans += sum(map(int,f.split('+')))
print(ans)

Measured memory_bytes: 70300
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;

const int maxN = 100010; 
const int INF = 1000000000;
const int MOD = 1000000007;
int n;
int main()
{
	scanf("%d",&n);
	int ans = n;
	int cnt = 0;
	for(int j = 1;j<=n;j++)
	{
		int tmp = 0;
		if(j % 2 == 0) continue;
		for(int i=1;i<=sqrt(j);i++)
		{
			if((j % i) == 0)
				tmp++;
		}
		if(tmp == 4)
			cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

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

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    ll n,i;
    cin >> n;
    vll p(n);
    vll a(3);
    REP(i,n){
        cin >> p[i];
    }
    ll count=0;
    FOR(i,1,n-2){
        a[0] = p[i-1];
        a[1] = p[i];
        a[2] = p[i+1];
        if(((a[0]<a[1])&&(a[1]<a[2]))||((a[0]>a[1])&(a[1]>a[2]))){
            count++;
        }
    }
    cout << count << endl;
}

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

int main() {
    long long N;
    cin >> N;
    long long k3 = N/3;
    long long  k5 = N/5;
    long long k15 = N/15;

    long long s = ( N*(N+1) + 15*(1+k15)*k15 - 5*(1+k5)*k5 - 3*(1+k3)*k3 )/2;
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3632
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    X, N = MAP()

    if N == 0:
        print(X)
        sys.exit()

    P = LIST()

    for i in range(100):
        if not X - i in P:
            print(X - i)
            sys.exit()
        elif not X + i in P:
            print(X + i)
            sys.exit()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
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;
typedef pair<int, int> P;

int main() {
    int n; cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(all(p));
    p[n-1] /= 2;
    int ans = 0;
    rep(i, n) {
        ans += p[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;

public class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] line = br.readLine().split(" ");
    int a = Integer.parseInt(line[0]);
    int b = Integer.parseInt(line[1]);
    if( (a+b)%2 == 1 )
      System.out.println("IMPOSSIBLE");
    else
      System.out.println((a+b)/2);
  }
}


Measured memory_bytes: 20692
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N;
ll bef = 0;
ll ans = 0;

signed main(){
    cin >> N;
    rep(i, N){
        ll A;
        cin >> A;
        ll X = max(A, bef);
        ans += X - A;
        bef = X;
    }
    cout << ans << endl;
}

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

using namespace std;

#define ll long long
#define ld long double
#define ull unsigned long long
#define __ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int main() {
    __;
    string s;
    cin >> s;
    int x = 0, y = 0;
    map<char, int> mp;
    for (int i = 0; i < s.size(); ++i) {
        mp[s[i]] = 1;
        if (s[i] == 'N') {
            if (x > 0)x = 0;
            else x--;
        }
        if (s[i] == 'S') {
            if (x < 0)x = 0;
            else x++;
        }
        if (s[i] == 'W') {
            if (y > 0)y = 0;
            else y--;
        }
        if (s[i] == 'E') {
            if (y < 0)y = 0;
            else y++;
        }
    }
    if (mp['N'] == 0 && mp['S'] == 0) {
        if (mp['E'] && mp['W']) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (mp['W'] == 0 && mp['E'] == 0) {
        if (mp['N'] && mp['S']) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (mp['W'] == 1 && mp['E'] == 1) {
        if (mp['N'] && mp['S']) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
if n<3:
  print(abs(h[0]-h[1]))
  exit()
dp=[0]*(n)
dp[1]=abs(h[0]-h[1])
dp[2]=abs(h[0]-h[2])
for i in range(3,n):
  dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])


Measured memory_bytes: 13980
#include<stdio.h>

int main(){

  int N,i,j,v,A[1001];

  scanf("%d",&N); /*Input value of N*/

  for(i=0;i<N;i++)
    scanf("%d",&A[i]);/*Input value of A[]*/
 
  for(j=0;j<N-1;j++)
    printf("%d ",A[j]);
  
  printf("%d\n",A[j]);


  for(i=1;i<N;i++){/*From 1 to N-1*/
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
      A[j+1]=v;
      }
  
    for(j=0;j<N-1;j++)
      printf("%d ",A[j]);
    
    printf("%d\n",A[j]);
  }

  return 0;
}

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

struct UnionFind {
  vector<int> par;

  UnionFind(int N) : par(N) {
    for(int i = 0; i < N; i++) par[i] = i;
  }

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

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

  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  long n, q;
  cin >> n >> q;
  
  UnionFind tree(n);
  for (long i = 0; i < q; i++) {
    long t, u, v;
    cin >> t >> u >> v;
    if (t == 0) {
      tree.unite(u, v);
    } else if (t == 1) {
      cout << tree.same(u, v) << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3980
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//数値
		int d = Integer.parseInt(sc.next());
		int n = Integer.parseInt(sc.next());
		if(d==0 && n!=100) {
		    System.out.println(n);
		}else if(d==0 && n==100) {
			System.out.println(n+1);
		}
		if(d==1&& n!=100) {
			System.out.println(n*100);
		}else if(d==1 && n==100) {
			System.out.println((n+1)*100);
		}
		if(d==2&& n!=100) {
		    System.out.println(n*10000);
		}else if(d==2 && n==100) {
			System.out.println((n+1)*10000);
		}
     }
}

Measured memory_bytes: 35612
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll MOD = 1000000007;
const double PI = 3.141592653589793238463;
const ll N=2e5+9;
int main()
{
    FASTINOUT;
    ll x,a,b;
    cin>>x>>a>>b;
    ll y[x];
    for (int i=0;i<x;i++)
        cin>>y[i];
    ll ans=0;
    for (int i=1;i<x;i++){
        ans+=min((y[i]-y[i-1])*a,b);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BSubstring solver = new BSubstring();
        solver.solve(1, in, out);
        out.close();
    }

    static class BSubstring {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();
            String T = in.next();
            int match_cnt = 0;
            int ans = 0;
            for (int i = 0; i <= S.length() - T.length(); i++) {
                String tmp = S.substring(i, i + T.length());
                match_cnt = Math.max(match_cnt, cnt(tmp, T));
            }
            ans = T.length() - match_cnt;
            // 出力
            out.println(ans);

        }

        int cnt(String S, String T) {
            int res = 0;
            for (int i = 0; i < T.length(); i++) {
                if (S.charAt(i) == T.charAt(i)) res++;
            }
            return res;
        }

    }
}



Measured memory_bytes: 35916
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Int32;
using static System.Math;
using System.Numerics;

class Program
{
    class Hoge
    {
        public int X;
        public int Y;
        public int Max;
        public int H;

        public Hoge(int x,int y,int max,int h)
        {
            X = x;
            Y = y;
            Max = max;
            H = h;
        }

        public bool SetMax(int max)
        {
            if (max == 0)
            {
                H = -2;
                return false;
            }
            if (H == -1)
            {
                Max = Min(max, Max);
                return true;
            }
            if (max < H)
            {
                H = -2;
                return false;
            }
            return true;
        }

        public bool SetH(int h)
        {
            if (H == -1)
            {
                if (Max < h)
                {
                    H = -2;
                    return false;
                }
            }
            else if (H != h)
            {
                H = -2;
                return false;
            }
            H = h;
            return true;
        }
    }
    static void Main(string[] args)
    {
        label:
        int n = Parse(ReadLine());
        var sp = ReadLine().Split();
        int x = Parse(sp[0]);
        int y = Parse(sp[1]);
        int h = Parse(sp[2]);
        var list = new List<Hoge>(101 * 101);
        for (int row = 0; row <= 100; ++row)
        {
            for (int col = 0; col <= 100; ++col)
            {
                int sum = h + Abs(row - y) + Abs(col - x);
                if (h == 0)
                {
                    if (0 < sum)
                    {
                        list.Add(new Hoge(col, row, sum, -1));
                    }
                }
                else
                {
                    list.Add(new Hoge(col, row, sum, sum));
                }
            }
        }
        for (int i = 1; i < n; ++i)
        {
            sp = ReadLine().Split();
            x = Parse(sp[0]);
            y = Parse(sp[1]);
            h = Parse(sp[2]);
            bool allOK = true;
            foreach(var hoge in list)
            {
                int sum = h + Abs(hoge.X - x) + Abs(hoge.Y - y);
                if (h == 0)
                {
                    allOK &= hoge.SetMax(sum);
                }
                else
                {
                    allOK &= hoge.SetH(sum);
                }
            }
            if (!allOK) list = list.FindAll(ho => ho.H != -2);
        }
        WriteLine($"{list[0].X} {list[0].Y} {list[0].H}");
        //goto label;
    }
}


Measured memory_bytes: 28768
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

int main()
{
	int a, b;
	int max;
	cin >> a >> b;
	max = a + b;
	if (max < a - b) max = a - b;
	if (max < a * b) max = a * b;
	cout << max << "\n";
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    int a = reader.nextInt();
    int b = reader.nextInt();
    if (a <= 5) {
      out.println(0);
    } else if (a <= 12) {
      out.println(b/2);
    } else {
      out.println(b);
    }
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public int[] nextIntArray(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLongArray(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
}

class Algorithm {
  private static void swap(Object[] list, int a, int b) {
    Object tmp = list[a];
    list[a] = list[b];
    list[b] = tmp;
  }
  
  public static <T extends Comparable<? super T>> boolean nextPermutation(T[] ts) {
    int rightMostAscendingOrderIndex = ts.length - 2;
    while (rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0) {
      rightMostAscendingOrderIndex--;
    }
    if (rightMostAscendingOrderIndex < 0) {
      return false;
    }
    
    int rightMostGreatorIndex = ts.length - 1;
    while (ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0) {
      rightMostGreatorIndex--;
    }
    
    swap(ts, rightMostAscendingOrderIndex, rightMostGreatorIndex);
    for (int i = 0; i < (ts.length - rightMostAscendingOrderIndex - 1) / 2; i++) {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    }
    return true;
  }
}



Measured memory_bytes: 20692
// AOJ 1030 Cubes Without Holes
// 2018.2.3 bal4u@uu

#include <stdio.h>

#include <stdio.h>
#include <string.h>
 
char buf[15], *p;
int in()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	p++;
	return n;
}

char f[134217728];
int ans;
 
int main()
{
	int cno, n, h, a, b, i, k, t, ans;
	char *c;

	cno = 0;
	while (fgets(p=buf, 15, stdin) && *p != '0') {
		cno++;
		n = in(), h = in();

		ans = 0;
		while (h--) {
			fgets(p=buf, 15, stdin);
			c = p, p += 3, a = in()-1, b = in()-1;
			if (*c == 'x' && *(c+1) == 'y') {
				t = (a << 18) | (b << 9);
				i = n; while (i--) {
					k = i | t;
					if (f[k] != cno) f[k] = cno, ans++;
				}
			} else if (*c == 'x' && *(c+1) == 'z') {
				t = (a << 18) | b;
				i = n; while (i--) {
					k = t | (i << 9);
					if (f[k] != cno) f[k] = cno, ans++;
				}
			} else {
				t = (a << 9) | b;
				i = n; while (i--) {
					k = t | (i << 18);
					if (f[k] != cno) f[k] = cno, ans++;
				}
			}
		}
		printf("%d\n", n*n*n - ans);
	}
	return 0;
}


Measured memory_bytes: 126100
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<deque>

using namespace std;

#define sz(x) (int)(x.size())
#define rep(i, a, b) for(int i=a;i<b;++i)
#define per(i, a, b) for(int i=b-1;i>=a;--i)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

////////////////

int const N = 1e5 + 41;

void solve(){
	int a, b, c;
	cin >> a >> b >> c;
	rep(i, 0, N){
		if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1){
			cout << i << endl;
			return;
		}
		int na = b / 2 + c / 2;
		int nb = a / 2 + c / 2;
		int nc = b / 2 + a / 2;
		a = na;
		b = nb;
		c = nc;
	}
	cout << -1 << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <cmath>
#include <string>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <limits>  //std::numeric_limits<int>::max(), min()


std::array<bool, 10> flag;
std::unordered_map<int, std::string> dp;


int n2p ( int a ) {
  int num = 0;
  if ( a == 1 ) num = 2;
  if ( a == 2 || a == 3 || a == 5 ) num = 5;
  if ( a == 4 ) num = 4;
  if ( a == 6 || a == 9 ) num = 6;
  if ( a == 7 ) num = 3;
  if ( a == 8 ) num = 7;
  return num;
}

bool large(std::string& s, std::string& t) {
  if(s.size()!=t.size()){
    return s.size()>t.size();
  }
  return s>t;
}

std::string sol (int n) {
  if ( dp.count(n) != 0 ) return dp[n];
  if ( n == 0 ) return "";

  std::string ret="";
  for(int i=0; i<10; i++) {
    if ( flag[i] && (n-n2p(i)) >= 0 ) {
      char c = '0' + i;
      std::string res = c + sol(n-n2p(i));
      if ( res.back() == '-' ) continue;
      if ( large(res,ret) ) ret = res;
    }
  }
  if ( ret == "" ) ret = "-";
  return dp[n] = ret;
}



int main(){
  int N, M; std::cin >> N >> M;
  for(int i=0; i<M; i++) {
    int x; std::cin >> x;
    flag[x] = true;
  }

  std::cout << sol(N) << std::endl;
  return 0;
}

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

int main()
{
    int N, K, S;
    cin >> N >> K >> S;

    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        if (i < K)
        {
            A[i] = S;
        }
        else
        {
            if (S == 1e9)
            {
                A[i] = S - 1;
            }
            else
            {
                A[i] = S + 1;
            }
        }
    }
    for (int a : A)
    {
        cout << a << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1664
import sys
from bisect import bisect_right


def solve(t):
    global A, B, C
    k = bisect_right(H, B * t)
    cnt = 0
    for i in range(k, N):
        h = H[i]
        h -= B * t
        cnt += (h + C - 1) // C
    return cnt <= t


N, A, B = map(int, input().split())
C = A - B
H = [int(s) for s in sys.stdin.readlines()]

H.sort()

# [ok, ng) - Maximum
# (ng, ok] - Minimum
# ok が 最終的な答え
ng = 0
ok = 10 ** 9 + 1000
k = 0
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if solve(mid):
        ok = mid
    else:
        ng = mid

print(ok)


Measured memory_bytes: 14244
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int i,cunt=0;
    int mx =0;
    for(i=0; i<s.length(); i++)
    {
        if(s[i]=='R')
            cunt++;

    }
    if(cunt == 3 || cunt == 1)
        cout<<cunt<<endl;
    else if(cunt == 2)
    {
        if(s[1] == 'S')
            cout<<1<<endl;
        else
            cout<<2<<endl;
    }
    else
        cout<<0<<endl;


    return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>
 
using namespace std;
  
/********** TEMPLATE STARTS HERE ***********/
    
#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define test int t; cin >> t; while(t--)
#define skip continue
#define stop break
#define sz(v) (int)v.size()
#define endl '\n'
#define PI 3.1415926535897932384626433832795
#define EPS 1e-9
#define gcd __gcd 
#define mp make_pair
#define debug(a) cout << #a << ": " << a << endl
#define debug1(a, l, r) FR(i, l, r) cout << a[i] << " "; cout << endl
#define SET(a, b) memset(a, b, sizeof(a));
#define refresh fflush(stdout);
#define digits(n) (int)(log10(n) + 1)
  
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pii> vii;
typedef vector <pll> vll;
    
const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;
    
template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
   
/*********** TEMPLATE ENDS HERE *************/

const int N = 1e5 + 7;

int H1[N];
int H2[N];

main()
{
	IOS
	
	int n;
	cin >> n;
	
	int lo1 = 0;
	int lo2 = 0; 
	
	int sec1 = 0;
	int sec2 = 0;
	
	int nr1 = 0;
	int nr2 = 0;
	
	for(int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		
		if((i & 1) == 1)
		{
			H1[x]++;
			
			if(x == nr1)
			{
				lo1++;
				continue;
			}
			
			if(H1[x] >= lo1)
				sec1 = lo1, lo1 = H1[x], nr1 = x;
			else
				if(H1[x] > sec1)
					sec1 = H1[x];
		}
		else
		{
			H2[x]++;
			
			if(x == nr2)
			{
				lo2++;
				continue;
			}
			
			if(H2[x] >= lo2)
				sec2 = lo2, lo2 = H2[x], nr2 = x;
			else
				if(H2[x] > sec2)
					sec2 = H2[x];
		}
	}
	
	if(nr1 != nr2)
		cout << n - lo1 - lo2;
	else
		cout << n - max(lo1 + sec2, sec1 + lo2);
}

Measured memory_bytes: 1024
w = input()
l = len(w)
flag = True
for i in range((l - 1)//2):
  if w[i] != w[l - i - 1]:
    flag = False
    break
mid = (l - 1) // 2
mid_mid = mid // 2
for i in range(mid_mid + 1):
  if w[i] != w[mid - i - 1] or not flag:
    flag = False
    break
  if w[i + mid + 1] != w[l - i - 1]:
    flag = False
    break
if flag:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 9004