akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int n;
    scanf("%d",&n);
    int q;
    scanf("%d",&q);
    vector<int> c(n);
    rep(i,n) scanf("%d",&c[i]),--c[i];
    vector<int> l(q),r(q);
    rep(i,q){
        scanf("%d %d",&l[i],&r[i]);
        --l[i];
    }

    int sq = sqrt(n);
    vector<int> qi(q,0);
    for(int i=0;i<q;i++) qi[i] = i;
    sort(qi.begin(),qi.end(),[&](const int &i,const int &j){
        if(l[i] / sq != l[j] / sq) return l[i] < l[j];
        return r[i] < r[j];
    });

    vector<int> cnt(n,0);
    int ans = 0;

    auto add = [&](int id){
        //if(id<0 ||id>=n) return;
        if(cnt[c[id]]==0) ++ans;
        ++cnt[c[id]];
    };

    auto del = [&](int id){
        //if(id<0 ||id>=n) return;
        if(cnt[c[id]]==1) --ans;
        --cnt[c[id]];
    };

    
    vector<int> queryans(q);
    int nl = 0,nr = 0;
    for(int i:qi){
        //cout << nl << " " << nr  << endl;
        while(nl > l[i]) --nl,add(nl);
        while(nr < r[i]) add(nr),++nr;
        while(nl < l[i]) del(nl),++nl;
        while(nr > r[i]) --nr,del(nr);

        queryans[i] = ans;
    }

    rep(i,q) printf("%d\n",queryans[i]);
    return 0;
}

Measured memory_bytes: 15464
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int n;
ll ans;

void dfs(ll x, int a, int b, int c){
    if(x > n) return;
    if(a&b&c) ans++;//bit積
    dfs(x*10+3, 1, b, c);
    dfs(x*10+5, a, 1, c);
    dfs(x*10+7, a, b, 1);
}


int main(){
    cin >> n;
    dfs(0,0,0,0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
using namespace std;
#define int long long
typedef pair<int, int> P;
struct edge { int to, cost; };
int T[114514], X[114514], Y[114514];
signed main() {
	int n;
	cin >> n;
	int nx = 0, ny = 0;
	for (int i = 0; i < n; i++)cin >> T[i + 1] >> X[i] >> Y[i];

	for (int i = 0; i < n; i++) {
		int t = T[i + 1] - T[i];
		int x = X[i];
		int y = Y[i];
		int kyori = abs(x - nx) + abs(y - ny);
		if ((kyori <= t)&&( (kyori % 2) == (t % 2))) {

			nx = x;
			ny = y;
		}
		else {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}

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

using namespace std;
using ll = long long int;

int main() {
    int H, W;
    cin >> H >> W;
    string field[H];
    for (int h = 0; h < H; h++) {
        cin >> field[h];
    }

    int N = H * W;
    int dest[N][N];
    for (int hf = 0; hf < H; hf++) {
        for (int wf = 0; wf < W; wf++) {
            for (int ht = 0; ht < H; ht++) {
                for (int wt = 0; wt < W; wt++) {
                    int d = abs(hf - ht) + abs(wf - wt);
                    int nt = ht * W + wt;
                    int nf = hf * W + wf;

                    if (field[ht][wt] == '#' or field[hf][wf] == '#') {
                        dest[nf][nt] = -1;
                        dest[nt][nf] = -1;
                    } else if (d == 1) {
                        dest[nf][nt] = 1;
                        dest[nt][nf] = 1;
                    } else if (d == 0) {
                        dest[nf][nt] = 0;
                    } else {
                        dest[nf][nt] = -1;
                        dest[nt][nf] = -1;
                    }
                }
            }
        }
    }

    for (int n = 0; n < N; n++) {
        for (int nf = 0; nf < N; nf++) {
            for (int nt = 0; nt < N; nt++) {
                if (dest[nf][n] >= 0 and dest[n][nt] >= 0) {
                    if (dest[nf][nt] == -1) {
                        dest[nf][nt] = dest[nf][n] + dest[n][nt];
                    } else {
                        dest[nf][nt] = min(dest[nf][nt],
                                           dest[nf][n] + dest[n][nt]);
                    }
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            ans = max(dest[i][j], ans);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 896
N=int(input())
S=input()
ap=[0]*(N+1)
bp=[0]*(N+1)
a=0
b=0
for i in range(N):
  if S[i]=='W':
    a+=1
  else:
    b+=1
  ap[i+1]=a
  bp[i+1]=b
ans=10**9
for j in range(1,N+1):
  ans=min(ap[j-1]+bp[N]-bp[j],ans)
print(ans)

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

N, K = MAP()

ans = (N//K)**3
if K%2:
	print(ans)
else:
	ans += (N//(K//2) - N//K)**3
	print(ans)

Measured memory_bytes: 5840
#include <bits/stdc++.h>
using namespace std;
string s1,s2;
int main(){
    int x,y;
    cin>>x>>y;
    char a=x+'0',b=y+'0'; 
    for(int i=0;i<x;i++){
        s1+=b;
    }
    for(int i=0;i<y;i++){
        s2+=a;
    }
    if(s1>=s2) cout<<s2;
    else cout<<s1;
    return 0;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

const int MOD = 1000000007;

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

inline void sub(int &a, int b) {
    a -= b;
    if (a < 0) {
       a += MOD;
   }
}

inline int mul(int a, int b) {
    return (long long) a * b % MOD;
}

inline int power(int a, int b) {
    int res = 1;

    while (b > 0) {
        if (b & 1) res = mul(res, a);
        b >>= 1;
        a = mul(a, a);
    }

    return res;
}

inline int inverse(int x) {
    return power(x, MOD - 2);
}

const int MN = 100010;

int N;
vi g[MN], g2[MN];
int dp[MN][2];

void pre(int v, int p) {
    for (int to : g[v]) if (to != p) {
        pre(to, v);
        g2[v].pb(to);
    }
}

void dfs(int v) {
    int c[2] = {1, 0};

    rep(i, g2[v].size()) {
        int to = g2[v][i];
        dfs(to);
        int nx[2] = {0, 0};

        rep(j, 2) {
            rep(k, 2) {
                int val = mul(dp[to][j], c[k]);
                add(nx[j | k], val);
            }
        }
        c[0] = nx[0], c[1] = nx[1];
    }

    dp[v][0] = (c[0] + c[1]) % MOD;
    dp[v][1] = c[0];
}

int main() {
    cin >> N;
    rep(i, N-1) {
        int x, y;
        cin >> x >> y;
        --x; --y;
        g[x].pb(y); g[y].pb(x);
    }
    pre(0, -1);
    dfs(0);
    cout << (dp[0][0] + dp[0][1]) % MOD << endl;
	return 0;
}

Measured memory_bytes: 18944
#include<stdio.h>
#define max(a,c) ((a)>=(c)?(a):(c))
#define min(b,d) ((b)<=(d)?(b):(d))
int main()
{
	int a,b,c,d,min,max;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a>d||c>b)
	printf("0\n");
	else
	{
		min=min(b,d);
		max=max(a,c);
		printf("%d\n",min-max);
		}
	return 0;
	}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
 
int main() {
 
    int N, K, a, b, c;
	long int sum=0, times;
 
 
 
	scanf("%d %d", &N, &K);
 
	times = N / K;
 
	if (K % 2 != 0) {
		printf("%ld\n", times*times*times);
	}
	else {
		sum = times*times*times;
		times = 2 * N / K - times;
		sum += times*times*times;
		printf("%ld\n", sum);
	}
 
 
 
	return 0;
}
 

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

const int red = 0;
const int blue = 1;

struct point
{
	int x; int y; int color;
};
point p[200];

bool order(point a, point b) {
	return (a.x < b.x);
}
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		p[i].x = a;
		p[i].y = b;
		p[i].color = red;
	}
	
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		p[i+n].x = a;
		p[i+n].y = b;
		p[i+n].color = blue;
	}
	sort(p, p + 2 * n,order);
	int cnt = 0;
	for (int i = 0; i < 2*n; i++) {
		if (p[i].color == blue) {
			int max_j, maxblue;
			maxblue = -1;
			for (int j = 0; j < i; j++) {
				if (p[j].color == red && p[j].y > maxblue && p[j].y < p[i].y) {
					maxblue = p[j].y;
					max_j = j;
				}
			}
			if (maxblue != -1) {
				cnt++;
				p[max_j].color = 3;
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<utility>
#include<array>
#include<set>
#include <numeric>
#include <stdio.h>
#include <map>
#include <iomanip>
#include <sstream>
//#include <boost/math/common_factor_rt.hpp>
#include<fstream>
#define EPS (1e-7)
using namespace std;
#define ll long long



class Employee {
public:
	int id;
	int parent;
	vector<int> children;
	int salary;

	Employee() {
		
	}

	Employee(int num, int nparent) {
		id = num;
		parent = nparent;
		salary = -1;
	}



};



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





pair<int, int> count_nonzero_cluster(vector<int>& vs) {

	int number = 0;
	int prev = 0;
	int vmax = -1;
	pair<int, int> re = make_pair(number, vmax);
	for (auto& v:vs)
	{
		if (prev <= 0 && v > 0) {
			re.first += 1;
		}
		if (re.second < v)re.second = v;
		prev = v;
	}


	return re;
}





int main() {
	
	int N;
	cin >> N;
	vector<pair<int,int>> A(N);
	int order;
	for (auto i = 0; i < N; i++)
	{
		cin >> order;
		A[i] = make_pair(order, i);
	}

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


	for (auto i = 0; i < N; i++)
	{
		cout << A[i].second + 1<< " ";
	}
	
	cout << endl;

	return 0;
}

Measured memory_bytes: 1664
n, k = map(int, input().split())
s = input()
s = list(map(int, s))

v = []
cnt = 1
for i in range(n - 1):
	if s[i] == s[i + 1]:
		cnt = cnt + 1
	else:
		v.append(cnt)
		cnt = 1
v.append(cnt)
m = len(v)

sum = [0] * (m + 1)
for i in range(1, m + 1):
	sum[i] = sum[i - 1] + v[i - 1]

ans = 0
for i in range(m + 1):
	if s[0] == 0:
		if i % 2 == 0:
			ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])
		else:
			ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])
	else:
		if i % 2 == 0:
			ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])
		else:
			ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])

k = k - 1
for i in range(m + 1):
	if s[0] == 0:
		if i % 2 == 1:
			ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])
		else:
			ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])
	else:
		if i % 2 == 1:
			ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])
		else:
			ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])

print(ans)

Measured memory_bytes: 8656
import java.io.*;

import java.math.BigInteger;
import java.util.*;

import java.util.ArrayList;

import java.util.Scanner;


public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static final int mod = 1000000007;
    static final int mod1=1073741824;

    public static int gcd(int a, int b) {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int m=n-1;
        int a[]=new int[m];

        HashMap<Integer,Integer>hm=new HashMap<>();
        for(int j=0;j<m;j++)
        {
            a[j]=sc.nextInt();
            hm.put(a[j],hm.getOrDefault(a[j],0)+1);

        }
        for(int j=1;j<=n;j++)
        {
            if(hm.get(j)==null)
                System.out.println(0);
            else
                System.out.println(hm.get(j));
        }


    }

}










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

import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def main():
    N,M = map(int,input().split())
    S = input().strip()
    T = input().strip()
    L = lcm(N,M)
    for i in range(fractions.gcd(N,M)):
        if S[i*L//M] != T[i*L//N]:
            print("-1")
            return
    print(L)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5344
#include<bits/stdc++.h>
using namespace std;
int main()
{
  	int N,K,Q;
	cin>>N>>K>>Q;
 	vector<int> vec(N,0);
	for(int i=0;i<Q;i++)
    {
		int temp;
		cin>>temp;
      	vec[temp-1]++;
    }
  	for(int i=0;i<N;i++)
    {
		if((Q-vec[i])>=K) cout<<"No"<<endl;
      	else cout<<"Yes"<<endl;
    }
}
		

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;
#define LL long long

int N,A[222222];
LL K;
bool vzt[222222]={};
vector<int>path;

int main() {
	cin>>N>>K;
	for(int i=0;i<N;i++){
		cin>>A[i];
		A[i]--;
	}
	int ad=0;
	while(!vzt[ad]){
		path.push_back(ad);
		vzt[ad]=true;
		ad=A[ad];
	}
	if(path.size()>K)cout<<path[K]+1<<endl;
	else{
		int st;
		for(st=0;path[st]!=ad;st++);
		K-=st;
		K%=(path.size()-st);
		cout<<path[st+K]+1<<endl;
	}

	return 0;
}



Measured memory_bytes: 5244
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
int main() {
	int n;
	cin >> n;
	cout << (1 + n)*n / 2;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int m = sc.nextInt();
	boolean[] ans = new boolean[n];
	int p;
	String s;
	int countAC = 0;
	int countWA = 0;
	int[] cw = new int[n];
	for (int i=0; i<m; i++) {
	    p = sc.nextInt() - 1;
	    s = sc.next();
	    if (s.equals("AC")) {
		if (ans[p] == false) {
		    countAC++;
		    ans[p] = true;
		    countWA += cw[p];
		}
	    } else {
		cw[p]++;
	    }
	}
	System.out.print(countAC + " " + countWA);
    }
}


Measured memory_bytes: 60344
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define PB push_back
#define fst first
#define sec second
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ms(a,x) memset(a,x,sizeof(a))
typedef long long LL;
#define pi pair < int ,int >
#define MP make_pair

using namespace std;
const double eps = 1E-8;
const int dx4[4]={1,0,0,-1};
const int dy4[4]={0,-1,1,0};
const int inf = 0x3f3f3f3f;
const int N=1e5+10;

int n,k;

struct node
{
	int x,y;
}d_pos[N];

pair<int,int>a[123456];

int main()
{
	LL ans=-1;
	cin>>n>>k;
	for (int i=1;i<=n;i++)
	{
		cin>>d_pos[i].x>>d_pos[i].y;
	}
	int nn=1;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
		{
			a[nn++]=make_pair(d_pos[i].x,d_pos[j].y);
		}
	}

	for (int i=1;i<=nn;i++)
	{
		for (int j=1;j<=nn;j++)
		{
			if (j!=i)
			{
				int res=0;
				int mi_x=min(a[i].first,a[j].first);
				int ma_x=max(a[i].first,a[j].first);
				int mi_y=min(a[i].second,a[j].second);
				int ma_y=max(a[i].second,a[j].second);
				for (int k=1;k<=n;k++)
				{
					int t_x=d_pos[k].x,t_y=d_pos[k].y;
					if (mi_x<=t_x&&t_x<=ma_x&&mi_y<=t_y&&t_y<=ma_y) res++;
				}
				if (res>=k)
				{
					LL fuck=1LL*(ma_x-mi_x)*(ma_y-mi_y);
					//ans=min(ans,fuck);
					if (ans==-1) ans=fuck;
					else ans=min(ans,fuck);
				}
			}
		}
	}
	//cout<<ans<<endl;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  string c[3]; rep(i, 3) cin >> c[i];
  cout << c[0][0] << c[1][1] << c[2][2] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h> 
int main(){
    int a,b,i,d;
    
    while(1){
        scanf("%d %d",&a,&b);
        
        if(a==0 && b==0)
            break; 
        
        for(i=0;i<a;i++){
            for(d=0;d<b;d++) {
                printf("#"); 
                
            } 
            printf("\n");
        } 
        printf("\n");
        
    } 
    
    return 0; 
    
} 


Measured memory_bytes: 2044
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

signed main() {
    int A,B; cin >> A >> B;
    string S; cin >> S;
    bool can = true;
    bool can2;
    if(S.size()!=A+B+1) can = false;
    rep(i,S.size()){
        if(i==A){
            if(S[i]!='-') can = false;
        } else {
            can2 = false;
            rep(j,10){
                if(S[i]==(char)('0'+j))
                can2 = true;
            }
            if(!can2) can = false;
        }
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, K;
    scan(N, K);
    auto A = aryread();
    A.sort();

    auto combination_mod = Combination_mod(N);

    long ans;
    foreach (i; 0 .. N)
    {
        long cnt = combination_mod(i, K - 1, MOD);
        long r = cnt * A[i] % MOD;
        ans = (ans + r) % MOD;
    }
    foreach (i; 0 .. N)
    {
        long cnt = combination_mod(N - i - 1, K - 1, MOD);
        long r = cnt * A[i] % MOD;
        ans = (MOD + ans - r) % MOD;
    }
    writeln(ans);
}

alias Combination_mod = Combination_modImpl!long;
struct Combination_modImpl(T)
{
    T _n, _m;
    T[] _fact, _factinv;
    this(T maxnum, T mod = 10 ^^ 9 + 7)
    {
        _n = maxnum;
        _m = mod;
        _fact = new T[](_n + 1);
        _factinv = new T[](_n + 1);
        _fact[0] = 1;
        foreach (i; 1 .. _n + 1)
            _fact[i] = _fact[i - 1] * i % _m;
        T powmod(T x, T n, T m)
        {
            if (n < 1)
                return 1;
            if (n & 1)
            {
                return x * powmod(x, n - 1, m) % m;
            }
            T tmp = powmod(x, n / 2, m);
            return tmp * tmp % m;
        }

        foreach (i; 0 .. _n + 1)
            _factinv[i] = powmod(_fact[i], _m - 2, _m);
    }

    T opCall(T n, T k, T dummy = 10 ^^ 9 + 7)
    {
        return n < k ? 0 : ((_fact[n] * _factinv[n - k] % _m) * _factinv[k] % _m);
    }
}


Measured memory_bytes: 4472
def cc
	n,k = gets.chomp.split(/\s/).map{|x| x.to_i}

    rr = 0
    for i in 1..n
        m = 0
        l = i
        while l <= k-1
            l *= 2
            m += 1
        end

        r = Rational(1, n)
        r *= Rational(1, 2)**m
        rr += r
    end

    puts rr.to_f
end

cc


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

typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	set<int> cnt;
	int n, k;
	
	cin >> n >> k;
	
	for (int i = 0; i < k; ++i) {
		int d;
		cin >> d;
		
		for (int j = 0; j < d; ++j) {
			int a;
			cin >> a;
			cnt.insert(a);
		}
	}
	
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (!cnt.count(i)) {
			++ans;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int main(void){
    string s;
    int size, num = 0;
    cin >> size >> s;
    for(int i = 0;i < size;i++){
        if(s[i] == 'R')++num;
    }
    if(num > (size - num))cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int a,b;
  cin >> a >> b;
  if(a+b >= 10) cout << "error" << endl;
  else cout << a+b << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){ 
	int a,b;
	cin >>a>>b;
	if(a%3!=0&&b%3!=0&&(a+b)%3!=0){
		cout << "Impossible"<<endl;
	}
	else
		cout << "Possible"<<endl;
	return 0;
}

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

ll readLL(){
	ll i;
	scanf("%lld",&i);
	return i;
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

int main(){
	int n=read();
	vector<ll> x;
	REP(i,n)
		x.PB(read());
	vector<ll> dif;
	REP(i,n-1)
		dif.PB(x[i+1]-x[i]);
	vector<int> from;
	REP(i,n-1)
		from.PB(i);
	int m=read();
	ll k=readLL();
	REP(i,m){
		int a=read()-2;
		swap(from[a],from[a+1]);
	}
	vector<int> to(n-1);
	REP(i,n-1)
		to[from[i]]=i;
	vector<int> c(n-1,INT_MIN);
	REP(i,n-1)if(c[i]==INT_MIN){
		vi t;
		int f=i;
		do{
			t.PB(f);
			f=to[f];
		}while(f!=i);
		int g=t.size();
		REP(j,g)
			c[t[(k+j)%g]]=dif[t[j]];
	}
	REP(i,n-1)
		x[i+1]=x[i]+c[i];
	for(auto v:x)
		cout<<v<<endl;
}


Measured memory_bytes: 4264
if __name__ == "__main__":
    n = int(input())
    plan = list()
    for i in range(n):
        plan.append(list(map(int, input().split())))

    pos = [0, 0]
    time = 0
    for i in range(n):
        delta_t = plan[i][0] - time
        delta_x = plan[i][1] - pos[0]
        delta_y = plan[i][2] - pos[1]
        if delta_t < delta_x + delta_y:
            print('No')
            exit()
        elif (delta_t - delta_x - delta_y) % 2 == 1:
            print('No')
            exit()
        pos[0] = plan[i][1]
        pos[1] = plan[i][2]
        time = plan[i][0]

    print('Yes')


Measured memory_bytes: 27292
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N, K; cin >> N >> K;
	string S; cin >> S;

	//vector<pair<char, int>>v;
	//v.eb(S[0], 1);
	//rep(i, 1, S.size()) {
	//	if (S[i] == v.back().first)v.back().second++;
	//	else v.emplace_back(S[i], 1);
	//}
	//dump(v);

	//map<char, vector<int>>mp;
	//for (auto p : v) {
	//	mp[p.first].eb(p.second);
	//}


	auto t = S;
	t.erase(unique(all(t)), t.end());
	dump(t);
	int l = count(all(t), 'L');
	int r = t.size() - l;

	int m = min(l, r);
	for (int i = 1; K and i < t.size(); i += 2, K--) {
		t[i] = t[0];
	}
	t.erase(unique(all(t)), t.end());

	cout << N - t.size() << endl;


	return 0;
}


Measured memory_bytes: 512
#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); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> x(N);
    vector<ll> y(N);
    rep(i,N) cin >> x[i] >> y[i];
    ll ans = 4000000000000000001;
    for (ll i = 0; i < N; i++){
        for (ll j = i + 1; j < N; j++){
            for (ll k = 0; k < N; k++){
                for (ll l = k + 1; l < N; l++){
                    ll ans_sub = abs(y[l] - y[k]) * abs(x[j] - x[i]);
                    ll cnt = 0;
                    rep(m,N){
                        ll min_x = min(x[i], x[j]);
                        ll max_x = max(x[i], x[j]);
                        ll min_y = min(y[k], y[l]);
                        ll max_y = max(y[k], y[l]);
                        if (min_x <= x[m] && x[m] <= max_x && min_y <= y[m] && y[m] <= max_y){
                            cnt++;
                        }
                        if (cnt >= K) ans = min(ans, ans_sub);
                    }
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3588
S = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(S[int(input()) - 1])

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   	int n; double d;
  	cin >> n >> d;
  	int c=0;
  	double x,y;
  	for(int i=0;i<n;i++){
      cin >>x>>y;
      if(d*d>=(x*x+y*y))
         c++;
         }
    cout << c;
    return 0;
}

Measured memory_bytes: 3704
main :: IO ()
main = do
  n <- readLn
  print $ solve n

solve :: Int -> Int
solve n
  | n `elem` [ 10 ^ p | p <- [1..5] ] = 10
  | otherwise = digitSum n

digitSum :: Int -> Int
digitSum n
  | q == 0 = r
  | otherwise = r + digitSum q
  where (q, r) = n `divMod` 10

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

    using namespace std;


    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int a,b,c,k;
        cin>>a>>b>>c>>k;
        int total=0;
        if(a>=k){
            total+=k;
            cout<<total;
            return 0;
        }
        else{
            total+=a;
            k-=a;
        }
        if(b>=k){
            cout<<total;
            return 0;
        }
        else{
            k-=b;
        }
        if(c>=k){
            total+=-k;
            cout<<total;
            return 0;
        }
        return 0;
    }


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <queue> 
#include <cassert>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

#define INF 2000000000
#define MOD 998244353

using namespace std;

int main() {
	int n;
	int a = 0, b = 0, c = 0;
	cin >> n;
	int x;
	while (n--) {
		cin >> x;
		if (x % 4 == 0)
			a++;
		else if (x % 2 == 0)
			b++;
		else
			c++;
	}	
	if (c > a + 1) {
		cout << "No" << endl;
	}
	else if (c > a) {
		if (b > 0)
			cout << "No" << endl;
		else
			cout << "Yes" << endl;
	} else {
		cout << "Yes" << endl;
	}
	return 0;
}	

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect

sys.setrecursionlimit(10**6)
def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline() for _ in range(line)]

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
N,X = zz()
x = zz()

distance = [0]*N
for i in range(N):
    distance[i] = abs(x[i] - X)
# print(distance)
ans = distance[0]
for d in distance:
    ans = gcd(ans, d)
    # print(ans)
print(ans)

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int m, k;
  cin >> m >> k;
  int mask = (1 << m) - 1;
  dump(m, k, mask);
  if (m == 0) {
    if (k == 0) {
      cout << "0 0" << endl;
    } else {
      cout << -1 << endl;
    }
    return;
  }
  if (m == 1 && k == 1) {
    cout << -1 << endl;
    return;
  }
  if (k > mask) {
    cout << -1 << endl;
    return;
  }
  int cnt = 0;
  if (k == 0) {
    for (int i = 0; i <= mask; i++) {
      cout << cnt++ << " ";
    }
    for (int i = 0; i <= mask; i++) {
      cout << --cnt << " ";
    }
  } else {
    for (int i = 0; i <= mask; i++) {
      if (i != k) cout << cnt << " ";
      cnt++;
    }
    cout << k << " ";
    for (int i = mask; 0 <= i; i--) {
      cnt--;
      if (i != k) cout << cnt << " ";
    }
    cout << k << " ";
  }
  cout << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 1792
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

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

int main(){
  int n;
  cin >> n;
  string s;
  int ans = n;
  map<string,int> table;
  for(int i=0;i<n;i++){
    cin >> s;
    if(table.find(s) != table.end()) ans--;
    table[s] = 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 18788
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int H,W,n,buf;
	vector<int> a;
	vector<int> c;
	vector<int> map;
	cin>>H>>W;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>buf;
		a.push_back(buf);
	}

	int mode=1;//1==行き -1==帰り
	int ptr=0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(!a[ptr])ptr++;
			a[ptr]--;
			map.push_back(ptr);
		}
		if(mode==1){
			for(int j=0;j<W;j++){
				cout<<map[j]+1;
				if(j<W-1)cout<<" ";
			}
		}else{
			for(int j=W-1;j>=0;j--){
				cout<<map[j]+1;
				if(j!=0)cout<<" ";
			}
		}
		cout<<endl;
		map.clear();
		mode = -mode;
	}
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

int main() {

	for (string s; cin >> s&&s!="0";) {
		int a = 0;
		for (int i = 0; i < s.size(); i++) {
			a += s[i] - '0';
		}
		cout << a << endl;
	}

	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>

using namespace std;

    int main(){

        long long n ;
        cin>>n;
        
        long long h = 0;
        
        long long k;
        
        vector<long long> v ;

        for(int i = 0 ; i < n ; i++){
            cin>>k;
            v.push_back(k);
        }
        
        for(int j = 0 ; j < n-1 ; j++){
        	
        	if(v.at(j+1) < v.at(j)){
        		h = h + (v.at(j)-v.at(j+1));
        		v.at(j+1) = v.at(j) ;
        	}
        	
        } 
        
        cout<<h;

    }

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

int main() {
  int N;
  int sum = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int A,B;
    cin >> A >> B;
    sum +=  B - A + 1;
  }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 500, dir[4][2] = {0, 1, 1, 0, 0, -1, -1, 0};
int n, m, mn;
ll s[maxn * maxn + 10], a[maxn + 10][maxn + 10];

bool ispr(int x) {
	for (int i = 2; i * i <= x; ++i)
		if (x % i == 0) return 0;
	return 1;
}

int main() {
	scanf("%d", &n);
	if (n == 2) {
		printf("%d %d\n%d %d\n", 4, 7, 23, 10);
		return 0;
	}
	for (int i = 1, p = 1; i <= n * 2; ++i) {
		for (++p; !ispr(p); ++p);
		s[i] = p;
	}
	mn = (1 - n) & 1 ? (2 - n) / 2 : (1 - n) / 2;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			if ((i + j) % 2 == 0) {
				int x = (i + j) / 2, y = (i - j) / 2 - mn + 1;
				a[i][j] = s[x] * s[y + n];
			}
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j) {
			if ((i + j) % 2) {
				ll g = 1;
				for (int k = 0; k < 4; ++k) {
					int dx = i + dir[k][0], dy = j + dir[k][1];
					if (dx >= 1 && dx <= n && dy >= 1 && dy <= n)
						g = g / __gcd(g, a[dx][dy]) * a[dx][dy];
				}
				a[i][j] = g + 1;
			}
			printf("%lld%c", a[i][j],  " \n"[j == n]);
		}
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll n;
  cin >> n;

  ll a = 1, b, sum, ans = mod;
  ll ta, tb;
  FOR(i, 1, n){
    b = n - a;
    sum = 0;
    ta = a, tb = b;
    while(ta){
      sum += ta % 10;
      ta /= 10;
    }
    while(tb){
      sum += tb % 10;
      tb /= 10;
    }
    if(sum < ans) ans = sum;
    a++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
#define Mx 200001
#define inf 1e15
const int MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


typedef long long  L;
//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a,b,a1,a2,a3,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,q,q1,q2,q3,q4,r,s,t,
u,v,x,y,z,sum,mx=-inf,mn=inf,flg,flg1,flg2,id1,id2,id3,id4,lim;

//double rat;
L A[Mx+5],B[Mx+5];


//struct node{L nid,nv;node(L nid_,L nv_){nid=nid_;nv=nv_;}};
//vector<node>V;
void solve(){
	c=(a+b);
	d1=n/c;
	d2=d1*a;
	d1=n%c;
	if(d1<a){
		d2+=d1;
	}else{
		d2+=a;
	}
	printf("%lld\n",d2);
}
int main()
{
    scanf("%lld%lld%lld",&n,&a,&b);
    solve();
    return 0;
}
/// lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		long count=0;
		int whc=0;
		int blc=0;
		char[] str=S.toCharArray();
		for(int i=0;i<S.length();i++) {
			if(str[i]=='B') {
				blc++;
			} else {
				count+=blc;
				whc++;
			}
		}
		System.out.println(count);

	}

}


Measured memory_bytes: 28580
#include <iostream>

using namespace std;

long N, D, Q;
long d[500000], q[500000];
long dp1[500000], dp2[500001];

int main(){
    
    cin >> N >> D;
    for(int i = 0; i < N; i++) cin >> d[i];
    cin >> Q;
    for(int i = 0; i < Q; i++) {
        cin >> q[i];
        q[i]--;
    }
    dp1[0] = D;
    for(int i = 1; i < N; i++) {
        dp1[i] = min(abs(dp1[i-1]), abs(abs(dp1[i-1])-d[i-1]));
    }
    dp2[N] = 1;
    for(int i = N-1; i >= 0; i--){
        if(d[i] <= dp2[i+1]) dp2[i] = dp2[i+1]+d[i];
        else if(d[i] < 2*dp2[i+1]){
            dp2[i] = dp2[i+1]+d[i];
        }else{
            dp2[i] = dp2[i+1];
        }
    }
    for(int i = 0; i < Q; i++){
        //cout << dp1[q[i]] << ' ' << dp2[q[i]+1] << endl;
        if(dp1[q[i]] >= dp2[q[i]+1]){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
}

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int n, m;
    cin >> n >> m;

    vector< int > ks(m);
    auto ss = make_vector(m, 0, 0);
    range(i, 0, m) {
        cin >> ks[i];
        ss[i].resize(ks[i]);
        cin >> ss[i];
    }

    vector< int > ps(m);
    cin >> ps;

    auto check = [&](int bit) {
        range(i, 0, m) {
            int cnt = 0;
            for (auto s: ss[i]) {
                if (bit & (1 << s - 1)) cnt += 1;
            }

            if (cnt % 2 != ps[i]) return 0;
        }

        return 1;
    };

    int ans = 0;
    range(bit, 0, 1 << n) {
        ans += check(bit);
    }

    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int main(){
    int h1,m1,h2,m2,k;
    scanf("%d%d%d%d%d",&h1,&m1,&h2,&m2,&k);
    int t1 = h1*60+m1;
    int t2 = h2*60+m2;
    if (t2 < t1) t2 += 24*60;
    int dif = t2-t1;
    printf("%d",max(0,dif-k));
}


Measured memory_bytes: 3824
N, x = list(map(int, input().split(" ")))

if x == 1 or x >= 2 * N - 1:
    print("No")
else:
    m = N
    if x == m:
        print("Yes")

        ans = range(1, 2 * N )
        for i in ans:
            print(i)
    elif x < m:
        print("Yes")
        for i in range(x + 1, m + 1):
            print(i)
        for i in range(1, x + 1):
            print(i)
        for i in range(m + 1 , 2* N):
            print(i)
    else:
        print("Yes")
        for i in range(1,m):
            print(i)
        for i in range(x,N* 2):
            print(i)
        for i in range(m, x):
            print(i)




Measured memory_bytes: 49500
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380
LLI gcd(LLI a, LLI b) { return b ? gcd(b, a % b) : a; }
bool h[1000000];
void Eratosthenes() {
    for(int i = 0; i < 1000010; i++) {
        h[i] = true;
    }
    for(int i = 2; i < sqrt(1000010); i++) {
        if(h[i]) {
            for(int j = 0; i * (j + 2) < 1000010; j++) {
                h[i * (j + 2)] = false;
            }
        }
    }
}

int main() {
    cout << fixed << setprecision(10);

    Eratosthenes();

    LLI A, B;
    cin >> A >> B;
    vector<int> v;
    int cnt = 1;
    for(LLI i = 2; i < 1000010; i++) {
        if(!h[i]) continue;
        if(A % i == 0 && B % i == 0) {
            while(A % i == 0 && B % i == 0) {
                A /= i;
                B /= i;
            }
            cnt++;
        }
    }
    if(1 != gcd(A, B)) cnt++;
    cout << cnt;
    return 0;
}

Measured memory_bytes: 1280
import java.math.BigInteger;
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = Long.parseLong(scanner.nextLine());

        long result = 1;
        for (long i = 2; i <= n; i++) {
            result *= i;
            if (result > 1000000007) {
                result %= 1000000007;
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 23124
#include<cstdio>
#include<iostream>
using namespace std;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
char field[12][12];
void solve(int y,int x);
int main(){

    while(scanf("%s",field[0])!=EOF){
        for(int i=1;i<12;i++)scanf("%s",field[i]);
        int cnt=0;
        for(int i=0;i<12;i++){
            for(int j=0;j<12;j++){
                if(field[i][j]=='1'){
                    solve(i,j);
                    cnt++;
                }
            }
        }
        printf("%d\n",cnt);
    }
    return 0;
}

void solve(int y,int x){
    if(y<0 || y>11)return;
    if(x<0 || x>11)return;
    if(field[y][x]=='1'){
        field[y][x]='0';
        for(int i=0;i<4;i++){
            solve(y+dy[i],x+dx[i]);
        }
    }
    return;
}

Measured memory_bytes: 1136
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]
 
use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;
 
use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;

    input!{
        s: String,
    }

    let mut cnt = 0;
    for c in s.chars() {
        let u = c as usize - 48;
        cnt += u;
    }

    if cnt % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
    
}

fn main() {
    solve();
}


Measured memory_bytes: 2404