akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, X;
	cin >> N >> X;
	int S[200];
	rep(i, N) cin >> S[i];
	sort(S, S + N);

	int L[200];
	rep(i, N) L[i] = lower_bound(S, S + N, S[i]) - S;

	ll mod = 1e9 + 7;
	ll M[201][201] = {};
	rep(i, N + 1) {
		M[i][0] = 1;
		rep1(j, i) M[i][j] = M[i][j - 1] * (i - j + 1) % mod;
	}

	ll dp[201][50001] = {};
	dp[N][50000] = 1;
	for (int i = N; i > 0; i--) {
		if (dp[i][50000]) {
			rep(j, i) {
				if (X > S[j]) dp[L[j]][X % S[j]] = (dp[L[j]][X % S[j]] + dp[i][50000] * M[i - 1][i - L[j] - 1]) % mod;
				else dp[L[j]][50000] = (dp[L[j]][50000] + dp[i][50000] * M[i - 1][i - L[j] - 1]) % mod;
			}
		}
		for (int k = 0; k < 50000; k++) {
			if (dp[i][k]) {
				rep(j, i) {
					dp[L[j]][k % S[j]] = (dp[L[j]][k % S[j]] + dp[i][k] * M[i - 1][i - L[j] - 1]) % mod;
				}
			}
		}
	}

	ll kotae = dp[0][50000] * X % mod;
	for (int k = 0; k < 50000; k++) {
		kotae += dp[0][k] * k;
		kotae %= mod;
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 79104
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int[] a = new int[n+1];
        int[] b = new int[n];
        for(int i = 0;i<a.length;i++) {
            a[i] = stdIn.nextInt();
        }
        for(int i = 0;i<b.length;i++) {
            b[i] = stdIn.nextInt();
        }
        long count = 0;
        for(int i = 0;i<b.length;i++) {
            if(a[i]>=b[i]) {
                count += b[i];
                a[i] -= b[i];
                b[i]  = 0;
            } else {
                count += a[i];
                b[i] -= a[i];
                a[i] = 0;
            }
            if(a[i+1]>=b[i]) {
                count += b[i];
                a[i+1] -= b[i];
                b[i] = 0;
            } else {
                count += a[i+1];
                b[i] -=a[i+1];
                a[i+1] = 0;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 82712
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

using namespace std;


void output(vector<int> & V);
void input(vector<int> & V);


int main()
{
    vector<int> V, U;
    input(V);
    input(U);

    //法1
    // bool result = true;
    // vector<int>::iterator it = U.begin();
    // while (it != U.end())
    // {
    //     if(!binary_search(V.begin(), V.end(), *it))
    //         result = false;
    //     it++;
    // }
    // cout << result << endl;

    //法2
    cout << includes(V.begin(), V.end(), U.begin(), U.end()) << endl;

}

void input(vector<int> & V)
{
    int n;
    cin >> n;

    int a;
    while (n--)
    {
        cin >> a;
        V.push_back(a);
    }
}



Measured memory_bytes: 5184
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int n;
vector<int> a;
int dp[3010][3010];
bool vis[3010][3010];

int solve(int p, int q)
{
    if (vis[p][q])
        return dp[p][q];
    vis[p][q] = true;
    bool turn = (n + q - p) & 1;
    if (p == q)
    {
        if (turn)
            return dp[p][q] = a[p];
        else
            return dp[p][q] = -a[p];
    }
    if (turn)
        dp[p][q] = max(solve(p + 1, q) + a[p], solve(p, q - 1) + a[q]);
    else
        dp[p][q] = min(solve(p + 1, q) - a[p], solve(p, q - 1) - a[q]);
    return dp[p][q];
}

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

    cin >> n;
    a.resize(n);
    rep(i, n) cin >> a[i];
    cout << solve(0, n - 1) << endl;
}

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

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string S;
	int l;
	char tmp;

	cin >> S;
	l = S.size();

	if(l == 3) {
		tmp = S.at(0);
		S.at(0) = S.at(2);
		S.at(2) = tmp;
	}

	cout << S << endl;

}

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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
const int N = 1e5+5;

ll n , k , gc[N] , mod=1e9+7 , ans;

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

ll solve(ll num)
{
    ll tmp = fp(k/num,n); //3add el arkam elee divisble by num
    gc[num] = tmp;
    for(int i=num*2; i<=k; i+=num)
    {
        gc[num] -= gc[i];
        gc[num] = (gc[num]+mod)%mod;
    }
    return (gc[num]*num)%mod;
}

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

    cin >> n >> k;

    for(int i=k; i>0; i--)
    {
        ans += solve(i);
        ans %= mod;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 4396
/**
 *    author:  Baibhav Kumar
 *    created: 24.07.2020 19:00:00      
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
	long long n;
	cin >> n;
 	long long rs = 100 , step = 0;
	while (rs < n) {
		rs += rs / 100;
		step++;
	}
	cout << step << endl;
}


Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(" ");
        var K = int.Parse(input[0]);
        var N = int.Parse(input[1]);
        var A = new List<int>();
        var line = Console.ReadLine().Split(" ");
        for(int i = 0; i < N; i++)
        {
            A.Add(int.Parse(line[i]));
        }

        var min = K - (K - A[N - 1] + A[0]);
        for(int i = 0; i < N - 1; i++)
        {
            var distance = K - (A[i + 1] - A[i]);
            if (min > distance) min = distance;
        }

        Console.WriteLine(min);
    }
}


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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> wa(n,0);
    vector<bool> ac(n,false);

    string s;
    int p;

    int ans[2] = {};

    for(int i = 0; i < m; ++i){
        cin >> p >> s;

        if(ac[p-1]) continue;

        if(s == "AC"){
            ac[p - 1] = true;
            ans[0]++;
            ans[1] += wa[p-1];
        }

        if(s == "WA"){
            wa[p-1]++;
        }
    }

    cout << ans[0] << " " << ans[1] << endl;
}

Measured memory_bytes: 640
while True:
    name,type = map(str, raw_input().split())
    ans = ""
    if (type == 'X'):
        break
    names = []
    if (name.find("_") != -1):
        names = name.split("_")
    elif (name[0].islower() == True):
        tmp = name[0]
        for i in range(1, len(name)):
            if (name[i].isupper() == True):
                names.append(tmp)
                tmp = name[i]
            else:
                tmp += name[i]
        if (len(tmp) > 0):
            names.append(tmp)
    else:
        tmp = name[0]
        for i in range(1, len(name)):
            if (name[i].isupper() == True):
                names.append(tmp)
                tmp = name[i]
            else:
                tmp += name[i]
        if (len(tmp) > 0):
            names.append(tmp)
    # print names
    if (type == "U"):
        for x in names:
            ans += x[0].upper()
            ans += x[1:].lower()
    elif (type == "L"):
        cnt = 0
        for x in names:
            if (cnt == 0):
                ans += x.lower()
            else:
                ans += x[0].upper()
                ans += x[1:].lower()
            cnt += 1
    else:
        ans = "_".join(names)
        ans = ans.lower()
    print ans

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

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

//#define int long long
#define ll long long

ll INF = (1LL << 60);
int mod = 998244353;
using P = pair<ll, ll>;

signed main() {
	int a, b; cin >> a >> b;
	int sum = a + b;
	if (sum % 2 == 0)cout << sum / 2 << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}



Measured memory_bytes: 3560
N=int(input())
A=[0 for i in range(N)]
A=input().split()
for i in range(N):
    A[i]=(int)(A[i])
for i in range(N):
    v=A[i]
    j=i-1
    while j>=0 and A[j]>v:
        A[j+1]=A[j]
        j=j-1
        A[j+1]=v
    for i in range(N):
        if i!=N-1:
            print(A[i],end=" ")
        if i==N-1:
            print(A[i])



Measured memory_bytes: 5984
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main() {
	LL N;
	cin >> N;
	cout << (N - 2) * 180 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
 
using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    vector<double> p(n);
    rep(i, n) cin >> p[i];
    double dp[n + 1][n + 1];
    rep(i, n + 1)rep(j, n + 1) dp[i][j] = 0;
    dp[0][0] = 1;

    _rep(i, 1, n + 1)rep(j, i + 1){
        if(j > 0) dp[i][j] = dp[i - 1][j] * (1 - p[i - 1]) + dp[i - 1][j - 1] * p[i - 1];
        else dp[i][j] = dp[i - 1][j] * (1 - p[i - 1]);
    }

    double ans = 0;
    _rep(i, n / 2 + 1, n + 1) ans += dp[n][i];
    cout << setprecision(15) << ans << endl;
}

Measured memory_bytes: 74176
#include<cstdio>
using namespace std;
int a,b;
int main(){
    scanf("%d%d",&a,&b);
    if(a>0)puts("Positive");               
    else if(b>=0)puts("Zero");             
    else if((a&1)^(b&1))puts("Positive"); 
    else puts("Negative");
    return 0;
}

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

int main(void) {
    int M, D;
    cin >> M >> D;
    int ans = 0;
    for (int m = 1; m <= M; m++) {
        for (int d = 1; d <= D; d++) {
            int d1 = d % 10;
            int d10 = d / 10;
            if (d1 >= 2 && d10 >= 2 && d1 * d10 == m) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
	int n, a[111];

	scanf("%d", &n);

	for(int i = 0; i < n; i++) scanf("%d", a + i);

	int ans = 1e9;

	for(int j = 0; j <= 100; j++) {
		int tmp = 0;
		for(int i = 0; i < n; i++) {
			tmp += (a[i] - j) * (a[i] - j);
		}
		ans = min(ans, tmp);
	}

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


Measured memory_bytes: 256
x=int(input())

if x==2:
    print(2)
    exit()

if x%2==0:x+=1

while True:
    
    k=1

    while True:
        if x%(2*k+1)==0:
            break
        if x**(1/2)<2*k+1:
            print(x)
            exit()

        k+=1
    
    x+=2

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

int main(){
	int n;cin>>n;
	deque<int> dq;
	bool flag=1;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		if(flag) dq.push_back(x);
		else dq.push_front(x);
		flag=!flag;
	}
	if(flag){
		cout<<dq.front();
		dq.pop_front();
		while(!dq.empty()){
			cout<<' '<<dq.front();
			dq.pop_front();
		}
		cout<<'\n';
	}else{
		cout<<dq.back();
		dq.pop_back();
		while(!dq.empty()){
			cout<<' '<<dq.back();
			dq.pop_back();
		}
		cout<<'\n';
	}
	return 0;
}

Measured memory_bytes: 2944
#include<iostream>
using namespace std;
#define MAX 2000000

int h, A[MAX+1];

void maxHeapify(int i){
    int l, r , largest;
    l = i *2;
    r = i *2+1;
    if(l <= h && A[l]> A[i]){
        largest = l;
    }else{
        largest = i;
    }
    if(r <= h && A[largest] < A[r]){
        largest = r;
    }
    if ( largest != i){
        swap(A[i],A[largest]);
        maxHeapify(largest);
    }
}

int main(){
    cin >> h;

    for(int i=1;i<=h;i++) cin >> A[i];

    for(int i = h/2;i>=1;i--)maxHeapify(i);

    for(int i=1;i<=h;i++){
        cout << " " << A[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 5032
#include<iostream>
using namespace std;
#define ll long long
#define pb push_back
ll dp[405][405];
int n;
ll cs(ll arr[],int x,int y,int len){
    if(len==1)
        return 0;
    if(len==2)
        return arr[x]+arr[(x+1)%n];
    // if(dp[x][y]!=0)
    //     return dp[x][y];
    ll m=1000000000000000000,sum=0;
    for(int i=0;i<len-1;i++){
        sum+=(arr[(x+i)%n]);
        ll temp=dp[x][(x+i)%n]+dp[(x+i+1)%n][y];
        if(m>temp)
            m=temp;
    }
    sum+=arr[(x+len-1)%n];
    dp[x][y]=m+sum;
    return dp[x][y];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    while(t--){
        cin>>n;
        // for(int i=0;i<=n;i++){
        //     for(int j=0;j<=n;j++){
        //         dp[i][j]=0;
        //     }
        // }
        ll arr[n],ans=1000000000000000000;
        for(int i=0;i<n;i++){
            cin>>arr[i];
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
				if(i+j>=n)
                  continue;
                dp[j][(i+j)%n]=cs(arr,j,(i+j)%n,i+1);
                if(i==n-1){
                    if(ans>dp[j][(j+n-1)%n])
                        ans=dp[j][(j+n-1)%n];
                }
            }
        }
        
        cout<<ans<<"\n";
    }
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;


int main() {
  int N;
  string S;
  cin >> N >> S;
  int ans=0;

  rep(i,N-2){
    if(S[i]=='A'){
      if(S[i+1]=='B'){
        if(S[i+2]=='C')ans++;
      }
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int num[101];
vector<int> G[101];
int n,m,K;
int mem[1<<16],used[1<<16];
int dfs(int bit){
  if(bit == 0) return 0;
  if(used[bit]++) return mem[bit];
  int &res = mem[bit] = 1e9;
  for(int k=0;k<K;k++){  
    int nbit = 0;
    for(int i=0;i<n;i++){
      int nx = G[i][k];
      if(num[i]<0||num[nx]<0||!(bit>>num[i]&1))continue;
      nbit |= (1<<num[nx]);
    }
    res = min(res,1+dfs(nbit));
  }
  return res;
}

int main(){

  cin>>n>>m>>K;
  memset(num,-1,sizeof(num));
  for(int i=0,a;i<m;i++)cin>>a,num[a-1]=i;
  
  for(int i=0;i<n;i++){
    G[i].resize(K);
    for(int j=0;j<K;j++)cin>>G[i][j],G[i][j]--;
  }
  cout<<dfs((1<<m)-1)<<endl;
  return 0;
}

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

int main(){
	int N, A;
	int count;
	int x = 100;

	cin >> N;

	for(int i=0;i<N;i++){
		cin >> A;
		count = 0;
		while(A%2 == 0){
			A /= 2;
			count++;
		}
		if(count < x) x = count;
	}
	cout << x << endl;
}

Measured memory_bytes: 256
//
// Created by kuribohkute on 20/04/2019.
//
#include <unordered_map>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;
#define mp make_pair
#define X first
#define Y second

int main () {
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++) {
        if (s[i] == s[i + 1]) {
            cout << "Bad";
            return 0;
        }
    }
    cout << "Good";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  int n;cin >> n;
  string s;cin >> s;

  vector<int> r, g;
  ll b = 0;
  rep(i,n) {
    if(s[i] == 'R') r.push_back(i+1);
    else if(s[i] == 'G') g.push_back(i+1);
    else b++;
  }

  ll res = 0;
  rep(i,r.size() ) {
    rep(j,g.size()) {
      int rr = r[i];
      int gg = g[j];
      ll bb = b;
      if(rr < gg) {
	int index;
	if( (rr + gg) % 2 == 0) {	
	  index = (rr + gg) / 2;	
	  if(rr < index && index < gg) {
	    if(s[index-1] == 'B') bb--;
	  }
	}
	index = 2*gg - rr;
	if(gg < index && index <= n) {
	  if(s[index-1] == 'B') bb--;
	}
	index = 2*rr - gg;	
	if(1 <= index && index < gg) {
	  if(s[index-1] == 'B') bb--;
	}	
      }
      else {
	int index;
	if( (rr + gg) % 2 == 0) {	
	  index = (rr + gg) / 2;	
	  if(gg < index && index < rr) {
	    if(s[index-1] == 'B') bb--;
	  }
	}
	index = 2*rr - gg;
	if(rr < index && index <= n) {
	  if(s[index-1] == 'B') bb--;
	}
	index = 2*gg - rr;	
	if(1 <= index && index < rr) {
	  if(s[index-1] == 'B') bb--;
	}	
      }
      res += max((ll)0,bb);      
    }
  }
  cout << res << "\n";
  return 0;
}


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

// 約数の列挙
vector<int> divisor(int n) {
    vector<int> res;
    for (int i=1;i*i<=n;++i) {
        if (n%i == 0) {
            res.push_back(i);
            if (i != n/i) res.push_back(n/i);
        }
    }
    return res;
}

bool flag[101010];
bool ok[101010];
ll sum[101010];


int main() {

    for (ll i=2; i<=100000; ++i) {
        flag[i] = true;
        vector<int> tmp = divisor(i);
        ll ret = 1;
        for (int p : tmp) {
            if (p == i) continue;
            ret *= (ll)p;
            if (ret >= 2*i) {
                ok[i] = true;
                break;
            }
        }

        if (ret >= 2*i) {
            ok[i] = true;
        }
    }

    for (int i=2; i<=100000; ++i) {
        sum[i] += sum[i-1] + ok[i];
    }

    int q;
    cin >> q;

    rep(i, q) {
        int n;
        cin >> n;
        cout << sum[n] << endl;
    }

    return 0;
}



Measured memory_bytes: 4132
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
vector<char>s(3);
int counter=0;
for(int i=0;i<3;i++){
    cin>>s[i];
    if(s[i]=='1')counter++;
}
cout<<counter;
  return 0;
}


Measured memory_bytes: 256
import math

s = input()
s += "R"
n = len(s)
ans = [0] * n
r_count = 0
l_count = 0
state = "r"
for i in range(n):
    if state == "r":
        if s[i] == "R":
            r_count += 1
        else:
            l_count += 1
            r_idx = i-1
            l_idx = i
            r_count -= 1
            ans[r_idx] += r_count // 2 + 1
            ans[l_idx] += math.ceil(r_count / 2) + 1
            r_count = 0
            state = "l"
    else:
        if s[i] == "L":
            l_count += 1
        else:
            r_count += 1
            l_count -= 1
            ans[r_idx] += math.ceil(l_count / 2)
            ans[l_idx] += l_count // 2
            l_count = 0
            state = "r"
            
ans = list(map(str, ans[:-1]))
print(" ".join(ans))

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

using namespace std;

int main()
{
   cin.tie(0);
   cin.sync_with_stdio(0);
   long long n;
   cin>>n;
   int  maxi = INT_MIN;
   long long des = sqrt(n);

   for(int i = 1 ;i <=des ;i++){
    if(n%i==0){
        maxi = max(maxi , i);
    }
   }

   if(maxi ==1) cout<< n-1<<"\n";
   else  cout<<((n/maxi)-1)+maxi-1<<"\n";
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns, MagicHash #-}
import Control.Monad
import Control.Applicative
import Data.List
import Data.Maybe
import Data.Bits
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
import Data.Vector.Unboxed ((!))
import Data.Tuple
import Data.Ord (Down(..))
import Data.Coerce
                                 
query :: Int -> [(Int,Int)] -> Int
query n =
  snd
  . V.ifoldl' (\(x,cnt) a b -> let x' = min b x
                               in if x'-1 == a
                                  then (n,cnt+1)
                                  else (x',cnt)) (n,0)
  . V.init . V.accum min (V.replicate n n)
     
main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine
  ls <- map ((\(x:y:_) -> (x-1,y-1)) . unfoldr (B.readInt . B.dropWhile (== ' ')))
          . B.lines
        <$> B.getContents
  putStrLn $ show $ query n ls


Measured memory_bytes: 5116
using System;
using System.Collections.Generic;
using System.Linq;

class Procon {
    public Procon () { }
    static void Main (string[] agrs) {
        new Procon ().Do ();
    }

    Scanner cin;
    public void Do () {
        cin = new Scanner ();

        int A = cin.nextInt ();
        int B = cin.nextInt ();

        Console.WriteLine (Math.Max (Math.Max (A + B, A - B), A * B));
    }
}

class Scanner {
    string[] s;
    int i;
    int max_i;

    public Scanner () {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString () {
        if (i >= s.Length) {
            s = Console.ReadLine ().Split (' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0) {
                return "";
            }
            return s[i++];
        } else {
            return s[i++];
        }
    }

    public int nextInt () {
        return int.Parse (nextString ());
    }

    public long nextLong () {
        return long.Parse (nextString ());
    }

    public double nextDouble () {
        return double.Parse (nextString ());
    }

    public string[] arrayString () {
        return Console.ReadLine ().Split (' ');
    }

    public int[] arrayInt () {
        string[] str = Console.ReadLine ().Split (' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++) {
            array[i] = int.Parse (str[i]);
        }
        return array;
    }

    public long[] arrayLong () {
        string[] str = Console.ReadLine ().Split (' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++) {
            array[i] = long.Parse (str[i]);
        }
        return array;
    }

    public double[] arrayDouble () {
        string[] str = Console.ReadLine ().Split (' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++) {
            array[i] = double.Parse (str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main(){
  while(true){
  int N;
  int n;
  int d;
  cin>>N;
  if(N==0){
    break;
  }
  int l=0,r=0,u=0,b=0;
  map<int,pair<int,int>> mp;
  mp[0]={0,0};
  for(int i=1;i<N;i++){
    cin>>n>>d;
    int x=mp[n].first;
    int y=mp[n].second;
     if(d==0){
       mp[i]={x-1,y};
       l=min(l,x-1);
     }
     if(d==1){
       mp[i]={x,y-1};
       b=min(b,y-1);
     }
     if(d==2){
       mp[i]={x+1,y};
       r=max(r,x+1);
     }
     if(d==3){
       mp[i]={x,y+1};
       u=max(u,y+1);
     }
   }
   cout<<r-l+1<<" "<<u-b+1<<endl;
 }
     return 0;
}



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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = 0; i < (a); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  map<ll, int> a;
  rep(i, n) {
    ll b;
    cin >> b;
    a[b]++;
  }
  int ans = 0;
  for(auto i = a.begin(); i != a.end(); ++i) {
    if(i->second & 1) ans++;
  }
  out(ans);
  return 0;
}


Measured memory_bytes: 6528
type tree = Nil | Node of int * tree * tree

let create () = Nil

let insert x t =
  let rec doit = function
    | Nil -> Node (x, Nil, Nil)
    | Node (y, l, r) ->
      if x < y then Node (y, doit l, r)
      else Node (y, l, doit r) in
  doit t

let preorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> f x; doit l; doit r in
  doit t

let inorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> doit l; f x; doit r in
  doit t

let print t =
  inorder (fun e -> print_string " "; print_int e) t;
  print_newline ();
  preorder (fun e -> print_string " "; print_int e) t;
  print_newline ()

let find x t =
  let rec doit = function
    | Nil -> false
    | Node (y, _, _) when x = y -> true
    | Node (y, l, _) when x < y -> doit l
    | Node (_, _, r) -> doit r in
  doit t

let delete x t =
  let rec min_val = function
    | Nil -> assert false
    | Node (x, Nil, _) -> x
    | Node (_, l, _) -> min_val l in
  let rec remove_min = function
    | Nil -> assert false
    | Node (_, Nil, r) -> r
    | Node (x, l, r) -> Node (x, remove_min l, r) in
  let rec doit = function
    | Nil -> assert false
    | Node (y, l, r) ->
      if x = y then
        if l = Nil then r
        else if r = Nil then l
        else Node (min_val r, l, remove_min r)
      else if x < y then Node (y, doit l, r)
      else Node (y, l, doit r) in
  doit t

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let m = read_int () in
  let t = ref (create ()) in
  for _ = 0 to m - 1 do
    match read_line () |> split_on_char ' ' with
    | ["insert"; n] -> t := insert (int_of_string n) !t
    | ["find"; n] -> print_endline (if find (int_of_string n) !t then "yes" else "no")
    | ["delete"; n] -> t := delete (int_of_string n) !t
    | _ -> print !t
  done

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

using namespace std;


int main()
{
   string str,str2;
   cin >> str >> str2;
   int size = str.size();
   int temp = 0;
   for(int i=0;i<size;i++)
   {
        if(str[i]!=str2[i])
        {
             temp+=1;
        }
   }
   cout << temp;
return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <cstdio>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10
const int MAX_N =10000000;


bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

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

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

ll gcd(ll a,ll b) { return b ? gcd(b, a%b) : a; }

ll func(ll a,ll b,ll& ans_x,ll& ans_y){
    if(b == 0){
        ans_x = 1;
        ans_y = 0;
        return a;
    }else{
        ll ret = func(b,(a%b),ans_y,ans_x);
        ans_y -= (a/b)*ans_x;
        return ret;
    }
}

ll par[MAX_N],ranking[MAX_N];

void init(ll n){
    rep(i,n){
        par[i]=i;
        ranking[i]=0;
    }
}

ll find(ll x){
    if(par[x]==x) return x;
    else return par[x]=find(par[x]);
}

void unite(ll x,ll y){
    x=find(x);
    y=find(y);
    if(x==y) return;
    
    if(ranking[x]<ranking[y]) par[x]=y;
    else{
        par[y]=x;
        if(ranking[x]==ranking[y]) ranking[x]++;
    }
}

bool same(ll x,ll y){
    return find(x)==find(y);
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll d=0;
    rep(i,n){
        if(a[i]%2!=0 && (i+1)%2!=0) d++;
    }
    cout<<d<<endl;
    return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>

int main(int argc, char const *argv[]) {
  int n,m,l,i,j,k;
  int a[100][100]={0},b[100][100]={0};
  long long int c[100][100]={0};
  scanf("%d %d %d", &n, &m, &l);
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  //printf("\n");
  for (i = 0; i < m; i++) {
    for (j = 0; j < l; j++) {
      scanf("%d", &b[i][j]);
    }
  }
  //printf("\n");
  for (i = 0; i < n; i++) {
    for (j = 0; j < l; j++) {
      for (k = 0; k < m; k++) {
          c[i][j]+=a[i][k]*b[k][j];
      }
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < l; j++) {
      printf("%lld", c[i][j]);
      if (j < l-1) {
        printf(" ");
      }
    }
    printf("\n");
  }
  return 0;
}

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

int main(){

int tate, yoko;
cin >> tate >> yoko;

int a[tate][yoko] = {};
int b[yoko] = {};
int c[tate] = {};

    for(int i=0; i<tate ;i++){
        for(int j=0;j<yoko;j++){
                cin >> a[i][j];
        }
    }

    for(int j=0;j<yoko;j++){
        cin >> b[j];
    }

    for(int i=0; i<tate; i++){
        for(int j=0;j<yoko;j++){
           c[i] += a[i][j] * b[j];
        }
    }

   for (int i = 0; i<tate ; i++){
    cout << c[i] <<endl;
    }
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+6;
ll a[N],f[N];
int n;
ll k;

bool cmp(ll x,ll y)
{
    return x>y;
}

bool check(ll x)
{
    ll tmp=0;
    for (int i=1;i<=n;i++)
    {
        ll t=x/f[i];
        tmp+=max((a[i]-t),0ll);
    }

   // cout<<x<<" "<<tmp<<endl;
    if (tmp<=k) return 1;
    return 0;
}
int main(){
    scanf("%d%lld",&n,&k);

    for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
    for (int i=1;i<=n;i++) scanf("%lld",&f[i]);

    sort(a+1,a+n+1,cmp);
    sort(f+1,f+n+1);

    ll l=0,r=1e18;
    ll ans=0;
    while (l<=r)
    {
        ll mid=(l+r)/2;

        if (check(mid))
        {
            r=mid-1;
            //cout<<mid<<endl;
            ans=mid;
        }
        else l=mid+1;
    }

    printf("%lld\n",ans);
}


Measured memory_bytes: 3328
def culc(x, y):
    if x > y:
        n_large = x
        n_small = y
    else:
        n_large = y
        n_small = x

    while True:
        # print("L:%d, S:%d" % (n_large, n_small))
        n_remainder = n_large % n_small
        if n_remainder == 0: break
        n_large = n_small
        n_small = n_remainder

    return n_small

if __name__ == "__main__":

    num = input().split(" ")
    x = int(num[0])
    y = int(num[1])

    print(culc(x, y))


Measured memory_bytes: 5600
from numpy import argsort
n, m = map(int, input().split())
a=[]
b=[]
for i in range(n):
    ab=list(map(int, input().split()))
    a.append(ab[0])
    b.append(ab[1])

total_cost = 0
order = argsort(a)
for i in range(len(a)):
    new_shop = order[i]
    new_drinks = b[new_shop]
    if m-new_drinks>0:
        total_cost = total_cost + a[new_shop] * b[new_shop]
        m=m-new_drinks
    else:
        total_cost = total_cost + a[new_shop] * m
        break
print(total_cost)

Measured memory_bytes: 21596
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef vector <int> vi;
#define REP(i,n) for (int i=0; i<n; i++)
#define ALL(x) x.begin(), x.end()
#define ADD(a,b,c) "("+ a +" "+ c +" "+ b +")"

string i2s(int n){
  stringstream ss;
  ss << n;
  return ss.str();
}

int op(int x, int y, int mode){
	switch (mode){
	case 0:
		return x+y;
	case 1:
		return x-y;
	case 2:
		return x*y;
	}
}

string check(vi x, int n){
	int x0=x[0], x1=x[1], x2=x[2], x3=x[3];
	string s0=i2s(x0), s1=i2s(x1), s2=i2s(x2), s3=i2s(x3);
	string ops="+-*", eq1, eq2;
	int n1 = ops.size();
	REP(i1, n1){
		int a1 = op(x0, x1, i1);
		eq1 = ADD(s0, s1, ops[i1]);
		REP(i2, n1){
			int a2 = op(a1, x2, i2);
			eq2 = ADD(eq1, s2, ops[i2]);
			REP(i3, n1)
				if (op(a2, x3, i3)==n) return ADD(eq2, s3, ops[i3]);
			a2 = op(x2, x3, i2);
			eq2 = ADD(s2, s3, ops[i2]);
			REP(i3,n1)
				if (op(a1, a2, i3)==n) return ADD(eq1,eq2,ops[i3]);
		}
	}
	return "";
}

vi getx(){
	string line;
	getline(cin,line);
	istringstream is(line);
	vi x;
	int tmp;
	bool f = true;
	while(is>>tmp){
		if (tmp!=0) f = false;
		x.push_back(tmp);
	}
	if (f) x.clear();
	return x;
}

int f0041(){
	int n=10;
	while (true){
		vi x = getx();
		if (x.empty()) return 0;

		sort(ALL(x));
		bool f = true;
		do{
			string s = check(x, n);
			if (s != ""){
				cout<<s<<endl;
				f = false;
				break;
			}
		}while (next_permutation(ALL(x)));
		if (f) cout<<"0"<<endl;
	}
}

int main(void){
	f0041();
}

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

int main(){
    string s;
    int sum;
    while(1){
        
        sum = 0;
        cin >> s;
        for (int i=0;i<s.length();i++){
            sum += s[i] - '0';
        }
        if(s[0]=='0') break;
        cout << sum << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3216
import math
m = int(input())
prime = []
for j in range(m):
    n = int(input())
    pri  = []
    
    i = 2
    while i <= math.sqrt(n):
        while n % i == 0:
            pri.append(i)
            n//=i
        i+=1
    
    if n != 1:
        pri.append(n)
        
    if len(pri) == 1:
        prime.append(pri[0])
    
print(len(prime))


Measured memory_bytes: 5684
#include<bits/stdc++.h>
using namespace std;
int n,a[100010];
void f(int p){
    int dx=0,dy=a[p]-p;
    for(int i = p+1;i<=n&&a[i]==p;++i){
        ++dx;
    }
    if((dx&1)||(dy&1))puts("First");
    else puts("Second");
}
int main()
{
    // freopen("in.txt","r",stdin);
    cin>>n;
    for(int i = 1;i <= n;++i)scanf("%d",&a[i]);
    if(n==1){
        if(a[1]&1)puts("Second");
        else puts("First");
        return 0;
    }
    sort(a+1,a+1+n,greater<int>());
    int p = 1;
    for(int i = 1;i <= n;++i){
        if(a[i+1]<i+1){
            p=i;
            break;
        }
    }
    f(p);
    return 0;
}


Measured memory_bytes: 640
w, h = map(int, input().split())

w_cost = [int(input()) for i in range(w)]
h_cost = [int(input()) for i in range(h)]

w_cost = sorted(w_cost, reverse = True)
h_cost = sorted(h_cost, reverse = True)
w_cnt = 0
h_cnt = 0
ans = 0

while True:
    if not w_cost:
        ans += sum(h_cost)   
        break
    elif not h_cost:
        ans += sum(w_cost)
        break
    elif w_cost[-1] < h_cost[-1]:
        ans += w_cost[-1] * (h+1-h_cnt)
        w_cnt += 1
        del w_cost[-1]
    else:
        ans += h_cost[-1] * (w+1-w_cnt)
        h_cnt += 1
        del h_cost[-1]
        
print(ans)

Measured memory_bytes: 12248
import java.util.Scanner;

public class Main {
	public static void main(String[] a) {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n=sc.nextInt();
			if(n==0)break;
			int A[]=new int[n];
			double sum=0;
			for(int i=0;i<n;i++) {
			A[i]=sc.nextInt();
			sum+=A[i];
			}
			sum/=n;
			double ans=0;
			for(int i=0;i<n;i++) {
				ans+=Math.pow(A[i]-sum, 2);
			}
			ans/=n;
			System.out.println(Math.sqrt(ans));
		}
	}
}


Measured memory_bytes: 31168
#include <iostream>

using namespace std;

int main()
{
    int w, n;
    char comma;
    int a, b;
    int ans[32];
    
    cin >> w >> n;
    for (int i = 1; i <= w; i++)
        ans[i] = i;

    for (int i = 0; i < n; i++) {
        cin >> a >> comma >> b;
        int tmp = ans[a];
        ans[a] = ans[b];
        ans[b] = tmp;
    }

    for (int i = 1; i <= w; i++)
        cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 1160
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	listB := make([]int, n-1)
	for i := 0; i < n-1; i++ {
		fmt.Scan(&listB[i])
	}
	result := 0
	result += listB[0]
	for i := 1; i < n-1; i++ {
		if listB[i-1] < listB[i] {
			result += listB[i-1]
		} else {
			result += listB[i]
		}
	}
	result += listB[n-2]
	fmt.Println(result)

}


Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))
t = True
ans = 0
while t:
    for i in range(n):
        if a[i] % 2 == 1:
            t = False
            break
        else:
            a[i] /= 2
    if t:
        ans += 1
print(ans)



Measured memory_bytes: 9132
import java.util.Scanner;
public class Main
{
   public static void main(String[] args)
   {
      Scanner scanner = new Scanner(System.in);

      int animals = scanner.nextInt();
      int legs = scanner.nextInt();
      
      boolean possible = false;
      
      if (legs % 2 == 0)
      {
         if (4 * animals >= legs)
         {
            possible = true;
         }
      }
      
      if (animals > legs / 2)
      {
         possible = false;
      }
      
      if (possible)
      {
         System.out.println("Yes");
      }
      
      else
      {
         System.out.println("No");
      }
   }
}
   
   

Measured memory_bytes: 35724
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

template<long long Mod>
struct mint{
    long long x;
    mint(long long x=0) :x((x% Mod+Mod)%Mod){}

    mint operator-() const { return mint(-x); }

    mint& operator+=(const mint a) {
        if((x += a.x) >= Mod) x -= Mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if((x += Mod-a.x) >= Mod) x -= Mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= Mod;
        return *this;
    }

    mint operator^(long long t) const {
        mint ret(1);
        mint a = *this;
        while(t){
            if(t&1){
                ret *= a;
            }
            a *= a;
            t >>= 1;
        }
        return ret;
    }
    mint inv() const { return *this ^ (Mod-2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }

    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint operator/(const mint a) const { return mint(*this) /= a; }

    friend istream& operator>>(istream& is, mint& a) { return is >> a.x; }
    friend ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
};

int N, C;
int A[400], B[400];

bool visS[401][401] ={};
mint<MOD> memoS[401][401];
mint<MOD> sum(int x, int k){
    if(x == 0) return 0;
    if(visS[x][k]) return memoS[x][k];
    visS[x][k] = true;
    return memoS[x][k] = (mint<MOD>(x)^k) + sum(x-1, k);
}

bool vis[401][401] ={};
mint<MOD> memo[401][401];
mint<MOD> solve(int n, int k){
    if(n == N) return 1;
    if(vis[n][k]) return memo[n][k];
    vis[n][k] = true;
    mint<MOD> ret = 0;
    /*rep(j, k+1){
        for(int i=A[n]; i<=B[n]; i++){
            ret += (mint<MOD>(i)^j) * solve(n+1, k-j);
        }
    }*/
    rep(j, k+1){
        ret += (sum(B[n], j)-sum(A[n]-1, j)) * solve(n+1, k-j);
    }
    return memo[n][k] = ret;
}

signed main(){
    cin >> N >> C;
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    cout << solve(0, C) - solve(0, C-1) << endl;
}

Measured memory_bytes: 6476
#include<stdio.h>

int position(int a[], int start, int end)
{
	int pvalue= a[end], i, pindex,temp;
	for(i=pindex=start; i<end; i++)
	{
		if(a[i]<pvalue)
		{
			temp = a[i];
			a[i] = a[pindex];
			a[pindex] = temp;
			pindex++;
		}
	}
	temp = a[i];
	a[i] = a[pindex];
	a[pindex] = temp;
	return pindex;
}

void quicksort(int a[], int start, int end)
{
	if(start>=end) return;
	int index = position(a,start, end);
	quicksort(a,start, index-1);
	quicksort(a, index+1, end);
	return;
}

int main()
{
	int n,i, a[100];
	long long two, sum;
	while(~scanf("%d", &n))
	{
		for(i=0; i<n; i++)
			scanf("%d", a+i);
		quicksort(a,0,n-1);
		sum = a[0];
		for(i=two=1; i<n; i++)
		{
			sum += two*a[i];
			two *= 2;
		}
		double fin = (double)sum/two;
		printf("%lf\n", fin);
	}
	return 0;
}

Measured memory_bytes: 504
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (100010)
#define P (1000000007)
#define M ()
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c){
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
char s[N]; int n,f[N];
int main(){
	scanf("%s",s+1),n=strlen(s+1);
	bool fl=0; for(int i=1;i<=n;i++)if(s[i]==s[i-1])fl=1;
	if(!fl){puts("1");return 0;}
	int S=0,p[3]={0,-1,-1}; f[0]=1;
	for(int i=1;i<=n;i++){
		(S+=s[i]-'a'+1)%=3;
		if(S==0&&i<n)f[i]++;
		if(p[(S+1)%3]!=-1)(f[i]+=f[p[(S+1)%3]])%=P;
		if(p[(S+2)%3]!=-1)(f[i]+=f[p[(S+2)%3]])%=P;
		p[S]=i;
	}
	printf("%d\n",f[n]);
} 

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

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()


int main() {

  string s;
  cin >> s;
  for(int i=1;i<s.size();i++){
      if(s[i-1]==s[i]){
          cout << "Bad" << endl;
          return 0;
      }
  }

  cout << "Good" << endl;
  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    int i;
    string s,u[7];
    u[0]="SUN";
    u[1]="MON";
    u[2]="TUE";
    u[3]="WED";
    u[4]="THU";
    u[5]="FRI";
    u[6]="SAT";
    cin >> s;
    for(i=0;i<7;i++){
        if(u[i]==s){
            cout << 7-i;
        }
    }




}

Measured memory_bytes: 256