akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

int a, b, c, d;

int main()
{
	IOS;
	cin >> a >> b >> c >> d;
	int x = c - a;
	int y = d - b;
	cout << c - y << ' ' << d + x << ' ' << a - y << ' ' << b + x << endl;
	return 0;
}



Measured memory_bytes: 256
Sd=STDIN.gets.chomp
T=STDIN.gets.chomp
for index2 in 0..Sd.length-T.length do
 index=Sd.length-T.length-index2
 flag=true
 for ind2 in 0...T.length do
  if !['?',T[ind2,1]].include?(Sd[index+ind2,1]) then
   flag=false
  end
 end
 if flag then
  newS=Sd[0...index]+T+Sd[index+T.length..Sd.length-1]
  break
 end
end
if !flag then
 puts "UNRESTORABLE"
else 
 newS=newS.gsub('?','a')
 puts newS
end

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

int main() {
    int N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    for (int i = 0; i < N; i++) cin >> w[i] >> v[i];
    
    vector<ll> dp(W+1, 0);
    for (int i = 0; i < N; i++) {
        for (int j = W; j >= w[i]; j--) {
            dp[j] = max(dp[j], dp[j-w[i]]+v[i]);
        }
    }
    ll ans = 0;
    for (int i = 0; i <= W; i++) ans = max(ans, dp[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3992
#include <iostream>

using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))

int main()
{
    int L,A,B,C,D;
    cin >> L >> A >> B >> C >> D;
    int maxA,maxB;
    maxA=A/C;
    if(A%C!=0) ++maxA;
    maxB=B/D;
    if(B%D!=0) ++maxB;
    cout << L-(MAX(maxA,maxB)) << endl;
    return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <map>
#include <functional>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> pt(N,0);
  for(int i=0; i<N*(N-1)/2; i++){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(c > d) pt[a-1] += 3;
    else if(c < d) pt[b-1] += 3;
    else{
      pt[a-1] += 1;
      pt[b-1] += 1;
    }
  }
  map<int,vector<int>,greater<int> > sort;
  for(int i=0; i<N; i++)
    sort[pt[i]].push_back(i);
  vector<int> rank(N,0);
  int count = 1;
  map<int,vector<int> >::iterator p;
  for(p = sort.begin(); p != sort.end(); p++){
    vector<int> vt = (*p).second;
    int ct = 0;
    for(int i=0; i<vt.size(); i++){
      rank[vt[i]] = count;
      ct++;
    }
    count += ct;
  }
  for(int i=0; i<rank.size(); i++) cout << rank[i] << endl;
  return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,f=0,ff=0;
    cin>>a>>b>>c>>d;
    while(a>0 &&c>0)
    {
        c-=b;

        if(c<=0)
        {
            ff=1;
            break;
        }
        a-=d;
        if(a<=0)
        {
            f=1;
            break;
        }

    }

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

}


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

using ll = long long;
using namespace std;

int main(){
    string S;
    cin >> S;
    int N = S.length();
    vector<int> A(N,0);

    int i=0;
    while(i<N){
        int R_cnt = 1;
        for(int j=i+1;j<N-1;j++){
            if(S[j] == 'R'){
                R_cnt++;
            }else{
                break;
            }
        }
        A[i+R_cnt-1] += (R_cnt+1)/2;
        A[i+R_cnt] += R_cnt - (R_cnt+1)/2;

        int L_cnt = 1;
        for(int j=i+R_cnt+1;j<N;j++){
            if(S[j] == 'L'){
                L_cnt++;
            }else{
                break;
            }
        }
        A[i+R_cnt-1] += L_cnt - (L_cnt+1)/2;
        A[i+R_cnt] += (L_cnt+1)/2;

        i += R_cnt+L_cnt;
    }

    rep(i,N) cout << A[i] << ' ';
}


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

typedef long double ld;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

#define FOR(i, b, e) for (int i = b; i <= e; i++)
#define FORD(i, b, e) for (int i = b; i >= e; i--)
#define SIZE(x) ((int)(x).size())
#define pb push_back
#define st first
#define nd second
#define all(a) begin(a), end(a)
#define watch(x) cerr << (#x) << " is " << (x) << '\n';

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

    string s;
    cin >> s;

    if (s == "Sunny") cout << "Cloudy";
    if (s == "Cloudy") cout << "Rainy";
    if (s == "Rainy") cout << "Sunny";

    return 0;
}


Measured memory_bytes: 256
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn=200003;
int x[1001];
void primefactor(int n){

  bool flag=true;
  for( int i=2LL ;i*i<=n;i++){
    while(n%i==0){
      x[i]++;
      n/=i;
      flag=false;
    }
  }
  if(n!=1)x[n]++;
}


int main(){
  int n;
  ll x;
  cin>>n>>x;
  ll a[maxn];
  ll res=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for (int i=1;i<n;i++){
    if(a[i]+a[i-1]>x){
      ll tmp=a[i]+a[i-1]-x;
      if(tmp>a[i]){a[i]=0;res+=tmp;}
      else{a[i]-=tmp;res+=tmp;}
    }
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    bool maki = true;
    for(int i=1;i<n;i++) if(a[i] <= a[i-1]) maki = false;
    if(maki) {
    	cout << 1 << endl;
    	return 0;
    }
    ll le = 1, ri = n, mid;
    while(ri - le > 1){
    	mid = (ri + le) / 2;
    	deque<pair<ll,ll> > dq;
    	bool ok = true;
    	for(int i=1;i<n;i++){
    		if(a[i] > a[i-1])continue;
    		else{
    			if(dq.empty()){
    				dq.push_back({a[i], 2LL});
    			}else{
    				while(!dq.empty() && dq.back().first > a[i]){
    					dq.pop_back();
    				}
    				if(dq.empty()){
    					dq.push_back({a[i], 2LL});
    				}else{
    					ll num = a[i];
    					while(!dq.empty() && dq.back().first == num && dq.back().second >= mid) dq.pop_back(), num--;
    					if(num == 0LL) ok = false;
    					if(dq.empty() || dq.back().first != num) dq.push_back({num,2LL});
    					else{
    						pair<ll,ll> p;
    						p = dq.back();
    						dq.pop_back();
    						dq.push_back({p.first, p.second+1});
    					}
    				}
    			}
    		}
    	}
    	if(ok) ri = mid;
    	else le = mid;
    }
    cout << ri << endl;
    return 0;
}


Measured memory_bytes: 1792
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#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>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

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


int main() {

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

    cout << max({A + B, A - B, A * B}) << endl;

}
























Measured memory_bytes: 256
def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)

def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max,mod=DIV):
    fac,finv,inv = [0]*max, [0]*max, [0]*max
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod -inv[mod%i] * (mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
    class CONV:
        def __init__(self):
            pass
        def ncr(self,n,k):
            if(n<k):
                return 0
            if(n<0 or k<0 ):
                return 0
            return fac[n]*(finv[k]*finv[n-k]%mod)%mod
    return CONV()



def main():
    N = iRaw()
    XLs = [isRaw() for _ in range(N)]
    XLs.sort(key = lambda xl:xl[0]+xl[1])
    curX = -(10**10)
    curL = 0
    ans = 0
    for X,L in XLs:
        if curX+curL <= X-L:
            ans+=1
            curX = X
            curL = L
    return ans


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 66008
#include <bits/stdc++.h>
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    cout<<(a+b)/2<<endl;
}


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

using namespace std;
typedef long long ll;

int main() {
    ll l, r, d;
    cin >> l >> r >> d;
    ll ans = 0;
    for (ll i = l; i <= r; i++) {
        if (i % d == 0) {
            ans++;
        }
    }
    cout << ans;
    return 0;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

bool check(char a, char b, char c) {
  return a != 's' && a == b && b == c;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  while (cin >> s) {
    if (check(s[0], s[1], s[2])) cout << s[0] << endl;
    else if (check(s[3], s[4], s[5])) cout << s[3] << endl;
    else if (check(s[6], s[7], s[8])) cout << s[6] << endl;
    else if (check(s[0], s[3], s[6])) cout << s[0] << endl;
    else if (check(s[1], s[4], s[7])) cout << s[1] << endl;
    else if (check(s[2], s[5], s[8])) cout << s[2] << endl;
    else if (check(s[0], s[4], s[8])) cout << s[0] << endl;
    else if (check(s[2], s[4], s[6])) cout << s[6] << endl;
    else cout << 'd' << endl;
  }

  return 0;
}


Measured memory_bytes: 3224
from collections import Counter
import numpy as np

h, w = map(int, input().split())
arr = [list(map(str, input().rstrip())) for _ in range(h)]

arr = sum(arr, [])

arr = Counter(arr)
arr = np.array(list(arr.values()))


def solve(arr):
    # 偶数×偶数なら、制約がかなりきつい
    if h % 2 == 0 and w % 2 == 0:
        return np.all(arr % 4 == 0)

    # 奇数×奇数なら、
    elif h % 2 == 1 and w % 2 == 1:
        even = (h + w) // 2 - 1
        if (arr % 2 == 1).sum() != 1:
            return False
        odd = arr[np.where(arr % 2 == 1)].sum()
        if odd % 4 == 3:
            even -= 1
        arr = arr[np.where(arr != odd)]
        ans = (arr % 4 == 2).sum() <= even
        ans &= np.all(arr[np.where(arr % 4 != 2)] % 4 == 0)
        return ans

    #　どちらかの辺が偶数なら
    else:
        even = h // 2 if h % 2 == 0 else w // 2
        ans = (arr % 4 == 2).sum() <= even
        ans &= np.all(arr[np.where(arr % 4 != 2)] % 4 == 0)
        return ans


print("Yes" if solve(arr) else "No")

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

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

int main()
{
    ll n,min=M,tmp;
    cin >> n;
    vll a(n);
    rep(i,n)cin >> a[i];
    rep(i,n){
        ll j=0;
        while(a[i] %  (int)pow(2,j) == 0){
            //if(a[i]%(int)pow(2,j) != 0)break;
            tmp = j;
            j++;
        }
        if(min >= tmp)min = tmp;
    }
    cout << min << endl;
    return 0;
}

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

int dfs(vector<int> gra[] , vector<int>& dp , int source )
{
    if(dp[source] != INT_MIN) return dp[source];
    if(gra[source].size() == 0)
    {
        dp[source] = 0;
        return 0;
    }
    int ans = 0;
    for(int i = 0 ; i < gra[source].size() ; i++)
    {
        ans = max(ans,dfs(gra,dp,gra[source][i]));
    }
    dp[source] = 1 + ans;
    return dp[source];
}
int main()
{  
    int n,m;
    cin>>n>>m;
    vector<int> gra[n+1];
    for(int i = 0 ; i < m ; i++)
    {
        int a ,b ;
        cin>>a>>b;
        gra[a].push_back(b);
    }
    vector<int> dp(n+1,INT_MIN);
    int ans = INT_MIN;
    for(int i = 1 ; i <= n ; i++)
    {
        ans = max(ans , dfs(gra,dp,i));
    }
    cout<<ans<<endl;
    return 0;
        
}



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

int main(){
    int n;
    cin >> n;
    vector<P> ans;
    if(n % 2){
        for(int i = 1; i <= n-1; i++){
            for(int j = i+1; j <= n; j++){
                if(i + j != n) ans.push_back(P(i,j));
            }
        }
    } else {
         for(int i = 1; i <= n-1; i++){
            for(int j = i+1; j <= n; j++){
                if(i + j != n+1) ans.push_back(P(i,j));
            }
        }
    }
    cout << ans.size() << endl;
    rep(i,ans.size()){
        cout << ans[i].first << " " << ans[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<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.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int n,m;
int mul(int a,int b){
  return a * b % m;
}
void add(int &a,int b){
  a += b;
  if(a >= m)
    a -= m;
}
int po2(int a){
  return (a-2) * (a - 1) % m;
}
// int odw3 = 1;
// int po3(int a){
//   return a * (a - 1) % m * (a - 2) % m * odw3 % m;
// }
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> m;
  vector<int> zost(3 * n + 1);
//   while(odw3 % 3 != 0)odw3 += m;
//   odw3 /= 3;
  zost[3*n] = 1;
  int res = 0;
  R(_,n+1){
    debug(zost);
    R(i,SZ(zost))add(res, zost[i]);
    debug(res);
    if(_ == n)break;
    
    for(int i = 3 * n - 1; i >= 0; i--){
      add(zost[i], zost[i + 1]);
    }
    
    vector<int> ak(3 * n + 1);
    R(i,SZ(zost)){
      if(i >= 2)add(ak[i - 2], mul(i-1, zost[i]));
      if(i >= 3)add(ak[i - 3], mul(po2(i), zost[i]));
    }
    swap(ak, zost);
  }
    
  cout << res << "\n";
}


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

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

    cout << d[n/2] - d[(n/2)-1] << endl;
}

Measured memory_bytes: 3772
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<utility>
#include<functional>
#include<algorithm>
#include<bitset>
#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
int main()
{
	string s;
	int res=1e9;
	cin>>s;
	for(int i=1;i<s.length();i++)
		if(s[i]!=s[i-1])
			res=min(max(i,max((int)s.length()-i,i)),res);
	cout<<min(res,(int)s.length());
	return 0;
}

Measured memory_bytes: 512
import fractions


def func(l):
    # r = fractions.gcd(l[0], l[1])
    for i in range(len(l) - 1):
        r = fractions.gcd(r, l[i + 1])
    return r


def func2(l):
    if len(l) == 1:
        return l[0]

    r = fractions.gcd(l[0], l[1])
    i = 2
    while i <= len(l) - 1:
        r = fractions.gcd(r, l[i])
        i += 1
    return r


def main():
    n, x = map(int, input().split())
    xl = [int(i) for i in input().split()]
    xl.append(x)
    xl.sort()

    # if n == 1:
    #     print(abs(xl[1] - xl[0]))
    #     return

    dl = []
    for i in range(len(xl) - 1):
        d = xl[i + 1] - xl[i]
        dl.append(d)

    print(func2(dl))


if __name__ == '__main__':
    main()


Measured memory_bytes: 16280
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
#define MOD 1000000007
#define EPS 10e-8
bool B[200007];

int main(){
    int N,k,l;
    l=0;
    bool A[200007];
    cin  >> N;
    rep(i,N){
        cin >> A[i+1];
    }
    for(int i=N;i>=1;i--){
        k=0;
        for(int j=i;j<=N;j+=i){
            if(B[j]==1){
                k++;
            }
        }
        if((k%2)!=A[i]){
            B[i]=1;
            l++;
        }
    }
    cout << l <<endl;

    rep(i,N){
        if(B[i+1]==1){
            cout << i+1 <<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[51],n,a,b,L,ok;
vector<ll> v[31];
int main(void){
    while(1){
    cin>>n;
    //cout<<n<<endl;
    if(n==0)return 0;
    ok=1;
    for(int i=0;i<31;i++)v[i]={};
    for(int i=0;i<n;i++){
        dp[i]=(1LL<<i);
    }
    for(int i=0;i<n;i++){
        cin>>a;
        for(int j=0;j<a;j++){
            cin>>b;
            v[b-1].push_back(i);
        }
    }
    for(int i=0;i<31;i++){
        L=0;
        for(auto x:v[i]){
            L|=dp[x];
        }
        if(L==(1LL<<n)-1){
            cout<<i+1<<endl;
            ok=0;
            break;
        }
        for(auto x:v[i]){
            dp[x]=L;
        }
    }
    if(ok)cout<<-1<<endl;
    }
}



Measured memory_bytes: 3080
# -*- coding: utf-8 -*-
#D - XXOR
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, K = map(int, readline().split())
A = list(map(int,readline().split()))

dp = [[0]*2 for i in range(41)]

for i in range(1,41):
    cnt = 0
    for j in range(N):
        cnt += 1 if (A[j] >> (40-i)) & 1 else 0
    if dp[i-1][1] == 1:
        dp[i][1] = 1
    if cnt >= N-cnt:
        #i行目は0にする
        dp[i][0] = dp[i-1][0] + 2**(40-i) * cnt
        if (K >> (40-i)) & 1 == 1:
            dp[i][1] = 1
    else:
        #i行目は1にしたい
        if dp[i][1] == 1:
            #1にする
            dp[i][0] = dp[i-1][0] + 2**(40-i)*(N-cnt)
        else:
            if (K >> (40-i))&1 == 1:
                #1にする
                dp[i][0] = dp[i-1][0] + 2**(40-i)*(N-cnt)
            else:
                #1にできないので0にする
                dp[i][0] = dp[i-1][0] + 2**(40-i)*cnt
print(dp[-1][0])

Measured memory_bytes: 84388
#define _CRT_SECURE_NO_WARNINGS
#include <array>
#include <cstdio>

using namespace std;

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || c > '9') break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

int main()
{
    int N;
    array<int, 100000> a;
    array<bool, 100000> b;

    b.fill(false);

    gc(N);

    for (int i = 0; i < N; i++)
    {
        gc(a[i]);
    }

    int x = 1;
    int cnt = 1;

    int nxt;
    while (true)
    {
        nxt = a[x - 1];
        if (nxt == 2) break;

        if (b[nxt - 1]) break;
        b[nxt - 1] = true;

        x = nxt;
        cnt++;
    }

    printf("%d\n", nxt == 2 ? cnt : -1);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]
int gcd(int x, int y)
{
    if(y==0)
        return x;
    return gcd(y, x%y);
}

 long long numbers[500005];

 int main(){

 long long a,b,x,counts=0;
 cin>>a>>b>>x;

 counts = (b/x)-(a/x);

 if(a%x == 0)
    counts++;

 cout<<counts<<endl;

return 0;
 }


Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>
using namespace std;
int l,r,ans;
char a[7];
inline bool judge(int i)
{
	sprintf(a,"%d",i);
	int len=strlen(a);
	for(int i=0;i<len/2;i++)
		if(a[i]!=a[len-i-1])return false;
	return true;
}
int main()
{
	scanf("%d%d",&l,&r);
	for(int i=l;i<=r;i++)
		if(judge(i))ans++;
	printf("%d\n",ans);
	return 0;
}

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

constexpr int kMod = 1'000'000'000 + 7;

int main() {
    int n, m; scanf("%d%d", &n, &m);
    long long x; scanf("%lld", &x);
    vector<tuple<int, int, int>> ed;
    for (int i = 0; i < m; ++i) {
        int u, v, w; scanf("%d%d%d", &u, &v, &w);
        u--, v--;
        ed.emplace_back(w, u, v);
    }
    vector<int> uf(n);
    iota(uf.begin(), uf.end(), 0);
    sort(ed.begin(), ed.end());

    function<int(int)> Find = [&](int x) {
        if (x == uf[x]) return x;
        return uf[x] = Find(uf[x]);
    };

    auto Merge = [&](int x, int y) {
        if ((x = Find(x)) == (y = Find(y))) return false;
        uf[x] = y;
        return true;
    };

    long long s = 0;
    vector<int> mst(m);
    for (int i = 0, j = 0; i < m; i = j) {
        for (j = i; j < m && get<0>(ed[j]) == get<0>(ed[i]); ++j) {
            int w, u, v;
            tie(w, u, v) = ed[j];
            if (Find(u) != Find(v)) mst[j] = 1;
        }
        for (int k = i; k < j; ++k) {
            int w, u, v;
            tie(w, u, v) = ed[k];
            if (Merge(u, v)) s += w;
        }
    }
    if (s > x) {
        puts("0");
        return 0;
    }
    if (s == x) {
        int p = 1, k = accumulate(mst.begin(), mst.end(), 0);
        for (int i = 0; i < k; ++i) p = (p + p) % kMod;
        p = (p + kMod - 2) % kMod;
        for (int i = 0; i < m - k; ++i) p = (p + p) % kMod;
        printf("%d\n", p);
        return 0;
    }
    int c = 0, d = 0, e = 0;
    for (int i = 0; i < m; ++i) {
        if (mst[i]) continue;
        iota(uf.begin(), uf.end(), 0);
        Merge(get<1>(ed[i]), get<2>(ed[i]));
        long long vl = get<0>(ed[i]);
        for (int j = 0; j < m; ++j) {
            if (i == j) continue;
            int w, u, v;
            tie(w, u, v) = ed[j];
            if (Merge(u, v)) vl += w;
        }
        if (vl == x) ++c;
        else if (vl < x) ++d;
        else ++e;
    }
    int p = 1;
    for (int i = 0; i < c; ++i) p = (p + p) % kMod;
    p = 2LL * (p + kMod - 1) % kMod;
    for (int i = 0; i < e; ++i) p = (p + p) % kMod;
    printf("%d\n", p);
    return 0;
}


Measured memory_bytes: 256
def main():
    import collections
    N = int(input())
    Sn = [input() for i in range(N)]
    c = collections.Counter(Sn)
    #print(Sn)
    #print(c)

    print("AC x " + str(c["AC"]))
    print("WA x " + str(c["WA"]))
    print("TLE x " + str(c["TLE"]))
    print("RE x " + str(c["RE"]))
    

if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;
const int MAXN = 2100;
const ll MOD = 1e9 + 7;

int N, K;
ll dp[MAXN][MAXN]; // my loc / loc + # of people left above me

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N >> K;
    dp[N][N] = 1;
    for (int i = N; i >= 1; i--)
    {
        ll ctot = 0;
        for (int j = i; j >= 0; j--)
        {
            ctot += dp[j][i];
            dp[j][i-1] = ctot % MOD;
        }
    }

    int cloc = N - K + 1;
    ll ans = (dp[0][cloc-1] - dp[0][cloc] + MOD) % MOD;
    for (int i = 0; i < cloc - 2; i++)
        ans = (ans * 2) % MOD;
    cout << ans << "\n";
}

Measured memory_bytes: 33024
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector <int> vi;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=100005;
const LL INF=1e17;
int n,x,y,z;
struct Node{
	int a,b;
}v[N];
LL ans=0,sum;
bool cmp(Node x,Node y){
	return x.a-x.b>y.a-y.b;
}
LL pre[N],suf[N];
multiset <int> S;
int main(){
	x=read(),y=read(),z=read(),n=x+y+z;
	For(i,1,n){
		int a=read(),b=read(),c=read();
		ans+=c,a-=c,b-=c;
		v[i].a=a,v[i].b=b;
	}
	sort(v+1,v+n+1,cmp);
	sum=0,S.clear();
	For(i,0,n+1)
		pre[i]=suf[i]=-INF;
	For(i,1,n){
		S.insert(v[i].a);
		sum+=v[i].a;
		if (S.size()>x){
			sum-=*S.begin();
			S.erase(S.begin());
		}
		if (S.size()==x)
			pre[i]=sum;
	}
	sum=0,S.clear();
	Fod(i,n,1){
		S.insert(v[i].b);
		sum+=v[i].b;
		if (S.size()>y){
			sum-=*S.begin();
			S.erase(S.begin());
		}
		if (S.size()==y)
			suf[i]=sum;
	}
	LL tmp=-INF;
	For(i,1,n-1)
		tmp=max(tmp,pre[i]+suf[i+1]);
	ans+=tmp;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7040
n,d=map(int,input().split())
adj=[]
for i in range(n):
  li=list(map(int,input().split()))
  adj.append(li)
count=0
for i in range(n):
  temp=adj[i]
  if (temp[0]*temp[0]+temp[1]*temp[1])<=d*d:
    count+=1
print(count)


Measured memory_bytes: 45424
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n,c,a[405],b[405],q[405][405],s[405][405],f[405][405],ans;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
	n=read(),c=read();
	for(int i=1;i<=400;++i){
		q[i][0]=1;
		for(int j=1;j<=400;++j) q[i][j]=(1ll*q[i][j-1]*i)%mod;
	}
	for(int i=0;i<=400;++i){
		s[i][0]=1;
		for(int j=1;j<=400;++j)
			s[i][j]=(s[i][j-1]+q[j][i])%mod;
	}
	for(int i=1;i<=n;++i) a[i]=read();
	for(int i=1;i<=n;++i) b[i]=read();
	f[0][0]=1;
	for(int i=1;i<=n;++i)
		for(int j=0;j<=c;++j)
			for(int k=0;k<=j;++k)
				f[i][j]=(1ll*f[i][j]+1ll*f[i-1][k]*((s[j-k][b[i]]-s[j-k][a[i]-1]+mod)%mod))%mod;
	printf("%d",f[n][c]);
}

Measured memory_bytes: 2176
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/03/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  vector<int> L(n); for(auto& l : L) cin>>l;
  sort(L.begin(), L.end());
  ll ans = 0;
  for (int i = 0; i < n-1; i++) {
    for (int j = i+1; j < n; j++) {
      int l = j, r = n;
      while (l+1<r) {
        auto c = (l+r)/2;
        if (L[c] < L[i]+L[j]) {
          l = c;
        } else {
          r = c;
        }
      }
      ans += l-j;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#S, L, h
import math
a, b, C = map(int, input().split())

S = a*b*math.sin(C*math.pi/180)*(1/2)
L = a+b+math.sqrt(a*a+b*b-2*a*b*math.cos(C*math.pi/180))
h = 2*S/a

print('%.4f'% S)
print('%.4f'% L)
print('%.4f'% h)

Measured memory_bytes: 7860
using System;

namespace Example03
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            float d = int.Parse(input[0]);
            float t = int.Parse(input[1]);
            float s = int.Parse(input[2]);

            if ((d / s) <= t) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 27468
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize,
        av: [usize; n]
    };
    let mut res = vec![0; n];
    for i in 0..n {
        let a = av[i] - 1;
        res[a] = i + 1;
    }
    println!("{}", res.into_iter().join(" "));
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 3840
#include <iostream>
using namespace std;
int n,a[200000];
int main(){
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=n-1;i>=0;i-=2){
        if(i!=n-1) cout<<" ";
        cout<<a[i];
    }for(int i=n%2;i<n;i+=2){
        cout<<" "<<a[i];
    }
}

Measured memory_bytes: 2944
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	static final int N=100000;
	static final int K=50000;
	static int n,k;
	static int w[],t[];
	
	public static boolean check_load(int limit)
	{
		int i,j;
		for(i=0;i<n;i++)
		{
			if(limit<w[i])
			{
				return false;
			}
		}
			Arrays.fill(t,0);
			i=j=0;
			while(i<n && j<k)
			{
				if(t[j]+w[i]<limit)
				{
					t[j]+=w[i++];
				}
				else if(t[j]+w[i]==limit)
				{
					t[j++]+=w[i++];
				}
				else
				{
					j++;
				}
				
			}
			return(i==n)?true:false;
	}
	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
        int i,l,u,a;
        Scanner scan=new Scanner(System.in);
        n=scan.nextInt();
        k=scan.nextInt();
        w=new int [n];
        t=new int [k];
        for(i=0;i<n;i++)
        {
        	w[i]=scan.nextInt();
        }
        
        l=0;
        u=0;
        for(i=0;i<n;i++)
        {
        	u+=w[i];
        }
        while(u-l>1)
        {
        	a=(l+u)/2;
        	if (check_load(a))
        	{
        		u=a;
        	}
        	else
        	{
        		l=a;
        	}
        }
        System.out.println(u);
        
	}

}

Measured memory_bytes: 64920
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int H,W,i,k,j;

    cin >> H >> W;
    for(j=0;j<W+2;j++){
        cout << "#";
    }
    cout << endl;
    
    for(i=0;i<H;i++){
        vector<char> v(W);
        cout << "#";
        for(k=0;k<W;k++){
            cin >> v.at(k);
            cout << v.at(k);
        }
        cout << "#" << endl;
    } 


    for(j=0;j<W+2;j++){
        cout << "#";
    }
    cout << endl;
    }

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

int main()
{
	int x, sum = 0;
	char ch;
	string str;
	cin >> x;
	ch = getchar();
	cin >> str;
	for (int i = 0, r = str.size() - 1;;)
	{
		while (str[i] == 'R') i++;
		while (str[r] == 'W') r--;
		if (str[i] == 'W' && str[r] == 'R' && i < r)
		{
			swap(str[i], str[r]);
			sum++;
		}
		if (r - i <= 1)
			break;
	}
	int i;
	for (i = 0; i < str.size(); i++)
	{
		if (str[i] == 'W')
			break;
	}
	for (i; i < str.size(); i++)
		if (str[i] == 'R')
			sum++;
	cout << sum << endl;
}

Measured memory_bytes: 3368
package main

import (
	"fmt"
	"sort"
	"math"
)

func makeabs(A []int) []int {
	for i := 0; i < len(A); i++ {
		A[i] = int(math.Abs(float64(A[i])))
	}
	return A
}

func sum(A []int) int {
	s := 0
	for _, a := range A {
		s += a
	}
	return s
}

func minAbs(A []int) int {
	s := math.Abs(float64(A[0]))

	for i := 1; i < len(A); i++ {
		if t := math.Abs(float64(A[i])); t < s {
			s = t
		}
	}

	return int(s)
}

func main() {
	var N int
	fmt.Scanf("%d", &N)

	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &A[i])
	}

	sort.Sort(sort.Reverse(sort.IntSlice(A)))

	n_neg := 0
	for _, a := range A {
		if a < 0 {
			n_neg++
		}
	}

	if n_neg % 2 == 0 {
		fmt.Println(sum(makeabs(A)))
	} else {
		fmt.Println(sum(makeabs(A)) - 2 * minAbs(A))
	}
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  cin >> n >> m;
  vector<int> a(n);
  int s = 0;
  for (int& x : a) {
    cin >> x;
    s += x;
  }
  sort(begin(a), end(a), greater<int>());
  if (a[m - 1] * 4 * m < s) {
    cout << "No\n";
  } else {
    cout << "Yes\n";
  }
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 256
n,m=input().split()
n,m=int(n),int(m)
if n==2 or m==2:
    print("0")
elif n==1 and m==1:
    print("1")
elif n==1 or m==1:
    print(n*m-2)
else:
    print(n*m-2*n-2*m+4)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
void solve(){
  long long a,b,k;
  cin >> k >> a >> b;
  long long res;
  if(k<a)res = k+1;
  else{
    if(a+2>=b)res=k+1;
    else{
      k-=(a-1);
      res = (k/2)*b-(k/2-1)*a+k%2;
    }
  }
  cout << res << endl;
}
void solve2(){
  int n;
  cin >> n;
  vector<long long>a(n);
  vector<long long>b(n);
  vector<long long>to_change(0);
  vector<long long>to_lower(0);
  long long k=0;
  long long min_c = 0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    k += a[i];
  }
  for(int i=0;i<n;i++){
    cin >> b[i];
    if(b[i]>a[i]){
      to_change.push_back(i);
      min_c += b[i];
    }else{
      min_c += a[i];
      to_lower.push_back(a[i]-b[i]);
    }
  }

  sort(to_lower.begin(),to_lower.end(),greater<int>());

  if(min_c <= k)cout << to_change.size() << endl;
  else{
    int cnt = 0;
    bool done = false;
    for(int i=0;i<to_lower.size();i++){
      min_c-=to_lower[i];
      cnt++;
      if(min_c <= k){
        done = true;
        break;
      }
    }
    if(done)cout << to_change.size()+cnt << endl;
    else cout << -1 << endl;
  }

}
int main(){
  solve2();
  return 0;
}


Measured memory_bytes: 5928
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
	string s,t;
	cin >> s >> t;
	if(s == t.substr(0, t.length()-1)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define mp make_pair
#define pb push_back
#define EB emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr double eps = 1e-14; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

vector<int> BM(string target,string pattern){
    vector<int> ret;
    int n = target.size();
    int m = pattern.size();
    // make dict
    map<char,int> dict;
    for(int i=0;i<m-1;i++) dict[pattern[i]] = m-1-i;

    int tail=m-1;
    while(tail<n){
        int k=m-1;
        int t = tail;
        while(k>=0 and target[t]==pattern[k]){
            k--;
            t--;
        }

        if(k==-1){                  // match
            ret.push_back(tail-m+1);
            tail++;
        }else if(!dict.count(target[t])){
            tail += k+1;
        }else{
            tail += max(1,dict[target[t]]-(m-1-k));
        }
    }
    return ret;
}

int main(){
    string t,p;
    cin >> t >> p;

    auto ans = BM(t,p);
    for(int a : ans) cout << a << endl;

    return 0;
}

Measured memory_bytes: 3152
#include<iostream>
using namespace std;
 
class Cube{
public:
  int f[6];
  Cube(){}
  void roll_z(){roll(1, 2, 4, 3);}//
  void roll_y(){roll(0, 2, 5, 3);}// to W
  void roll_x(){roll(0, 1, 5, 4);}// to N
  void roll(int i, int j, int k, int l){
    int t = f[i]; f[i] = f[j];  f[j] = f[k]; f[k] = f[l]; f[l] = t;
  } 
};
bool eq( Cube c1, Cube c2 ){
  for ( int i = 0; i < 6; i++ )
    if ( c1.f[i] != c2.f[i] ) return false;
  return true;
}

bool equal( Cube c1, Cube c2 ){
  for ( int i = 0; i < 6; i++){
   for ( int j = 0; j < 4; j++){
    if ( eq(c1, c2) ) return true;
     c1.roll_z();
}
if ( i % 2 == 0 ) c1.roll_y();
else c1.roll_x();
}
 return false;
}

int main(){
 Cube c1, c2;

  for ( int i = 0; i < 6; i++ ) cin >> c1.f[i];
  for ( int i = 0; i < 6; i++ ) cin >> c2.f[i];
 
  if ( equal(c1, c2) ) cout << "Yes" << endl;
  else cout << "No" << endl;

return 0;
}
  


Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>

typedef unsigned long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

int main(){
    ll m;
    cin >> m;
    vector<ll> c(m),d(m);
    for(int i = 0; i < m; i++){
        cin >> d[i] >> c[i];
    }

    ll sumc = 0, sumd = 0;
    for(int i = 0; i < m; i++){
        sumc += c[i];
        sumd += d[i]*c[i];
    }
    ll ans = sumc-1L + (sumd-1)/9L;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int E;

int main(int argc, char const* argv[])
{
    while ( cin >> E and E > 0 ) {
        int m = E;
        for (int z = 0; z * z * z <= E ; z++) {
            for (int y = 0; y * y <= E - z * z * z; y++) {
                int x = E - z * z * z - y * y;
                if ( x + y + z < m) m = x + y + z;
            }
        }
        cout << m << endl;
    }
    return 0;
}

Measured memory_bytes: 2992
# define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <unordered_set>
# include <unordered_map>
# include <climits>
# include <complex>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define STRING(x) string x;cin>>x;
# define STR(x) STRING(x);
# define DOUBLE(x) double x;cin>>x;
# define DBL(x) DOUBLE(x); 
# define ALL(x) begin(x),end(x)
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
//const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
const int M = 1000000007;
template<class T> void debug(T a) { for ( auto i : a )cout << i << endl; }

struct P
{
	int x, y;
	int t;
	int c;
	P(int x, int y, int t, int c) :x(x), y(y), t(t), c(c) {}
	bool operator<(const P &other)const { return t < other.t; }
	bool operator>(const P &other)const { return t > other.t; }
};


signed main()
{
	while ( true )
	{
		int w, h; cin >> w >> h;
		if ( !w )break;
		int a[100][100];
		bool goal[100][100] = {};
		int flag[100][100][2];
		memset(a, -1, sizeof a);
		FOR(i, 100)FOR(j, 100)FOR(k, 2)flag[i][j][k] = INF;
		vector<pii> s;
		priority_queue< P, vector<P>, greater<P> >que;
		FORI(i, 10, h + 10)
		{
			FORI(j, 10, w + 10)
			{
				char c; cin >> c;
				switch ( c )
				{
				case 'X':
					a[i][j] = -1;
					break;
				case 'S':
					a[i][j] = 0;
					que.emplace(i, j, 0, 0);
					que.emplace(i, j, 0, 1);
					flag[i][j][0] = flag[i][j][1] = 0;
					break;
				case 'T':
					a[i][j] = 0;
					goal[i][j] = true;
					break;
				default:
					a[i][j] = c - '0';
					break;
				}
			}
		}


		const int dy[9] = { 1,1,2,1,2,3,1,2,1 };
		const int dx[9] = { 2,1,1,0,0,0,-1,-1,-2 };
		bool ok = false;
		while ( !que.empty() )
		{
			P now = que.top(); que.pop();
			if ( goal[now.x][now.y] )
			{
				ok = true;
				cout << now.t << endl;
				break;
			}

			FOR(i, 9)
			{
				P next = now;
				if ( now.c % 2 )next.y += dy[i];
				else next.y -= dy[i];
				next.x += dx[i];
				next.c = (next.c + 1) % 2;
				next.t += a[next.x][next.y];
				if ( a[next.x][next.y] != -1 && flag[next.x][next.y][next.c] > next.t )
				{
					que.push(next);
					flag[next.x][next.y][next.c] = next.t;
				}
			}
		}

		if ( !ok )cout << -1 << endl;
	}
}

Measured memory_bytes: 3200
s=input()
stack_all=[]
stack_A=[]
point=0
#stack_allで全体の面積をはじめに求める
for i,j in enumerate(s):
    if j=="\\":
        stack_all.append(i)
    elif j=="/":
        try:
            left=stack_all.pop()
            po=i-left
            point +=po
            stack_A.append([left,po])
        except:continue
print(point)

#stack_Aに水が溜まっていくのをスタックしておく
#この過程で数字の小さいものは大きいものの上にきていることがわかるから重ねていく
stack_A.insert(0,[-1,-1])
stack_B=[]
if len(stack_A)==1:print(0)
else:
    for i in range(len(stack_A)-1,-1,-1):
        x,y=stack_A[i]
        px,py=stack_A[i-1]
        if x<px:
            stack_A[i-1]=[x,y+py]
        else:
            stack_B.append(stack_A[i])
    print(len(stack_B),*[j for i,j in stack_B[::-1]])


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

int main(){
  long long int n;
  cin>>n;
  long long int a,b;
  a=0;
  while(a*a<n){
    a++;
    if(n%a==0){
      b=n/a;
    }
  }
  long long int ansn=0;
  long long int x = max(a,b);
  for(int i = 0;x>0;x/=10)ansn++;
  cout<<ansn<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    int ct = 0;
    rep(i,s.size()) if (s[i] == 'R') ct++;
    if (ct == 3) cout << 3 << endl;
    else if (ct == 2) {
        if (s[0] == 'R' && s[2] == 'R') cout << 1 << endl;
        else cout << 2 << endl;
    }
    else if (ct == 1) cout << 1 << endl;
    else if (ct == 0) cout << 0 << endl;
}

Measured memory_bytes: 3620
#include<stdio.h>
int main()
{
    int K,count=0;
    long long N,mod,temp;
    scanf("%lld%d",&N,&K);
    temp=N;
    while(temp!=0){
        mod=temp%K;
        count++;
        temp=temp/K;
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 128