akhauriyash/Code-Regression huggingface dataset:
import math
S = int(input())

X2 = math.sqrt(S)
if X2.is_integer():
    print(0, 0, int(X2), 0, 0, int(X2))
else:
    X2 = int(math.floor(X2)) + 1
    Y3 = X2
    print(0, 0, X2, (X2*Y3)-S, 1, Y3)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define hell  1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb   push_back

int main()
{
	ios;
	ll n;
	cin>>n;
	cout<<2*n*3.141592653589793238;
}

Measured memory_bytes: 3820
#include <iostream>
#include <climits>
#include <cstring>
#include <algorithm>

using namespace std;

#define SIZE 420
long long cost[SIZE][SIZE], a[SIZE];

long long minimalSum(int l, int r) {
    if (     l     >=  r) return 0;
    if (cost[l][r] != -1) return cost[l][r];
    long long MIN = LLONG_MAX, sum = 0;
    for (int i = l; i <= r; i++) sum += a[i];
    for (int i = l; i <  r; i++) MIN = min(MIN, minimalSum(l  , i)
                                          +sum+ minimalSum(i+1, r));
    return cost[l][r] = MIN;
}

int main() {
    memset(cost, -1, sizeof cost);
    int N; cin >> N;
    for (int i = 0; i < N; i++) cin >> a[i];
    cout << minimalSum(0, N-1) << endl;
    return 0;
}


Measured memory_bytes: 1664
N = int(input())
S = input()

# R/G/Bそれぞれの個数
r = S.count('R')
g = S.count('G')
b = S.count('B')

# R,G,Bとなる選び方の総数。順番はRGBとは限らない
ans = r * g * b

# j-i != k-j は扱いにくい
# j-i == k-j　の数を求めて引く（余事象）
# この時、k == 2*j - i、すなわちi,jが決まればkは一意に定まる

# i = 0,1,2,...,N-3
# j = i+1,i+2,...,N-2
# k = 2*j-1

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k = 2 * j - i
        # k>=N となったらそれ以降jについてのfor回すのは無駄、次のjへ
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1

print(ans)


Measured memory_bytes: 9196
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] w = {1,2,4,8,16,32,64}; 
out:		for(int i = N; i > 0; i--) {
			for(int j = w.length - 1; j >= 0; j--) {
				if(i == w[j]) {
					System.out.println(w[j]);
					break out;
				}
			}
		}
	}
}

Measured memory_bytes: 23892
#include <cstdio>
int mp[9][9],ans,flag[9],N;
void dfs(int x)
{
    int cnt=0;
    flag[x]=1;
    for(int i=1;i<=N;i++)
        cnt+=flag[i];
    if(cnt==N)
    {
        flag[x]=0;
        ans++;
        return;
    }
    for(int i=1;i<=N;i++)
        if(mp[x][i]==1&&flag[i]==0)
            dfs(i);
    flag[x]=0;
    return;
}
int main()
{
    int M,a,b;
    scanf("%d%d",&N,&M);
    for(int i=0;i<M;i++)
    {
        scanf("%d%d",&a,&b);
        mp[a][b]=1;
        mp[b][a]=1;
    }
    dfs(1);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
N = int(input())
a = list(map(int, input().split()))
a.insert(0,0)
b = [0] * (N + 1)
ans = []
count = 0
for i in reversed(range(1,N + 1)):
  if a[i] == 1:
    sumi = 0
    j = 2
    while True:
      if (i * j) > N:
        break
      sumi += b[i * j]
      j += 1
    if sumi % 2 == 0:
      b[i] = 1
      count += 1
      ans.append(int(i))
  else:
    sumi = 0
    j = 2
    while True:
      if (i * j) > N:
        break
      sumi += b[i * j]
      j += 1
    if sumi % 2 == 1:
      b[i] = 1
      count += 1
      ans.append(int(i))
ans.sort()
print(count)
print(' '.join(map(str, ans)))

Measured memory_bytes: 20600
import java.util.Scanner;

public class Main{
    public static void main(String[] args ){
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        int f = scanner.nextInt();
        int r = scanner.nextInt();
        while(m != -1 || f != -1 || r != -1){
            if(m == -1 || f == -1)
                System.out.println("F");
            else if(m + f >= 80)
                System.out.println("A");
            else if(m + f >= 65)
                System.out.println("B");
            else if(m + f >= 50)
                System.out.println("C");
            else if(m + f >= 30){
                if(r >= 50)
                    System.out.println("C");
                else
                    System.out.println("D");
            }
            else
                System.out.println("F");

            m = scanner.nextInt();
            f = scanner.nextInt();
            r = scanner.nextInt();
        }
    }
}



Measured memory_bytes: 26436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    ll N; cin >> N;
    vector<ll> A(N+1), B(N+1);
    ll sumA = 0;
    for (ll i = 0; i < N+1; i++) {
        cin >> A[i];
        sumA += A[i];
    }
    if(N == 0){
        if(A[0] == 1){
            printf("1\n");
            return 0;
        }
        else{
            printf("-1\n");
            return 0;
        }
    }

    if(A[0] != 0){
        printf("-1\n");
        return 0;
    }

    B[0] = 1;
    ll sumP = 1;

    for (ll i = 1; i < N+1; i++) {
        if(sumA - sumP >= B[i-1] - A[i-1]){
            B[i] = 2 * (B[i-1] - A[i-1]);
            sumP += B[i-1] - A[i-1];
        }
        else if (sumA == sumP){
            B[i] = B[i-1] - A[i-1];
        }
        else{
            B[i] = sumA - sumP + B[i-1] - A[i-1];
            sumP = sumA;
        }

        
        if(B[i] < A[i]){
            printf("-1\n");
            return 0;
        }
    }

    ll ans = 0;
    for (ll i = 0; i < N+1; i++) {
        ans += B[i];
        
    }
    printf("%lld\n", ans);

}


Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int k,n;
  cin >> k >> n;
  vector<int> a(n);
  for (auto &e: a) cin >> e;
  sort(a.begin(),a.end());
  int diff = k - (a.back() - a[0]);
  for(int i=1;i<a.size();i++){
    diff = max(diff,abs(a[i]-a[i-1]));
  }
  cout << k-diff << '\n';
  return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

vii G;
vl a;

void NO() {
  cout << "NO" << endl;
  exit(0);
}

ll dfs(int now, int par) {
  if (G[now].size() == 1) return a[now];
  vl b;
  ll sum = 0;
  rep (i, G[now].size()) {
    if (G[now][i] == par) continue;
    b.push_back(dfs(G[now][i], now));
    sum += b.back();
  }

  if (sum < a[now]) NO();
  sort(all(b));
  int s1 = sum - b.back(), s2 = b.back();
  int mi;

  if (s1 <= s2) {
    mi = s2;
  }
  else {
    if (sum % 2 == 0) mi = sum / 2;
    else mi = sum / 2 + 1;
  }
  if (mi > a[now]) NO();
  return 2*a[now] - sum;
}

int main() {
  int n;
  cin >> n;
  
  a.resize(n);
  rep (i, n) {
    cin >> a[i];
  }

  if (n == 2) {
    if (a[0] == a[1]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
  }
  
  G.resize(n);
  rep (i, n - 1) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }

  int root;
  for (root = 0; root < n; root++) {
    if (G[root].size() > 1) break;
  }
  
 

  if (dfs(root, -1) == 0) {
    cout << "YES" << endl;
  }
  else {
    NO();
  }
}


Measured memory_bytes: 15872
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}
ll slide(vector<ll>& v, ll a, ll b) {
	ll azv = abs(v[0] - a);
	ll bzv = abs(v[0] - b);
	ll aov = abs(v[1] - a);
	ll bov = abs(v[1] - b);
	v[0] = a;
	v[1] = b;
	return max((azv + bov), (bzv + aov));
}


void solv() {
	int a[6], b, c, d, e, k;

	cin >> a[0];
	cin >> a[1];
	cin >> a[2];
	cin >> a[3];
	cin >> a[4];
	cin >> k;
	for (size_t i = 0; i < 5; i++)
	{
		for (size_t j = 0; j  < 5; j ++)
		{
			if (i == j) continue;
			if (abs(a[i] - a[j]) > k) {
				cout << ":(" << endl;

					return;
			}
		}
	}
	cout << "Yay!" << endl;
}

int main() {
	//COMinit();
	solv();

	return 0;
}


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

int main(){
	int n,i,j,c,white_cnt;
	//int d;///////debug
	
	while(true){
		cin >> n;
		if(n == 0)break;
		white_cnt = 0;
		vector<int> table(n);
		for(i = 0; i < n; i++){
			cin >> c;
			if((i+1)%2 == 0){
				table[i] = c;
				if(table[i-1] != c){
					for(j=i-1;j>=0;j--){
						if(table[j] != c){
							table[j] = c;
						}else{
							break;
						}
					}
				}
			}else{
				table[i] = c;
			}
			/////////////coco/////////////
			/*
			for(d=0;d<=i;d++){
				if(table[d]){
					cout<<"x";
				}else{
					cout<<"o";
				}
			}
			cout<<endl;
			*/
			/////////////made/////////////
		}
		for(i=0;i<n;i++){
			if(table[i] == 0){
				white_cnt++;
			}
		}
		cout << white_cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1532
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin >> s;
  int n = s.size(),i,ans = n;
  for(i=0;i<n-1;i++){
    if(s[i] != s[i+1]) ans = min(ans,max(i+1,n-i-1));
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 3840
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
using namespace std;
#define sci(n) scanf(“%lld”, &(n))
#define scd(n) scanf(“%Ld”, &(n))
typedef long long LL;

int main(void)
{
	LL n, a, b;
	cin >> n >> a >> b;
	if (n == 1)cout << "Hello World";
	else {
		cout << a + b;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

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

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

template <typename T, typename E, typename F, typename G>
struct SegmentTree{
    int n;
    F f;
    G g;
    T ti;
    vector<T> dat;
    SegmentTree(){};
    SegmentTree(F f, G g, T ti) : f(f), g(g), ti(ti){}

    void init(int n_){    
        n = 1;
        while(n < n_) n <<= 1;
        dat.assign(n << 1, ti);
    }

    void build(const vector<T> &v){
        int sz = v.size();
        init(sz);
        for(int i=0; i<sz; i++) dat[n + i] = v[i];
        for(int i=n-1; i>=0; i--) dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]);
    }

    void set_val(int k, T x){
        k += n;
        dat[k] = g(dat[k], x);
        while(k >>= 1) dat[k] = f(dat[(k << 1) | 0], dat[(k << 1) | 1]);    
    }

    T query(int a,int b){
        T vl = ti, vr = ti;
        for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
            if(l & 1) vl = f(vl, dat[l++]);
            if(r & 1) vr = f(dat[--r], vr);
        }
        return f(vl, vr);
    }
};

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

    using T = int;
    using E = int;
    auto f = [](T a, T b){
        return a | b;
    };
    auto g = [](T a, E b){
        return b;
    };
    T ti = 0;
    SegmentTree<T, E, decltype(f), decltype(g)> seg(f, g, ti);

    int n; cin>>n;
    string s; cin>>s;
    seg.build(vector<int>(n, 0));

    for(int i=0; i<n; i++){
        seg.set_val(i, 1 << (s[i] - 'a'));
    }

    int q; cin>>q;
    while(q--){
        int ty; cin>>ty;
        if(ty == 1){
            int i; cin>>i;
            char c; cin>>c;
            i--;
            seg.set_val(i, 1 << (c - 'a'));
        }
        else{
            int l, r; cin>>l>>r;
            l--, r--;
            int ans = __builtin_popcount(seg.query(l, r + 1));
            cout << ans << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 6940
#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;

// 插入此處

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

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

    int ans=1e9;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            string s=to_string(i);
            string t=to_string(n/i);
            ans=min(ans,max((int)s.length(),(int)t.length()));
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3684
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    ll n;
    std::cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    double sum = 0;
    for (int i = 0; i < n; i++) {
        sum += 1.0/a[i];
    }
    std::cout<<setprecision(10) << 1.0/sum << std::endl;
}


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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define    ss   second
#define    ff   first
#define    pb   push_back
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);


int main() {
    FIO;
    ll n;
    cin >> n;
    vector<pair<ll, ll>>r;
    vector<pair<ll, ll>>b;

    for (ll i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        r.push_back({y, x});
    }
     for (ll i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        b.push_back({x, y});
    }

    sort(r.begin(), r.end());
    reverse(r.begin(), r.end());
    sort(b.begin(), b.end());
    vector<bool> used(n, false);
    ll  c = 0;
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < n ; j++) {
       if(b[i].ff > r[j].ss && b[i].ss > r[j].ff && !used[j]) {
        c++;
        used[j] = true;
        break;
       }

    }
    }

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


Measured memory_bytes: 3580
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n; cin >> n;
    vector<int> c(n), v(n), rv(n);
    for (int i = 0; i < n; ++i) cin >> v[i];
    for (int i = 0; i < n; ++i) cin >> c[i];
    for (int i = 0; i < n; ++i) rv[i] = v[i] - c[i];

    sort(rv.begin(), rv.end(), greater<int>());
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        if (0 < rv[i]) {
            sum += rv[i];
        } else {
            break;
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
/// You just can't beat the person who never gives up
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 3e3+5 ,mod = 998244353 ;

int main(){
    int a,b;
   	cin >> a >> b;
  	cout << a*b;
    return 0;
}


Measured memory_bytes: 3640
typedef  double ll;
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265359

int main() {
    ll n;
    std::cin >> n;
    
    vector<vector<ll>> xy(n,vector<ll>(2,0));
    for (int i = 0; i < n; i++) {
        std::cin >> xy[i][0] >> xy[i][1];
        // std::cout << xy[i][0] << std::endl;
    }
    
    for (int i = 0; i < n; i++) {
        ll p1 = 0;
        ll p2 = 0;
        ll m1 = 0;
        ll m2 = 0;
        
        for (int j = 0; j < n; j++) {
            if(i==j)continue;
            ll x = xy[j][0]-xy[i][0];
            ll y = xy[j][1]-xy[i][1];
            ll res = atan2(y,x);
            
            if(abs(res)<PI/2){
                p1 = max(p1,res+PI/2);
                m1 = max(m1,-(res-PI/2));
            }else{
                if(res>0){
                    p2 = max(p2,PI-(res-PI/2));
                    m2 = max(m2,-PI+(res+PI/2));                    
                }else{
                    p2 = max(p2,-(PI+(res-PI/2)));
                    m2 = max(m2,PI+(res+PI/2));                    
                }
            }
            p1 = min(p1,PI);
            p2 = min(p2,PI);
            m1 = min(m1,PI);
            m2 = min(m2,PI);
        }
        // std::cout << p1<<" "<<p2<<" "<<m1<<" "<<m2 << std::endl;

        std::cout<<setprecision(20) << (PI-min(p1+p2,PI)+PI-min(m1+m2,PI))/(2*PI) << std::endl;
    }
}


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

using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

vector<ll> adj;
ordered_set bdj;

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

	ll n,i,m,k,c = 0,t,s,ans = 0;

	cin >> n >> m >> k;
	for(i=1;i<=n;++i)
	{
		cin >> t;
		adj.pb(t);
	}
	s = 0;
	for(i=1;i<=m;++i)
	{
		cin >> t;
		s += t;
		bdj.insert(s);
	}
	ans = max(ans,(ll)(bdj.order_of_key(k+1)));
	for(i=0;i<n;++i)
	{
		if(k>=adj[i])
			ans = max(ans,i+1);
		k -= adj[i];
		if(k>0)
			ans = max(ans,i+1+(ll)(bdj.order_of_key(k+1)));
	}
	cout << ans << "\n";
}

Measured memory_bytes: 17236
#include<iostream>
#include<cmath>
#include<cstdio>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>

using namespace std;
const long long int MOD=1e9+7;
double n;
double x[10], y[10];
long long f[100], invf[100];


// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

void fanc(long long n){
  f[1] = 1;
  invf[1] = 1;
  for(int i=2;i<=n;i++){
    f[i] = (i*f[i-1])%MOD;
    invf[i] = modinv(f[i], MOD);
  }
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> x[i] >> y[i];
  }
  double ans=0.0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      ans += sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
    }
  }
  ans/=(n*(n-1))/2;
  ans*=n-1;
  printf("%.8lf\n", ans);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define rrep(i,n) ll(i)=(n);ll now=-1;while((i)--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)<<"\n"
#define vll vector<ll>
#define pb push_back
using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {}
template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

void solve(ll H){
    ll S = floor(log2(H)), sum = 0;
    rep(i, S + 1) sum += pow(2, i);
    cout << sum << "\n";
}

int main() {
    ll H;
    ignore_ret(scanf("%lld",&H));
    solve(H);
    return 0;
}

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

typedef long long ll;

using namespace std;

long long gcd(long long a , long long b){
    return (a%b == 0)?b:gcd(b,a%b);
}

int main(){
    long long A, B, C, D;
    cin >> A >> B >> C >> D;
    long long sc = (A-1) / C + 1;
    long long sd = (A-1) / D + 1;
    long long ec = B / C ;
    long long ed = B / D ;
    long long E = C*D/gcd(D,C);
    long long se = (A-1) / E + 1;
    long long ee = B / E; 
    cout << B-A+1-(ec-sc+1)-(ed-sd+1)+(ee-se+1) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int N = scanner.nextInt();


        long sum =0;
        for (int i = 1; i <= N; i++) {
            if(i%3 != 0 && i%5 != 0){
                sum +=i;
            }
        }
        System.out.println(sum);

    }
}


Measured memory_bytes: 27228
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);
		
		//入力表示
		String S = scanner.next();
		
		if(S.equals("AAA") ||S.equals("BBB") ) {
			System.out.println("No");
		}
		else {
			System.out.println("Yes");
		}
		
		scanner.close();
	}
}

Measured memory_bytes: 22612
S = list(input())
#print(S)
cnt = 0
if len(S)%2 == 0:
  for i in range(len(S)//2):
    if S[i] != S[len(S)-i-1]:
      cnt += 1
else:
  for i in range((len(S)-1)//2):
    if S[i] != S[len(S)-1-i]:
      cnt +=1
print(cnt)

Measured memory_bytes: 3060
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	int a = Integer.parseInt(reader.readLine());
	int res =1000* ((a+999)/1000);
	System.out.println((res-a));
	}
}


Measured memory_bytes: 32684
let N = stdin.ReadLine() |> int

let A =
    [| for _ in [ 1..N ] do
        yield stdin.ReadLine() |> int |]

let As = A |> Array.sortDescending

A
|> Array.map (fun x ->
    if x = As.[0] then As.[1]
    else As.[0])
|> Array.iter stdout.WriteLine


Measured memory_bytes: 31308
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d, x, ans=0;
    cin >> n >> d >> x;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        ans += (d-1)/a + 1;
    }
    cout << ans+x << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

unsigned int calculate_solution (unsigned int target)
{
	if (target % 2U == 0U) { return target;      }
	else                   { return target * 2U; }
}

int main (void)
{
	// variables for `main`
	unsigned int N;
	int          retval_scanf;

	// STEP.01
	// read out the given data
	retval_scanf = scanf("%d", &N);

	// STEP.02
	// calcualte & output the points
	printf("%d\n", calculate_solution(N));

	// STEP.END
	return EXIT_SUCCESS;
}

Measured memory_bytes: 128
S=input()

# 条件1：S の先頭の文字は大文字の A
if S[0]=='A':
    
    # 条件2：S の3文字目〜最後から2番目の文字の間に C が1つ含まれる
    if len([s for s in S[2:len(S)-1] if s=='C'])==1:

        # 条件3：以上の A, C を除く全ては小文字
        s=S[1:S.index('C')]+S[S.index('C')+1:]
        if s==s.lower():
            print("AC")
        
        else:
            print("WA")

    else:
        print("WA")

else:
    print("WA")


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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 GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
int dx[4] = { 0,  0, 1, -1 };
int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	double n; cin >> n;
	if ((int)n % 2 == 0) {
		cout << setprecision(10) << (n / 2.0) / n << endl;
	}
	else {
		cout << setprecision(10) << (int)(n / 2.0 + 1) / n << endl;
	}
}


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

using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    int n,m,i,sum=0;
    cin>>n>>m;
    int ara[n];
    for(i=0;i<m;i++)
    {
        cin>>ara[i];
        sum+=ara[i];

    }
    if (sum>n)cout<<-1;
    else cout<<n-sum;

    return 0;
}



Measured memory_bytes: 3660
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

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

int main(){
    int n;
    cin >> n;
    if(n==1){
        cout << 1 << endl;
        cout << 0 << endl;
    }else if(n==2){
        cout << 2 << endl;
        cout << 0 << endl;
        cout << 11 << endl;
    }else{
        cout << n-1 << "\n";
        rep(i,n-1){
            cout << 0;
            rep(j,i){
                cout << 1;
            }
            cout << "0\n";
        }
    }
    return 0;
}


Measured memory_bytes: 3108
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
const int N=300010;
char s[N];
int a[N];
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	for (int i=n;i>=1;i--)
		a[i]=a[i+1]+(s[i]=='W');
	long long ans=0;
	for (int i=1;i<=n;i++)
		if (s[i]=='B') ans+=a[i];
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int main() {
  ll h,w;
  while(cin>>h>>w) {
    if (h == 1 || w == 1) {
      cout << 1 << endl;
      continue;
    }
    if (h%2==0 && w%2==0) {
      cout << h*w/2 << endl;
    } else if (h%2 && w%2==0) {
      cout << h*w/2 << endl;
    } else if (h%2==0 && w%2) {
      cout << h*w/2 << endl;
    } else {
      cout << h*w/2+1 << endl;
    }
  }
}


Measured memory_bytes: 256
package main

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

func isqrt(n int) int {
	if n < 0 {
		panic("isqrt argument must be nonnegative")
	}

	if n <= 1 {
		return n
	}

	ok := 0
	ng := 3037000500 // 3037000499 * 3037000499 < math.MaxInt64 < 3037000500 * 3037000500
	if n < ng {
		ng = n
	}
	for ng-ok > 1 {
		m := ok + (ng-ok)/2
		if m*m <= n {
			ok = m
		} else {
			ng = m
		}
	}
	return ok
}

func main() {
	defer flush()

	N := readInt()

	if N == 2 {
		// K = 2
		println(1)
		return
	}

	result := 2 // K = N - 1, N
	for K := 2; K <= isqrt(N); K++ {
		t := N
		for t >= K && t%K == 0 {
			t /= K
		}
		if t%K == 1 {
			result++
		}

		if (N-1)%K == 0 && (N-1)/K > K {
			result++
		}
	}
	println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int X, Y, Z;
  cin >> X >> Y >> Z;
  cout << Z << ' ' << X << ' ' << Y << endl;
}


Measured memory_bytes: 256
s=input()
f=int(s[0:2])
l=int(s[2:4])

if 12>=f>=1 and 12>=l>=1:
    k=3
elif not(12>=f>=1) and 12>=l>=1:
    k=1
elif not(12>=l>=1) and 12>=f>=1:
    k=2
else:
    k=4
ans=['','YYMM','MMYY','AMBIGUOUS','NA']
print(ans[k])

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

int sum[6000][6000];
int X[6000], Y[6000];
int X1[600000], X2[600000], Y1[600000], Y2[600000];
int n, m;

int compress(int*x, int*X1, int*X2) {
	vector<int>v;
	rep(i, n)v.push_back(x[i]);
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	rep(i, m) {
		X1[i] = lower_bound(v.begin(), v.end(), X1[i]) - v.begin();
		X2[i] = upper_bound(v.begin(), v.end(), X2[i]) - v.begin() - 1;
	}
	rep(i, n) {
		x[i] = lower_bound(v.begin(), v.end(), x[i]) - v.begin();
	}
	return (int)v.size();
}
signed main() {
	scanf("%d%d", &n, &m);
	rep(i, n)scanf("%d%d", &X[i], &Y[i]);
	rep(i, m)scanf("%d%d%d%d", &X1[i], &Y1[i], &X2[i], &Y2[i]);
	int h = compress(X, X1, X2), w = compress(Y, Y1, Y2);
	rep(i, n)sum[X[i]][Y[i]]++;
	rep(i, h + 1)for (int j = 1; j <= w; j++) {
		sum[i][j] += sum[i][j - 1];
	}
	for (int i = 1; i <= h; i++)rep(j, w + 1) {
		sum[i][j] += sum[i - 1][j];
	}
	rep(i, m) {
		if (X2[i] < 0 || Y2[i] < 0) {
			puts("0"); continue;
		}
		int ans = sum[X2[i]][Y2[i]];
		if (X1[i] > 0)ans -= sum[X1[i] - 1][Y2[i]];
		if (Y1[i] > 0)ans -= sum[X2[i]][Y1[i] - 1];
		if (X1[i] > 0 && Y1[i] > 0)ans += sum[X1[i] - 1][Y1[i] - 1];
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 128424
/**
 *    +--+--+--++--++--In the name of ALLAH--++--++--+--+--+
 *
 *    author:  skmonir
 *    created: 01-Jun-2020 09:32:58
**/

#include <bits/stdc++.h>

using namespace std;

#define endl                '\n'
#define TN                  typename
#define mod                 998244353LL
#define len(x)              (int) x.size()
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define mem(x, y)           memset(x, y, sizeof x)
#define FOR(x, l, r)        for (int x = l; x <= r; ++x)
#define ROF(x, l, r)        for (int x = l; x >= r; --x)

template <TN T> inline void Int(T &n) {
    n = 0; int f = 1; int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> inline void umin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void umax(T &a, T b) {a = a > b ? a : b;}
template <TN T, TN W> inline void Int(T &x, W &y) {Int(x), Int(y);}
template <TN T, TN W, TN Q> inline void Int(T &x, W &y, Q &z) {Int(x, y), Int(z);}

const int N = 3e3 + 7;
const int inf = 1e9 + 7;

int n, s;
int A[N];
long long inv;
long long pw[N];
long long dp[N][N];

template <TN T> inline T my_pow(T base, T exp, T md) {
    base %= md; T res = 1;
    if (base < 0) base += md;
    if (exp < 0) exp += md - 1;
    for (; exp > 0; exp >>= 1) {
        if (exp & 1) res = (res * base) % md;
        base = (base * base) % md;
    }
    return res;
}

long long call(int id, int taken, int sum) {
    if (sum == s) {
        return pw[n];
    }
    if (sum > s || id > n) {
        return 0;
    }
    long long &res = dp[id][sum];
    if (~res) {
        return res;
    }
    res = call(id + 1, taken, sum);
    res += (inv * call(id + 1, taken + 1, sum + A[id])) % mod;
    res %= mod;
    return res;
}

int solve() {
    cin >> n >> s;
    for (int i = 1; i <= n; ++i) {
        cin >> A[i];
    }

    pw[0] = 1;
    for (int i = 1; i < N; ++i) {
        pw[i] = (pw[i - 1] * 2) % mod;
    }

    memset(dp, -1, sizeof dp);
    inv = my_pow(2LL, -1LL, mod);

    cout << call(1, 0, 0) << endl;

    return 0;
}

int main() {
    int tests = 1, CaseNo = 0;
    // Int(tests);
    while (tests--) {
        //printf("Case %d: ", ++CaseNo);
        solve();
    }
    return 0;
}

Measured memory_bytes: 74492
import sys
sys.setrecursionlimit(1000000000)
char = list(input())
char_list_num = len(char)
count_list = [0] * char_list_num

def f(first_char,n,add_num):
    if first_char == char[n+add_num] and n + add_num != char_list_num - 1:
        return f(first_char,n+add_num,add_num)
    else:
        return n+add_num

num = 0
while not num == char_list_num - 1:
    reach_loop_num = f(char[num],num,1)
    diff = reach_loop_num - num
    if reach_loop_num == char_list_num - 1:
        if char[num] == char[reach_loop_num]:
            diff += 1
        else:
            count_list[reach_loop_num] += 1
    if char[num] == 'R':
        if diff % 2 == 0:
            count_list[reach_loop_num] += int(diff/2)
            count_list[reach_loop_num-1] += int(diff/2)
        else:
            count_list[reach_loop_num] += int(diff/2)
            count_list[reach_loop_num-1] += int(diff/2) +1
    else:
        if diff % 2 == 0:
            count_list[num] += int(diff/2)
            count_list[num-1] += int(diff/2)
        else:
            count_list[num] += int(diff/2) +1
            count_list[num-1] += int(diff/2)
    num = reach_loop_num
print(' '.join(map(str,count_list)))

Measured memory_bytes: 90636
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
#define ff(i,n,m) for(int i=n;i<m;i++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	int x;
	cin >> x;
	int ans = 0;
	int sum = 0;
	while (sum < x) {
		ans++;
		sum += ans;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	long long int a, b, c, x, y;
	cin>>a>>b>>c>>x>>y;
	if (2*c>a+b){
		long long int res= a*x+b*y;
		cout<<res<<endl;
		return 0;
	}
	c=2*c;
	int t= min(x, y);
	long long int ans = t*c;
	x-=t;
	y-=t;
	if (y>0){
		ans+=min(b, c)*y;
	}	
	if (x>0){
		ans+=min(a,c)*x;
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 256
def move(s):
    returnR = 0
    returnL = 0
    cntR = s.count("R")
    cntL = s.count("L")
    if cntR%2 == 0:
        returnL += cntR//2
        returnR += cntR//2
    else:
        returnL += cntR//2
        returnR += cntR//2 + 1
        
    if cntL%2 == 0:
        returnR += cntL//2
        returnL += cntL//2
    else:
        returnR += cntL//2 
        returnL += cntL//2 + 1

    for i in range(cntR-1):
        print("0"+" ",end="")
    print(str(returnR)+" ",end="")

    print(str(returnL)+" ",end="")
    for i in range(cntL-1):
        print("0"+" ",end="")

    
s = input()
listS = []

while s.find("LR") > 0:
    listS.append(s[:s.find("LR")+1])
    s=s[s.find("LR")+1:]
listS.append(s)

for s in listS:
    move(s)

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

int main(){
	int n, k, m, ans;
	
	while(true){
		cin>>n>>k>>m;
		
		vector<int> vb(n);
		
		for(int i = 0; i < n; i++)vb[i] = i;
		
		if(!n&&!k&&!m) break;
		
		m--;k--;
		
		while(1){
			vb.erase(vb.begin()+m);
			m = (m+k)%vb.size();
			if(vb.size()==1){ cout<<vb[0]+1<<endl; break;}
		}
		
	}
	
	return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    ll total = 0;
    rep(i, N){
        cin >> a[i];
        total += a[i];
    }

    ll left = 0, right = 0, ans = 1e12;
    rep(i, N-1){
        left += a[i];
        right = total - left;
        ans = min(ans, abs(left-right) );
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
A_list = list(map(int,input().split()))
A_dict = dict()
for elem in A_list:
    if not elem in A_dict:
        A_dict[elem] = 1
    else:
        A_dict[elem] += 1
total = 0
A_dict = sorted(A_dict.items(), key=lambda x: x[1])
for i in range(len(A_dict) - K):
    total += A_dict[i][1]
print(total)


Measured memory_bytes: 40092
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

#define B       (cout << "Sehen Sie mich!" << endl)
#define VB(val) (cout << val << endl)

inline int ctoi(const char c){
        if('0' <= c && c <= '9') return (c -'0');
        return -1;
}

int main()
{
        char x, y;
        cin >> x >> y;
        if (x < y)
                VB("<");
        else if (x > y)
                VB(">");
  		else
          		VB("=");
}

Measured memory_bytes: 256
#include<iostream>
//#include<pair>
#include<vector>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

class data{
public:
	vector<int> num;
	string s;
};

int main(){
	int n;
	string str;
	vector<data> vec;
	while(cin>>str){
		cin>>n;
		data dt;
		dt.num.push_back(n);
		dt.s=str;
		int cnt=0;
		for(int i=0;i<vec.size();i++){
			if(str==vec[i].s){
				vec[i].num.push_back(n);
				cnt++;
			}
		}
		if(cnt==0)vec.push_back(dt);
	}
	//rep(i,vec.size())cout<<vec[i].s<<" ";
	//cout<<endl;
	//for(int i=0;i<vec.size();i++)cout<<vec[i].s<<" ";
	//cout<<endl;
	for(int i=0;i<vec.size();i++){
		//cout<<i<<endl;
		for(int j=vec.size()-1;j>=1;j--){
			//cout<<j<<" ";
			if(vec[j-1].s>vec[j].s){
				data alt=vec[j];
				vec[j]=vec[j-1];
				vec[j-1]=alt;
			}
			//rep(i,vec.size())cout<<vec[i].s<<" ";
			//cout<<endl;
		}
		//cout<<endl;
	}
	for(int i=0;i<vec.size();i++){
		int volume=vec[i].num.size();
		sort(vec[i].num.begin(),vec[i].num.end());
	}
	for(int i=0;i<vec.size();i++){
		cout<<vec[i].s<<endl;
		cout<<vec[i].num[0];
		for(int j=1;j<vec[i].num.size();j++){
			cout<<" "<<vec[i].num[j];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1248
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;
use std::cmp::max;

fn main() {
    input! {
        R: usize,
        C: usize,
        K: usize,
        rcvs: [(usize, usize, i64); K],
    }

    let mut values: Vec<Vec<i64>> = Vec::with_capacity(R + 1);
    for _ in 0..R + 1 {
        values.push(vec![0i64; C + 1]);
    }

    for &(r, c, v) in rcvs.iter() {
        values[r][c] = v;
    }

    // for r in 0..R + 1 {
    //     for c in 0..C + 1 {
    //         eprintln!("values[{}][{}] = {}", r, c, values[r][c]);
    //     }
    // }


    let mut dp: Vec<Vec<Vec<i64>>> = Vec::with_capacity(R + 1);
    for _ in 0..R + 1 {
        let mut dp2: Vec<Vec<i64>> = Vec::with_capacity(C + 1);

        for _ in 0..C + 1 {
            dp2.push(vec![0i64; 4])
        }

        dp.push(dp2);
    }

    for r in 1..R + 1 {
        for c in 1..C + 1 {
            for n in 0..4 {
                if n == 0 {
                    let mut tmp = 0;
                    tmp = max(tmp, dp[r][c - 1][0]);
                    tmp = max(tmp, dp[r - 1][c][0]);
                    tmp = max(tmp, dp[r - 1][c][1]);
                    tmp = max(tmp, dp[r - 1][c][2]);
                    tmp = max(tmp, dp[r - 1][c][3]);
                    dp[r][c][n] = tmp;
                } else {
                    let mut tmp = 0;
                    tmp = max(tmp, dp[r][c - 1][n]);
                    tmp = max(tmp, dp[r][c - 1][n - 1] + values[r][c]);
                    if n == 1 {
                        tmp = max(tmp, dp[r - 1][c][0] + values[r][c]);
                        tmp = max(tmp, dp[r - 1][c][1] + values[r][c]);
                        tmp = max(tmp, dp[r - 1][c][2] + values[r][c]);
                        tmp = max(tmp, dp[r - 1][c][3] + values[r][c]);
                    }

                    dp[r][c][n] = tmp
                }
                // eprintln!("dp[{}][{}][{}] = {}", r, c, n, dp[r][c][n]);
            }
        }
    }

    // for n in 0..4 {
    //     for r in 0..R + 1 {
    //         for c in 0..C + 1 {
    //             eprint!("{} ", dp[r][c][n]);
    //         }
    //         eprintln!("");
    //     }
    //     eprintln!("---");
    // }

    let mut ans = 0;
    ans = max(ans, dp[R][C][0]);
    ans = max(ans, dp[R][C][1]);
    ans = max(ans, dp[R][C][2]);
    ans = max(ans, dp[R][C][3]);
    println!("{}", ans);
}


Measured memory_bytes: 713660