akhauriyash/Code-Regression huggingface dataset:
// g++ -std=c++11 -O2 -Wall -Wl,--stack=268435456

#include <bits/stdc++.h>
using namespace std;

typedef long long          ll;
typedef vector<int>        vi;
typedef vector< vi >       vvi;
typedef pair<int, int>     pi;
typedef vector< pi >       vpi;

#define F first
#define S second
#define PB push_back
#define PF pop_front
#define MP make_pair
#define REP(i,a,b) for (int i = (int)(a); i < (int)(b); i++)

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int  n, m, u, v;
    cin >> n >> m;
    vvi pa(n);
    vi deg(n, 0), mlen(n, 0);
    REP(i, 0, m) {
        cin >> u >> v;
        u--;  v--;
        pa[v].PB(u);
        deg[u]++;
    }
    queue<int> q;
    REP(i, 0, n) {  if (deg[i] == 0)  q.push(i); }
    while (! q.empty()) {
        int v = q.front();  q.pop();  
        for (int u : pa[v]) {
            mlen[u] = max(mlen[u], 1+mlen[v]);
            if (--deg[u] == 0) { q.push(u); }
        }
    }
    int ans = 0;
    REP(i, 0, n) { ans = max(ans, mlen[i]); }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const long long inf = 123456789123456789;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	vector<vector<long long> > dp(N + 1);
	dp[0] = vector<long long>(N + 1, 0);
	for (int i = 1; i <= N; ++i) {
		dp[i] = vector<long long>(N - i + 1, -inf);
		for (int j = 0; j <= N - i; ++j) {
			dp[i][j] = max(A[j + i - 1] - dp[i - 1][j], A[j] - dp[i - 1][j + 1]);
		}
	}
	cout << dp[N][0] << '\n';
	return 0;
}

Measured memory_bytes: 35584
from sys import stdin
sp = stdin.readline().split()
A, B = int(sp[0]), int(sp[1])

def div(num):
    l = []
    for itr in range(1,num+1):
        if num % itr == 0:
            l.append(itr)
    return l

B_divisor = div(B)
if A in B_divisor:
    print(A+B)
else:
    print(B-A)

Measured memory_bytes: 3060
# 入力 : 数字2つ
x, y = map(int, input().split())

# 出力　x, y が同一のグループに属しているか判定してください。

list1 = [1, 3, 5, 7, 8, 10, 12]
list2 = [4, 6, 9, 11]
list3 = [2]

if x in list1 and y in list1:
    print("Yes")
elif x in list2 and y in list2:
    print("Yes")
elif x in list3 and y in list3:
    print("Yes")
else :
    print("No")


Measured memory_bytes: 3060
N = int(input())
W = list(map(int, input().split()))

sm = sum(W)
mn = sm  # tmp

x1 = 0
for wi in W:
    x1 = x1 + wi
    x2 = sm - x1

    ab = abs(x1 - x2)
    mn = min(mn, ab)

print(mn)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

bool binary_search(vector<int> S, int T){
  int n = S.size();
  int left = 0, right = n, mid;
  while (left<right){
    mid = (left+right)/2;
    if (S[mid]>T) right = mid;
    else if (S[mid]<T) left = mid+1;
    else return true; //return mid
  }

  return false;
}

int main(){
  int n; cin >> n;
  vector<int> S(n);
  rep(i,n) cin >> S[i];
  int q; cin >> q;
  int T, cnt=0;
  rep(i,q){
    cin >> T;
    cnt += binary_search(S,T);
  }
  cout << cnt << endl;
  
  // cout << fixed << setprecision(6);
  return 0;
}



Measured memory_bytes: 3580
import random
import fractions

def solve(N, K, A):
    gcd = A[0]
    for x in A:
        gcd = fractions.gcd(gcd, x)
    if K % gcd == 0 and max(A) >= K:
        return 'POSSIBLE'
    else:
        return 'IMPOSSIBLE'

def solve2(N, K, A):
    mx = max(A)
    B = [False] * (mx + 1)
    for i in A:
        B[i] = True
    while True:
        update = False
        for i in range(mx + 1):
            if not B[i]:
                continue
            for j in range(i + 1, mx + 1):
                if not B[j]:
                    continue
                d = abs(i - j)
                if not B[d]:
                    update = True
                    B[d] = True
        if not update:
            break
    return 'POSSIBLE' if K <= mx and B[K] else 'IMPOSSIBLE'

#for i in range(100000):
#    N = random.randint(1, 5)
#    K = random.randint(1, 20)
#    A = [random.randint(1, 20) for i in range(N)]
#    if solve(N, K, A) != solve2(N, K, A):
#        print(N, K, A)
#        print(solve(N, K, A))
#        print(solve2(N, K, A))
#        break

N, K = map(int, input().split())
A = list(map(int, input().split()))
print(solve(N, K, A))


Measured memory_bytes: 16632
#pragma GCC optimize ("O3")
#pragma GCC target (sse, sse1, sse2, tune=native, popcnt)

#include <bits/stdc++.h>
/*
const int MAX_MEM = 25e7;
int mpos = 0;
char mem[MAX_MEM];
inline void* operator new(size_t n) {
    char *res = mem + mpos;
    mpos += n;
    assert(mpos <= MAX_MEM);
    return (void *) res;
}
inline void operator delete(void *) {}
*/
using namespace std;

#define loop(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, n) for(int i = a; i < n; ++i)
#define vec vector
#define paii pair<int, int>
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define SZ(x) (int)x.size()
#define Unique(x) x.erase(unique(all(x)), x.end())

#define int long long

const int inf = 1e17 + 47, MAXN = 2047, N = 20, mod = 1e9 + 7;

mt19937 rnd(time(0));

int n;
int dp[MAXN * 2][MAXN * 2];

int bin_pow(int a, int n) {
    if(n == 0) return 1;
    int b = bin_pow(a, n / 2);
    b = (b * b) % mod;
    if(n % 2 == 1) b = (b * a) % mod;
    return b;
}

void solve() {
    loop(i, MAXN * 2) loop(j, MAXN * 2) dp[i][j] = 0;
    cin >> n;
    vec<paii> p(n);
    loop(i, n) {
        int a, b;
        cin >> a >> b;
        p[i] = {a, b};
        dp[MAXN - a][MAXN - b]++;
    }
    int ans = 0;
    loop(a, 2 * MAXN) {
        loop(b, 2 * MAXN) {
            if(a != 0) dp[a][b] += dp[a - 1][b];
            if(b != 0) dp[a][b] += dp[a][b - 1];
            dp[a][b] %= mod;
        }
    }
    vec<int> fact(MAXN * 4, 1);
    FOR(i, 1, MAXN * 4) fact[i] = (fact[i - 1] * i) % mod;
    loop(i, n) {
        int a = 2 * p[i].fr, b = 2 * p[i].sc;
        ans = (ans + dp[MAXN + a / 2][MAXN + b / 2]) % mod;
        int t = (fact[a + b] * bin_pow(fact[a], mod - 2)) % mod;
        t = (t * bin_pow(fact[b], mod - 2)) % mod;
        ans = (ans + mod - t) % mod;
    }
    ans = (ans * bin_pow(2, mod - 2)) % mod;
    cout << ans << endl;
}

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

    #ifdef COFFEE_MACHINE
        freopen("input.cpp", "r", stdin);
        freopen("output.cpp", "w", stdout);
    #endif // COFFEE_MACHINE

    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
}


Measured memory_bytes: 134400
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		long h = sc.nextLong(), n = sc.nextLong();
		long all =0;
		for(;n > 0; n--) {
			all += sc.nextLong();
		}
		pw.print(all < h ? "No" : "Yes");
		pw.close();
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}

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

int main(void){
	int a, b;

	scanf("%d %d", &a, &b);

	if(a >= 1 && a <= pow( 10.0, 9.0) && b >= 1 && b <= pow( 10.0, 9.0)){
		printf("%d %d %f\n", a / b, a % b, (double)a / (double)b);
	}

	return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;

int findContinuousIntervals(vi &h, int n)
{
	int i = 0, res = 0;
	while(i < n)
	{
		if(h[i] == 0)
			i++;
		else
		{
			res ++;
			while(i< n && h[i] >0)
				i++;
		}
	}
	return res;
}

int main()
{
	//ifstream cin("input.txt");
	ll n;
	cin>>n;
	vi h(n);

	rep(i,0,n-1)
		cin>>h[i];
	int count = 0;
	while(*max_element(h.begin(), h.end()) != 0)
	{
		count += findContinuousIntervals(h,n);
		rep(i, 0, n-1)
			if(h[i] >0)
				h[i]--;
	}
	cout<<count;
}


Measured memory_bytes: 3604
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
#include <string>
#include <utility>

using namespace std;

typedef enum {ROOT, LEAF, INTR} LEAF_TYPE;
string lt2str(LEAF_TYPE lt){
  switch(lt){
  case ROOT:
    return "root";
  case LEAF:
    return "leaf";
  case INTR:
    return "internal node";
  default:
    return "?";
  }
}

//returns max depth
int dfs
(int node, vector<int>& d, vector<int>& h,
 int depth, const vector<vector<int> > & ch){ 
  const vector<int>& childs = ch[node];
  d[node] = depth;
  int max_depth = depth;
  for (int child : childs){
    max_depth = max(max_depth, dfs(child, d, h, depth+1, ch));
  }
  h[node] = max_depth - depth;
  return max_depth;
}


int sibling(int node, const vector<vector<int> > & ch, const vector<int> & p){
  if(-1 == p[node]) return -1;
  const vector<int>& children = ch[p[node]];
  if(children.size() < 2) return -1;
  if(children[0] != node) return children[0];
  else return children[1];
}

int main(){
  int n; // 1..100000
  cin >> n;

  vector<int> v(n);
  vector<vector<int> > ch(n);
  vector<int> p(n, -1); //parent
  for(int i=0;i<n;++i){
    int id;
    cin >> id;
    //int k;
    //cin >> k;
    for(int j=0; j<2; ++j){
      int child;
      //cout << "?? 1" << endl;  
      cin >> child;
      //cout << "?? 2" << endl;  
	    
      if(child == -1) continue;
      //cout << "?? 3" << endl;
      //cout << "id child " << id << child <<endl;
      ch[id].push_back(child);
      //cout << "?? 4" << endl;  
      p[child] = id;
      //cout << "?? 5" << endl;  
    }
  }



  const int root_id = find(p.begin(), p.end(), -1) - p.begin();

  vector<int> d(n, -1);
  vector<int> h(n, -1);
  //dfs

  dfs(root_id, d, h, 0, ch);

  

  vector<LEAF_TYPE> l(n);
  for(int i=0; i<n; ++i){
    if(ch[i].size() == 0){
      l[i] = LEAF;
    }
    else{
      l[i] = INTR;
    }
  }
  l[root_id] = ROOT;

  //node 0: parent = -1, depth = 0, root, [1, 4, 10]

  for(int i=0; i<n; ++i){
    cout << "node " << i << ": "
	 << "parent = " << p[i] << ", "
	 << "sibling = " << sibling(i, ch, p) << ", "
	 << "degree = " << ch[i].size() << ", "
	 << "depth = " << d[i] << ", "
	 << "height = " << h[i] << ", "
	 << lt2str(l[i]) 
	 << endl;
  }


  
  //cout  << endl;
  return 0;
}

Measured memory_bytes: 1220
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set

//#define      ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define        fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define        f first
#define        s second
#define        pb push_back
#define        eb emplace_back
#define        mp  make_pair
#define        forn(i,n) for(int i=0;i<n;++i)
#define        show(b) for(auto const&x: b) cout<<x<<" "
#define        sshow(b) for(auto x:b) cout<<x<<" "
#define        fix(b,val)   memset(b,val,sizeof(b))
#define        pill(b,n,v)  fill(b,b+n,v)
#define        itn          int
#define        w(t)     int t;cin>>t;while(t--)
#define        mx(a,b,c) max(a,max(b,c))
#define        mn(a,b,c) min(a,min(b,c))
#define        intmax    INT_MAX
#define        intmin    INT_MIN
#define        nl        "\n"
#define        prt(val)  cout<<val<<"\n"
#define        all(v)    v.begin(),v.end()
#define        trace1(x)                cerr<<#x<<": "<<x<<endl
#define        trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define        trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define        trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define        trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define        trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef       long long int ll;
typedef       long double LD;
typedef       unsigned long long int LL;
typedef       pair<int,int> pii;
typedef       pair<long long int,int> pli;
typedef       pair<int,long long int> pil;
typedef       pair<long long int,long long int> pll;
const int N=2*1e6+10;
const int mod=1e9+7;
//mt19937 rnd(time(NULL));

/*------Global--------*/

/*-----Functions------*/
template<typename T>
void show2d(const vector<vector<T>>& adj)
{
    for(auto x:adj)
    {
        for(auto y:x)
        { 
           cout<<y<<" ";
        }
    cout<<"\n";
    }
}

ll modexp(ll a,ll b,ll mod)
{
    ll x=1;
    while(b)
    {
        if(b&1)
        x = ((x%mod) * (a%mod))%mod;
        a = ((a%mod) * (a%mod))%mod;
        b = b / 2;
    }
    return x;
}

void rf()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int32_t main()
{
    fast;
  //  rf();
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int tot = (h2-h1)*60 + (m2-m1);
    tot -= k;
    cout<<tot<<nl;
}

Measured memory_bytes: 3544
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
using namespace std;
using P=pair<int,int>;//x num
int main(){
    int N,M;
    cin>>N>>M;
    vector<P> V;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        V.emplace_back(a,1);
    }
    for(int i=0;i<M;i++){
        int b,c;
        cin>>b>>c;
        V.emplace_back(c,b);
    }
    sort(V.begin(), V.end(),greater<P>());
    int64_t sum=0,ans=0;
    for(auto p:V){
        int64_t b,c;
        tie(c,b)=p;
        ans+=c*min(b,N-sum);
        sum+=min(b,N-sum);
        if(sum==N) break;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2420
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const int MAXN = 120;

vector<int> eds[MAXN];
ll mx[MAXN];
vector<int> st;

pair<int, int> dfs1(int v, int p) {
	pair<int, int> ans = make_pair(0, v);
	for (int u: eds[v]) {
		if (u == p)
			continue;
		pair<int, int> tmp = dfs1(u, v);
		++tmp.first;
		ans = max(ans, tmp);
	}
	return ans;
}

bool get(int v, int p, int d) {
	st.push_back(v);
	if (v == d)
		return 1;
	for (int u: eds[v]) {
		if (u == p)
			continue;
		if (get(u, v, d))
			return 1;
	}
	st.pop_back();
	return 0;
}

void gogo(int v, int p, int h) {
	int cnt = 0;
	for (int u: eds[v])
		if (u != p)
			++cnt;
	mx[h] = max(mx[h], ll(cnt));
	for (int u: eds[v]) {
		if (u != p)
			gogo(u, v, h + 1);
	}
}

int n;

ll solve(int n, vector<pair<int, int> > ed) {
	for (int i = 0; i < n; ++i)
		eds[i].clear();
	for (int i = 0; i < ed.size(); ++i) {
		int a, b;
		tie(a, b) = ed[i];
		eds[a].push_back(b);
		eds[b].push_back(a);
	}
	int a = dfs1(0, -1).second;
	int b, d;
	tie(d, b) = dfs1(a, -1);
	st.clear();
	for (int i = 0; i <= n; ++i)
		mx[i] = 0;
	get(a, -1, b);
	if (d % 2 == 0) {
		return -1;
	}
	else {
		gogo(st[d / 2], st[d / 2 + 1], 0);
		gogo(st[d / 2 + 1], st[d / 2], 0);
		ll ans = 1;
		for (int i = 0; i < d / 2; ++i) {
			ans = (ans * mx[i]);
		}
		return ans * 2;
	}
}

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	vector<pair<int, int>> ed;
	for (int i = 0; i < n - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		eds[a].push_back(b);
		eds[b].push_back(a);
		ed.emplace_back(a, b);
	}
	int a = dfs1(0, -1).second;
	int b, d;
	tie(d, b) = dfs1(a, -1);
	cout << d / 2 + 1 << " ";
	get(a, -1, b);
	if (d % 2 == 0) {
		gogo(st[d / 2], -1, 0);
		ll ans = 1;
		for (int i = 0; i < d / 2; ++i) {
			ans = (ans * mx[i]);
		}
		int mxx = d / 2;
		for (auto p: ed) {
			if (dfs1(p.first, p.second).first > mxx || dfs1(p.second, p.first).first > mxx)
				continue;
			for (int i = 0; i <= n; ++i)
				mx[i] = 0;
			gogo(p.first, p.second, 0);
			gogo(p.second, p.first, 0);
			ll ans2 = 1;
			for (int i = 0; i < d / 2; ++i) {
				ans2 = min(ans, (ans2 * mx[i]));
			}
			ans = min(ans, 2 * ans2);
		}
		cout << ans << "\n";
	}
	else {
		cout << solve(n, ed) << "\n";
	}
	return 0;
}




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

int main() {
	long long n, cnt = 0;
	cin >> n;
	bool flag = false;
	for(int i = 1; pow(3, i) <= n; ++i){
		if(pow(3, i) == n)
			flag = true;
	}
	
	while(n > 0){
		cnt++;
		n /= 3;
	}
	if(flag)
		cnt--;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1200
//https://atcoder.jp/contests/agc004/tasks/agc004_a
//A - Divide a Cuboid
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll A,B,C; cin>>A>>B>>C;
    auto calc=[](ll x,ll y, ll z){
        return (x*y*z);
    };
    ll ans=INT64_MAX;
    //A
    ll a=A/2;
    ll aa=A-a;
    ans=min(abs(calc(a,B,C) - calc(aa,B,C)),ans);
    //B
    ll b=B/2;
    ll bb=B-b;
    ans=min(abs(calc(A,b,C) - calc(A,bb,C)),ans);
    //C
    ll c=C/2;
    ll cc=C-c;
    ans=min(abs(calc(A,B,c) - calc(A,B,cc)),ans);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys

n=int(input())
List=[list(map(int,input().split())) for i in range(n)]
#print(List)

w=sorted(List, key=lambda x: x[1])

t=0
for i in w:
  t=t+i[0]
  if t>i[1]:
    print("No")
    sys.exit()

print("Yes")

Measured memory_bytes: 55264
N = int(input())
C = input()
nw = C.count('W')
nr = N - nw

if nw == N or nr == N:
    print(0)
else:
    a = C[:nr]
    b = C[nr:]
    nw = a.count('W')
    nr = b.count('R')
    n = min(nw, nr)
    m = max(nw, nr) - n
    print(n + m)

Measured memory_bytes: 9400
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce

X = a_int()
i = X // 200
print(2000 // 200 - i)


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint a,b,k;cin >> a>>b>>k;
    lint ans=0,x=0;

    IREP(i,101){
        if (a % i != 0 || b % i != 0){
            continue;
        }
        x++;
        if(x==k){

            cout << i << "\n";
            return 0;
        }
    }



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 2e9;
int dp[110][110][2];
int main(){ 
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];

  for (int i = 0; i < 110; i++) {
    for (int j = 0; j < 100; j++) {
      for (int k = 0; k < 2; k++) dp[i][j][k] = INF;
    }
  }

  if (s[0][0] == '.') dp[0][0][0] = 0;
  else dp[0][0][1] = 1;

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      for (int k = 0; k < 2; k++) {
        if (dp[i][j][k] == INF) continue;
        if (i + 1 < h) {
          int d = (s[i + 1][j] == '#');
          if (!d) {
            dp[i + 1][j][d] = min(dp[i + 1][j][d], dp[i][j][k]);
          } else {
            dp[i + 1][j][d] = min(dp[i + 1][j][d], dp[i][j][k] + (k ? 0 : 1));
          }
        }
        if (j + 1 < w) {
          int d = (s[i][j + 1] == '#');
          if (!d) {
            dp[i][j + 1][d] = min(dp[i][j + 1][d], dp[i][j][k]);
          } else {
            dp[i][j + 1][d] = min(dp[i][j + 1][d], dp[i][j][k] + (k ? 0 : 1));
          }
        }
      }
    }
  }

  cout << min(dp[h-1][w-1][0], dp[h-1][w-1][1]) << endl;
  return 0;
} 

Measured memory_bytes: 384
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	int N;
	cin >> N;

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

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (!(i & 1) && (A[i] & 1)) ans++;
	}

	cout << ans << "\n";

	return 0;
}



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

int main() {
  string str;
  bool chk = true;
  
  cin >> str;
  
  if(str.size() % 2 == 1) chk = false;
  
  for(int i = 0; i < str.size() / 2; i=i+2){
    if(str.substr(i,2) != "hi") chk = false;
  }
  
  if(chk == true) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 256
#include<iostream>
int main(){for(float a,b,c,d,e,f,x,y;;printf("%.3f %.3f\n",x,y)){if((std::cin>>a>>b>>c>>d>>e>>f).eof())break;y=(c*d-a*f)/(b*d-a*e);x=d?f/d-e*y/d:c/a-b*y/a;}}

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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
using intmap = map<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
inline bool bit (ll b, ll i) { return b & (1 << i); }
inline ll ceiv (ll a, ll b) { return (a + b - 1) / b; }
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define debug(x) cerr << #x << ": " << x << '\n'
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main() {
    string s;
    cin >> s;
    
    int ans = 0;
    for(char c : s){
        ans = (ans + c - '0') % 9;
    }
    
    cout << (ans % 9 == 0 ? "Yes" : "No") << endl;
}

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

using namespace std;
#ifdef ONLINE_JUDGE
#define cerr if(false)cerr
#endif

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int long long
#define ld1 long double
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout<<setprecision(14);
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
#define mm0(X) memset((X), 0, sizeof((X)))
#define mm1(X) memset((X), -1, sizeof((X)))
#define INF (int)1e9
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define endl '\n'
#define vcc vector<char>
#define rep(i,a,b) for(int i=a;i<b;i++)

// if you have no idea just guess the appropriate well-known algo instead of doing nothing -- Benq inspiration
const int mod=998244353;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int powmod(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return powmod(a,mod-2);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

const int N=(int)1e6+6;

void solve(){
    char a;
    cin >> a;
    if(a>='A' and a<='Z'){
        cout<<'A';
    }else cout<<'a';
    cout<<endl;
}

int32_t main() {
    faster;

#ifndef ONLINE_JUDGE
    READ("input.txt");
    WRITE("output.txt");
    double beg=clock();
#endif

    int t=1;
//    cin>>t;

//    cout<<"hello"<<endl;
    while(t--){
        solve();
    }

#ifndef ONLINE_JUDGE
    double endd=clock();
    cout<<endl;
    cerr<<"*** Total time = "<<(endd-beg)/CLOCKS_PER_SEC;
#endif
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main() {
	int n;
	cin>>n;
	vector<double> p(n+1);
	for(int i=1;i<=n;i++) {
		cin>>p[i];
	}
	vector<vector<double>> dp(n+1,vector<double> (n+1));
	dp[0][0] = 1.0;
	for(int i=1;i<=n;i++) {
		dp[i][0] = (1-p[i])*dp[i-1][0];
		for(int j=1;j<=i;j++) {
			dp[i][j] = (dp[i-1][j-1]*p[i]) + (dp[i-1][j] * (1-p[i]));
		}
	}
	double ans = 0;
	for(int i=n;i>n/2;--i) {
		ans+=dp[n][i];
	}
	cout<<setprecision(10)<<ans<<"\n";
}


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

int main() {

	int n; cin >> n;
	
	vector<long long> a(n); for (int i = 0; i < n; i++) {
		long long tmp_a;
		cin >> tmp_a;
		a[i] = tmp_a - (i + 1);
	}

	sort(a.begin(), a.end());

	long long tmp_b;
	if (n % 2 == 0) tmp_b = (a[n / 2 - 1] + a[n / 2]) / 2;
	else tmp_b = a[(n - 1) / 2];

	long long ans = 0;
	for (int i = 0; i < n; i++) ans += abs(a[i] - tmp_b);
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long ans1 = 0;
		long ans2 = 0;
		int problems = sc.nextInt();
		int submissions = sc.nextInt();
		int[] solved = new int[problems+1];
		int[] penalty = new int[problems+1];

		for(int i=0; i<submissions; i++) {
			int submit = sc.nextInt();
			String result = sc.next();

			if(submit <= problems) {
				if(solved[submit] == 1) {
					continue;
				} else if(result.equals("AC")) {
					 ans1++;
					 ans2 += penalty[submit];
					 solved[submit] = 1;
				} else if(result.equals("WA")) {
					penalty[submit] += 1;
				}
			}
		}

		System.out.println(ans1 + " " + ans2);





		// Scanner sc = new Scanner(System.in);
		// Queue<Integer> q1 = new LinkedList<Integer>();
		// Queue<String> q2 = new LinkedList<String>();

		// long ans1 = 0;
		// long ans2 = 0;
		// int problems = sc.nextInt();
		// int submissions = sc.nextInt();
		// int[] solved = new int[problems+1];

		// for(int i=0; i<submissions; i++) {
		// 	int submit = sc.nextInt();
		// 	String result = sc.next();
		// 	// System.out.println(result);

		// 	if(q1.isEmpty() || q1.peek() == submit) {
		// 		q1.add(submit);
		// 		q2.add(result);
		// 	} else {
		// 		while(!q1.isEmpty()) {
		// 			int subVal = q1.remove();
		// 			String resVal = q2.remove();
		// 			if(resVal.equals("AC")) {
		// 				if(subVal <= problems && solved[subVal] == 0) { 
		// 					ans1++;
		// 					solved[subVal] = 1;
		// 				}
		// 				while(!q1.isEmpty()) {
		// 					q1.remove();
		// 					q2.remove();
		// 				}
		// 				// System.out.println("Emptied.");
		// 			} else {
		// 				ans2++;
		// 			}
		// 		}

		// 		q1.add(submit);
		// 		q2.add(result);
		// 	}
		// }

		// while(!q1.isEmpty()) {
		// 	int subVal = q1.remove();
		// 	String resVal = q2.remove();
		// 	if(resVal.equals("AC")) {
		// 		if(subVal <= problems && solved[subVal] == 0) { 
		// 			ans1++;
		// 			solved[subVal] = 1;
		// 		}
		// 		while(!q1.isEmpty()) {
		// 			q1.remove();
		// 			q2.remove();
		// 		}
		// 		// System.out.println("Emptied.");
		// 	} else {
		// 		ans2++;
		// 	}
		// }

		// System.out.println(ans1 + " " + ans2);
	}
}

Measured memory_bytes: 63732
#include <cmath>
#include <string>
#include <iostream>
#define to36(x) (x < 10 ? (char)(x + 48) : (char)(x + 55))
#ifdef _MSC_VER
#define __builtin_popcount(x) (__popcnt(x))
#define __builtin_popcountll(x) (__popcnt(x) + __popcnt(x >> 32))
#endif
using namespace std;
int N, M, Q; long long a[1009], b[1009]; string s[1009], t;
int main() {
	while (cin >> N >> M >> Q, N) {
		fill(a, a + Q, 0);
		fill(b, b + M, (1LL << N) - 1);
		s[0] = string(M, '0');
		for (int i = 0; i < Q; i++) {
			cin >> t >> s[i + 1];
			for (int j = N - 1; j >= 0; j--) a[i] = a[i] * 2 + t[j] - 48;
		}
		for (int i = 0; i < Q; i++) {
			for (int j = 0; j < M; j++) b[j] &= (s[i][j] == s[i + 1][j]) ? ~a[i] : a[i];
		}
		for (int i = 0; i < M; i++) {
			if (__builtin_popcountll(b[i]) == 1) cout << to36((int)(log2(b[i])));
			else cout << '?';
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 4240
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
//        System.out.println("A: "+A+" B:"+B);
        int result = A * B;
//        System.out.println("result: "+result);
        System.out.println(result);
    }
}

Measured memory_bytes: 35700
use std::io::{BufRead, Write};
use std::io;

// binary search impl which guarantees lower bound
fn binary_search<'a, T: Ord>(a: &'a [T], x: &T) -> usize {
    let mut l = 0;
    let mut h = a.len();
    while l < h {
        let mid = (l + h) / 2;
        if x <= &a[mid] {
            h = mid;
        } else {
            l = mid + 1;
        }
    }
    l
}

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let _: usize = buf.trim_right().parse().unwrap();
    buf.clear();
    input.read_line(&mut buf).unwrap();
    let mut a: Vec<usize> = buf.split_whitespace().map(|x| x.parse().unwrap()).collect();
    buf.clear();
    input.read_line(&mut buf).unwrap();
    let mut b: Vec<usize> = buf.split_whitespace().map(|x| x.parse().unwrap()).collect();
    buf.clear();
    input.read_line(&mut buf).unwrap();
    let mut c: Vec<usize> = buf.split_whitespace().map(|x| x.parse().unwrap()).collect();
    a.sort();
    b.sort();
    c.sort();
    let mut b_sum = vec![0usize; b.len()];
    let mut a_sum = vec![0usize; a.len()];
    let mut acc = 0;
    for (idx, i) in b.iter().cloned().enumerate().rev() {
        acc += c.len() - binary_search(&*c, &(i + 1));
        b_sum[idx] = acc;
    }
    acc = 0;
    for (idx, i) in a.iter().cloned().enumerate().rev() {
        let b_idx = binary_search(&*b, &(i + 1));
        if b_idx != b.len() {
            acc += b_sum[b_idx];
        }
        a_sum[idx] = acc;
    }
    writeln!(output, "{}", acc).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "2
1 5
2 4
3 6
",
            "3\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "3
1 1 1
2 2 2
3 3 3
",
            "27\n",
        );
    }

    #[test]
    fn case3() {
        test(
            "6
3 14 159 2 6 53
58 9 79 323 84 6
2643 383 2 79 50 288
",
            "87\n",
        );
    }

    #[test]
    fn test_lower_bound() {
        let a = [0, 1, 1, 1, 1, 1, 1, 1, 1, 2];
        assert_eq!(::binary_search(&a, &1), 1);
    }
}


Measured memory_bytes: 14588
import java.util.*;

class Main {
    Scanner sc = new Scanner(System.in);

    public void run() {
        while(sc.hasNext()){
        	int a=sc.nextInt(),b=sc.nextInt();
        	ln(a+b);
        }
    }
    public static void main(String[] args) {
        new Main().run();
    }
    public static void pr(Object o) {
        System.out.print(o);
    }
    public static void ln(Object o) {
        System.out.println(o);
    }
    public static void ln() {
        System.out.println();
    }
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  if(n%2==0){
    cout << (n/2)*(n/2-1)/2*4 << endl;
    for(int i=1;i<=n/2-1;i++){
      for(int j=i+1;j<=n/2;j++){
        cout << i << " " << j << endl;
        cout << i << " " << n+1-j << endl;
        cout << n+1-i << " " << j << endl;
        cout << n+1-i << " " << n+1-j << endl;
      }
    }
  }
  else{
    cout << (n/2)*(n/2-1)/2*4+n-1 << endl;
    for(int i=1;i<=n/2-1;i++){
      for(int j=i+1;j<=n/2;j++){
        cout << i << " " << j << endl;
        cout << i << " " << n-j << endl;
        cout << n-i << " " << j << endl;
        cout << n-i << " " << n-j << endl;
      }
    }
    for(int i=1;i<=n-1;i++){
      cout << i << " " << n << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  int N;
  cin>>N;
  string s[10000];
  int a,b,c;
  a=0;
  b=0;
  c=0;
  long long answer=0;
  for(int i=0;i<N;i++){
    cin>>s[i];
    for(int j=0;j<s[i].size()-1;j++){
      if(s[i][j]=='A'&&s[i][j+1]=='B') answer++;
    }
    if(s[i][0]=='B') b++;
    if(s[i][s[i].size()-1]=='A') a++;
    if(s[i][0]=='B'&&s[i][s[i].size()-1]=='A') c++;
  }
  answer+=min(a,b);
  if(a==b&&b==c&&a!=0) answer--;
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 3428
#include <bits/stdc++.h>
using namespace std;
constexpr long long mod = 1000000007;
int main(){
 
  int n;
  cin >> n;
  vector<long long> a(n);
  for(int i = 0; i < n; ++i){
   cin >> a[i]; 
  }
  vector<long long> s(n, 0);
  s[n-1] = a[n-1];
  for(int i = n-2; i >= 0; --i){
  	s[i] = (s[i+1] + a[i])%mod;
  }

  long long ans = 0;
  for(int i = 0; i < n-1; ++i){
  	ans += a[i]*s[i+1];
    ans %= mod;
  }
  cout << ans << '\n';
  
  
  return 0;
}

Measured memory_bytes: 6404
# -*- coding: utf-8 -*-
"""
C - Half and Half
https://beta.atcoder.jp/contests/abc095/tasks/arc096_a

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


def solve(A, B, C, X, Y):
    if A + B <= 2 * C:
        return A * X + B * Y

    m = min(X, Y)
    ans = 2 * m * C

    Y -= m
    if 2 * C < B:
        ans += 2 * C * Y
    else:
        ans += B * Y

    X -= m
    if 2 * C < A:
        ans += 2 * C * X
    else:
        ans += A * X

    return ans


def main(args):
    A, B, C, X, Y = map(int, input().split())
    ans = solve(A, B, C, X, Y)
    print(ans)


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


Measured memory_bytes: 3064
using System;
using System.IO;

namespace Contest
{
    class Program
    {
        public void Solve()
        {
            var sc = new Scanner();
            int N = sc.NextInt();
            int K = sc.NextInt();

            Console.WriteLine(N - K + 1);
        }

        static void Main() => new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
        _separator = ' ';
    }
    private char _separator;
    private StreamReader _stream;
    private int _pos;
    private string[] _line;
    #region get a element
    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(_separator);
            _pos = 0;
        }
        return _line[_pos++];
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    #endregion
    #region convert array
    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }
    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }
    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }
    #endregion
    #region get array
    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(_separator);
        _pos = _line.Length;
        return _line;
    }
    public int[] IntArray()
    {
        return ToIntArray(Array());
    }
    public long[] LongArray()
    {
        return ToLongArray(Array());
    }
    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }
    #endregion
}

Measured memory_bytes: 11092
#include <atcoder/all>
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
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);
}
/*-------------------------------------------*/

struct S {
    ll n0, n1, inv;
};
using F = bool;

S op(S l, S r) {
    return S{l.n0 + r.n0, l.n1 + r.n1, l.inv + r.inv + l.n1 * r.n0};
}
S e() { return S{0, 0, 0}; }
S mapping(F f, S x) { return f ? S{x.n1, x.n0, x.n0 * x.n1 - x.inv} : x; }
F composition(F f, F g) { return f ^ g; }
F id() { return 0; }

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

    int n, q;
    cin >> n >> q;
    vector<S> a(n);
    rep(i, n) {
        int x;
        cin >> x;
        a[i] = S{!x, x, 0};
    }
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);
    while(q--) {
        int t, l, r;
        cin >> t >> l >> r;
        if(t == 1)
            seg.apply(l - 1, r, 1);
        else
            cout << seg.prod(l - 1, r).inv << "\n";
    }

    return 0;
}

Measured memory_bytes: 20332
#include<bits/stdc++.h>
using namespace std;
using ll = int;
using ull = unsigned long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int
;
long long gcd(long long a, long long b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

long long lcm(long long a, long long b){
   return a * b / gcd(a, b);
}
int main(){
  ll n,y;
  cin >> n >> y;
  for(ll i=0;i<=n;i++){
    for(ll j=0;j<=n;j++){
      if(n-i-j<0)break;
      else if(1000*i+5000*j+10000*(n-i-j)==y){
        cout << n-i-j << " " << j << " "<< i;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (auto &e: h) cin >> e;

    int ans = 0;
    int cur = 0;
    for (int i = 1; i < n; ++i) {
        if (h[i-1] >= h[i]) {
            ++cur;
            ans = max(cur, ans);
        } else {
            cur = 0;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    int N,M,C;
    int S=0, count=0;
    cin>>N>>M>>C;
    vector<vector<int>> A(N, vector<int>(M));
    vector<int> B(M);
    for(int i=0;i<M;i++){
        cin>>B.at(i);
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            cin>>A.at(i).at(j);
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            S+=A.at(i).at(j)*B.at(j);
        }
        if(S+C>0){
            count++;
        }
        S=0;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return list(sys.stdin.readline())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007

#A
"""
a = IR(2)
b = IR(2)
print(min(a)+min(b))
"""

#B
n = I()
d, x = LI()
a = IR(n)
ans = x
for i in a:
    k = 0
    while k * i + 1 <= d:
        ans += 1
        k += 1
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;
const int mod998 = 998244353;

int N, A, B, K, V, P, u[100000], l[100000], res[100000];
vector<int>v[100000];
bool b[100000];

void dfs1(int x) {
	b[x] = true;
	for (int i : v[x]) {
		if (!b[i]) {
			u[i] = min(u[i], u[x] + 1);
			l[i] = max(l[i], l[x] - 1);
			dfs1(i);
			u[x] = min(u[x], u[i] + 1);
			l[x] = max(l[x], l[i] - 1);
		}
	}
}

bool dfs2(int x, int p) {
	res[x] = p;
	b[x] = false;
	for (int i : v[x]) {
		if (b[i]) {
			if (l[i] <= p + 1 && p + 1 <= u[i]) {
				if (!dfs2(i, p + 1))return false;
			}
			else if (l[i] <= p - 1 && p - 1 <= u[i]) {
				if (!dfs2(i, p - 1))return false;
			}
			else return false;
		}
	}
	return true;
}

int main() {
	cin >> N;
	for (int i = 1; i < N; ++i) {
		cin >> A >> B;
		--A; --B;
		v[A].push_back(B);
		v[B].push_back(A);
	}
	for (int i = 0; i < N; ++i) {
		l[i] = -0xE869120;
		u[i] = 0xE869120;
	}
	cin >> K;
	for (int i = 0; i < K; ++i) {
		cin >> V >> P;
		--V;
		u[V] = l[V] = P;
	}
	dfs1(V);
	if (dfs2(V, P)) {
		puts("Yes");
		for (int i = 0; i < N; ++i) {
			cout << res[i] << endl;
		}
	}
	else {
		puts("No");
	}
}

Measured memory_bytes: 12288
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int n = sc.nextInt();
		int[] array = new int[n];
		int sum = 0;

		for(int i = 0;i < n;i++){
			sum += sc.nextInt();
		}
		if(h-sum<=0){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 48820
#include<bits/stdc++.h>
#define pb push_back
#define mod int(1e9+7)
#define N int(1e5+100)
#define pi 3.141592653589793238
#define ll unsigned long long int
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define si second
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int r;
	cin>>r;
	printf("%.2f\n",(2*pi*r));
   return 0;
}

Measured memory_bytes: 3768
n,k = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in range(n):
    for j in range(i, n):
        b.append(sum(a[i:j+1]))
assert(len(b) == n*(n+1)//2)

b.sort(reverse=True)
m = max(b).bit_length()
mask = 0
for i in range(m-1, -1, -1):
    mask += 1<<i
    cnt = 0
    for j in b:
        if j < mask:
            break
        if j&mask == mask:
            cnt += 1
    if cnt < k:
        mask -= 1<<i
print(mask)

Measured memory_bytes: 84572