akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <numeric>
#include <iomanip>
using namespace std;

int gcd(int x, int y) {
	if (x < y)
		return gcd(y, x);
	int r;
	while ((r = x % y)) {
		x = y;
		y = r;
	}
	return y;
}

int lcm (int x, int y) {
	return x * y / gcd(x, y);
}

int main(int argc, char** argv) {
	int n;
	vector<int>	a, child;
	int llcm, sum;

	cin >> n;
	a.resize(n);
	child.resize(n);
	for (auto &i : a) {
		cin >> i;
	}
	fill(child.begin(), child.end(), 1);

	if (a.size() <= 1) {
		llcm = a.at(0);
	}
	else {
		llcm = lcm(a.at(0), a.at(1));
		for (int i = 2; i < a.size(); i++) {
			llcm = lcm(llcm, a.at(i));
		}
	}

	for (int i = 0; i < a.size(); i++) {
		child.at(i) *= llcm / a.at(i);
	}

	sum = accumulate(child.begin(), child.end(), 0);

	//cout << fixed << setprecision(15);
	cout << static_cast<double>(llcm) / static_cast<double>(sum) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
int main(void)
{
  int n,k,c;
  char s[55];
  scanf("%d%d%s",&n,&k,s);
  c=tolower(s[k-1]);
  s[k-1]=c;
  printf("%s",s);
  return 0;
}


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

double dp[3000][3000];
double l[3000];
int mod = pow(10,9) +7;
deque<vector<int>> d;

int main() {
  int n; 
  cin >> n;
  for(int i = 1;i<n+1;i++){  
    cin >> l[i];
  }
  dp[1][0] = 1-l[1];
  dp[1][1] = l[1];
  
  for(int i = 2;i< n+1;i++){
    for(int j = 0;j < i+1; j++){
      if(i == j){
        dp[i][j] = dp[i-1][j-1]*l[i];
      }else if(j == 0){
        dp[i][j] = dp[i-1][j]*(1-l[i]);
      }else{
        dp[i][j] = dp[i-1][j-1]*l[i] + dp[i-1][j]*(1-l[i]);
      }
     // cout << dp[i][j] << " " ;
    }
   // cout << endl;
  }
  double res = 0;
  for(int i = int(n/2)+1 ; i<n+1;i++){
    res += dp[n][i];
  }
  cout << fixed << setprecision(10) << res;
}


Measured memory_bytes: 68992
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
const int mod = 1e9 + 7, inf = 1e16;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int modpow(int x, int n) {
	if (n == 0) return 1;
	if (n % 2) return (x * modpow(x * x % mod, n / 2) % mod + mod) % mod;
	return (modpow(x * x % mod, n / 2) + mod) % mod;
}

int fact(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= (i + 1);
		ans %= mod;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) swap(n, r);
	if (n - r < r) r = n - r;
	return fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) % mod;
}

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

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

template <typename T>
void greater_sort(vector<T>& vec) {
	
	sort(all(vec), greater<T>());
	return;
}

double n,m,d;
signed main() {
	cin>>n>>m>>d;
	if(d==0.0) {
		printf("%.10Lf\n",1.0/n*(m-1.0));
	}
	else {
		printf("%.10Lf\n",2.0*(n-d)/n/n*(m-1.0));
	}
}


Measured memory_bytes: 256
import Data.List


main = do
    n <- getLine
    as <- map read . words <$> getLine
    putStrLn $ show $ ans as

ans as = foldl1 max diffs
    where
        combs = [(x, y) | (x:rest) <- tails as, y <- rest]
        diffs = map (\p -> abs $ (fst p) - (snd p)) combs


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define all(c) (c).begin(),(c).end()
#define endl '\n'
using namespace std;

//                                          mdsaqib
signed main(){
    fast;
    int n,m,k;
    cin >> n >> m >> k;
    vector <int> A(n,0),B(m,0);
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    for(int i=0;i<m;i++){
        cin >> B[i];
    }
    vector <int> SA(n,0),SB(m,0);
    int sum=0;
    for(int i=0;i<n;i++){
        sum+=A[i];
        SA[i]=sum;
    }
    sum=0;
    for(int i=0;i<m;i++){
        sum+=B[i];
        SB[i]=sum;
    }
    int mx=0;
    int ii=0,jj=0;
    for(int i=0;i<n;i++){
        if(SA[i]>k){
            break;
        }
        ii=i+1;
    }
    mx=ii;
    if(ii>0){
        for(int i=ii-1;i>=0;i--){
            for(int j=jj;j<m;j++){
                if(SA[i]+SB[j]>k){
                    break;
                }
                jj=j+1;
            }
            mx=max(mx,i+jj+1);
        }
    }
    jj=0;
    for(int i=0;i<m;i++){
        if(SB[i]>k){
            break;
        }
        jj=i+1;
    }
    mx=max(mx,jj);
    cout << mx;
}

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

long long const MAX = 1 << 19;
long long dp[42][MAX];
long long const MOD = 1000000007;

long long mod_p(long long p, long long q) {
	return (p+q) % MOD;
}
long long mod_m(long long p, long long q) {
	return (p*q) % MOD;
}
int x, y, z, n;
bool appear_xyz(long long p) {
	return (((p >> (z - 1)) & 1) ^ ((p >> z) & 1)) & (((p >> (z + y - 1)) & 1) ^ ((p >> (z + y)) & 1))
		& ((p >> (x + y + z - 1) & 1) ^ (p >> (x + y + z)));
}

long long all_one;
long long deny(long long t) {
	return (t^all_one)&all_one;
}

int main() {
	cin >> n >> x >> y >> z;
	long long all = 1;
	for (int i = 0; i < n; i++) {
		all = all * 10 % MOD;
	}	

	int w = x + y + z + 1;
	all_one = (1 << w) - 1;
	dp[0][0] = 1;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= all_one; j++) {
			dp[i][j] = 0;
		}
	}
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= all_one; j += 2) {
			for (int k = 1; k <= 10; k++) {
				long long next = (deny(j) << k) & all_one;
				if (!appear_xyz(next)) {
					dp[i + 1][next] = mod_p(dp[i][j], dp[i + 1][next]);
				}
			}
		}
	}
	long long ans = 0;
	for (int j = 0; j <= all_one; j++) {
		ans = mod_p(ans, dp[n][j]);
	}
	cout << (all - ans + MOD) % MOD << endl;
}

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

using namespace std;

int main(){
    int k,n;
    cin >> n >> k;
    vector <int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    if(k==2){
        cout << n-1 << endl;
        return 0;
    }
    if(n%(k-1)==1){
        cout << (n+k-3)/(k-1) << endl;
    }
    else{
        cout << (n+k-2)/(k-1) << endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N,M; cin >> N >> M;
  vector<int> data(M); REP(i,M) cin >> data.at(i);
  
  REP(i,M){
    N -= data.at(i);
  }
  if(N < 0)
    cout << "-1" <<endl;
  else
    cout << N << endl;
}

Measured memory_bytes: 3612
#include<stdio.h>
#include<iostream>
using namespace std;
int main(void){
	int N,X,Y,Z;
	int ans=0,clear=0;
	int a[100],b[100],c[100];
	
	cin >> N;
	cin >> X;
	for(int i=0;i<X;i++){
		cin >> a[i];
	}
	cin >> Y;
	for(int i=0;i<Y;i++){
		cin >> b[i];
	}
	cin >> Z;
	for(int i=0;i<Z;i++){
		cin >> c[i];
	}
	
	for(int i=0;i<Z;i++){
		for(int j=0;j<Y;j++){
			if(c[i]==b[j]){
				ans++;
				clear = 1;
				break;
			}
		}
		for(int j=0;j<X;j++){
			if(c[i]==a[j]){
				clear = 1;
				break;
			}
		}
		if(clear==0){
			ans++;
		}else{
			clear = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3120
from collections import deque
H, W = map(int, input().split())
edges = [0] * (W + 2)
field = [edges]
WH = 0
for _ in range(H):
    row = [c == '.' for c in input()]
    field.append([0] + row + [0])
    WH += sum(row)
field.append(edges)
que = deque([(1, 1, 1)])  # x, y, cnt
enq, deq = que.append, que.popleft
while que:
    x, y, cnt = deq()
    if (x, y) == (W, H):
        print(WH - cnt)
        exit()
    for dx, dy in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
        nx, ny = x + dx, y + dy
        if field[ny][nx]:
            enq((nx, ny, cnt + 1))
            field[ny][nx] = 0
print(-1)

Measured memory_bytes: 3316
n = int(input())
slist = list(map(int, input().split()))
q = int(input())
tlist = list(map(int, input().split()))

s_unique = list(set(slist))
s_unique.sort()

cnt = 0
for t in tlist:
    low = 0
    high = len(s_unique)
    s = (low + high) // 2

    while low <= high:
        if t == s_unique[s]:
            break
        elif t > s_unique[s]:
            low = s + 1
        elif t < s_unique[s]:
            high = s - 1
        s = (low + high) // 2

    if t == s_unique[s]:
        cnt += 1

print(cnt)



Measured memory_bytes: 16704
#include <iostream>
using namespace std;
int main() {
  int a, b, sum;
  while(cin >> a >> b) {
    int count=0;
    sum = a+b;
    for(int i=10; ; i*=10) {
      count++;
      if(sum%i==sum) break;
    }
    cout << count << endl;
  }
  return 0;
}


Measured memory_bytes: 1164
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;

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


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

int bubbleSort(int a[],int n){
	int flag = 1;
	int num = 0;
	while(flag){
		flag = 0;
		for(int j=n-1;j>0;j--){
			if(a[j]<a[j-1]){
				int t;
				t = a[j];
				a[j] = a[j-1];
				a[j-1] = t;
				num++;
				flag = 1;
			}
		}
	}
	return num;
}

int main(){
	int n;
	cin>>n;
	int A[n],as;
	for(int i=0;i<n;i++){
		cin>>A[i];
	}
	as = bubbleSort(A,n);
	for(int i=0;i<n;i++){
		if(i){
			cout<<" ";
		}
		cout<<A[i];
	}
	cout<<endl;
	cout<<as<<endl;
	return 0;
} 


Measured memory_bytes: 3100
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<map>
using namespace std;
#define REP(i,st,ed) for(int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(int i=st,i##end=ed;i>=i##end;--i)
int read(){
	int x=0,f=1;
	char c=getchar();
	while((c<'0')||(c>'9')){if(c=='-')f=-1;c=getchar();}
	while((c>='0')&&(c<='9'))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
const int maxn=200005;
int a[maxn],b[maxn],n,m;
map<int,int>cnt1,cnt2;
int main(){
	n=read();
	REP(i,1,n)a[i]=read(),cnt1[a[i]]++;
	m=read();
	REP(i,1,m)b[i]=read(),cnt2[b[i]]++;
	bool ans=1;
	REP(i,1,m)
		if(cnt1[b[i]]<cnt2[b[i]]){ans=0;break;}
	puts(ans?"YES":"NO");
	return 0;
}

Measured memory_bytes: 20608
#include<bits/stdc++.h>
#define ll long long
#define rg register
using namespace std;
const int MAXN=1e5+10;
struct gao{   int Le,Ri;   }Area[MAXN];
int n,K,Ls,B[MAXN];
ll Ans=1e18,A[MAXN],Dp[MAXN],Lsh[MAXN<<1];
inline int Read()
{   rg int a=0,c=1;   rg char b=getchar();
	while(b!='-'&&(b<'0'||b>'9'))b=getchar();
	if(b=='-')c=-1,b=getchar();
	while(b>='0'&&b<='9')a=a*10+b-48,b=getchar();
	return a*c;
}
inline ll Min(rg ll A,rg ll B){   return A<B?A:B;   }
inline ll Max(rg ll A,rg ll B){   return A>B?A:B;   }
inline ll Dist(rg ll A,rg ll B){   return (Lsh[B]+K-Lsh[A])%K;   }
namespace Tree
{   int Id[MAXN<<2],Lan[MAXN<<2];
	inline void Push_Lan(rg int S,rg int New){   Lan[S]=Id[S]=New;   }
	inline void Push_down(rg int S)
	{   Lan[S]?(Push_Lan(S<<1,Lan[S]),Push_Lan(S<<1|1,Lan[S])):(void)0,Lan[S]=0;   }
	inline int Modify(int S,int Le,int Ri,int Al,int Ar,int New)
	{   if(Al>Ar) return 0;
		if(Al<=Le&&Ri<=Ar) return Push_Lan(S,New),0;   rg int Mid=(Le+Ri)>>1;
		Push_down(S),Al<=Mid?Modify(S<<1,Le,Mid,Al,Ar,New):0,Mid<Ar?Modify(S<<1|1,Mid+1,Ri,Al,Ar,New):0;
	}
	inline int Query(rg int S,rg int Le,rg int Ri,rg int Aim)
	{   if(Le==Ri) return Id[S];   rg int Mid=(Le+Ri)>>1;
		return Push_down(S),Aim<=Mid?Query(S<<1,Le,Mid,Aim):Query(S<<1|1,Mid+1,Ri,Aim);
	}
}using Tree::Modify;using Tree::Query;
int main()
{   n=Read(),K=Read();
	for(rg int i=1;i<=n;i++) A[i]=Read(),B[i]=Read();
	for(rg int i=1;i<=n;i++) if(A[i]*2>K&&B[i]==1) return puts("-1"),0;
	for(rg int i=1;i<=n;i++) A[i]=A[i]+A[i-1];
	for(rg int i=1;i<=n;i++)
		if(B[i]==2) Area[i].Le=0,Area[i].Ri=K-1;
		else Area[i].Le=(-2ll*A[i-1]%K+K)%K,Area[i].Ri=(-2ll*A[i]%K+K)%K;
	for(rg int i=1;i<=n;i++) Lsh[++Ls]=Area[i].Le,Lsh[++Ls]=Area[i].Ri;
	sort(Lsh+1,Lsh+Ls+1),Ls=unique(Lsh+1,Lsh+Ls+1)-Lsh-1;
	for(rg int i=1;i<=n;i++)
	{   Area[i].Le=lower_bound(Lsh+1,Lsh+Ls+1,Area[i].Le)-Lsh;
		Area[i].Ri=lower_bound(Lsh+1,Lsh+Ls+1,Area[i].Ri)-Lsh;
	}
	for(rg int i=n,Pos,Le,Ri;i>=1;i--)
	{   Le=Area[i].Le,Ri=Area[i].Ri,Pos=Query(1,1,Ls,Le),Dp[i]=Dp[Pos]+(Pos?Dist(Le,Area[Pos].Le):0);
		Le<=Ri?(Modify(1,1,Ls,1,Le-1,i),Modify(1,1,Ls,Ri+1,Ls,i)):Modify(1,1,Ls,Ri+1,Le-1,i);
	}
	for(rg int i=1,Pos;i<=Ls;i++)
		Pos=Query(1,1,Ls,i),Ans=Min(Ans,Dp[Pos]+(Pos<=1?0:Dist(i,Area[Pos].Le)));
	printf("%lld\n",Ans+2ll*A[n]);
}


Measured memory_bytes: 7168
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <type_traits>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;



typedef int64 ll;
typedef uint64 ull;

template<uint MD>
struct ModInt {
	uint v;
	ModInt() : v{ 0 } {}
	ModInt(ll v) : v{ normS(v%MD + MD) } {}
	static uint normS(const uint &x) { return (x<MD) ? x : x - MD; };
	static ModInt make(const uint &x) { ModInt m; m.v = x; return m; }
	const ModInt operator+(const ModInt &r) const { return make(normS(v + r.v)); }
	const ModInt operator-(const ModInt &r) const { return make(normS(v + normS(MD - r.v))); }
	const ModInt operator*(const ModInt &r) const { return make((ull)v*r.v%MD); }
	ModInt& operator+=(const ModInt &r) { return *this = *this + r; }
	ModInt& operator-=(const ModInt &r) { return *this = *this - r; }
	ModInt& operator*=(const ModInt &r) { return *this = *this*r; }
};

using mint = ModInt<1000000007>;
int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n;
	std::string s;
	std::cin >> n >> s;
	mint dp[5003][5003] = {};
	dp[0][0] = mint(1);
	for (uint32 i = 1;i <= n;++i) {
		dp[i][0] = dp[i - 1][1] + dp[i - 1][1] + dp[i - 1][0];
		for (uint32 j = 1;j <= i;++j) {
			dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j + 1] + dp[i - 1][j + 1];
		}
	}
	std::cout << dp[n][s.length()].v << "\n";
	return 0;
}

Measured memory_bytes: 98048
import java.util.Scanner;

public class Main {
    static final Scanner sc = new Scanner(System.in);
    
    public static void main(String[] args) {
        int N = nint();
        int Q = nint();
        char[] S = nstr().toCharArray();
        int[] count = new int[N];
        
        for (int i = 1; i < N; i++) {
            count[i] = count[i-1];
            if(S[i] == 'C' && S[i-1] == 'A') {
                count[i]++;
            }
        }
        
        for (int i = 1; i <= Q; i++) {
            int l = nint();
            int r = nint();
            System.out.println(count[r-1] - count[l-1]);
        }
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


Measured memory_bytes: 63664
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;

int main(){
   int n,k;
   cin>>n>>k;
   int p=(n-1)*(n-2)/2-k;
   if(p<0){
       cout<<-1<<endl;
       return 0;
   }
   cout<<n-1+p<<endl;
   for(int i=1;i<n;i++)cout<<1<<" "<<i+1<<endl;
   int cnt=0;
   for(int i=1;i<n;i++){
       for(int j=i+1;j<n;j++){
           if(cnt<p){
               cout<<i+1<<" "<<j+1<<endl;
               cnt++;
           }
       }
   }
}

   


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
  char a;
  int accum['z'-'a'+1]={0};
  while(cin>>a){
    if('A' <= a && a <= 'z'){
      accum[(int)(a-'A')%('a' - 'A')]++;
    }
  }
  for(int i=0; i<='z'-'a'; i++){
    cout << (char)(i+'a') << " : " << accum[i] << endl;
  }
  return 0;
}



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

using namespace std;
const double pi=acos(-1.0);
const int N=2e3+10;
typedef long long ll;
struct p{
    int index;
    int t;
}a[N];
int cmp(p x,p y){
    return x.t>y.t;
}
ll dp[N][N];
int main()
{
   int n;
   cin>>n;
   for(int i=0;i<n;i++){
        a[i].index=i;
        cin>>a[i].t;
   }
   sort(a,a+n,cmp);
   for(int i=0;i<n;i++){
        for(int j=0;j+i<n;j++){
            int k=i+j;
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]+(ll)1*a[k].t*abs(a[k].index-i));
            dp[i][j+1]=max(dp[i][j+1],dp[i][j]+(ll)1*a[k].t*abs(a[k].index-n+1+j));
        }
   }
   ll ans=0;
   for(int i=0;i<=n;i++)
    ans=max(ans,dp[i][n-i]);
    cout<<ans<<endl;
}



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

int main() {
	int N;
	cin >> N;
	int ans = 100;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		int cnt = 0;
		while (A > 0) {
			if (A % 2 == 0)	{
				A /= 2;
				cnt++;
			}
			else {
				break;
			}
		}
		if (ans > cnt) {
			ans = cnt;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::cmp;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

struct Segtree{
    n:i64,
    t:i64,
    node:Vec<i64>,
}
impl Segtree{
    fn init(&mut self){
        for i in 0..2*self.n+1{
            self.node.push(self.t);
        }
    }
    fn update(&mut self,k:i64,x:i64){
        let mut k=k+self.n;
        let mut i=k as usize;
        self.node[i]=x;
        k>>=1;
        while k>0{
            i=k as usize;
            self.node[i]=cmp::min(self.node[i<<1],self.node[i<<1|1]);
            k>>=1;
        }
    }
    fn query(&mut self,l:i64,r:i64)->i64{
        let mut vl:i64=self.t;
        let mut vr:i64=self.t;
        let mut l=l+self.n;
        let mut r=r+self.n;
        while l<r{
            if (l&1)>0{
                let i:usize=l as usize;
                vl=cmp::min(vl,self.node[i]);
                l=l+1;
            }
            if (r&1)>0{
                r=r-1;
                let i:usize=r as usize;
                vr=cmp::min(vr,self.node[i]);
            }
            l>>=1;
            r>>=1;
        }
        cmp::min(vl,vr)
    }
}
fn main() {
    let n:i64=read();
    let q:i32=read();
    let mut tree=Segtree{
        n:n,
        t:2147483647,
        node:Vec::new(),
    };
    tree.init();
    for i in 0..q{
        let com:i32=read();
        let mut x:i64=read();
        let mut y:i64=read();
        if com==0{
            tree.update(x,y);
        }else{
            println!("{}",tree.query(x,y+1));
        }
    }
}


Measured memory_bytes: 6980
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
//#include "graph.cpp"
#define ll long long
#define loop(i,n) for(int i=0 ; i<n ; ++i)
#define rep(i,x,n) for(int i=x ; i<=n ; ++i)
#define iteloop(type,data,name,it) for(type<data>::iterator it=name.begin() ;it!=name.end() ; ++it)
using namespace std;
using namespace __gnu_pbds;

int getSum(int st,int en){
    int res=0;
    for(int i=st;i<=en;i++)res+=i;
    return res;
}

int main(){
    cin.sync_with_stdio(false), cin.tie(0) , cout.tie(0);
  ///  freopen("in.txt","rt",stdin);
  int n,l;
  cin>>n>>l;
  int st=l , en=l+n-1;
  if(st==0 || en==0){
    cout<<getSum(st,en)<<endl;
    return 0;
  }
  if(st/abs(st) != en/abs(en)){
    cout<<getSum(st,en)<<endl;
    return 0;
  }
  if(st/abs(st) == 1){
    cout<<getSum(st,en)-st<<endl;
  }else{
    cout<<getSum(st,en)-en<<endl;
  }
}


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let a = input::<i64>();
    let b = input::<i64>();
    let t = input::<i64>();

    let ans = (t / a) * b;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  double a,b,c,d;
  cin >> a >> b >> c;
  if(a*a*b/2<c){
    d=(b-c/(a*a))*2;
    printf("%lf",atan(d/a)*180/M_PI);
  }
  else{
    d=(c/(a*b))*2;
    printf("%lf",90-atan(d/b)*180/M_PI);
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N, K, S;
  cin >> N >> K >> S;

  vector<int> answer;
  rep(i, K) answer.push_back(S);
  if (S != 1000000000)
    rep(i, N - K) answer.push_back(S + 1);
  else
    rep(i, N - K) answer.push_back(S - 1);
  for (auto i : answer) {
    cout << i << " ";
  }
  cout << endl;
  return 0;
}


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


def main():
    x = y = z = 0
    ans = 0

    k, s = map(int, input().split())

    for x in range(k + 1):
        for y in range(k + 1):
            z = s - x - y
            if 0 <= z <= k:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
int n = Integer.parseInt(sc.next());
int m = Integer.parseInt(sc.next());
long nk=1;
long mk=1;
for (int i = 1; i <= n; i++) {
    nk*=i;
    nk=nk%1000000007;
}
for (int i = 1; i <= m; i++) {
    mk*=i;
    mk=mk%1000000007;
}
long ans;

if(n==m){
    ans=(2*(nk*mk))%1000000007;
    out.println(ans);
}else if(n-m==1||n-m==-1){
    ans=(nk*mk)%1000000007;
    out.println(ans);
}else{
    ans=0;
    out.println(ans);}
}
}

Measured memory_bytes: 23764
#include<iostream>

int main(void)
{
	using namespace std;
	double c = 0, n, x, half, halfhalf, temp;
	while(1)
	{
		cin >> n >> x;
		if(n == 0 && x == 0)
			break;
		half = x / 2;
		for(double i = n; i > 0; i--)
		{
			temp = x - i;
			halfhalf = temp / 2;
			for(double j = i - 1; j > 0; j--)
			{
				if(temp - j > 0 && temp - j < halfhalf)
					c++;
			}
		}
		cout << c << endl;
		c = 0;
	}
}


Measured memory_bytes: 3292
#include<bits/stdc++.h>
#include <queue>
#include <cstring>
#define mp make_pair
#define pb push_back
#define p push

#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long int

#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld%lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);

#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define SIZE 1000000007
#define MAXN 100005

using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph ;


int main(){
   IOS
   ll a,b,n;
    cin>>a>>b>>n;
    ll k= a*b;
    if(k > n)cout<<n;
    else cout << k;
    return 0;
}


Measured memory_bytes: 768
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		Map<String,Set<Integer>> words = new TreeMap<String, Set<Integer>>();
		
		while(sc.hasNextLine()){
			String[] strs = sc.nextLine().split(" ");
			
			if(words.containsKey(strs[0])){
				words.get(strs[0]).add(Integer.parseInt(strs[1]));
			}else{
				Set<Integer> tmp = new TreeSet<Integer>();
				tmp.add(Integer.parseInt(strs[1]));
				words.put(strs[0], tmp);
			}
		}
		
		for(String str:words.keySet()){
			System.out.println(str);
			boolean first = false;
			
			for(Integer i:words.get(str)){
				if(first){
					System.out.print(" ");
				}else{
					first = true;
				}
				
				System.out.print(i);
			}
			System.out.println();
		}
		
	}
}

Measured memory_bytes: 12000
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-25 13:10:23
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

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

  int n; cin >> n;
  vector<int> a(n); cin >> a;

  int odd = 0, eve = 0;

  for (int e : a) {
    odd += (e & 1);
    eve += !(e & 1);
  }

  cout << ((odd & 1) ? "NO" : "YES") << endl;

  return 0;
}

Measured memory_bytes: 640
x = input()
A = int(x[0])
B = int(x[1])
C = int(x[2])
D = int(x[3])

def cal(a, b, opx):
    if opx == "+":
        return a + b
    else:
        return a - b

op = ["+", "-"]
result = ""
for op1 in op:
    for op2 in op:
        for op3 in op:
            if cal(cal(cal(A, B, op1),C,  op2), D, op3) == 7:
                print(str(A) + op1 + str(B) + op2 + str(C) + op3 + str(D) + "=7")
                exit()
                
            

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

int main() {
  int h,n; cin>>h>>n;
  int a; for(int i=0;i<n;i++) {cin>>a; h-=a;}
  if (h>0) cout<<"No"<<endl;
  else if (h<=0) cout<<"Yes"<<endl;
  else if ("あぶないよー！")cout<<"ｳｯ"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
long long ans;
int n;
char s[1005];
int main (){
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> s[i];
	if(n % 2 != 0) puts("No");
	else {
		for(int i = 1; i <= n / 2;i++){
			if(s[i] != s[i+n/2]) {
				puts("No");
				return 0;
			}
		}
		puts("Yes");
	}
}

Measured memory_bytes: 256
from math import gcd
def main():
    def factorization(n):
        arr = []
        temp = n
        for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
            if temp % i == 0:
                cnt = 0
                while temp % i == 0:
                    cnt += 1
                    temp //= i
                arr.append([i, cnt])
        if temp != 1:
            arr.append([temp, 1])
        if arr == []:
            arr.append([n, 1])
        return arr

    a, b = map(int, input().split())
    g = gcd(a,b)
    g_fac = factorization(g)
    r = len(g_fac)
    if g_fac[0][0] != 1:
        r += 1
    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 63656
{-# LANGUAGE BangPatterns #-}
module Main where

import qualified Data.IntSet as IS
import Data.List (foldl')
import Control.Monad
import Data.List (sortBy)
import Data.Ord (comparing)

greedy
  :: Foldable f
  => s -- ^ empty set
  -> (a -> s -> Maybe s) -- insert an element
  -> f a
  -> s
greedy e ins = foldl' (\s a -> case ins a s of
  Just s' -> s'
  _ -> s) e

assign :: Int -> (Int, Int) -> (Int, IS.IntSet) -> Maybe (Int, IS.IntSet)
assign duration (d, v) (!total, !s) = do
  day <- IS.lookupLE (duration - d) s
  return (total + v, IS.delete day s)

readL :: Read a => IO [a]
readL = map read . words <$> getLine

main = do
  [n, duration] <- readL
  jobs <- map (\[a, b] -> (a :: Int, b :: Int)) <$> replicateM n readL
  let (total, _) = greedy (0, IS.fromList [0..duration]) (assign duration)
        $ sortBy (comparing (negate . snd)) jobs
  print total


Measured memory_bytes: 88444
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,c;
    cin >> n >> m >> c;
    int b[m];
    for(int i = 0;i < m;i++)
    {
        cin >> b[i];
    }
    int count = 0;
    for(int i = 0;i < n;i++)
    {
        int sum = 0;
        for(int j = 0;j < m;j++)
        {
            int x;
            cin >> x;
            sum += x * b[j];
        }
        if(sum + c > 0)
        {
            count++;
        }
    }
    cout << count;

    return 0;
}

Measured memory_bytes: 256
import numpy as np
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
 
def do():
    n=INT()
    A=[]
    B=[]
    for i in range(n):
        a,b=INTM()
        A.append(a)
        B.append(b)
        #print(A,B)
    A=sorted(A)
    B=sorted(B,reverse=True)
    if n%2==1:
        ta=A[n//2]
        tb=B[n//2]
        print(tb-ta+1)
    else:
        ta1=A[n//2-1]
        ta2=A[n//2]
        tb1=B[n//2-1]
        tb2=B[n//2]
        avea=(ta1+ta2)/2
        aveb=(tb1+tb2)/2
        print(int((aveb-avea)*2)+1)
        
        
    
if __name__ == '__main__':
    do()

Measured memory_bytes: 44948
import java.io.{BufferedReader, IOException, InputStream, InputStreamReader}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{min, max, abs}

object Main {
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val S = sc.next

    def two = (S zip S.drop(1)).zipWithIndex find { case ((c1, c2), _) => c1 == c2 }
    def three = (S zip S.drop(1) zip S.drop(2)).zipWithIndex find { case (((c1, c2), c3), _) => c1 == c2 || c1 == c3 || c2 == c3}

    val ans = (two map { case (_, i) =>
      s"${i + 1} ${i + 2}"
    }) orElse (three map { case (_, i) =>
      s"${i + 1} ${i + 3}"
    }) getOrElse "-1 -1"

    println(ans)
  }

  def main(args: Array[String]): Unit = {
    solve()
  }



  class InputReader(val stream: InputStream) {
    val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

}


Measured memory_bytes: 64276
// abc057_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;


set<ll> get_divisors(ll n){
    set<ll> res;
    for (ll i = 1; i * i <= n; i++){
        if (n % i == 0){
            res.insert(i);
//            res.insert(n / i);
        }
    }
    return res;
}

int count_digits(ll n){
    int cnt = 0;
    while (n){
        n /= 10;
        cnt++;
    }
    return cnt;
}

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll N;
    cin >> N;

    auto st = get_divisors(N);

    int ans = INF;
    for (auto a: st){
        ll b = N / a;

        int tmp = max(count_digits(a), count_digits(b));
        ans = min(ans, tmp);
    }

    print(ans);


    return 0;
}


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

#define test(t) while(t--)
#define fo(i,k,n) for(int i=k;i<n;i++)
#define refl(a,x) for(auto& a:x)
#define MIN(a,b)  (a>b?b:a)
#define ll  long long int
#define MOD 1e9 + 7
#define in  cin>>
#define out cout<<
#define en "\n"
#define sp " "
#define fi first
#define se second
#define fast()  ios_base::sync_with_stdio(false);cin.tie(0);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
//typedef pair<int,int> pai;
//typedef pair<char,int> pac;



/*bool f(int x,int y){

return x>y;
}*/


using namespace std;

void solve()
{ ll s,w;
  in s>>w;
  if(w>=s){
    out "unsafe"<<en;
  }
  else
    out "safe"<<en;

}

int main(){ fast()
             //freopen("input.txt","r",stdin);
	         //freopen("output.txt","w",stdout);
             ll t=1;
            //cin>>t;
            test(t){
            solve();
            }
return 0;}


Measured memory_bytes: 3636
from itertools import product

def inc(i, j, H, W, field):
    if not(0 <= i <= H-1 and 0 <= j <= W-1):
        pass
    elif field[i][j] == "#":
        pass
    else:
        field[i][j] += 1


def main():
    H, W = [int(i) for i in input().split()]
    ans = [[0] * W for _ in range(H)]
    for i in range(H):
        line = input()
        for j in range(W):
            if line[j] == "#":
                ans[i][j] = "#"
                for d in product([-1, 0, 1], repeat=2):
                    d_i, d_j = d
                    inc(i+d_i, j+d_j, H, W, ans)
    for a in ans:
        print(*a, sep="", end="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 46576
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <boost/range/algorithm.hpp>
#include <boost/integer/common_factor_rt.hpp>

using namespace std;

int N, T;

int main() {

    while (cin >> N) {
        int W[N], ret = 100 * 100;
        for (int i = 0; i < N; i++) {
            cin >> W[i];
        }
        for (int i = 0; i < N; i++) {
            int left_sum = 0, right_sum = 0;
            for (int j = 0; j < i; j++) {
                left_sum += W[j];
            }
            for (int j = i; j < N; j++) {
                right_sum += W[j];
            }
            ret = min(ret, abs(left_sum - right_sum));
        }
        cout << ret << endl;
    }

    return 0;
}


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


int main() {
    int i, j, d[7], d_next[7];
    string dire;

    cin >> d[1] >> d[2] >> d[3] >> d[4] >> d[5] >> d[6];
    cin >> dire;
    for(i=0;i<dire.size();i++){
        if(dire[i] == 'E'){
            d_next[1]=d[4];
            d_next[2]=d[2];
            d_next[3]=d[1];
            d_next[4]=d[6];
            d_next[5]=d[5];
            d_next[6]=d[3];
        }else if(dire[i] == 'N'){
            d_next[1]=d[2];
            d_next[2]=d[6];
            d_next[3]=d[3];
            d_next[4]=d[4];
            d_next[5]=d[1];
            d_next[6]=d[5];
        }else if(dire[i] == 'S'){
            d_next[1]=d[5];
            d_next[2]=d[1];
            d_next[3]=d[3];
            d_next[4]=d[4];
            d_next[5]=d[6];
            d_next[6]=d[2];
        }else{
            d_next[1]=d[3];
            d_next[2]=d[2];
            d_next[3]=d[6];
            d_next[4]=d[1];
            d_next[5]=d[5];
            d_next[6]=d[4];
        }
        for(j=1;j<7;j++){
            d[j] = d_next[j];
        }
    }

    cout << d[1] << endl;
    return 0;
}



Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,n)  for(ll i=0;i<n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef pair<int,int> pii;
int main()
{
	IOS;
	//ll T; cin>>T;
	//ll M=pow(10,9)+7;
	int T=1;
	while(T)
	{
		ll n; cin>>n;
		string s; cin>>s;
		int i=0,j=n-1;
		int ans=0;
		while(i<j)
		{
			if(s[i]=='W'&&s[j]=='R')
			{
				char temp=s[i];
				s[i]=s[j];
				s[j]=temp;
				i++;
				j--;
				ans++;
			}
			else if(s[i]=='W'&&s[j]=='W')
			{
				j--;
			}
			else if(s[i]=='R'&&s[j]=='R')
			{
				i++;
			}
			else if(s[i]=='R'&&s[j]=='W')
			{
				i++;
				j--;
			}
		}
		cout<<ans;
		T--;
	}
	return 0;
}

Measured memory_bytes: 3696
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int n;
vector<int> a;
vector<vector<bool> > used;
vector<vector<long long> > dp;

long long solve(int l, int r) {
	if (l > r) return 0;
	if (used[l][r]) return dp[l][r];
	used[l][r] = true;
	return dp[l][r] = max(a[r] - solve(l, r - 1), a[l] - solve(l + 1, r));
}

int main() {
	cin >> n;
	a.resize(n);
	used.assign(n, vector<bool>(n));
	dp.assign(n, vector<long long>(n));
	for (int i = 0; i < n; ++i) cin >> a[i];
	cout << solve(0, n - 1) << endl;

	return 0;
}

Measured memory_bytes: 72064
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    string S;cin>>S;
    vector<bool> V(26,false);
    for (auto s :S)
    {
        V[s-97]=true;
    }
    if (accumulate(ALL(V),0)==26)
    {
        cout << "None" << endl;
    }
    else
    {
        REP(i,26)
        {
            if (!V.at(i))
            {
                char c = i+97;
                cout << c << endl;
                break;
            }
        }
    }
  
    return 0;
}



Measured memory_bytes: 512
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n, k int
	var s string
	fmt.Scan(&n, &k, &s)
	k--
	b := s[0:k] + strings.ToLower(string(s[k])) + s[k+1:]

	fmt.Println(b)
}


Measured memory_bytes: 1844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int N;
    cin >> N;
    
    vector<long long int> sA(N+1, 0);
    for(int n=0; n<N; n++) {
        long long int a;
        cin >> a;
        sA[n+1] = sA[n]+a;
    }
    
    long long int ans=1e14;
    for(int n=1; n<N; n++) {
        ans = min(ans, abs(2*sA[n]-sA[0]-sA[N]));
    }
    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 1792
from itertools import combinations
from collections import Counter

def resolve():
	n = int(input())
	seq = []
	for _ in range(n):
		v = input()[0]
		if v in ['M', 'A', 'R', 'C', 'H']:
			seq.append(v)
	c = Counter(seq)
	ans = 0
	for comb in combinations(c.values(), 3):
		tmp = 1
		for i in comb:
			tmp *= i
		ans += tmp
	print(ans)
resolve()

Measured memory_bytes: 53976
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sn = new Scanner(System.in);
		System.out.println(isValid(sn.next())? "VALID": "INVALID");
		
	}
	
	static boolean isValid(String pass){
		if(pass.length() < 6) return false;
		boolean upper = false;
		boolean lower = false;
		boolean number = false;
		for(int i = 0; i < pass.length(); i++){
			int code = (int)pass.charAt(i);
			if(code >= 97 && code <= 122) lower = true;
			if(code >= 65 && code <= 90) upper = true;
			if(code >= 48 && code <= 58) number = true;
		}
		return upper && lower && number;
	}
}

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

const int MAX_N = 100007;

int N;
int K;
long long h[MAX_N];

int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> h[i];

  sort(h, h + N);

  long long ans = 10000000009;

  for (int i = 0; i < N - K + 1; i++) {
    ans = min(ans, h[i + K - 1] - h[i]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
import itertools

n, m = map(int, input().split())
path = [[False] * n for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True
ans = 0
for i in itertools.permutations(range(n), n):
    if i[0] == 0:
        for j in range(n):
            if j == n - 1:
                ans += 1
                break
            if not path[i[j]][i[j + 1]]:
                break
print(ans)

Measured memory_bytes: 3064
import Data.Char

solve :: Int -> Int -> Int
solve n m 
    | m > n = 0
    | (length $ show m) < 3 = (solve n (m*10+7)) + (solve n (m*10+5)) + (solve n (m*10+3))
    | check = 1 + (solve n (m*10+7)) + (solve n (m*10+5)) + (solve n (m*10+3))
    | otherwise = (solve n (m*10+7)) + (solve n (m*10+5)) + (solve n (m*10+3))
        where
            xs = map digitToInt $ show m
            check = (elem 7 xs) && (elem 5 xs) && (elem 3 xs)

main = do
    n <- readLn :: IO Int
    print $ if (length $ show n) < 3 then 0 else solve n 0

Measured memory_bytes: 1020
#include<stdio.h>
int main(){
	int string=0,i;
	int cnt[26]={0};

	while((string=getchar()) != EOF){
		if('A'<=string && string <= 'Z'){	//oomoji
			cnt[string-'A']++; //-'A' 
		}else if('a'<=string && string <= 'z'){
			cnt[string-'a']++;
		}
    }
	for(i=0;i<=25;i++){
		printf("%c : %d\n",'a'+i,cnt[i]);
	}
	return 0;
}

Measured memory_bytes: 1760
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
int main() {
  int N, A, B; cin >> N >> A >> B;
  if((B-A)%2==0) cout << "Alice" << endl;
  else cout << "Borys" << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
        var A, B, C, D, E int
        fmt.Scan(&A, &B, &C, &D, &E)

        arr := []int{A, B, C, D, E}
        l := len(arr)
        for i := 0; i < l; i++ {
                for j := i; j < l; j++ {
                        a := arr[i] % 10
                        b := arr[j] % 10
                        if a == 0 {
                                a += 10
                        }
                        if b == 0 {
                                b += 10
                        }
                        if a < b {
                                tmp := arr[i]
                                arr[i] = arr[j]
                                arr[j] = tmp
                        }
                }
        }

        sum := 0
        for i := 0; i < l; i++ {
                sum += arr[i]
                if i != l-1 {
                        a := arr[i] % 10
                        if a != 0 {
                                sum += 10 - (arr[i] % 10)
                        }
                }
        }
        fmt.Print(sum)
}


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

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

	int A,B;
	cin>>A>>B;

	cout<<A * B<<endl;		

	return 0;
}

Measured memory_bytes: 3652