akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
constexpr lint MOD = 1000000007;

int main()
{
    lint n;
    cin >> n;
    vector<lint> dp(n+1, 1);
    lint sum = 2;
    for (int i = 2; i <= n; i++)
    {
        dp[i] = (sum - dp[i - 2] + MOD) % MOD;
        sum = (sum + dp[i]) % MOD;
    }

    lint ans = 0;
    for (int i = 0; i < n-1; i++)
    {
        ans += dp[i] * (((n-1)*(n-1) + i+1) % MOD) % MOD;
        ans %= MOD;
    }
    ans = (ans + dp[n - 1] * (n - 1)) % MOD;
    ans = (ans + dp[n]) % MOD;

    cout << ans << endl;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;


vector<int>  dx = {1,-1,0,0};
vector<int>  dy = {0,0,1,-1};


int main() {

	int k; cin >> k;	
	int t; cin >> t;

	vector<int> a(t);
	int mx = 0;
	int maxi = 0; 
	for (int i = 0; i < t; i++) {
		cin >> a[i];
		if (mx < a[i]) {
			mx = a[i];
			maxi = i;
		}
	}

	
	for (int i = 0; i < t; i++) {
		if (i != maxi) {
			mx -= a[i];
		}
	}
	if (mx <= 0) {
		cout << 0 << endl;	
	}else {
		cout << mx - 1 << endl;
	}
		
	return 0;
}


Measured memory_bytes: 256
from scipy.sparse.csgraph import floyd_warshall
from copy import deepcopy

def check(a):
    dist = floyd_warshall(a)

    for i in dist:
        if float("inf") in i:
            return True
    return False

N,M = map(int,input().split())

edge = [[float("inf") for i in range(N)] for j in range(N)]


ab = []
for _ in range(M):
    a,b = map(int,input().split())
    ab.append((a,b))
    edge[a-1][b-1] = 1
    edge[b-1][a-1] = 1

ans = 0
for a,b in ab:
    tmp = deepcopy(edge)
    tmp[a-1][b-1] = float("inf")
    tmp[b-1][a-1] = float("inf")

    if check(tmp):
        ans += 1

print(ans)

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

typedef pair<long long , long long> P;

void solve(long long N){
    vector<P> facts;
    long long base = 2;
    long long exp = 0;
    long long n = N;
    while (base*base<=n) {
        while (n%base==0) {
            n /= base;
            exp++;
        }
        if (exp>0) {
            facts.push_back(make_pair(base, exp));
        }
        base++; exp=0;
    }
    if (n>1) {
        facts.push_back(make_pair(n,1));
    }

    if (facts.size() == 0) {
        cout << 0 << endl;
        return;
    }
    long long ans = 0;
    for (long long i=0; i<facts.size(); i++) {
        long long tmp = facts[i].second;
        long long base = 1;
        while (tmp >= base) {
            ans++;
            tmp -= base;
            base++;
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3688
#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;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, k;
    cin >> n >> k;
    ll current = 1;
    REP (i, n) {
        if (current < k) {
            current *= 2;
        } else {
            current += k;
        }
    }
    cout << current << endl;
    return 0;
}

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;





int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	ll A, V, B, W, T;

	cin >> A >> V >> B >> W >> T;

	cout << (abs(A - B) + (-V + W) * T <= 0 ? "YES\n" : "NO\n");

	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
	return 0;
}


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

using namespace std;

int main(void)
{
    int N;
    string S;
    cin >> N >> S;

    if ((int) S.length() <= N) {
        cout << S << endl;
    }
    else {
        cout << S.substr(0,N) + "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
N,M,V,P = map(int, input().split())

A = list(map(int, input().split()))


A.sort(reverse=True)
ok = P-1
ng = N 
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    curr_max = A[mid] + M

    if curr_max < A[P-1]:
        ng = mid
        continue

    cnt = 0
    # midと上位P-1位に＋Mした分
    cnt += M + (P-1) * M
    for i in range(P-1, N):
        if i == mid: continue

        cnt += min(M, max(0, curr_max - A[i]))

    if cnt >= M*V:
        ok = mid
    else:
        ng = mid

print(ok + 1)

Measured memory_bytes: 14964
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define trace(x)     cerr<<#x<<":"<<x<<endl;
#define trace2(x,y) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<endl;
#define trace3(x,y,z) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<"|"<<#z<<":"<<z<<endl;
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
const int maxn = 1e5+7;
int main(){
	fast_io;
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b && a!=c)||(a==c&&a!=b)||(b==c&&a!=b))
		cout<<"Yes";
	else cout<<"No";


	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
class Range {
    using T = long long;
    class Iterator {
        T val, step, diff;
    public:
        Iterator(T v, T s, T d): val(v), step(s), diff(d) {}
        T operator*() { return val + diff; }
        bool operator!=(const Iterator &itr) { return step > 0 ? val < itr.val : val > itr.val; }
        Iterator operator++() { val += step; return *this; }
    };
    Iterator _begin, _end;
public:
    Range(T b, T e, T s, T d): _begin(b, s, d), _end(e, s, d) {
        if (s < 0) { _begin = Iterator(e - 1, s, d); _end = Iterator(b - 1, s, d); }
    }
    Range(T b, T e, T s): Range(b, e, s, 0) {}
    Range(T b, T e): Range(b, e, 1, 0) {}
    Range(T e): Range(0, e, 1, 0) {}
    Iterator begin() { return _begin; }
    Iterator end() { return _end; }
};
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n, m, x;
    cin, n, m, x;
    vector<ll> c(n, 0);
    auto a = make_v(n, m, 0LL);
    for (ll i : Range(n)) {
        cin, c[i];
        for (ll j : Range(m)) {
            cin, a[i][j];
        }
    }
    int sz = 1 << n;
    const ll inf = 1LL << 60;
    ll ans = inf;

    for (ll i : Range(sz)) {
        vector<ll> sum(m, 0);
        ll cost = 0;
        for (ll j : Range(n)) {
            if ((i >> j) & 1) {
                for (ll k : Range(m)) {
                    sum[k] += a[j][k];
                }
                cost += c[j];
            }
        }
        bool ok = true;
        for (ll j : Range(m)) {
            ok &= sum[j] >= x;
        }
        if (ok) {
            chmin(ans, cost);
        }
    }
    if (ans == inf) ans = -1;
    print(ans);

    return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <cstdio>

using namespace std;

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

int dp[1001][(1 << 3)];
int list[1000];
int mod = 10007;

int main() {
	int n;
	cin >> n;
	getchar();
	REP(i, n) {
		char c[] = { 'J', 'O', 'I' };
		char in = getchar();
		REP(j, 3) if (in == c[j])
			list[i] = (1 << j);
	}

	dp[0][1] = 1;
	REP(i, n) {
		REP(j, 1 << 3) {
			if (!(j & list[i])) continue;
			REP(k, 1 << 3) {
				if (!(j & k)) continue;
				dp[i + 1][j] = (dp[i + 1][j] +  dp[i][k]) % mod;
			}
		}
	}

	int ans = 0;
	REP(i, 1 << 3) {
		ans = (ans + dp[n][i]) % mod;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
using namespace std;
typedef long long ll;
int main(void)
{
	ll k,a,b;
	cin>>k>>a>>b;
	ll ok=(a/k)*k;
	if(ok==a) printf("OK");
	else if(ok+k<=b) printf("OK");
	else printf("NG"); 
}

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

int main(){
    string s; cin >> s;
    if((s.at(2) == s.at(3)) && (s.at(4) == s.at(5))){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;

signed main(){
    ll n,m,x=-1,y=-1,ans=1;
    cin>>n>>m;
    vector<ll> fib(n+1,0);
    fib.at(0)=1;
    fib.at(1)=1;

    for(ll i=2;i <= n;i++)
    {
        fib.at(i)=fib.at(i-1)%mod+fib.at(i-2)%mod;
        fib.at(i)%=mod;
    }

    for(ll i=0;i < m;i++)
    {
        cin>>y;
        if(y==x+1){
            cout << 0 << endl;
            return 0;
        }
        ans*=fib.at(y-x-2);
        ans%=mod;
        x=y;
    }
    ans*=fib.at(n-y-1);
    ans%=mod;
    
    cout << ans%mod << endl;
}
//入力がない時初期値が効いてくるので、初期値はちゃんと考えて置くこと

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <math.h>
#include <numeric>
using namespace std;
int main(){
  long long int X;
  cin >> X;
  double tmp=100.;
  int count=0;
  while(tmp<X){
    tmp=floor(tmp*1.01);
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3600
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
void solve()
{
	int n,k,cnt=0;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		if (a >= k)
			cnt++;
	}
	cout << cnt;
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <ctype.h>
  
int strcmp_custom(char* s1, char* s2);
  
  
int main(int argc, const char * argv[]) {
    // insert code here...
      
    char w[11];
    char s[1000];
      
    scanf("%s",w);
      
    int count = 0;
    while(1){
        scanf("%s",s);
          
        if(strcmp(s, "END_OF_TEXT") == 0){
            break;
        }
        else if(strcmp_custom(s, w)){
            count++;
        }
          
    }
  
      
    printf("%d\n",count);
      
    return 0;
}
  
int strcmp_custom(char* s1, char* s2){
      
    int i=0;
    while(1){
          
        if(s1[i] == '\0' && s2[i] == '\0'){
            return 1;
        }
        if(s1[i] == '\0' || s2[i] == '\0'){
            return 0;
        }
        else if(toupper(s1[i]) == toupper(s2[i])){
            i++;
        }
        else{
            return 0;
        }
          
    }
  
}


Measured memory_bytes: 2028
import math
import fractions


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


def lcm(numbers):
    return reduce(lcm_base, numbers, 1)


def f(x):  # 2で割れる回数
    c = 0
    while x % 2 == 0:
        x //= 2
        c += 1
    return c


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a = list(set(a))

    # a -> a'
    for i in range(len(a)):
        if a[i] % 2 == 1:
            print(0)
            return
        a[i] //= 2

    # a' -> a''
    t = f(a[0])
    for i in range(len(a)):
        if(f(a[i]) != t):
            print(0)
            return
        a[i] //= 2**t

    l = 1
    for i in range(len(a)):
        l = lcm_base(l, a[i])
        if l > m:
            print(0)
            return

    m //= 2**t
    m //= l
    ans = (m+1)//2
    print(ans)


main()


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

using namespace std;
#define rep(j,n) for(int j=0;j<(n);j++)

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

const int mod = 998244353;
const ll MAX = 1000000000000001;
const int INF = 1001001001;

int main(int, char**)
{
    int n;
    cin >> n;

    vector<int> a(n);
    int all = 0;
    rep(i,n) {
        cin >> a[i];
        all ^= a[i];
    }
    rep(i,n) {
        int ans = a[i] ^ all;
        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
    int n;
    int j = 0;
    string s;
    //n = 1;
    //s = "z";
    cin >> n;
    cin >> s;
    for (int i = 0; i < n / 2; ++i) {
        if (s[i] == s[i + n / 2]) {
            j++;
        }
    }
    if(j == n/2 && n % 2 == 0)cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mk make_pair
#define pi pair<int, int>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;
int main()
{
   IOS;
   int X;
   cin >> X;
   if(X == 1)cout << 0;
   else cout << 1;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll d[41];
ll dp[41][2];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,K;
    cin>>N>>K;
    ll A[N];
    rep(i,0,N) cin>>A[i];
    rep(i,0,N){
        rep(j,0,41){
            if((ll(1)<<j)&A[i]){
                d[j]++;
            }
        }
    }
    rer(i,41,0){
            if(i==40){
                if(K&(ll(1)<<i)){
                    dp[i][0]=(N-d[i])<<i;
                    dp[i][1]=d[i]<<i;
                }
                else{
                    dp[i][0]=0;
                    dp[i][1]=-1e17;
                }
            }
            else{
                dp[i][0]=dp[i+1][0]+((K&(ll(1)<<i)?N-d[i]:d[i])<<i);
                if(K&(ll(1)<<i)){
                    dp[i][1]=max(dp[i+1][1]+(max(N-d[i],d[i])<<i), dp[i+1][0]+(d[i]<<i));
                }
                else dp[i][1]=dp[i+1][1]+(max(N-d[i],d[i])<<i);
            }
    }
    cout <<max(dp[0][0], dp[0][1])<<"\n";
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
using State = string::const_iterator;
State ed;
bool consume(State &begin, char expected) {
  if(begin == ed) return false;
  if(*begin == expected) {
    begin++;
    return true;
  } else {
    return false;
  }
}
int pl(State &begin, int depth);
int mul(State &begin, int depth);
int par(State &begin, int depth);
int num(State &begin);
bool ok = true;
void check(int num) {
  ok &= 0 <= num && num < 1024;
}
int pl(State &begin, int depth) {
  int num = mul(begin, depth);
  while(1) {
    if(consume(begin, '+')) {
      num += mul(begin, depth);
      check(num);
    } else if(consume(begin, '-')) {
      num -= mul(begin, depth);
      check(num);
    } else {
      return num;
    }
  }
}
int mul(State &begin, int depth) {
  int num = par(begin, depth);
  if(consume(begin, '*')) {
    num *= mul(begin, depth);
    check(num);
    return num;
  } else {
    return num;
  }
}
int par(State &begin, int depth) {
  if(consume(begin, '(')) {
    State prev = begin;
    int res = pl(begin, depth+1);
    check(res);
    bool op = false;
    int nowdepth = depth;
    for(auto it=prev;it<begin;++it) {
      if(*it == '(') nowdepth++;
      else if(*it == ')') nowdepth--;
      else if(depth == nowdepth) {
        op |= *it == '+' || *it == '-' || *it == '*';
      }
    }
    ok &= op;
    ok &= consume(begin, ')');
    return res;
  } else {
    return num(begin);
  }
}
int num(State &begin) {
  int res = 0;
  if(!isdigit(*begin)) {
    ok = false;
    return -1;
  }
  while(isdigit(*begin)) {
    res <<= 1;
    res += *begin - '0';
    check(res);
    if(!ok) break;
    begin++;
  }
  return res;
}
int dfs(int n, int k, string &s) {
  if(n == k) {
    State begin = s.begin();
    ed = s.end();
    ok = true;
    int res = pl(begin, 0);
    ok &= begin == ed;
    return ok ? res : -1;
  } else if(s[k] != '.') {
    return dfs(n, k+1, s);
  } else {
    int ma = -1;
    string tmp = "01+-*)(";
    for(int i=0;i<(int)(tmp.size());++i) {
      s[k] = tmp[i];
      ma = max(ma, dfs(n, k+1, s));
    }
    s[k] = '.';
    return ma;
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  string s; cin >> s;
  int n = (int)(s.size());
  cout << dfs(n, 0, s) << endl;
}



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

int n,r,ans;
char t[((int)(2e5))+50];

int main(){
	cin>>n;
	for (int i = 0; i < n; i++){
		cin>>t[i];
		if(t[i] == 'R') r++;
	}
	for (int i = 0; i < r; i++){
		if(t[i] == 'R') ans++;
	}
	cout<<r-ans;
}


Measured memory_bytes: 3820
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;
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;}
const long long INF = 1LL << 60;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b)cout<<c<<endl;
	else if(a==c)cout<<b<<endl;
	else cout<<a<<endl;
	
	
	
	return 0;
}

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

typedef long long int ll;
typedef pair<int,int> pi;
priority_queue<pi, vector<pi>, greater<pi> > pq; //min heap

ll mini(ll a,ll b){	return a<b?a:b;}
ll maxi(ll a,ll b){	return a>b?a:b;}
ll gcd(ll a,ll b){	if(b == 0)	return a;return gcd(b,a%b);}
ll binpow(ll n,ll x){	ll ans = 1;while(x){if(x & 1)	ans *= n;n *= n;x >>= 1;}return ans;}

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

    int n;
    cin>>n;
    vector<double> probs(n+1,0);
    for(int i=1;i<=n;++i)   cin>>probs[i];

    vector<double> dp(n+1,0);

    dp[0] = 1;
    for(int i=1;i<=n;++i){
        for(int j=i;j>=1;--j){
            dp[j] = dp[j-1]*probs[i] + dp[j]*(1-probs[i]);
        }
        dp[0] = dp[0]*(1-probs[i]);
    }

    double ans = 0;

    for(int i=(n+1)/2;i<=n;++i){
        ans += dp[i];
    }

    cout<<setprecision(10)<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 3916
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string s;
	cin >> s;
	rep(i, s.size()) if(s[i] == '7'){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

public class AtCoder
{
  public static void Main()
  {
    Func<(int, int)[], bool> check = (s) =>
    {
      int h = 0;
      foreach (var p in s)
      {
        int b = h + p.Item1;
        if (b < 0) {
          return false;
        }
        h += p.Item2;
      }
      return true;
    };

    var n = int.Parse(Console.ReadLine().Trim());

    var ls = new List<(int, int)>();
    var rs = new List<(int, int)>();
    int total = 0;
    for (var i = 0; i < n; i++)
    {
      var s = Console.ReadLine().Trim();

      int h = 0, b = 0;
      foreach (var c in s)
      {
        if (c == '(')
        {
          ++h;
        }
        else
        {
          --h;
        }
        b = Math.Min(b, h);
      }
      if (h > 0)
      {
        ls.Add((b, h));
      }
      else { 
        rs.Add((b - h, -h)); 
      }
      total += h;
    }

    var lsDsc = ls.OrderByDescending(e => e).ToArray();
    var rsDsc = rs.OrderByDescending(e => e).ToArray();

    if (check(lsDsc) && check(rsDsc) && (total == 0))
    {
      Console.WriteLine("Yes");
    }
    else
    {
      Console.WriteLine("No");
    }
  }
}

Measured memory_bytes: 74772
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main() {
    int x, a=0,b=0,c=0,d=0;
    scanf("%d",&x);
    string s;
    for (int i = 0; i < x; i++) {
        cin>>s;
        if(s=="AC")
            a++;
        else if (s=="WA")
        b++;
        else if(s=="TLE")
            c++;
        else if(s=="RE")
            d++;
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",a,b,c,d);

}

Measured memory_bytes: 3700
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[110];
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
		for(int i = 1; i <= n; i++)
		{
			scanf("%d",&a[i]);
		}
		int m;
		scanf("%d",&m);
		for(int i = 1 ;i <= m; i++)
		{
			int p,q;
			scanf("%d%d",&p,&q);
			int sum=0;
			for(int i = 1; i <= n; i++)
			{
				if(i==p)
				{			
					sum+=q;
				}
				else
				sum+=a[i];
			}
			printf("%d\n",sum);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main() {
	long a, n, other = 0, ans = 0;
	cin >> n;
	vector<int> nums(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a > n)other++;
		else nums[(int)a - 1]++;
	}
	for (int i = 0; i < n; i++) {
		if (nums[i] != (i + 1) && nums[i] != 0) {
			if (nums[i] > (i + 1))ans += nums[i] - (i + 1);
			else ans += nums[i];
		}
	}
	ans += other;

	cout << ans << endl;

}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    char S[20], T[20];
    scanf("%s %s", S, T);
    int a, b;
    cin >> a >> b;
    char U[20];
    scanf("%s", U);
    if (strcmp(S, U) == 0)
        a--;
    else
        b--;
    cout << a << " " << b;

    return 0;
}

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

int main(){
	int x, y, z;
	cin >> x >> y;
	if(x > y){
		z = x;
		x = y;
		y = z;
	}
	
	while(1){
		z = x%y;
		if(z == 0)
			break;
		x = y;
		y = z;
	}
	
	cout << y << endl;
	
	return 0;
}

Measured memory_bytes: 1160
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

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

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	cin >> N;
	LL ret = 0;
	REP(i, N){
		LL a = i + 1;
		if((a % 3) == 0) continue;
		if((a % 5) == 0) continue;
		ret += a;
	}

	cout << ret << endl;


	return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int,int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
struct edge { int to, cost; };
int V;
vector<edge> G[100000];
int d[100000]; int ds[100000]; int dg[100000]; ll cnt[100000] = {};
void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P>>que;
	fill(d, d + V, (int)MOD);
	d[s] = 0;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < (int)G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}
int main() {
	int m;
	cin >> V >> m;
	int s, g; cin >> s >> g; s--; g--;
	rep(i, m) {
		int x, y; cin >> x >> y; x--; y--;
		G[x].push_back({ y,1 });
		G[y].push_back({ x,1 });
	}
	dijkstra(s);
	rep(i, V) {
		ds[i] = d[i];
	}
	dijkstra(g);
	rep(i, V) {
		dg[i] = d[i];
	}
	int r = ds[g];
	rep(i, V) {
		if (ds[i] < (int)MOD) {
			cnt[ds[i]]++;
		}
	}
	ll res = 0;
	rep(i, V) {
		int x = r - dg[i] - 2;
		if (x < 0)continue;
		res += cnt[x];
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 12048
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1)%1000000007;
    }
}

/* ユークリッドの互除法 最大公約数*/
/*ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
*/


/*最小公倍数*/
/*
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
*/

/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    //頂点sからｔへたどり着けるか
    // 頂点数と辺数
    ll n,m;
    cin>>n>>m;
    graph g(n);
    for(ll i=0;i<m;i++){
        ll a,b;
        cin>>a>>b;
        g[--a].push_back(--b);
        //g[b].push_back(a);
    }
    ll s=0,t=n-1;
    // 頂点 s をスタートとした探索
    vector<ll>dist(n,-1);
    queue<ll>que;
    dist[s]=0,que.push(s);
    while(!que.empty()){
        ll v=que.front();
        que.pop();
        for(auto nv:g[v]){
            if(dist[nv]==-1){
                dist[nv]=dist[v]+1;
                que.push(nv);
            }
        }
    }
     // t に辿り着けるかどうか
    if(dist[t]!=-1&&dist[t]==2){
        cout<<"POSSIBLE"<<endl;
        //cout<<dist[t]<<endl;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
        //cout<<dist[t]<<endl;
    }


    

}

Measured memory_bytes: 11252
#include<iostream>
#include<vector>
#include<stdio.h>
using namespace std;
int n;
int a[105];
vector<int >vec;
int main()
{
    while(~scanf("%d",&n))
    {
        vec.clear();
        for(int i=1; i<=n; i++)
        {
            scanf("%d",&a[i]);
        }
        int cnt=1;
        for(int i=2; i<=n; i++)
        {
            if(a[i]==a[i-1])
            {
                cnt++;
            }
            else
            {
                if(cnt>1)
                {
                    vec.push_back(cnt);
                    cnt=1;
                }
            }
        }
        if(cnt>1)
        {
            vec.push_back(cnt);
            cnt=1;
        }
        int ans=0;
        for(int i=0; i<vec.size(); i++)
        {
            ans=ans+vec[i]/2;
        }
        printf("%d\n",ans);
    }
    return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        int m = in.nextInt();
        if(n%m==0){
            out.println(n/m);
        }
        else{
            out.println(n/m+1);
        }
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

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

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}



Measured memory_bytes: 32904
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int res = n;
  for(int i = 0; i <= n; i++){
    int cc = 0;
    int t = i;
    while(t > 0){
      cc += t % 6;
      t /= 6;
    }
    t = n - i;
    while(t > 0){
      cc += t % 9;
      t /= 9;
    }
	if(res > cc)
      res = cc;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Linq;
using System.Collections.Generic;

namespace competitive
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine().ToInt();
            var ls = new List<int>();
            for (int i = 0; i < n; i++)
            {
                var si = Console.ReadLine().ToInt();
                ls.Add(si);
            }
            var dp = new bool[110, 10010];
            // dp[i,j] = i番目まで見たときに成績の値がjにできるかどうか
            // dp[i + 1,j] = dp[i, j] | dp[i, j - a_i] if j - a_i >= 0
            //               dp[i, j]
            // dp[0,j] = False but dp[0,0] = True
            dp[0, 0] = true;
            for (int i = 0; i < n; i++)
            {
                var a_i = ls[i];
                for (int j = 0; j < 10005; j++)
                {
                    if (j - a_i >= 0)
                    {
                        dp[i + 1, j] = dp[i, j] | dp[i, j - a_i];
                    }
                    else
                    {
                        dp[i + 1, j] = dp[i, j];
                    }
                }
            }
            var maxes = 0;
            for (int j = 0; j < 10005; j++)
            {
                if (dp[n, j] && j % 10 != 0)
                {
                    maxes = j;
                }
            }
            Console.WriteLine(maxes);
        }
    }

    public static class Extensions
    {
        public static int ToInt(this string str) => int.Parse(str);
    }
}


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

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef gp_hash_table<int, null_type,hash<int>, equal_to<int>, direct_mask_range_hashing<int>, linear_probe_fn<>,
    hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>,true>> hash_set;
typedef gp_hash_table<int,null_type> hash_map;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-9
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

const ld PI = (ld)4*atanl(1);

mt19937 g1(chrono::steady_clock::now().time_since_epoch().count());

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int main(){
    int len;
  string s; cin>>len>>s; int res = 0;
  for(int i=2; i<s.size(); i++){
    string sub = s.substr(i-2,3);
    if(sub == "ABC") res++;
  }
  cout<<res<<endl;
}

Measured memory_bytes: 256
def CountingSort(A,B,k):
    n=len(A)
    C=[0]*(k+1)
    for i in range(n):
        C[A[i]] +=1
    for i in range(1,k+1):
        C[i]=C[i-1]+C[i]
    for i in reversed(range(n)):
        B[C[A[i]]-1]=A[i]
        C[A[i]] -=1


n=int(input())
A=list(map(int,input().split()))
B=[0]*n
CountingSort(A,B,10000)
print(*B)


Measured memory_bytes: 224512
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
int main(){
  int n,l;
  cin >> n >> l;
  int min = 100;
  int ans = 0;
  for (int i=l;i<l+n;i++){
    ans += i;
    if (abs(min) > abs(i)){
      min = i;
    }
  }
  cout << ans-min << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	n, k := getInt(), getInt()
	m := make(map[int]int)
	for i := 0; i < n; i++ {
		x := getInt()
		m[x]++
	}

	xs := make([]int, 0, len(m))
	for _, v := range m {
		xs = append(xs, v)
	}
	sort.Ints(xs)

	ans := 0
	diff := len(xs) - k
	for i := 0; diff > 0; i++ {
		ans += xs[i]
		diff--
	}

	fmt.Println(ans)
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K,sum=0,a;
  cin >> N>>K;
  a=N;
  for(int i=0;i< K-N +1;i++){
    
    if(a/10000 == a%10 && a%10000/1000 == a%100/10){
      sum++;
    }
    a++;
  }
  cout << sum << endl;
}



Measured memory_bytes: 256
n,c=map(int,input().split())
p=[list(map(int,input().split())) for _ in range(n)]
p.sort()
res = [0 for _ in range(100005)]
res0 = [[0,0] for _ in range(c)]
np = []
for s,t,c in p:
    if res0[c-1][0] == 0:
        res0[c-1] = [s,t]
    elif res0[c-1][1] ==s:
        res0[c-1][1] =t
    else:
        np.append(res0[c-1][:])
        res0[c-1]=[s,t]
for sres0 in res0:
    if sres0 != [0,0]:
    	np.append(sres0)

for s,t in np:
    res[s] += 1
    res[t+1]-=1

ress = [0]
for i in range(100005):
    ress.append(ress[-1]+res[i])

print(max(ress))

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

void binary(int *J, int n);

int main(){
    int N;
    int F[100][10];
    int P[100][11];
    int J[10];
    int C[100]={};
    int profits=0,max=-1000000000;

    cin >> N;
    for(int i=0;i<N;i++){
        for(int j=0;j<10;j++){
            cin >> F[i][j];
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<11;j++){
            cin >> P[i][j];
        }
    }
    for(int i=1;i<=1023;i++){
        binary(J,i);
        for(int j=0;j<N;j++) C[j]=0;
        profits=0;
        for(int j=0;j<N;j++){
            for(int k=0;k<10;k++){
                C[j]+=F[j][k]*J[k];
            }
        }
        for(int j=0;j<N;j++){
            profits+=P[j][C[j]];
        }
        if(profits>max) max=profits;
    }

    cout << max;

    return 0;
}

void binary(int *J, int n){
    for(int i=0;i<10;i++){
        J[i]=n%2;
        n=n/2;
    }
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var option = Console.ReadLine();
        var counter = 0;
        for(var i = 0; i < option.Length; i++)
        {
            if (option.Substring(i, 1) == "o") counter++;
        }
        Console.WriteLine(700 + 100 * counter);
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <map>
#include <ctime>
#include <cstdlib>
#include <random>
using namespace std;

int main(){
	string s;
	cin >> s;
	if(s.at(0) == s.at(1) && s.at(1) == s.at(2))cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn._

object Main extends App {

  val s = readLine()
  def solve() = {
    if(s == "RRR") 3
    else if(s == "RRS" || s == "SRR") 2
    else if(s.contains("R")) 1
    else 0
  }

  println(solve())

}



Measured memory_bytes: 54456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i=0; i < (int)(N); i++)
 
int main() {
  int N;
  int K;
  
  cin >> N >> K;
 
  int ans = 0;
  
  rep(i, N) {
    int x;
    cin >> x;
    int dA, dB;
    dA = x;
    if (x > K){
      dB = x - K;
    }
    else{
      dB = K - x;
    }
    if (dA > dB) {
      ans += 2*dB;
    }
    else {
      ans += 2*dA;
    }
  }
  cout << ans << endl;
}

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

int main() {

  int N;
  cin >> N;

  set<int> even;
  for (int i = 0; i < N; i++) {
    int n_;
    cin >> n_;
    if (n_ % 2 == 0){
      even.insert(n_);
    }
  }

  string answer = "APPROVED";
  
  for(auto item:even) {
    if (item % 3 != 0 && item % 5 != 0) {
      answer = "DENIED";
      break;
    }
  }

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<stdio.h>
#include<map>
using namespace std;
int main(){
    string s;
    long long int i,j,k,L,m,dp[220][10][10];
    cin >> s;
    scanf("%lld\n",&m);
    L=s.size();
    dp[0][0][0]=1;
    for(i=0;i<L;i++){
        const int D=s[i]-'0';
        for(j=0;j<2;j++){
            for(k=0;k<m+1;k++){
                for(int d=0;d<=(j?9:D);d++){
                    if(d==0){
                        dp[i+1][j||(d<D)][k]+=dp[i][j][k];
                    }
                    else{
                    dp[i+1][j||(d<D)][k+1]+=dp[i][j][k];
                    }
                }
            }
        }
    }
    printf("%lld\n",dp[L][0][m]+dp[L][1][m]);
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define prvsort(v) sort(v.begin(), v.end(), greater<pair<ll, ll>>())
#define ll long long
#define ld long double
#define fixset(val) fixed << setprecision(10) << val 
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define mod 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll N, M, K; cin >> N >> M >> K;
  vector<ll> A(N + 1), B(M + 1);
  A[0] = 0; B[0] = 0;
  rep(i, 0, N) {
  	ll a; cin >> a;
    A[i + 1] = A[i] + a;
  }
  rep(i, 0, M) {
  	ll b; cin >> b;
    B[i + 1] = B[i] + b;
  }
  ll ans = 0, j = M;
  rep(i, 0, N + 1) {
  	if (A[i] > K) break;
    while(A[i] + B[j] > K) {
    	j--;
    }
    ans = max(ans, i + j);
  }
  cout << ans << endl;
}

Measured memory_bytes: 6428
import java.io.UnsupportedEncodingException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws UnsupportedEncodingException {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        char[] c = S.toCharArray();
        byte[] ascii = S.getBytes("US-ASCII");
        byte[] newAscii = new byte[S.length()];

        for(int i=0;i<S.length();i++){
            newAscii[i] = (byte)((ascii[i]+N-'A')%(26) + 'A');
        }
        System.out.println(new String(newAscii,"US-ASCII"));

    }
}

Measured memory_bytes: 24020
N = int(input())
import math
c = []
for i in range(1,math.floor(N**0.5)+1):
  if N % i == 0:
    c.append([i,int(N/i)])
cc = []
for j in c:
  r = max(len(str(j[0])),len(str(j[1])))
  cc.append(r)
print(min(cc))

Measured memory_bytes: 9436