akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main()
{
	int n, m, q, l, r;
	cin >> n >> m >> q;
	vector<vector<int>> data(n+1,vector<int>(n+1));
	vector<int> ans;
	rep(i, 0, m) {
		cin >> l >> r;
		data[l][r]++;
	}
	rep(i, 0, n) {
		rep(i2, 0, n) {
			data[i+1][i2+1] += data[i+1][i2]+data[i][i2+1]-data[i][i2];
		}
	}
	rep(i, 0, q) {
		cin >> l >> r;
		ans.push_back(data[r][r] - data[r][l - 1] - data[l - 1][r] + data[l - 1][l - 1]);
	}
	rep2(v, ans)printf("%d\n", v);
	return 0;
}

Measured memory_bytes: 4924
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog ender-zzm.enbar.cn
*/
#include <bits/stdc++.h>
using namespace std;

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
inline int readint(){
    register int x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}

inline long long readlong() {
	register long long x = 0, flag = 1;
	register char ch;
	while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}
template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 
#define ri readint
#define rl readlong

int main() {
	int x;
	x = ri();
	if (x >= 30) puts("Yes");
	else puts("No");
}


Measured memory_bytes: 3616
# -*- coding: utf-8 -*-

A = int(input())
B = int(input())
C = int(input())
X = int(input())


def solve(a, b, c):
    ans = 0
    for i in range(a+1):
        for j in range(b+1):
            for k in range(c+1):
                temp = i * 500 + j * 100 + k * 50
                if temp == X:
                    ans += 1
    return ans


def main():
    ans = solve(A, B, C)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<cstring>
using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define fo(a,b) for(int o=a;o<b;++o)
#define fdi(a,b) for(int i=a-1;i>=b;--i)
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
//////////////////////

#ifdef _DEBUG
int const N = 41;
#else
int const N = 2e5 + 41;
#endif
int const MOD = 1e9 + 7;

int n, p[N], ans, two[N];
vector<int> vh[N];
vector<int> e[N];

void add(int &a, int b){
	a += b;
	if(a >= MOD) a -= MOD;
}

int mul(int a, int b){
	return a * 1LL * b % MOD;
}

namespace lca{
	int const L = 18;
	int lca[N][L], q, tin[N], tout[N], h[N];

	void dfs(int x, int p = -1){
		vh[h[x]].pb(x);
		++q;
		tin[x] = q;
		fi(0, L) lca[x][i] = -1;
		lca[x][0] = p;
		fi(1, L){
			int pp = lca[x][i-1];
			if(pp != -1) lca[x][i] = lca[pp][i-1];
		}
		fi(0, sz(e[x])){
			int y = e[x][i];
			h[y] = h[x] + 1;
			dfs(y, x);
		}
		++q;
		tout[x] = q;
	}

	bool isa(int x, int y){
		return tin[x] <= tin[y] && tout[x] >= tout[y];
	}

	int getlca(int x, int y){
		if(isa(x, y)) return x;
		if(isa(y, x)) return y;
		fdi(L, 0){
			if(lca[x][i] == -1 || isa(lca[x][i], y)) continue;
			x = lca[x][i];
		}
		return lca[x][0];
	}

	void build(){
		dfs(0);
	}
};

set<int> v;
vector<int> e0[N];
int p0[N];

int buildtree(){
	vector<pii> a;
	for(int x : v){
		a.pb(mp(lca::tin[x], x));
	}
	sort(a.begin(), a.end());
	set<pii> b;
	fi(0, sz(a)){
		int x = a[i].second;
		set<pii> :: iterator it = b.upper_bound(mp(lca::tout[x], -1));
		if(it == b.end()) p0[x] = -1;
		else{
			p0[x] = (*it).second;
			e0[p0[x]].pb(x);
		}
		b.insert(mp(lca::tout[x], x));
	}
	return a[0].second;
}

void clear(){
	for(int x : v){
		e0[x].clear();
	}
	v.clear();
}

int d0[N][2];
int d1[N][3];

void dfs(int x){
	memset(d0[x], 0, sizeof(d0[x]));
	int m = sz(e0[x]);
	fi(0, m){
		int y = e0[x][i];
		dfs(y);
	}
	fi(0, m+1) fo(0, 3) d1[i][o] = 0;
	d1[0][0] = 1;
	fi(0, m){
		int y = e0[x][i];
		fo(0, 3){
			for(int o1=0;o1<2;++o1){
				int no = o + o1;
				no = min(no, 2);
				int v0 = d0[y][o1];
				int v1 = d1[i][o];
				int v = mul(v0, v1);
				add(d1[i+1][no], v);
			}
		}
	}
	if(sz(e0[x]) == 0){
		d0[x][0] = 1;
		d0[x][1] = 1;
	}else{
		fo(0, 3){
			add(d0[x][(o%2)], d1[m][o]);
		}
	}
}

void solve(){
	two[0] = 1;
	fi(1, N) two[i] = mul(2, two[i-1]);
	fi(1, n+1){
		e[p[i]].pb(i);
	}
	lca::build();
	fi(0, N){
		if(sz(vh[i]) > 0){
			fj(0, sz(vh[i])){
				v.insert(vh[i][j]);
				if(j){
					v.insert(lca::getlca(vh[i][j], vh[i][j-1]));
				}
			}
			//
			/*fj(0, sz(vh[i])){
				fo(0, sz(vh[i])){
					v.insert(lca::getlca(vh[i][j], vh[i][o]));
				}
			}*/
			//
			int r = buildtree();
			dfs(r);
			int v0 = two[n+1-sz(vh[i])];
			int v1 = d0[r][1];
			//cerr << i << " " << mul(v0, v1) << endl;
			add(ans, mul(v0, v1));
			clear();
		}
	}
}

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

	scanf("%d",&n);
	fi(1, n+1){
		scanf("%d",&p[i]);
	}

	solve();

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

	return 0;
}

Measured memory_bytes: 58068
n = int(input())
test = [1, 2, 3, 4, 5, 6, 7, 8, 9]

ans = 'No'
for i in test:
    if n % i == 0:
        if int(n/i) <= 9:
            ans = 'Yes'
            break
    else:
        ans = 'No'

print(ans)


Measured memory_bytes: 2940
N, M = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(M)]

count = [0 for i in range(N)]

# for aibi in ab:
#     ai = aibi[0]
#     bi = aibi[1]
#
#     if bi < ai:
#         tmp = ai
#         ai = bi
#         bi = tmp
#
#     for j in range(ai - 1, bi - 1):
#         count[j] += 1

for aibi in ab:
    ai = aibi[0]
    bi = aibi[1]
    if ai != 1 and bi != 1:
        count[ai - 1] += 1
        count[bi - 1] += 1
    else:
        if ai == 1:
            count[bi - 1] += 1
        else:
            count[ai - 1] += 1

yes_or_no = True
for num in count:
    if num % 2 == 1:
        yes_or_no = False

if yes_or_no:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 28392
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
int main(){
  ll n;
  cin>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  map<ll,ll>M;
  rep(i,n)M[a[i]]++;
  ll ans=0;
  for(auto p:M){
    if(p.second>=p.first)ans+=p.second-p.first;
    else ans+=p.second;
  }
  cout<<ans<<endl;
}

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

void solve(long long N, long long A, long long B)
{
    long long sum = 0;
    long long keta_sum = 0;
    for (int i = 1; i <= N; i++)
    {
        keta_sum = 0;
        string num = to_string(i);
        for (int j = 0; j < (int)(num.size()); j++)
        {
            string ke;
            ke = num[j];
            int keta = stol(ke.c_str());
            keta_sum += keta;
        }

        if (keta_sum <= B && keta_sum >= A)
        {
            sum += i;
        }
    }
    cout << sum << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int grd(int a,int b)
{
  int c,d;
  if(a<b) {
    c = a;
    a = b;
    b = c;
  }
  while(b > 0){
    d = a%b;
    a = b;
    b = d;
  }
  return a;
}
int main(){
  int a,b,c;
  scanf("%d %d",&a,&b);
  c = grd(a,b);
  printf("%d\n",c);
  return 0;
}



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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int n;
    scanf(" %d", &n);
    vector<int> a(n);
    rep(i,n) scanf(" %d", &a[i]);

    map<int,int> count, most_left;
    for(int i=n-1; i>=0; --i)
    {
        ++count[a[i]];
        most_left[a[i]]=i;
    }

    vector<ll> k,ct,ml;
    for(const auto &x:count)
    {
        int key = x.fi;
        k.pb(key);
        ct.pb(count[key]);
        ml.pb(most_left[key]);
    }

    int S = k.size();
    // rep(i,S) printf(" %d: count = %d, most_left = %d\n", k[i],ct[i],ml[i]);

    vector<ll> ans(n);

    for(int i=S-1; i>0; --i)
    {
        if(ml[i]==0) break;

        ll diff = k[i]-k[i-1];

        assert(diff>0);

        ans[ml[i]] += diff*ct[i];
        ct[i-1] += ct[i];
        ml[i-1] = min(ml[i-1],ml[i]);
        ct[i]=0;

        // printf("-----\n");
        // rep(j,S) printf(" %lld: count = %lld, most_left = %lld\n", k[j],ct[j],ml[j]);
        // printf("-----\n");
    }

    rep(i,S) ans[0]+=k[i]*ct[i];

    rep(i,n) printf("%lld\n", ans[i]);
    return 0;
}


Measured memory_bytes: 14176
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = 0;
        int b = 0;
        int ab = 0;
        int o = 0;
        String line;
        while(true) {
            try {
                line = sc.nextLine();
            }catch(Exception e) {
                break;
            }
            String[] linesp = line.split(",");
            int x = Integer.parseInt(linesp[0]);
            String blood = linesp[1];
            if(blood.equals("A")) {
                a++;
            }else if(blood.equals("B")) {
                b++;
            }else if(blood.equals("AB")) {
                ab++;
            }else if(blood.equals("O")) {
                o++;
            }
        }
        System.out.println(a);
        System.out.println(b);
        System.out.println(ab);
        System.out.println(o);
    }
}



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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;


using A = array<ll, 3>;

V<A> solve(V<ll> a) {
    int n = int(a.size());
    V<A> dp(n + 1, A{});
    for (int i = 0; i < n; i++) {
        dp[i+1][0] = dp[i][0] + a[i];
        dp[i+1][2] = min(dp[i][0], dp[i][2]) + (a[i] == 0 ? 2 : a[i] % 2);
        dp[i+1][1] = min({dp[i][0], dp[i][2], dp[i][1]}) + 1 - a[i] % 2;
    }
    return dp;
}

int main() {
    int n;
    cin >> n;
    V<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    auto s1 = solve(a);
    reverse(a.begin(), a.end());
    auto s2 = solve(a);
    reverse(s2.begin(), s2.end());
    ll mi = TEN(18);

    for (int i = 0; i < n; i++) {
        for (int x = 0; x < 9; x++) {
            mi = min(mi, s1[i][x/3] + s2[i][x%3]);
        }
    }
    cout << mi << endl;
    return 0;
}



Measured memory_bytes: 12772
N,K = map(int, input().split())
min_num = 0
max_num = 0
for i in range(K):
    min_num += i
    max_num += N - i
ans = max_num - min_num + 1
for i in range(K, N+1):
    min_num += i
    max_num += N - i
    ans += max_num - min_num + 1
print(ans%(10**9 + 7))

Measured memory_bytes: 9124
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;

int main(void){
  long int N,R;
  cin >> N >> R;
  
  long int W=1;
  long int i=R;
  while(N>=R){
	R*=i;
    W++;
  }
  
  cout << W << endl;
  
	return 0; 
}

Measured memory_bytes: 256
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

/* Mulmod */
LL mulmod(LL a, LL b) {
	a = (a + MOD) % MOD;
	b = (b + MOD) % MOD;
	LL res = 0;
    a %= MOD; 
  
    while(b) { 
        if(b&1) res = (res+a)%MOD; 
        a = (a*2)%MOD; 
        b >>= 1;
    }
    return res; 
}

void solve() {
	int n, k;
	in2(n, k);
	
	LL a[n];
	for(int i=0;i<n;i++) inl(a[i]);
	
	sort(a, a+n); 
    LL prod = 1;
    if(!a[n-1] && (k%2 == 1)) finish(0);
  
    if(a[n-1] <= 0 && (k%2 == 1)) { 
        for(int i=n-1;i>=n-k;i--) {
			prod = mulmod(prod, a[i]);
		}
        finish(prod);
    } 
  
    int i=0, j=n-1; 
  
    if(k&1) { 
        prod = mulmod(prod, a[j]);
        j--; k--; 
    } 
    k = k/2;
  
    for(int idx=0;idx<k;idx++) { 
        LL l = a[i]*a[i + 1]; 
        LL r = a[j]*a[j - 1]; 
        if(l>r) { 
            prod = mulmod(prod, l);
            i+=2; 
        } else { 
            prod = mulmod(prod, r);
            j-=2; 
        } 
    } 
    cout<<prod<<en;
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 5244
N,K = map(int, input().split())
x = list(map(int, input().split()))

if x[K-1]*x[0]>0:
    tmp_min = max(abs(x[0]),abs(x[K-1]))
else:
    tmp_min = abs(x[0]-x[K-1])+min(abs(x[0]),abs(x[K-1]))

for i in range(1,N-K+1):
    if x[K-1+i]*x[i]>0:
        tmp_distance = max(abs(x[i]),abs(x[K-1+i]))
    else:
        tmp_distance = abs(x[i]-x[K-1+i])+min(abs(x[i]),abs(x[K-1+i]))
    if tmp_distance<tmp_min:
        tmp_min=tmp_distance
print(tmp_min)

Measured memory_bytes: 62576
#include<stdio.h>

int main(void) {
    long long int i, n, a, b, c, sum = 0;
    scanf("%lld", &n);
    for (i = 0; i < n; i++) {
        a = i + 1;
        b = a % 3;
        c = a % 5;
        if (b == 0 || c == 0) {
            a = 0;
        }
        sum += a;
    }
    printf("%lld\n", sum);
    return 0;
}

Measured memory_bytes: 1712
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int n;
   cin>>n;
   vector<int> a(n,0);
   map<int,int> m;
   long long int sum=0;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
       sum+=a[i];
       m[a[i]]++;
   }
   int q;
   cin>>q;
   while(q--)
   {
       int x,y;
       cin>>x>>y;
       sum+=((m[x])*y)-(m[x]*x);
       m[y]=m[x]+m[y];
       m[x]=0;
       cout<<sum<<endl;
   }
    
}

Measured memory_bytes: 7980
#include <bits/stdc++.h>
using namespace std;
int main () {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> data(H + 2, vector<char>(W + 2, ' '));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> data.at(i + 1).at(j + 1);
    }
  }
  vector<int> dx {-1,1,0}, dy {-1,1,0};
  int count;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (data.at(i + 1).at(j + 1) == '.') {
        count = 0;
        for(int k: dx) {
          for(int l: dy) {
            if (data.at(i + 1 + l).at(j + 1 + k) == '#') count++;
          }
        }
        data.at(i + 1).at(j + 1) = (char) count + '0'; 
      }
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << data.at(i + 1).at(j + 1);
    }
    cout << endl;
  }
  return 0;
}


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

#define ll long long

using namespace std;

int main() {
    string s;
    cin >> s;
    string ans = "";

    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'B') {
            if (!ans.empty()) ans.pop_back();
        } else {
            ans += s[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
import sys
from collections import defaultdict

if __name__ == '__main__':
    n, v = map(int, sys.stdin.readline().split())
    a = tuple(map(int, sys.stdin.readline().split()))
    b = tuple(map(int, sys.stdin.readline().split()))
    c = tuple(map(int, sys.stdin.readline().split()))
    d = tuple(map(int, sys.stdin.readline().split()))
    mp = defaultdict(int)
    for val1 in c:
        for val2 in d:
            mp[val1+val2] += 1
    print(sum(mp[v-val1-val2] for val1 in a for val2 in b))



Measured memory_bytes: 179200
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

int main() {

	for (int i = 0; i < 5; i++) {

		int a;
		cin >> a;
		if (a == 0) {
			cout << i + 1;
		}

	}

	return 0;

}

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

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

	vector<int> a( n );
	for( int i = 0; i < n; ++i ) {
		cin >> a.at( i );
	}

	int x = a.at( 0 );
	int y = a.at( 0 );
	int64_t z = a.at( 0 );

	for( int i = 1; i < n; ++i ) {
		if( a.at( i ) < x ) { x = a.at( i ); }
		if( a.at( i ) > y ) { y = a.at( i ); }
		z += a.at( i );
	}

	cout << x << " " << y << " " << z << endl;
}



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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

string s;
int w,n;

int main(){
  cin>>s>>w;
  n=s.size();
  string res;
  for(int i=0;i<n;i+=w)res+=s[i];
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let s: String = scan(tokens);
    let s = s.as_bytes();
    if s[2] == s[3] && s[4] == s[5] {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

--Input functions with ByteString
readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine


decrease :: [Integer] -> [Bool]
decrease [h] = [True]
decrease (x:y:hs)
         | x >= y = [True] ++ decrease (y:hs)
         | x >= y - 1 = [True] ++ decrease (y - 1:hs)
         | x < y  = [False]
         | otherwise = [False]

buildStairs :: Integer -> [Integer] -> String
buildStairs n h = if foldr (&&) True $decrease (reverse h) then "Yes" else "No"

main = do
     n <- getInt
     h <- getIntList
     putStrLn $buildStairs n h


Measured memory_bytes: 16764
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef vector<vector<int>> Graph;
void add_edge(Graph& g, int from, int to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

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


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

	ll n;
	cin >> n;
	vector<ll> a(n); rep(i,n) cin >> a[i];

	ll height = a[0], ans = 0;
	rep(i,n){
	  ans += max(0LL,height - a[i]);
	  height = max(height, a[i]);
	}
	
	cout << ans << en;
}



Measured memory_bytes: 4776
N, K = map(int, input().split())
S = input()

# 1回のチェンジで全体の幸福度は1または2上昇させることができる
# 幸福度の最大はN-1
# これらから残りの試行で可能な最大幸福度をもとめる

# 現在の幸福度を出す

koufuku = 0

for i in range(N):
    if S[i] == 'L':
        if i == 0:
            continue
        if S[i-1] == 'L':
            koufuku += 1
    else:
        if i == N-1:
            continue
        if S[i+1] == 'R':
            koufuku += 1

max_koufuku = min(N-1, koufuku + 2*K)
print(max_koufuku)

Measured memory_bytes: 39792
x,k,d=map(int,input().split())
from math import *
x=abs(x)
if k*d<x:
    ans=x-k*d
elif k*d==x:
    ans=0
else:
    t=ceil(x/d)
    if (k-t)%2==0:
        ans=abs(x-t*d)
    else:
        ans=abs(x-(t-1)*d)
print(ans)

Measured memory_bytes: 9184
# coding: utf-8
A, B, K = map(int, input().split())
a = set(i for i in range(A, min(A + K, B + 1)))
b = set(j for j in range(max(B - K + 1, A), B + 1))
c = list(a | b)
c.sort()
for k in c:
    print(k)

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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long

const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;
const ll mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> a(m);
    for (auto &c : a) cin >> c.fi >> c.se;
    for (int i = 0; i <= 999; i++) {
        string lol = to_string(i);
        if ((int)lol.size() != n) continue;
        bool f = true;
        for (auto &c : a) {
            if (lol[c.fi - 1] - '0' != c.se) f = false;
        }
        if (f) {
            cout << i;
            return 0;
        }
    }
    cout << -1;
    return 0;
}


Measured memory_bytes: 3676
def b_scoring():
    D = int(input())
    Contests = [int(i) for i in input().split()]
    Satisfaction = [[int(i) for i in input().split()] for j in range(D)]
    Training_data = [int(input()) for _ in range(D)]

    ans = []
    s = 0
    last = {i: 0 for i in range(1, 27)}
    for d, t in enumerate(Training_data, 1):
        s += Satisfaction[d - 1][t - 1]
        last[t] = d

        satisfaction_decreasing = 0
        for i in range(1, 27):
            satisfaction_decreasing += Contests[i - 1] * (d - last[i])
        s -= satisfaction_decreasing
        ans.append(s)
    return '\n'.join(map(str, ans))

print(b_scoring())

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

#define REP(i, start, count) for (int i = (start); i < (int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int N;

int main(void)
{
    cin >> N;

    vector<int> A(N);
    rep(i, N - 1) {
        int a;
        cin >> a;
        a--;
        A[a]++;
    }

    rep(i, N) {
        cout << A[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4052
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//ll ad[200005][200005];
static const int num=200005;
vector<ll>ad[num];
ll vt[num];
ll sum=1;
void dfs(ll nd,ll pt)
{
    vt[nd]=1;
    for(auto it:ad[nd])
    {
        if(it!=pt && vt[it]==0)
        {
            sum+=1;
          //cout<<sum<<" ";
            dfs(it,nd);
        }
    }
}
int main()
{
   ll n,m;
   cin>>n>>m;
   if(m==0)
   {
     cout<<1<<endl;
   return 0;
   }
   ll ans=INT_MIN;
   while(m--)
   {
       ll x,y;
       cin>>x>>y;
       ad[x].push_back(y);
       ad[y].push_back(x);
       
      
   }
    for(ll i=1;i<=n;i++)
       {
           if(vt[i]==0)
           {
               dfs(i,-1);
               ans=max(ans,sum);
               sum=1;
           }
       }
   cout<<ans<<endl;
}

Measured memory_bytes: 25460
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

vl divisor(ll n) {
  vl div;
  for(ll i=1;i*i<=n;i++) {
    if(i*i<n&&!(n%i)) {
      div.push_back(i);
      div.push_back(n/i);
    }
    else if(i*i==n) div.push_back(i);
  }
  return div;
}

int main() {
  ll N;
  cin >> N;
  int ans=0;
  vl div=divisor(N);
  for(ll x:div) {
    if(x==1) continue;
    ll num=N;
    while(!(num%x)) num/=x;
    ans+=(num%x==1);
  }
  ans+=divisor(N-1).size();
  cout << --ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int>v;
    long long sum=0;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        v.push_back(a);
        sum+=a;
    }
    sort(v.rbegin(),v.rend());
    for(int i=0;i<min(k,n);i++)
    {
        sum-=v[i];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 1400
n,m = map(int,input().split())
h = list(map(int,input().split()))
ans = []
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] < h[b-1]:
        if not a-1 in ans:
            ans.append(a-1)
    elif h[a-1] > h[b-1]:
        if not b-1 in ans:
            ans.append(b-1)
    else:
        if not a-1 in ans:
            ans.append(a-1)
        if not b-1 in ans:
            ans.append(b-1)
print(n-len(ans))


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

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 101010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int n;cin>>n; int q;cin>>q;
  vector<int> vec (n,0);
  for (int i = 0; i < n; i++)
  {
     cin>>vec[i];
  }
  reverse(ALL(vec));
  vector<int> sum(n+1),esum(n+1);
  for (int i = 0; i < n; i++)
  {
    sum[i+1] = sum[i] + vec[i];
    esum[i+1] = esum[i] +(i%2 == 0?vec[i]:0);
  }
  vector<int> ths,vals;
  for (int i = 0; i < (n-1)/2; i++)
  {
    int th = (vec[i+1]+vec[i*2+2])/2 + 1;
    int val = (sum[i+1]-sum[0]) + esum[n] - esum[i*2+2];
    ths.push_back(th);vals.push_back(val);

  }
  reverse(ALL(ths));
  reverse(ALL(vals));
  // int q;cin>>q;
  for (int i = 0; i < q; i++)
  {
    int x;cin>>x;
    int it = upper_bound(ALL(ths),x) - ths.begin();
    if(it == 0)cout<<sum[(n+1)/2] - sum[0]<<endl;
    else cout<<vals[it-1]<<endl; 
  }
  //https://drken1215.hatenablog.com/entry/2019/01/13/033500
  
  
  

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

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

  return 0;
}


Measured memory_bytes: 6720
first = [int(i) for i in str(input()).split()]
n = first[0]
m = first[1]
a = [int(i) for i in str(input()).split()]

v = sum(a)/(4*m)

c= 0
for coso in a:
    if coso >= v:
        c += 1

if c >= m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import sys

n, m = map(int, input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]

for i in range(n-m+1):
  for j in range(n-m+1):
    f = True
    for k in range(m):
      for l in range(m):
        if a[i+k][j+l] != b[k][l]:
          f = False
    if f == True:
      print("Yes")
      sys.exit()
      
print("No")

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

using namespace std;

const int MX = 300001, md = 998244353;

long long f[MX], inv[MX], f_inv[MX];

long long C(int n, int k) {
	return f[n] * f_inv[k] % md * f_inv[n - k] % md;
}

int main() {
	f[0] = f[1] = inv[1] = f_inv[0] = f_inv[1] = 1;
	for (int i = 2; i < MX; i++) {
		inv[i] = md - inv[md % i] * (md / i) % md;
		f[i] = f[i - 1] * i % md;
		f_inv[i] = f_inv[i - 1] * inv[i] % md;
	}
	
	int n, a, b;
	long long k;
	ignore = scanf("%d %d %d %lld", &n, &a, &b, &k);
	
	long long x0 = 1, y0 = 0, z0 = a;
	long long x1 = 0, y1 = 1, z1 = b;
	while (z0 > 0) {
		long long f = z1 / z0;
		long long x2 = x1 - x0 * f;
		long long y2 = y1 - y0 * f;
		long long z2 = z1 - z0 * f;
		x1 = x0; y1 = y0; z1 = z0;
		x0 = x2; y0 = y2; z0 = z2;
	}
	
	long long g = z1, x = x1, y = y1;
	
	if (k % g != 0) {
		printf("%d\n", 0);
		return 0;
	}
	
	k /= g;
	a /= g;
	b /= g;
	
	x *= k;
	y *= k;
	
	if (x < 0) {
		long long f = (b - 1 - x) / b;
		x += b * f;
		y -= a * f;
	}
	else {
		long long f = x / b;
		x -= b * f;
		y += a * f;
	}
	
	if (y > n) {
		long long f = (y - n + a - 1) / a;
		x += b * f;
		y -= a * f;
	}
	
	int ans = 0;
	while (min(x, y) >= 0 && max(x, y) <= n) {
		ans = (ans + C(n, x) * C(n, y)) % md;
		x += b;
		y -= a;
	}
	
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 7296
def calc(n)
    return @d if n == 1
    return @memo[n] if @memo[n]

    x = [n * @d]

    x << calc(n/2) + @a + (n % 2) * @d
    x << calc(n/2 + 1) + @a + @d if n % 2 != 0

    x << calc(n/3) + @b + (n % 3) * @d if n > 2
    x << calc(n/3 + 1) + @b + (3 - n % 3) * @d if n % 3 != 0

    x << calc(n/5) + @c + (n % 5) * @d if n > 4
    x << calc(n/5 + 1) + @c + (5 - n % 5) * @d if n % 5 != 0

    return @memo[n] = x.min
end

gets.to_i.times do
    @memo = {}
    n, @a, @b, @c, @d = gets.split.map(&:to_i)
    p calc(n)
end

Measured memory_bytes: 18184
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>


#define LL long long int
using namespace std;

int main(void)
{
	int n, k;
	int ans = 1;
	cin >> n >> k;

	for (int i = 0; i < n; i++) {
		ans = min(ans * 2, k + ans);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int t[110], p[110], x[110];
int score[110];

int main(){
    int n;
    cin >> n;
    int tot = 0;
    rep(i, n) cin >> t[i], tot += t[i];
    int m;
    cin >> m;
    rep(i, m){
        cin >> p[i] >> x[i];
        p[i]--;
    }
    rep(i, m) cout << tot - t[p[i]] + x[i] << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

int main(){
    int n;
    cin>>n;
    map<int,int> m;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    rep(i,n){
        m[a[i]]++;
        if(m[a[i]]<2){
            int mul=2;
            do{
                m[a[i]*mul]++;
                mul++;
            }while(a[i]*mul<=1000000);
        }
    }
    int ans=0;
    rep(i,n) if(m[a[i]]==1)ans++;
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  ll N, M;
  cin >> N >> M;
  vector<ll> a(N);
  for(int i = 0; i < N; i++) {
    cin >> a[i];
    a[i] /= 2;
  }

  bool ok = true;

  ll cnt_2 = 0;
  ll tmp = a[0];
  while(tmp % 2 == 0){
    tmp = tmp/2;
    cnt_2++;
  }


  for(int i = 0; i < N; i++){
    ll cnt_2_tmp = 0;
    ll tmp_a = a[i];
    while(tmp_a % 2 == 0){
      tmp_a = tmp_a/2;
      cnt_2_tmp++;
    }
    if(cnt_2 != cnt_2_tmp){
      ok = false;
      break;
    }
  }

  if(N > 1){
    if(ok){
    // すべて奇数の場合
    
    ll lcm_a = a[0] / gcd(a[0], a[1]) * a[1];

    for(int i = 1; i < N; i++){
      lcm_a = lcm_a / gcd(lcm_a, a[i]) * a[i];
    }
    
    ll cnt = M / lcm_a;

    cout << (cnt + 2 - 1) / 2 << endl;
    }else{
      cout << 0 << endl;
    }

  }else{

    ll cnt = M / a[0];

    cout << (cnt + 2 - 1) / 2 << endl;

  }

  
  return 0;
}


Measured memory_bytes: 1024
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, m, c = rm()
b = np.array(rl())
cnt = 0
for _ in range(n):
  a = np.array(rl())
  if np.sum(a*b) > -c:
    cnt += 1
print(cnt)
    










Measured memory_bytes: 27244
#include<stdio.h>
int main(){
	int i,j,tmp;
	int Mt[10];
	for(i=0;i<10;i++){
		scanf("%d",&Mt[i]);
	}
	for(;;){
		for(i=0;i<10;i++){
			for(j=i+1;j<10;j++){
				if(Mt[i]>Mt[j]){
					tmp=Mt[i];
					Mt[i]=Mt[j];
					Mt[j]=tmp;
				}
			}
		}
		if(Mt[0]<=Mt[1]){break;}
	}
		for(i=9;i>=7;i--){printf("%d\n",Mt[i]);}
	
	return 0;
}

Measured memory_bytes: 2728
#include <iostream>
#include <cmath>

int main(int argc, char *argv[]) {
    int N;
    scanf("%d", &N);
    int count=0;
    for(int i=1;i<=N;i+=2){
        int yakusu=0;
        for(int j=1; j<=N;j++){
            if(i%j==0){
                yakusu++;
            }
        }
        if(yakusu==8){
            count++;
        }
    }
    printf("%d\n",count);
    return 0;

}

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

int l[10] = {}, v[2];

void input(string s) {
	int x = 0,n=0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != ',') {
			n = n * 10 + s[i] - '0';
			continue;
		}
		if (x < 10) {
			l[x++] = n;
			n = 0;
		}
		else {
			v[0] = n;
			n = 0;
		}
	}
	v[1] = n;
}


int main() {
	string s;
	while (cin >> s) {
		int len = 0, x1 = 0;
		double x;
		input(s);
		for (int i = 0; i < 10; i++)
			len += l[i];
		x = (double)len * v[0] / (double)(v[0] + v[1]);
		for (int i = 0; i < 10; i++) {
			x1 += l[i];
			if (x1 >= x) {
				cout << i + 1 << endl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3044
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); i++)
#define rrep(i, to) for (int i = to - 1; i >= 0; i--)
#define repf(i, from, to) for (int i = (from); i < (to); i++)
#define all(v) v.begin(), v.end()
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  int n;
  V<int> a, b, c;
  cin >> n;
  a.resize(n);
  b.resize(n);
  c.resize(n);

  rep(i, n) {
    cin >> a[i];
  }
  rep(i, n) {
    cin >> b[i];
  }
  rep(i, n) {
    cin >> c[i];
  }

  sort(all(a));
  sort(all(c));

  ll ans = 0;
  rep(i, n) {
    auto low_a_it = lower_bound(all(a), b[i]);
    auto low_c_it = upper_bound(all(c), b[i]);

    ll a_num = low_a_it - a.begin();
    ll c_num = c.end() - low_c_it;

    ans += a_num * c_num;
  }

  cout << ans << endl;
}

Measured memory_bytes: 4488
# https://atcoder.jp/contests/abc136/tasks/abc136_d
# D - Gathering Children
import math
# 一番近いRLはどこか？

s_list = list(input().split()[0])
count_list = [0] * len(s_list)

# 最初がRだった子は、Rが連続する限り右へ行く。最初にLが出た瞬間が打ち止め
# 最初がLだった子は、Lが連続する限り左へ行く。最初にRが出た瞬間が打ち止め
rrl_list = ''.join(s_list).split('LR')
count_index = 0

for i, rrl in enumerate(rrl_list):
    if i != 0:
        rrl = 'R' + rrl
    if i != len(rrl_list) - 1:
        rrl = rrl + 'L'
    rl_r_index = rrl.find('RL')
    # rl_r_indexから偶数歩離れているマス目の数は
    # 左側
    r_count = math.floor(rl_r_index / 2)
    # print('左側：{}'.format(r_count))
    # 右側
    # print('右側: {}'.format(math.floor((len(rrl) - (rl_r_index+1)) / 2) + 1))
    r_count += math.floor((len(rrl) - (rl_r_index+1)) / 2) + 1

    l_count = len(rrl) - r_count
    count_list[count_index + rl_r_index] = r_count
    count_list[count_index + rl_r_index + 1] = l_count
    count_index += len(rrl)
    # print(rrl)
    # print(count_list)

ans = ' '.join([str(x) for x in count_list])
print(ans)


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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    if(s.size() < 26){
        bool memo[300] = {};
        for(int i = 0;i < s.size();i++){
            memo[s[i]] = true;
        }

        cout << s;
        for(char i = 'a';i <= 'z';i++){
            if(!memo[i]){
                cout << i << endl;
                return 0;
            }
        }
    }else{

        for(int i = 0;i < n;i++){
            int j;
            for(j = i+1;j < n;j++){
                if(s[j-1] < s[j]){
                    break;
                }
            }
            if(j == n){
                if(i == 0){
                    cout << -1 << endl;
                    return 0;
                }else{
                    for(int j = 0;j < i-1;j++){
                        cout << s[j];
                    }
                    char mi = CHAR_MAX;
                    for(int j = i;j < n;j++){
                        if(s[j] > s[i-1]){
                            mi = min(mi, s[j]);
                        }
                    }
                    cout << mi << endl;
                    return 0;
                }
            }
        }
    }
}








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

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double

using namespace std;

int lev[100005], good[100005];
int n, ans;

int main(){
  scanf("%d", &n);
  FI(i, 1, n){
    int x;
    scanf("%d", &x);
    FI(j, 0, 30){
      if(x <= (1 << j)){
        if(x == (1 << j)) good[i] = true;
        lev[i] = j;
        break;
      }
    }
  }
  FD(i, 30, 1){
    //level i
    int cumu = 0;
    FI(j, 1, n){
      if(lev[j] == i){
        if(!good[j]){
          if(cumu == -1){
            ans++;
            cumu = 0;
          }
          else if(cumu == -2) cumu = 0;
          else cumu = -1;
          
          good[j] = 1;
        }
        else{
          if(cumu == -1){}
          else if(cumu == 0){
            ans++;
            cumu = -2;
          }
        }
        lev[j]--;
      }
      else{
        if(cumu == -1) ans++;
        cumu = 0;
      }
    }
    if(cumu == -1) ans++;
    //printf("%d: %d\n", i, ans);
    //if(i <= 10){
    //  FI(j, 1, n) printf("%d[%d], ", lev[j], good[j]);
    //  printf("\n");
    //}
  }
  printf("%d\n", ans);
  return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner ob=new Scanner(System.in);
		double d=ob.nextInt();
		double t=ob.nextInt();
		double s=ob.nextInt();
		if((d*(1.0)/s)<=t){System.out.println("Yes");}
		else {System.out.println("No");}
	}
}

Measured memory_bytes: 26944
import sys
input = sys.stdin.buffer.readline

N, Ma, Mb = map(int, input().split())
ABC = [list(map(int, input().split())) for _ in range(N)]

INF = 10 ** 15
dp = [[INF for j in range(401)] for i in range(401)]
dp[0][0] = 0

for a, b, c in ABC:
  for i in range(400, -1, -1):
    for j in range(400, -1, -1):
      if dp[i][j] != INF:
        dp[i + a][j + b] = min(dp[i + a][j + b], dp[i][j] + c)

answer = INF
for i in range(1, 401):
  for j in range(1, 401):
    if dp[i][j] != INF and i / j == Ma / Mb:
      answer = min(answer, dp[i][j])
      
print(answer if answer != INF else -1)

Measured memory_bytes: 44124
a, b = map(int, input().split())

a1 = 0
a2 = 0
if a*100 % 8 == 0:
    a1 = a/0.08
else:
    a1 = a//0.08 + 1

a2 = (a+1)//0.08

b1 = b / 0.1
b2 = (b+1) / 0.1

a1 = int(a1)
a2 = int(a2)
b1 = int(b1)
b2 = int(b2)

al = []
bl = []

for i in range(a1, a2+1):
    al.append(i)
for i in range(b1, b2):
    bl.append(i)

ans = set(al) & set(bl)
if len(ans) == 0:
    print(-1)
else:
    print(min(ans))

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M;
    cin >> N >> M;
    ll ans = 1;
    for (ll x = 1; x * x <= M; x++) {
        if (M % x == 0 && N * x <= M && (M - (N - 1) * x) % x == 0) {
            ans = max(ans, x);
        }
        ll y = M / x;
        if (M % y == 0 && N * y <= M && (M - (N - 1) * y) % y == 0) {
            ans = max(ans, y);
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var reader = bufio.NewReader(os.Stdin)

func readLine() []string {
	var buf []byte
	for {
		line, prefix, err := reader.ReadLine()
		if err != nil {
			fmt.Println("readLine: ", err)
		}
		buf = append(buf, line...)
		if prefix == false {
			break
		}
	}
	s := string(buf)
	return strings.Split(s, " ")
}

func toints(s []string) []int {
	var ints []int
	for _, v := range s {
		int, _ := strconv.Atoi(v)
		ints = append(ints, int)
	}
	return ints
}

func main() {
	var k int
	var h []int

	a := toints(readLine())
	k = a[1]
	h = toints(readLine())

	numberOfRiders := 0
	for _, height := range h {
		if height >= k {
			numberOfRiders++
		}
	}

	fmt.Println(numberOfRiders)
}


Measured memory_bytes: 6784
n = int(input())
a = input()
b = input()
c = input()
ans =0

for i in range(n):
    x = a[i]
    y = b[i]
    z = c[i]
    if (x == y and y == z):
        pass
    elif (x == y or y == z or z == x):
        ans += 1
    else:
        ans += 2

print(ans)
        

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

int p[8];
const int a[8] = { 4,1,4,1,2,1,2,1 };

int next(int i) {
	return i == 7 ? 0 : i + 1;
}

bool rec(int s, int i) {
	if (a[s] > a[i]) {
		return true;
	}
	else if (a[s] < a[i]) {
		return false;
	}
	else {
		return rec(s + 1, i + 1);
	}
}

int main(){
	while (scanf("%d %d %d %d %d %d %d %d", &p[0], &p[1], &p[2], &p[3], &p[4], &p[5], &p[6], &p[7]) != EOF) {
		int l, c, min = 10000, s;
		for (int i = 0; i < 8; i++) {
			l = i;
			c = 0;
			for (int j = 0; j < 8; l = next(l), j++) {
				c += (a[l] - p[j] > 0 ? a[l] - p[j] : 0);
			}
			if (c < min) {
				min = c;
				s = i;
			}
			else if (c == min) {
				if (rec(s, i)) {
					s = i;
				}
			}
		}
		printf("%d", a[s]);
		for (int i = 1; i < 8; i++) {
			s = next(s);
			printf(" %d", a[s]);
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 2708
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(int _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 1000
#define maxh 10000

using namespace std;

int h, n;
pii v[maxn+5];
int d[maxh+5];
bool viz[maxh+5];

int Dp (int x) {
  if (x < 0 || x > h) return inf;
  if (viz[x]) return d[x];
  viz[x] = 1;
  for (int i = 1; i <= n; i++) d[x] = min(d[x], v[i].se + Dp(min(x+v[i].fi, h)));
  return d[x];
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> h >> n;
  int i, j, z, cur;
  for (i = 1; i <= n; i++) cin >> v[i].fi >> v[i].se;///fi=cat scade se=cost
  fill(all(d), inf); d[h] = 0; viz[h] = 1;
  cout << Dp(0);
  return 0;
}


Measured memory_bytes: 768