akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class A {
	char x, y;
public:
	A()
	{
		cin >> x >> y;
	}
	void solve()
	{
		if (x < y)
			cout << "<";
		else if (x == y)
			cout << "=";
		else
			cout << ">";
		cout << endl;
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;
const int N = 2048, M = 5e6 + 10, Mod = 1e9 + 7;

inline void Read(int &x)
{
	x = 0; register char cc = '\0'; int fff = 1;
	for (; cc < '0' || cc > '9'; cc = getchar())
		if (cc == '-') fff = -1;
	for (; cc >= '0' && cc <= '9'; cc = getchar())
		x = (x << 1) + (x << 3) + (cc & 15);
	x *= fff;
}

int n, K, num, f[N][N], fac[M + 10], ifac[M + 10];

inline int Pow(int x, int y) {
	int sum = 1;
	while (y) {
		if (y & 1) sum = (LL)sum * x % Mod;
		x = (LL)x * x % Mod; y >>= 1;
	}
	return sum;
}

inline int C(int x, int y) {
	if (x < y || y < 0) return 0;
	return (LL)fac[x] * ifac[x - y] % Mod * ifac[y] % Mod;
}

int main()
{
	fac[0] = ifac[0] = 1;
	for (int i = 1; i <= M; ++i) fac[i] = (LL)fac[i - 1] * i % Mod;
	ifac[M] = Pow(fac[M], Mod - 2);
	for (int i = M - 1; i >= 1; --i) ifac[i] = (LL)ifac[i + 1] * (i + 1) % Mod;
	
	Read(n), Read(K);
	if (K == 1) {
		printf("1\n"); /*!!!*/
		return 0;
	}
	num = (LL)n * K;
	
	f[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= i; ++j) {
			if (i > j) f[i][j] = f[i - 1][j];
			if (j > 0) f[i][j] = (f[i][j] + (LL)f[i][j - 1] * (n - (j - 1)) % Mod * C(num - (K - 1) * (j - 1) - i - 1,K - 2) % Mod) % Mod;
		}
	}
	
	printf("%d\n", f[n][n]);
	
	return 0;
}


Measured memory_bytes: 55552
#include<stdio.h>

int main(void){
	
	int x,y,sum,num;
	
	while(scanf("%d %d", &x, &y) != EOF){
		num=x+y;
		sum=0;
		while(num!=0){
			num/=10;
			sum++;
		}
		printf("%d\n", sum);
	}
	
	return 0;
}
 

Measured memory_bytes: 600
#include<iostream>
#include<string>

int main(){
  int n,ac=0,wa=0,tle=0,re=0;
  std::cin>>n;
  std::string str;
  for(int i=0;i<n;i++){
    std::cin>>str;
    if(str=="AC"){
      ac++;
    }
    if(str=="WA"){
      wa++;
    }
    if(str=="TLE"){
      tle++;
    }
    if(str=="RE"){
      re++;
    }
  }
  std::cout<<"AC x "<<ac<<std::endl;
  std::cout<<"WA x "<<wa<<std::endl;
  std::cout<<"TLE x "<<tle<<std::endl;
  std::cout<<"RE x "<<re<<std::endl;
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include <cstddef>
#include<set>
#include<stack>
#include <deque>
#include<queue>
#include<utility>
#include<vector>
#include<map>
#include<cmath>
#include<cstring>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#define  ll  long long
#define ull unsigned long long
#define  sl(a)  scanf("%lld",&a)
#define  si(a)  scanf("%d",&a)
#define mem(n,m) memset(n,m,sizeof(n))
#define PI acos(-1)
#define pb    push_back
#define pf    push_front
#define vll   vector<ll>
#define pll   pair<ll,ll>
#define mp  make_pair
#define vpll vector< pair <ll,ll> >
#define vplpll vector<pair<ll,pair<ll,ll> > >
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S(X) ( (X) * (X) )
#define forab(i, a, b) for(i = a; i <= b; i++)
#define forn(i, n) for(i = 0; i < n; i++)
#define print(a,b) printf("Case %lld: %lld\n",a,b)
using namespace std;
ll powd(ll a,ll b){if(b==1){return a;}if(b%2==1){return powd(a,b-1)*a;}else{ll x=powd(a,b/2); return x*x;}}
ll powm(ll a,ll b,ll m){if(b==0){return 1;}if(b==1){return a%m;}if(b%2==1){return ((powm(a,b-1,m)%m)*(a%m))%m;}else{ll x=powm(a,b/2,m); return ((x%m)*(x%m))%m;}}
ll gcd(ll a,ll b){if(a==0){return b;}return gcd(b,a%b);}
int main()
{
    ll s,x,t;
    sl(s);
    sl(x);
    sl(t);
    ll n=s/x;
    if(n*x!=s)
        n++;
    cout<<n*t<<endl;
    return 0;
}

Measured memory_bytes: 3668
num2alpha = lambda c: chr(c+64).lower()

N = int(input())
res = list()

while True:
  mod = N % 26
  if mod == 0:
      mod = 26

  res.insert(0,num2alpha(int(mod)))
  N = N // 26
  if mod == 26:
    N -= 1
  if N <= 0:
    break

print(''.join(res))

Measured memory_bytes: 9148
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using indexed_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define sim template <class c
#define ris return *this
#define dor > debug& operator<<
#define eni(x)                                                                 \
    sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(   \
              c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i;
    ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c&) { ris; }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define mem(a, s) memset(a, s, sizeof(a))
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for (int i = a; i >= b; --i)
typedef vector<int> vi;
typedef stack<int> sti;
typedef queue<int> qi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;
int _x[] = {0, 0, -1, 1, -1, 1, -1, 1};
int _y[] = {-1, 1, 0, 0, 1, -1, -1, 1};
void solve();
void pre();
int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    int t = 1;
    // cin >> t;
    rep(i, 1, t) {
        // cout << "Case # " << i << ": ";
        solve();
    }
    return 0;
}
const int mod = 1e9 + 7;
void pre() {}
void solve() {
    int n;
    cin >> n;
    vector<pii> v(n);
    rep(i, 0, n - 1) cin >> v[i].fi >> v[i].se;
    for (int i = 0; i + 2 < n; ++i) {
        if (v[i].fi == v[i].se && v[i + 1].fi == v[i + 1].se &&
            v[i + 2].fi == v[i + 2].se) {
            cout << "Yes";
            return;
        }
    }
    cout << "No";
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 1e18
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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


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

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;cin>>N>>M;
    vector<int> X(M),Y(M),Z(M);
    REP(i,M) cin>>X[i]>>Y[i]>>Z[i],--X[i],--Y[i];
    UnionFind uf(N);
    REP(i,M) uf.merge(X[i],Y[i]);
    set<int> se;
    REP(i,N) se.insert(uf.root(i));
    cout<<(int)se.size();
}

Measured memory_bytes: 6528
N,W=map(int,input().split())
w=[0 for _ in range(110)]
v=[0 for _ in range(110)]
for i in range(1,N+1):
    w[i],v[i]=map(int,input().split())
dp=[[0 for i in range(110000)] for j in range(110)]

for i in range(1,N+1):
    for j in range(W+1):
        dp[i][j]=dp[i-1][j]
        if j-w[i]>=0:
            dp[i][j]=max(dp[i][j], dp[i-1][j-w[i]]+v[i])

print(dp[N][W])

Measured memory_bytes: 201916
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

using ll = long long;

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

#define mp make_pair
#define mt make_tuple

/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

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

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
inline T sq(T a) { return a * a; }

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

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
    int H, W, N;
    cin >> H >> W >> N;

    set<int> wall[W];
    for (int i = 0; i < N; ++i) {
        int x, y;
        cin >> x >> y;
        wall[y - 1].insert(x - 1);
    }

    int ans = H;
    int tak = 0;
    for (int w = 0; w < W; ++w) {
        while (wall[w].find(tak) != wall[w].end()) {
            ++tak;
        }

        auto itr = wall[w].upper_bound(tak);
        if (itr != wall[w].end()) {
            ans = min(ans, *itr);
        }

        ++tak;
    }

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


Measured memory_bytes: 18944
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(),(c).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9 + 10;

int X, Y, Z;

int main() {
    cin >> X >> Y >> Z;
    int tmp = X;
    X = Y;
    Y = tmp;
    tmp = X;
    X = Z;
    Z = tmp;
    cout << X << " "<< Y << " " << Z << endl;
}

Measured memory_bytes: 3616
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    int N;
    cin >> N;

    vi A(N);
    rep(i, N) cin >> A[i];
    reverse(all(A));

    map<int, int> m;

    for(auto a : A)
    {
        auto itr = m.upper_bound(a);

        if (itr != m.end())
        {
            (*itr).second--;
            if ((*itr).second == 0) m.erase(itr);
        }

        m[a]++;
    }

    ll count = 0;
    for (auto x : m) count += x.second;

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;
 
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;
 
int main() {

    string S; cin >> S;
    ll cnt[26] = {};
    REP(i,S.size()) cnt[S[i] - 'a'] ++;

    ll ans = S.size() * (S.size() + 1) / 2;
    REP(i,26) {
        ans -= cnt[i] * (cnt[i] + 1) / 2;
    }

    cout << ans + 1 << endl;

    return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));


int main(){
    cout << fixed << setprecision(10);
    double a, b, c;
    cin >> a >> b >> c;
    c = c * PI / 180.0;
    double S = a * b * sin(c) / 2.0;
    cout << S << endl;
    double x = sqrt(a * a + b * b - 2 * a * b * cos(c));
    cout << a + b + x << endl;
    cout << 2.0 * S / a << endl;
}


Measured memory_bytes: 3596
N = int(input())
l = list(map(int, input().split()))

ans = 0
last_n = 0
for i in l:
    if i >= last_n:
        ans += i
        last_n = i
    else:
        ans -= last_n
        ans += i*2
        last_n = i
ans += l[0]
print(ans)

Measured memory_bytes: 9084
import java.util.*;
import java.math.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		while(scan.hasNext()){
			int N = scan.nextInt();
			for(int i = 0; i < N; i++){
				BigInteger a = scan.nextBigInteger();
				BigInteger b = scan.nextBigInteger();
				String num = String.valueOf(a.add(b));
				if(num.length() > 80){
					System.out.printf("%s\n", "overflow");
				} else{
					System.out.printf("%s\n", num);
				}
			}
		}
	}
}

Measured memory_bytes: 26088
#include <iostream>

using std::cout;
using std::endl;

int getDays(int month, int day);

int main()
{
    int month, day;
    while (true) {
        std::cin >> month >> day;

        if (month == 0 && day == 0) {
            break;
        }

        int days = getDays(month, day);
        int mod = days % 7;
        switch (mod) {
        case 1:
            cout << "Thursday" << endl;
            break;
        case 2:
            cout << "Friday" << endl;
            break;
        case 3:
            cout << "Saturday" << endl;
            break;
        case 4:
            cout << "Sunday" << endl;
            break;
        case 5:
            cout << "Monday" << endl;
            break;
        case 6:
            cout << "Tuesday" << endl;
            break;
        case 0:
            cout << "Wednesday" << endl;
            break;
        }
    }

    return 0;
}

int getDays(int month, int day)
{
    int days = 31 * (month - 1) + day;

    int minus = 0;
    if (month > 2) {
        minus += 2;
    }
    if (month > 4) {
        minus++;
    }
    if (month > 6) {
        minus++;
    }
    if (month > 9) {
        minus++;
    }
    if (month > 11) {
        minus++;
    }

    return (days -= minus);
}

Measured memory_bytes: 1152
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
#define _v1 CONCAT(qyw1, __LINE__) // unique name in same line (otherwise use __COUNTER__)
#define _v2 CONCAT(qyw2, __LINE__)
#define forbits(i, m) for (int _v1 = m, i = __builtin_ctz(_v1); _v1 != 0; _v1 ^= _v1 & -_v1, i = __builtin_ctz(_v1))
#define forsubm(s, m) for (int s = m; s >= 0; s = !s ? -1 : m & (s - 1))
int __nextXZW(int v){int t=v|(v-1);int w=(t+1)|(((~t&-~t)-1)>>(__builtin_ctz(v)+1));return w;}
#define ksets(i, n, k) for (int i = (1u << k) - 1, max = i << (n - k); i <= max; i = __nextXZW(i))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9+7;
const ll N = 5e5+5, inf = 1e9+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <atcoder/segtree> 
using namespace atcoder;

int op(int x, int y) { return max(x, y); }
int e() { return -1; }
int v_i;
bool f(int x) {
  return v_i > x;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n, q; cin >> n >> q;
  vector<int> a(n); rep (i, n) cin >> a[i];
  segtree<int, op, e> st(a);
  while (q--) {
    int type, x, y; cin >> type >> x >> y;
    x--;
    if (type == 1) {
      st.set(x, y);
    } else if (type == 2) {
      cout << st.prod(x, y) << '\n';
    } else {
      v_i = y;
      cout << st.max_right<f>(x)+1 << '\n';
    }
  }
  
  return 0;
}

Measured memory_bytes: 6096
def cp(n):
    lp=[0]*(n+1)
    pr=[]
    for i in range(2,n+1):
        if lp[i]==0:
            lp[i]=i
            pr.append(i)
        for p in pr:
            if p*i>n or p>lp[i]:
                break
            lp[p*i]=p
    return lp

def ra(a): #圧縮された要素を非保持
    ll,l=[],1
    for i in range(len(a)-1):
        if a[i]==a[i+1]:
            l+=1
        else:
            ll.append(l)
            l=1
    ll.append(l)
    return ll


n=int(input())
ans=0
cppp=cp(n)
for i in range(1,n):
    c=n-i
    prime=[]
    while c>1:
        prime.append(cppp[c])
        c//=cppp[c]
    l=ra(prime)
    k=1
    for j in l:
        k*=j+1
    ans+=k
print(ans-1)

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

void Main()
{
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double rb = m / 30.0 * M_PI;
    double xb = cos(rb) * b;
    double yb = sin(rb) * b;

    double ra = (h*60 + m) / (6.0 * 60.0) * M_PI; 
    double xa = cos(ra) * a;
    double ya = sin(ra) * a;

    double d = sqrt((xa - xb)*(xa - xb) + (ya - yb)*(ya - yb));
    cout << std::fixed << std::setprecision(20) << d << endl;
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


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

int main ()
{
  string N;
  int sum = 0;
  cin >> N;
  
  for (int i=0; i<N.length(); i++)
    sum += (int)(N[i] - '0');
  
  cout << (sum % 9 ? "No" : "Yes");
  
  return 0;
}

Measured memory_bytes: 3484
//SILENT KILLER
              //HARD WORK BEATS TALENT WHEN TALENT DOESNOT WORK HARD
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
  ll n;
    cin>>n;
    ll a[n+2],b[n+3];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
    }
  ll f=0;
    ll cnt=0;
    for(ll i=0;i<n;i++)
    {
        if(a[i]==b[i])cnt++;
        else cnt=0;
        if(cnt==3)
        {
            f=1;
            break;
        }

    }


    if(f==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


}


















Measured memory_bytes: 3544
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug { 
    ($($a: expr),*) => { 
        println!(concat!($(stringify!($a)," = {:?}, "),*), $($a),*);
    } 
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (a,b,c) = get!(u64, u64, u64);
    if a==b && b==c {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 8572
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <unordered_map>
#include <complex>
#include <stdio.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (LL)((a).size())

const LD PI = acos(-1.0);
const LD EPS = 1e-9;
const LL mod = 1000000007;
const LL INF = 1e9;
const LL LINF = 1e9;
const LL MAX = 2e5 + 7;
const LL MAXN = 5e5 + 1;

void bad()
{
	cout << "No";
	exit(0);
}

void ok()
{
	cout << "Yes";
	exit(0);
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("Out.txt", "w", stdout);

	int n;
	while (cin >> n)
	{
		VLL a(n), b(n);
		FOR(i, 0, n)
			cin >> a[i];
		FOR(i, 0, n)
			cin >> b[i];

		VLL c(n);
		FOR(i, 0, n)
			c[i] = b[i] - a[i];

		sort(ALL(c));
		LL cnt = 0;
		FOR(i, 0, n)
			if (c[i] < 0)
				cnt -= c[i];

		LL cnt2 = 0;
		FOR(i, 0, n)
			if (c[i] > 0)
				cnt2 += c[i] / 2;

		if (cnt2 < cnt)
			bad();

		ok();

	}
	return 0;
}

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

// macros
#define overload_rep(va_0, va_1, va_2, name, ...) name
#define rep_0(i, n) for(int i = 0; i < (n); ++i)
#define rep_1(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
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; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries
template<class Abel>
struct BinaryIndexedTree {
private:

    size_t sz;
    vector<Abel> node;

public:

    constexpr BinaryIndexedTree() noexcept {}
    constexpr BinaryIndexedTree(const size_t& sz_) noexcept { init(sz_); }
    ~BinaryIndexedTree() noexcept {}

    constexpr void init(const size_t& sz_) noexcept {
        size_t tmp = 1;
        while(tmp < sz_)tmp <<= 1;
        sz = tmp + 1;
        node.assign(tmp + 1, 0);
    }

    constexpr void add(const int& idx, const Abel& val) noexcept {
        for(int x = idx + 1; x <= sz; x += x & -x)node[x] += val;
    }

    constexpr Abel get(const int& idx) const noexcept {
        Abel res = 0;
        for(int x = idx + 1; x > 0; x -= x & -x)res += node[x];
        return res;
    }

    constexpr Abel get(const int& l, const int& r) const noexcept {
        return get(r - 1) - get(l - 1);
    }

    constexpr Abel operator () (const int& l, const int& r) const noexcept {
        return get(r - 1) - get(l - 1);
    }

    constexpr Abel operator [] (const int& idx) const noexcept {
        return get(idx + 1) - get(idx);
    }

};

// declarations

// solve
int main(){

    string S;
    cin >> S;

    int N = S.size();
    vector<vector<int>> pos(26);
    rep(i, N){
        S[i] -= 'a';
        pos[S[i]].push_back(i);
    }

    int idx = 0;
    bool odd_flag = false;
    vector<int> vec(N);
    vector<pair<int, int>> pat(N / 2);
    rep(i, 26){
        int sz = pos[i].size();
        if(sz % 2 == 1){
            if(odd_flag){
                cout << "-1\n";
                return 0;
            }
            odd_flag = true;
            vec[pos[i][sz / 2]] = N / 2;
        }
        rep(j, sz / 2){
            pat[idx++] = make_pair(pos[i][j], pos[i][sz - j - 1]);
        }
    }

    sort(all(pat));
    rep(i, N / 2){
        vec[pat[i].first] = i;
        vec[pat[i].second] = N - i - 1;
    }

    BinaryIndexedTree<int> bit(N);
    long long ans = 0;
    rep(i, N){
        ans += bit(vec[i], N);
        bit.add(vec[i], 1);
    }

    cout << ans << '\n';
    return 0;

}


Measured memory_bytes: 4236
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fir first
#define sec second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>

typedef long long ll;
typedef unsigned long long ull;

const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

inline ll read() {
    ll res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}

int n, ans;
bool good[20];
std::vector< Pair > a[20];

inline void check(int S) {
    int tmp = 0;
    bool flag = true;
    memset(good, 0, sizeof(good));
    for (int i = 0; i < n; i++) {
        if (S & (1 << i)) good[i + 1] = true, tmp++;
    }
    for (int i = 1; i <= n; i++) {
        if (!good[i]) continue;
        for (int j = 0; j < a[i].size(); j++) {
            int x = a[i][j].fir, y = a[i][j].sec;
            if (good[x] != y) {
                flag = false;
            }
        }
    }
    
    if (flag) {
        ans = std::max(ans, tmp);
    }
}

int main() {
    std::cin >> n;
    for (int i = 1; i <= n; i++) {
        int x;
        scanf("%d", &x);
        for (int j = 1; j <= x; j++) {
            int p, q;
            std::cin >> p >> q;
            a[i].push_back(mp(p, q));
        }
    }
    int lim = (1 << n) - 1;
    for (int S = lim; S >= 0; S--) {
        check(S);
    }
    printf("%d\n", ans);
    return 0;
}

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

int main() {
    int q;
    cin >> q;
    vector<int> l(q);
    vector<int> r(q);
    vector<int> state(100001, 0);
    int mx = 0;
    rep(i, 0, q) {
        cin >> l[i] >> r[i];
        mx = max(r[i], mx);
    }
    map<int, bool> mp;
    mp[2] = true;
    for(int i = 3; i < mx+1; i++) {
        mp[i] = true;
        for(int j = 2; j <= sqrt(i); j++) {
            if(i%j == 0) {
                mp[i] = false;
                break;
            }
        }
    }

    int sum = 0;
    for(int i = 1; i < mx+1; i++) {
        if(mp[i] == true && mp[(i+1)/2] == true) {
            sum++;
        }
        state[i] = sum;
    }
    for(int i = 0; i < q; i++) {
        cout << state[r[i]]-state[l[i]-1] << endl;
    }
    return 0;
}   

Measured memory_bytes: 6528
//omajinai
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//omajinai

int main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    ll x;
    cin >> x;

    ll sum = 0,count = 1;

    while(sum < x){
        sum += count;
        count ++;
    }

    cout << count-1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

void add(ll& a, ll b){a = (a+b) % MOD;}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> L(2*n);
    REP(i,2*n) cin>>L[i];
    VRSORT(L);
    int ans=0;
    for(int i=0;i<2*n;i+=2) ans+=min(L[i],L[i+1]);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i)  
#else
  #define DUMP(i)  
#endif

#define GETTYPE(i) 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const int EPS = 1e-9;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  while(cin >> s){
    int sum = 0;
    REP(i,SZ(s)){
      sum += s[i] - '0';
    }
    int n;
    stringstream ss(s);
    ss >> n;
    string ans;
    if(n % sum == 0)ans = "Yes";
    else ans = "No";
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
def main():
    from collections import deque

    N, M = map(int, input().split())
    connected_rooms = [[] for i in range(N + 1)]
    
    for i in range(M):
        a, b = map(int, input().split())
        connected_rooms[a].append(b)
        connected_rooms[b].append(a)
    
    def Breadth_First_Search(root):
        queue = deque([root]) #calculate distance from the root
        distance = [None] * (N + 1) #initialize distance
        distance[root] = 0
        
        while (queue): #do BFS and calculate distance recursively
            ver = queue.popleft()
            
            for index in connected_rooms[ver]:
                if (distance[index] == None):
                    distance[index] = distance[ver] + 1
                    queue.append(i)
        
        return (distance)
    
    dist = [None] * (N + 1)
    dist[0] = True
    
    Q = deque([1])
    while (Q):
        index = Q.popleft()
        for j in connected_rooms[index]:
            if (dist[j] == None):
                dist[j] = index
                Q.append(j)
    
    if (all(dist)):
        print('Yes')
        for i in dist[2:]:
            print(i)
    else:
        print('No')


if __name__ == '__main__':
    main()

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

#define ll long long int

using namespace std;
struct objects{
    int weight,value;
};
ll solve(){
   int n,w;
   cin>>n>>w;
   objects object[n];
   int totalvalue=0;
   for(int i=0;i<n;i++){
       cin>>object[i].weight>>object[i].value;
       totalvalue+=object[i].value;
   }
   ll dp[n+1][totalvalue+1];
    
   dp[0][0]=0;
   int ans=0;
   for(int i=1;i<=totalvalue;i++){
       dp[0][i]=1e18;
     
   }
   for(int i=0;i<n;i++){
       for(int j=0;j<=totalvalue;j++){
           if(j>=object[i].value){
                dp[i+1][j]=min(dp[i][j],dp[i][j-object[i].value]+object[i].weight);
           }
           else{
              
               dp[i+1][j]=dp[i][j];
           }
           if(dp[i+1][j]<=w){
               ans=max(ans,j);
           }
       }
   }
   return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<solve();
}

Measured memory_bytes: 79104
#include<iostream>
#include <algorithm>

using namespace std;

int main(void) {
	int N, D, X,ans=0;
	int A[100];

	cin >> N >> D >> X;
	for (int i=0;i < N;i++)
		cin >> A[i];

	for (int i=0;i < N;i++) {
		ans += 1+(D - 1) / A[i];
	}
	ans += X;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

int memo[3010][3010];
char s[3010], t[3010];

void backtrack(int a, int b) {
	if ((a == 0) || (b == 0))
		return;
	if (s[a - 1] == t[b - 1]) {
		backtrack(a - 1, b - 1);
		putchar(s[a - 1]);
	}
	else if (memo[a - 1][b] > memo[a][b - 1])
		backtrack(a - 1, b);
	else
		backtrack(a, b - 1);
}

int main() {
	int len1, len2;
	scanf("%s\n%s", s, t);
	len1 = strlen(s);
	len2 = strlen(t);
	memset(memo, 0, sizeof memo);
	for (int i = 1; i <= len1; i++)
		for (int j = 1; j <= len2; j++) {
			if (s[i - 1] == t[j - 1])
				memo[i][j] = memo[i - 1][j - 1] + 1;
			else
				memo[i][j] = max(memo[i - 1][j], memo[i][j - 1]);
		}
	backtrack(len1, len2);
	printf("\n");
	return 0;
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
int main(){
    long n;
    cin >> n;
    int a[n];
    int i;
    int ne;
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    ne=a[0];
    for(i=0;i<=n;i++){
        if(ne==2){
            cout << i+1 << endl;
            return 0;
        }
        else{
            ne=a[ne-1];
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 768
while True:
    try:
        s = input()
    except EOFError:
        break

    r = ''
    n = 1
    for c in s:
        if n < 0:
            n = int(c)
        elif c == '@':
            n = -1
        else:
            r += c * n
            n = 1
    print(r)

Measured memory_bytes: 6720
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
//#define at(x,i) get<i>(x);//
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void rle(string s,vector<char> &cha,vl &num){
    ll a=0,cnt=0;
    string t;char x=s[0];
    while(a<s.size()){
        if(x==s[a])cnt++;
        else{
            cha.pb(x);num.pb(cnt);
            x=s[a];cnt=1;
        }
        a++;
    }
    cha.pb(x);num.pb(cnt);
}
int main(){
  ll n,k;cin >> n >>k;
  string s;cin >> s;
  vector<char> cha;
  vl num;
  rle(s,cha,num);
  vl rcnt,ocnt;
  if(cha[0]=='0')rcnt.pb(0);
  rep(i,cha.size()){
    if(cha[i]=='0')ocnt.pb(num[i]);
    if(cha[i]=='1')rcnt.pb(num[i]);
  }
  if(cha[cha.size()-1]=='0')rcnt.pb(0);
  ll ans=0;
  if(ocnt.size()<=k){
    cout << n <<endl;
    return 0;
  }
  rep(i,ocnt.size()-k+1){
    ll tmp=0;
    rep(j,k){
      tmp+=rcnt[j+i];
    }
    rep(j,k){
      tmp+=ocnt[j+i];
    }
    tmp+=rcnt[k+i];
    chmax(ans,tmp);
  }
  cout << ans <<endl;
}

Measured memory_bytes: 2676
def main():
    X,Y,A,B,C  = map(int, input().split()) 
    sum = 0
    p = list(map(int, input().split()))
    q = list(map(int, input().split()))
    r = list(map(int, input().split()))
    list.sort(p,reverse=True)
    list.sort(q,reverse=True)
    list.sort(r,reverse=True)
    strr = len(r)
    pq = []


    rindex = 0

    for index in range(X):
        sum += p[index]
        pq.append(p[index])

    for index in range(Y):
        sum += q[index]
        pq.append(q[index])

    list.sort(pq,reverse=True)
    strpq = len(pq)

    for index in range(strr):
        if strpq > index and r[index] > pq[X+Y-1-index]:
            sum += r[index] - pq[X+Y-1-index]

    print (sum)


if __name__ == '__main__':
    main()


Measured memory_bytes: 23328
#include <bits/stdc++.h>
#define len(x) ((int)(x).size())
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  if (N < 3) {
    cout << 0 << endl;
    return 0;
  }

  vector<int> l(N, 0);
  for (size_t i = 0; i < N; i++) {
    cin >> l[i];
  }

  int ans = 0;

  for (size_t i = 0; i < N; i++) {
    for (size_t j = i + 1; j < N; j++) {
      for (size_t k = j + 1; k < N; k++) {
        int a = l[i], b = l[j], c = l[k];
        if(a!=b && b != c && c != a) {
          if(abs(a-b) < c && c < a + b) {
            ans++;
          }
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3648
#!/usr/bin/env python3
p = [1]*100000
p[0] = 0
p[1] = 0
p[2] = 1
for i in range(3,100000):
    if i%2==0:
        p[i]=0
    if p[i]==1:
        j = i + i
        while j < 100000:
            p[j] = 0
            j += i
a = [0]*100000
for i in range(2,100000):
    if i % 2 ==0:
        continue
    if p[i] and p[(i+1)//2]:
        a[i] = 1
s = [0]*100001
for i in range(2,100000):
    s[i+1]=s[i]+a[i]
#print(s)
Q = int(input())
for i in range(Q):
    l,r=map(int,input().split())
    print(s[r+1]-s[l])


Measured memory_bytes: 7892
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:

};

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

    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    long double res = A[0];

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

    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

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

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

// 座標圧縮しか思いつかない
// 爆弾の数が3×10^5だから、座標圧縮かな
// でも、爆弾が斜めにきれいに並んでいたら、座標圧縮しても意味ないじゃん。
// 行と列個別に「最も爆破できるケースを求めて」、それらをA,Bとして、
// (A,B)に爆破対称があるなら、max(R) + max(C) - 1, ないならmax(R) + max(C)

int main() {
    int H, W, M;
    cin >> H >> W >> M;
    set<int> X, Y;
    set<pair<int, int>> hw;
    vector<int> Xb(H, 0), Yb(W, 0);
    repeat(i, M) {
        int h, w;
        cin >> h >> w;
        --h, --w;
        hw.emplace(h, w);
        X.insert(h);
        Y.insert(w);
        ++Xb[h];
        ++Yb[w];
    }
    /* 
    cout << "Xb: " << endl;
    repeat(i, H) cout << Xb[i] << " ";
    cout << endl;
    cout << "Yb: " << endl;
    repeat(i, W) cout << Yb[i] << " ";
    cout << endl;
 */
    int R = -1, C = -1;
    for (int x : X) {
        setmax(R, Xb[x]);
    }
    for (int y : Y) {
        setmax(C, Yb[y]);
    }
    vector<int> Rx, Cy;
    for (int x : X) {
        if (R == Xb[x]) Rx.push_back(x);
    }
    for (int y : Y) {
        if (C == Yb[y]) Cy.push_back(y);
    }
    for (int x : Rx) {
        for (int y : Cy) {
            if (!hw.count(make_pair(x, y))) {
                cout << R + C << endl;
                return 0;
            }
        }
    }
    cout << R + C - 1 << endl;
    return 0;
}

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

#define S 100
#define BLACK 2
#define WHITE 0
#define GRAY 1

int n,a[S][S];
int cnd[S],d[S],f[S],T=0;
int nt[S];

int next(int u){
    for(int v=nt[u];v<n;v++){
        nt[u]=v+1;
        if(a[u][v])return v;
    }
    return -1;
}

void visit(int r){
    for(int i=0;i<n;i++)nt[i]=0;
    stack<int>st;
    st.push(r);
    cnd[r]=GRAY;
    d[r]=++T;

    while(!st.empty()){
        int u=st.top();
        int v=next(u);
        if(v!=-1){
            if(cnd[v]==WHITE){
                cnd[v]=GRAY;
                d[v]=++T;
                st.push(v);
            }
        }else{
            st.pop();
            cnd[u]=BLACK;
            f[u]=++T;
        }
    }
}

void outp(){
    for(int i=0;i<n;i++){
        cnd[i]=WHITE;
        //nt[i]=0;
    }

    for(int j=0;j<n;j++){
        if(cnd[j]==WHITE)visit(j);
    }
    for(int k=0;k<n;k++){
        cout<<k+1<<" "<<d[k]<<" "<<f[k]<<endl;
    }
}

int main(){
    int u,k,J,i,j;
    cin>>n;
    for(i=0;i<n;i++){
        for(j=0;j<n;j++)a[i][j]=0;
    }
    for(i=0;i<n;i++){
        cin>>u>>k;
        for(j=0;j<k;j++){
            cin>>J;
            a[u-1][J-1]=1;
        }
    }
    outp();
    return 0;
}


Measured memory_bytes: 3144
#include <stdio.h>
#include <algorithm>
using namespace std;

constexpr int kN = int(1E2 + 10);
int a[kN];
int main() {
	int n, ans = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) if (a[i] != a[j]) 
		for (int k = j + 1; k <= n; k++) if (a[j] != a[k] && a[i] + a[j] > a[k]) ans++;
	printf("%d\n", ans);
}


Measured memory_bytes: 1736