akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  
  int sw=0;
  
  if(A>=K){
    sw=K;
  }else if(A<K&&K<=B){
    //
  }else{
    sw=A-(K-(A+B));
  }
  
  cout<<sw<<endl;
}




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

UL N,Q;
UL S[10000];

int main() {
 scanf("%u",&N);
 rep(i,N) scanf("%u",&S[i]);
 scanf("%u",&Q);
 UL ans=0;
 rep(q,Q){
  UL t; scanf("%u",&t);
  rep(i,N) if(S[i]==t){ ans++; break; }
 }
 printf("%u\n",ans);
 return 0;
}



Measured memory_bytes: 3216
#include <stdio.h>
#include <string.h>
#define LEN 103

void rot(char *str, int n) {
  char tmp = str[n-1];
  int i;
  for(i = 0; i < n-1; ++i) {
    str[n-1-i] = str[n-2-i];
  }
  str[0] = tmp;
}

int main(void)
{
  int i, len, flag = 0;
  char s1[LEN], s2[LEN];
  scanf("%s", s1); scanf("%s", s2);
  len = strlen(s1);
  
  for(i = 0; i < len; ++i) {
    if(strcmp(s1, s2) == 0) { flag = 1; break; }
    rot(s1, len);
    if(strcmp(s1, s2) == 0) { flag = 1; break; }
  }
  if(flag == 1) { printf("Yes\n"); } else { printf("No\n"); }
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

const int MAX = 2e5;

int parent[MAX];
int rankb[MAX];
 
void init(int x) {
    for(int i = 0; i <= x; i++)
    parent[i] = i,rankb[i] = 0;
}
 
int root(int x) {
    return (parent[x]==x) ? x : parent[x]=root(parent[x]);
}
 
bool same(int x, int y) {
    return root(x) == root(y);
}
 
void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;

    if (rankb[x] < rankb[y])
        parent[x] = y;
    else {
        parent[y] = x;
        if (rankb[x] == rankb[y]) rankb[x]++;
    }
}

int N, M, K;
vi friends[MAX];
vi blocks[MAX];

vi solve() {
    init(N+10);
    REP (i, N) FORE (f, friends[i]) unite (i, f);
    map<int, int> group;
    REP (i, N) {
        group[root(i)]++;
    }
    vi ans;
    REP (i, N) {
        ll r = group[root(i)] - friends[i].size();
        FORE (b, blocks[i]) if (root(b) == root(i)) r--;
        ans.push_back(r-1);
    }
    return ans;
}

int main() {
    cin >> N >> M >> K;
    REP (i, M) {
        int a, b; cin >> a >> b; a--; b--;
        friends[a].push_back(b);
        friends[b].push_back(a);
    }
    REP (i, K) {
        int a, b; cin >> a >> b; a--; b--;
        blocks[a].push_back(b);
        blocks[b].push_back(a);
    }
    FORE (x, solve()) cout << x << endl;
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{
    int n;
    cin >> n;

    map<int, int> N;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;

        N[a]++;
    }

    int ans = 0;
    for(auto i: N)
        ans += (i.Y) % 2;

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


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

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (a > 0 || c > 0) {
		c -= b;
		if (c <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
		a -= d;
		if (a <= 0) {
			cout << "No" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3624
import itertools
import math

N = int(input())
XY = []
for i in range(N):
    x, y = map(int, input().split())
    XY.append([x, y])
p = list(itertools.permutations(list(range(N))))
dist = []
for i in p:
    d = 0
    for j in range(0, len(i)-1):
        d += math.sqrt((XY[i[j]][0]-XY[i[j+1]][0])**2+(XY[i[j]][1]-XY[i[j+1]][1])**2)
    dist.append(d)
print(sum(dist)/len(p))

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

vector<ll> a{1}, p{1};

ll f(ll n, ll x)
{
    if (n == 0)
        return x <= 0 ? 0 : 1;
    else if (x <= 1 + a[n - 1])
        return f(n - 1, x - 1);
    else
        return p[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1]);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, x;
    cin >> n >> x;
    for (int i = 0; i < n; i++)
    {
        a.push_back(a[i] * 2 + 3);
        p.push_back(p[i] * 2 + 1);
    }
    cout << f(n, x) << endl;
}

Measured memory_bytes: 256
from collections import Counter

n, k = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]
OVER_RUN = n*k

cnt = [-1] * (2 * 10**5 + 10)
transition = [[-1] * n for _ in range(58)]
transition[0] = [0 for _ in range(1,n+1)]
for i, item in enumerate(a + a):
    if cnt[item] == -1:
        cnt[item] = i
        continue
    if cnt[item] < n:
        transition[1][cnt[item]] = i+1 - cnt[item]
    cnt[item] = i

for i in range(2,58):
    for j in range(n): 
        walk = transition[i-1][j] + transition[i-1][(transition[i-1][j] + j) % n]
        if walk > OVER_RUN:
            transition[i][j] = OVER_RUN
        else:
            transition[i][j] = walk

step = 0
step_mod = 0
while True:
    itr = 57 
    while transition[itr][step_mod] + step >= OVER_RUN:
        itr -= 1
    step += transition[itr][step_mod]
    step_mod = step % n
    if itr == 0:
        break

# Simulation
target = a[step_mod:]
ans = []
cnt = Counter()
for item in target:
    if cnt[item] > 0:
        while True:
            p = ans.pop()
            cnt[p] -= 1
            if p == item or not p:
                break
    else:
        cnt[item] += 1
        ans.append(item)
print(" ".join([str(item) for item in ans]))

Measured memory_bytes: 176208
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M,C;
  cin >> N >> M >> C;
  int A[N][M];
  int B[M];
  for(int i=0; i<M; i++) cin >> B[i];
  for(int i=0; i<N; i++)
    for(int j=0; j<M; j++)
      cin >> A[i][j];
  
  int count=0;
  int sum;
  for(int i=0; i<N; i++){
    sum = 0;
    for(int j=0; j<M; j++)
      sum += A[i][j] * B[j];
    if(sum + C > 0) count++;
  }
      
  
  cout << count << endl;
  
  return 0;
}
    
    

Measured memory_bytes: 256
//subset sum problem

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long int ll;
typedef unsigned long long int ull;
#define fi first
#define se second
#define pb push_back
ll mod1=pow(10,9)+7;
int mod2=998244353;
ll inf=1e9;
ll maxxy=1e6+9;
typedef long double ld;
const double PI =  3.141592653589793238;

ll power(ll x, ll y, ll pp)
{
    ll res = 1;
    x = x % pp;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % pp;
        y = y>>1;
        x = (x*x) % pp;
    }
    return res;
}

ll modInverse(ll n, ll pp)
{
    return power(n, pp-2, pp);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<ll>a(n),b(n),c(n);
    for (int i = 0; i <n ; ++i) {
        cin>>a[i]>>b[i]>>c[i];
    }
    ll dp[n+1][3];
    dp[0][0]=0;
    dp[0][1]=0;
    dp[0][2]=0;
    for (int i = 1; i <=n ; ++i) {
        for (int j = 0; j <3 ; ++j) {
            if(j==0){
                dp[i][j]=a[i-1]+max(dp[i-1][1],dp[i-1][2]);
            }
            if(j==1){
                dp[i][j]=b[i-1]+max(dp[i-1][0],dp[i-1][2]);
            }
            if(j==2){
                dp[i][j]=c[i-1]+max(dp[i-1][0],dp[i-1][1]);
            }
        }
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<"\n";
    return 0;
}


Measured memory_bytes: 7928
import Control.Applicative

qsort :: [Int] -> [Int]
qsort []     = []
qsort (p:xs) = qsort lt ++ [p] ++ qsort gteq
  where lt   = [x | x <- xs, x < p ]
        gteq = [x | x <- xs, x >= p]


main :: IO()
main = do
  line <- map (read :: String -> Int) . words <$> getLine
  putStrLn $ unwords $ map show $ qsort line

Measured memory_bytes: 3620
#include<iostream>
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

int main(void){
    int n;
    cin>>n;
    vector <int> a(n);
    rep(i, n){
        cin>>a[i];
    }
    int diff=accumulate(a.begin(), a.end(), 0);
    int diffz;
    int mindiff=100000;
    rep(i, n){
        diff-=2*a[i];
        diffz=abs(diff);
        if(diffz<mindiff){
            mindiff=diffz;
        }
    }
    cout<<mindiff<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-14

#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp make_pair
#define pb push_back

#define fi first
#define se second

#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef long long ll;

void solve(){
	int N,K;
	cin >> N;
	cin >> K;
	int A = 1;
	rep(i,N){
		if(A > K) A += K;
		else A *= 2;
	}
	cout << A << endl;
}

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

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_Q = (int)(2e5 + 5);

int n, q;
string s;
char t[MAX_Q];
char d[MAX_Q];

int l, r;

bool check(int start, int target) {
  int ind = start;
  for (int i = 0; i < q; ++i) {
    if (s[ind] == t[i]) {
      ind += (d[i] == 'L') ? -1 : 1;
    }
  }

  return (ind == target);
}

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &q);

  cin >> s;

  s.insert(0, "*");
  s.push_back('*');

  for (int i = 0; i < q; ++i) {
    cin >> t[i] >> d[i];
  }

  int ok;
  int ng;

  ok = n + 1;
  ng = 0;

  while (abs(ok - ng) > 1) {
    int next = (ok + ng) / 2;
    if (check(next, n + 1)) {
      ok = next;
    }
    else {
      ng = next;
    }
  }

  r = ok;

  ok = 0;
  ng = n + 1;

  while (abs(ok - ng) > 1) {
    int next = (ok + ng) / 2;
    if (check(next, 0)) {
      ok = next;
    }
    else {
      ng = next;
    }
  }

  l = ok;

  printf("%d\n", r - (l + 1));

  return 0;
}


Measured memory_bytes: 900
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var k = int.Parse(line[0]);
        var n = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var difmax = a[0] + k - a[n - 1];
        for (int i = 0; i < n - 1; i++)
            difmax = Max(difmax, a[i + 1] - a[i]);
        Console.WriteLine(k - difmax);
    }
}


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

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char before = ' ';
        String ans = "Good";
        for (char c : s.toCharArray()) {
            if (c == before) {
                ans = "Bad";
                break;
            }
            before = c;
        }
        System.out.println(ans);

    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
     
    #define int long long
    #define MOD 1000000007
     
     
    using namespace std;
     
    signed main(){
     
        int N;
        cin >> N;
        int A[N],B[N],C[N];
     
        
     
        for(int i=0;i<N;i++){
            cin >> A[i];
        }
        
        for(int i=0;i<N;i++){
            cin >> B[i];
        }
     
        for(int i=0;i<N;i++){
            cin >> C[i];
        }
     
        sort(A,A+N);
        sort(B,B+N);
        sort(C,C+N);
     
        int sum = 0;
     
        for(int i=0;i<N;i++){
            auto itr1 = lower_bound(A,A+N,B[i]);
     
            int a = itr1-A;
            //cout <<c <<endl;
            auto itr2 = upper_bound(C,C+N,B[i]);
            int c = C+N-itr2;
            //cout <<a <<endl;
            sum = sum + c*a;
        }
     
        cout <<sum <<endl;
     
        return 0;
    }

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define debug(x) cout << "eta --- > " <<  x << '\n'
int main()
{

    ll n; cin >> n;
    if(n >= 400 && n <= 599)
    {
        cout << "8\n";
    }
    if(n >= 600 && n <= 799)
    {
        cout << "7\n";
    }
    if(n >= 800 && n <= 999)
    {
        cout << "6\n";
    }
    if(n >= 1000 && n <= 1199)
    {
        cout << "5\n";
    }
    if(n >= 1200 && n <= 1399)
    {
        cout << "4\n";
    }
    if(n >= 1400 && n <= 1599)
    {
        cout << "3\n";
    }
    if(n >= 1600 && n <= 1799)
    {
        cout << "2\n";
    }
    if(n >= 1800 && n <= 1999)
    {
        cout << "1\n";
    }

}


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

int main() {
  int n;
  while(cin >> n && (n>=0)) {
    string s;
    while(n>0) {
      s=(char)('0'+n%4)+s;
      n/=4;
    }
    if(s=="")s="0";
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0); 
	int N; cin >> N; 
	map<int, long long> dif; 
	map<int, long long> sum; 
	map<int, bool> seen; 
	int A[200010] = {}; 
	for(int i = 1; i <= N; i++){
		int a; cin >> a; 
		dif[i - a] ++; sum[i + a] ++; 
	}
	long long ans = 0; 
	for(int i = 1; i <= N; i++){
		if(seen[i + A[i]]) continue;
		ans += dif[i - A[i]] * sum[i + A[i]]; 
		seen[i + A[i]] = true; 
	}
	cout << ans << endl; 
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
constexpr double EPS = 1e-10;
constexpr int INF = 1001001001;
//constexpr ll INF = 1001001001001001001ll;



template< typename Monoid >
struct SegmentTree {
    using F = function< Monoid(Monoid, Monoid) >;

    int sz;
    vector< Monoid > seg;

    const F f;
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
        sz = 1;
        while (sz < n) sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x) {
        seg[k + sz] = x;
    }

    void build() {
        for (int k = sz - 1; k > 0; k--) {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }

    void update(int k, const Monoid &x) {
        k += sz;
        seg[k] = x;
        while (k >>= 1) {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }

    Monoid query(int a, int b) {
        Monoid L = M1, R = M1;
        for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if (a & 1) L = f(L, seg[a++]);
            if (b & 1) R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const {
        return seg[k + sz];
    }
};

int main() {
    int N, K; cin >> N >> K;
    vi P(N);
    SegmentTree< int > seg1(N, [](int a, int b) { return min(a, b); }, INT_MAX);
    SegmentTree< int > seg2(N, [](int a, int b) { return max(a, b); }, -1);
    rep(i, N) {
        cin >> P[i];
        seg1.update(i, P[i]);
        seg2.update(i, P[i]);
    }

    int ans = 1;

    set<int> dob;
    int tmp = 0;
    for (int i = 0 ; i < N ; i++) {
        if (P[i] < P[i + 1]) {
            tmp ++;
            if (tmp == K - 1) {
                dob.insert(i - K + 2);
                tmp = 0;
            }
        }
        else tmp = 0;
    }

    int num = 0;
    if (dob.count(0)) num++;

    for (int i = 1; i + K - 1  < N; i++) {
        if (num == 0 && dob.count(i)) {
            num++;
            ans++;
            continue;
        }
        if (num != 0 && dob.count(i)) continue;

        if (P[i - 1] < seg1.query(i, i + K - 1)
                && P[i + K - 1] > seg2.query(i, i + K - 1)) {
            continue;
        }
        ans++;
    }

    cout << ans << endl;


}

Measured memory_bytes: 10240
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] c = new int[n - 1];
		int[] s = new int[n - 1];
		int[] f = new int[n - 1];

		for (int i = 0; i < n - 1; i++) {
			c[i] = sc.nextInt();
			s[i] = sc.nextInt();
			f[i] = sc.nextInt();
		}

		for (int i = 0; i < n; i++) {
			int t = 0;
			for (int j = i; j < n - 1; j++) {
				if (t < s[j]) {
					t = s[j];
				} else if (t % f[j] == 0) {

				} else {
					t = t + f[j] - t % f[j];
				}
				t += c[j];
			}
			System.out.println(t);
		}

		sc.close();
	}
}

Measured memory_bytes: 26984
n = int(input())
s = input()
s = list(s)
alfa = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
for i in range(len(s)):
    s[i] = alfa[(alfa.index(s[i])+n)%len(alfa)]
ans = ""
for i in range(len(s)):
    ans += s[i] 
print(ans)

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

using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
signed main(){
  int n;
  cin>>n;
  cout<<50<<endl;
  int a[50];
  int c=n/50;
  lp(i,50) a[i]=i+c;
  lp(i,n%50){
    lp(j,50){
      if(i==j) a[j]+=50;
      else a[j]--;
    }
  }
  lp(i,50) cout<<a[i]<<" ";
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int a[101][101],n,b[101][101];
void dfs(int x,int y)
{
	long long s=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			b[i][j]=max(b[i-1][j],b[i][j-1])+a[i][j];
		}
	} 
	cout<<b[n][n]<<endl;
    return;
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=2;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cin>>a[i][j];
		}
	}
	if(n==1)
	{
		cout<<a[1][1]+a[2][1];
		return 0;
	}
	dfs(1,1);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int x, t;
  cin >> x >> t;
  if(x-t < 0) print(0);
  else print(x-t);
}


Measured memory_bytes: 632
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int[] number = new int[6];
    for (int i = 0; i < 6; i++) {
      number[i] = Integer.parseInt(br.readLine());
    }
    int K = number[5];
    int range = 0;
    String ans = "Yay!";
    for (int i = 0; i < 5; i++) {
      for (int j = i + 1; j < 5; j++) {
        range = number[j] - number[i];
        if (range > K) {
          ans = ":(";
          break;
        }
        range = 0;
      }
      if (ans != "Yay!") break;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21204
#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#include<set>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#define maxn zhi5968
typedef long long ll;
using namespace std;

int main()
{
	string s;
	cin>>s;
	ll ans=0,cnt=0;
	for(int i=0;i<s.length();i++)
		if(s[i]=='W')
			ans+=(i-(cnt++));
	cout<<ans<<endl; 
	return 0;
}


Measured memory_bytes: 640
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n, m = list(map(int,ipti().split()))
    s = [0] * m
    c = [0] * m
    ans = [-1] * n

    for i in range(m):
        s[i], c[i] = list(map(int,ipti().split()))
        s[i] -= 1
        if ans[s[i]] == -1:
            ans[s[i]] = c[i]
        elif ans[s[i]] == c[i]:
            pass
        else:
            print(-1)
            sys.exit()

    if n == 1:
        if ans[0] == -1:
            ans[0] = 0
        print(ans[0])
        sys.exit()
    elif ans[0] == 0:
        print(-1)
        sys.exit()

    if ans[0] == -1:
        ans[0] = 1

    for i in range(1,n):
        if ans[i] == -1:
            ans[i] = 0

    for i in range(n):
        ans[i] = str(ans[i])

    print(''.join(ans))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd_ll(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int fiv(int n){
  if(n==0){
    return 0;
  }
  else if(n==1){
    return 1;
  }
  return fiv(n-1)+fiv(n-2);
}
ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}
int main(){
  int n,y;
  cin>>  n >>y;
  
  bool ok =false;
  for(int a=0; a<=n;a++){
    int b= y- 9000*a-1000*n;
    int c= 5000*a+5000*n-y;
    if(b>=0 && b%4000 ==0 && c>=0&& c%4000 ==0 ){
      cout << a <<" "<<b/4000 <<" "<< c/4000<<endl;
      ok=true;
      break;
    }
    
  }
  if(!ok) cout <<-1 <<" "<<-1<<" "<<-1<<endl;

}



Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{

long long int n,a[100],i,j,count=0,b[1000];
cin>>n;
for(i=0;i<n;i++)
{cin>>a[i];
b[i]=a[i];
}


sort(a,a+n);

for(i=0;i<n;i++)
{
  if(a[i]!=b[i])
    count++;
}
if(count<=2)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;

return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: print('Yes' if b else 'No')
YESNO=lambda b: print('YES' if b else 'NO')

def main():
    N,K=map(int,input().split())
    l=[0]*(K+1)
    ans=0
    for i in range(K,0,-1):
        tmp=pow(K//i,N,MOD)
        j=i*2
        while j<=K:
            if j>K:
                continue
            tmp-=l[j]
            tmp=(tmp+MOD)%MOD
            j+=i
        l[i]=tmp
        ans+=tmp*i
        ans%=MOD
    print(ans)
    
        

if __name__ == '__main__':
    main()


Measured memory_bytes: 72564
# -*- coding:utf-8 -*-
import math

N, A, B = map(int, input().split(' '))
hn = sorted([int(input()) for i in range(N)])

maxT = int(hn[-1] / B) + 1
minT = 0

def enough(T):
    count = sum([math.ceil((h - B*T) / (A-B)) if (h - B*T) >= 0 else 0 for h in hn])
    return True if count <= T else False

while True:
    med = int((maxT + minT) / 2)
    if enough(med):
        maxT = med
    else:
        minT = med
    if maxT - minT <= 1:
        break
print(maxT)


Measured memory_bytes: 10952
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, L;
int A[100000];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> L;
  rep(i, N) cin >> A[i];
  int b = -1;
  rep(i, N-1) {
    if (A[i] + A[i+1] >= L) {
      b = i+1;
      break;
    }
  }
  if (b == -1) {
    cout << "Impossible\n";
  }
  else {
    cout << "Possible\n";
    for (int i=1; i<b; i++) {
      cout << i << "\n";
    }
    for (int i=N-1; i>=b; i--) {
      cout << i << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
double arr[n];
for(int i=0; i<n; ++i)
cin>>arr[i];
int sum(0);
for(int i=0; i<m; ++i)
sum+=arr[i];
int maxi=sum;
int st(0),en(m-1);
for(int i=m; i<n; ++i)
{
sum-=arr[i-m];
sum+=arr[i];
if(sum>maxi)
{
st=i-m+1;
en=i;
}
maxi=max(maxi,sum);
}
double tel(0);
for(int i=st; i<=en; ++i)
{
for(int j=1; j<=arr[i]; ++j)
tel+=((1/arr[i])*j);
}
cout<<fixed<<setprecision(15)<<tel;
}


Measured memory_bytes: 1792
n, x, y = [int(i) for i in input().split()]

ans = [0] * (n)
for i in range(n-1):
  for j in range(i+1, n):
    ans[min(abs(j-i), abs((x-1)-i)+1+abs(j-(y-1)))] += 1
   
  
ans = ans[1:]
[print(ans[i]) for i in range(len(ans))]

Measured memory_bytes: 3444
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<climits>
using namespace std;

int main() {
  int ans=0;
  int X = 0;
  int N = 0;

  cin >> N >> X;

  vector<int> L(N);
  for(long i = 0; i < N; i++){
    cin >> L[i];
  }

  int cnt = 1;//D1=0
  int tmp =0;
  
  for(long i = 0; i < N; i++){
    tmp = tmp + L[i];
    
    if(tmp > X){
      break;
    }
    cnt++;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(ll key, ll value){
      this->key = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

constexpr ll DIVIDE = 1E+9+7;

ll total_search(const int x, const int y, const int H, const int W, vector<vector<bool>>& a, vvll& dp){
  ll ans = 0;
  if(dp[x][y]>=0) return dp[x][y];
  if(x==H-1 && y==W-1) return dp[x][y]=1;
  if(x<H-1 && a[x+1][y]){
    ans += total_search(x+1, y, H, W, a, dp);
  }
  if(y<W-1 && a[x][y+1]){
    ans += total_search(x, y+1, H, W, a, dp);
  }
  return dp[x][y] = ans%DIVIDE;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll H, W;
  cin >> H >> W;
  vector<vector<bool>> a(H, vector<bool>(W, false));
  vvll dp(H, vll(W, -1));
  rep(i, 0, H){
    rep(j, 0, W){
      char tmp;
      cin >> tmp;
      if(tmp=='.') a[i][j] = true;
    }
  }

  ll ans = total_search(0, 0, H, W, a, dp);

  cout << ans%DIVIDE << "\n";

  return 0;
}

Measured memory_bytes: 8448
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
N = [A, B, C, D, E]
loss = []
for i in range(5):
  if N[i]%10 == 0:
    loss.append(10)
  else:
    loss.append(N[i]%10)
Wait = (N[loss.index(min(loss))]) 
N.remove(Wait)
for i in range(4):
  if N[i]%10 == 0:
    Wait += N[i]
  else:
    Wait += ((N[i]//10+1)*10)
print(Wait)

Measured memory_bytes: 9080
a, b, c = map(int, input().split())

if a == b == c and a%2 == 0:
  print(-1)
elif a%2 or b%2 or c%2:
  print(0)
else:
  ans = 0
  while a%2 == b%2 == c%2 == 0:
    a, b, c = (b+c)//2, (a+c)//2, (a+b)//2
    ans += 1
  print(ans)

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

int main() {
	long int s,d;
	cin >> s;
	int min = 1000;
	
	for(int i=0;i<8;i++){
		d = abs(s%1000-753);
		if(d<min) min = d;
		s = s/10;
	}

	cout << min << endl;

	return 0;
}

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> p(n), old_p(n);
    REP(i, n) cin >> p[i];
    copy(p.begin(), p.end(), old_p.begin());
    sort(p.begin(), p.end());
    int counter = 0;
    REP(i, n) if (p[i] != old_p[i]) counter++;
    if (counter == 0 || counter == 2) cout << "YES";
    else cout << "NO";
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a, b, cnt = 0, i;
    float t;
    
    scanf("%d %d %f", &a, &b, &t);
    t = t + 0.5;
    for(i = 0; i < 21; i++){
        if(t >= a){
            t = t - a;
            cnt = cnt + 1;
        }else{
            break;
        }
    }
    printf("%d\n", cnt * b);
    
}


Measured memory_bytes: 1748
#include<iostream>
#include<string>
using namespace std;
int main(void){
	int n;
cin>>n;
bool f=false;
for(int i=0;i<n;i++){
	char a;
	cin>>a;
	if(a=='Y'){
		f=true;
	}
}
if(f){
	cout<<"Four"<<endl;
}else{
	cout<<"Three"<<endl;
}
return 0;
}

Measured memory_bytes: 256
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d,z;
    cin>>n;
    while(n>0){
        p=n%10;
        if(p==2){
            l++;
        }
        n/=10;
    }
    cout<<l<<endl;

    return EXIT_SUCCESS;
}



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

using namespace std;


int INF = 1 << 20;
#define MAX_V 500


// ????????¨????§??????? (???????????????????????????)
struct edge { int to, cap, rev; };
vector<vector<edge>> G( MAX_V ); // ??°???????????£??\???????????¨???
bool used[MAX_V]; // DFS??§?????§??????????????????????????°
				  // from??????to??????????????????cap???????????°?????????????????????
void add_edge( int from, int to, int cap ) {
	edge a;
	a.to = to;
	a.cap = cap;
	a.rev = G[to].size(); 
	edge b;
	b.to = from;
	b.cap = cap;
	b.rev = G[from].size();
	G[from].push_back( a );
	G[to].push_back( b );
}

void del_edge( int from, int to ) {
	auto ite = G[from].begin();
	while( ite < G[from].end() ) {
		if( ( *ite ).to == to ) {
			( *ite ).cap = 0;
		}
		ite++;

	}


	ite = G[to].begin();
	while( ite < G[to].end() ) {
		//cout << to << " " << ( *ite ).to << " " << ( *ite ).cap << endl;
		if( ( *ite ).to == from ) {
			( *ite ).cap = 0;
		}
		ite++;

	}
}

// ?¢?????????????DFS??§??¢???
int dfs( int v, int t, int f ) {
	if( v == t ) return f;
	used[v] = true;
	for( int i = 0; i < G[v].size(); i++ ) {
		edge &e = G[v][i];
		if( !used[e.to] && e.cap > 0 ) {
			int d = dfs( e.to, t, min( f, e.cap ) );
			if( d > 0 ) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
// s??????t???????????§???????±???????
int max_flow( int s, int t ) {
	for( size_t i = 0; i < MAX_V; i++ ) {
		used[i] = false;
	}
	int flow = 0;
	for( ;;) {
		memset( used, 0, sizeof( used ) );
		int f = dfs( s, t, INF );
		if( f == 0 ) return flow;
		flow += f;
	}
}

int main() {
	long long int N, E, Q;
	cin >> N >> E >> Q;
	for( size_t i = 0; i < E; i++ ) {
		long long int F, T;
		cin >> F >> T;
		F--; T--;
		add_edge( F, T, 1 );
		//add_edge( T, F, 1 );
	}
	for( size_t i = 0; i < Q; i++ ) {
		long long int M, A, B;
		cin >> M >> A >> B;
		A--; B--;
		if( M == 1 ) {
			add_edge( A, B, 1 );
			//add_edge( B, A, 1 );
		} else {
			del_edge( A, B );
		}
		auto memo = G;
		cout << max_flow( 0, N - 1 ) << endl;
		G = memo;
	}
}

Measured memory_bytes: 4024
#include <stdio.h>
#include <string.h>
#include <vector>

#define lli long long int
#define pb push_back

using namespace std;

int main() {
	lli lens, lent, ans = 0, temp = 0, id, x, left, right, mid;
	char s[100010], t[100010];
	vector<lli> pos[30];
	scanf("%s %s", s, t);
	lens = strlen(s);
	lent = strlen(t);
	for (lli i = 0; i < lens; i++)
		pos[s[i] - 'a'].pb(i + 1);
	for (lli i = 0; i < lens; i++)
		pos[s[i] - 'a'].pb(i + lens + 1);
	for (lli i = 0; i < lent; i++) {
		id = t[i] - 'a';
		if (pos[id].empty()) {
			ans = -1;
			break;
		}
		left = 0;
		right = pos[id].size() - 1;
		while (left <= right) {
			mid = (left + right) / 2;
			if (pos[id][mid] > temp) {
				x = pos[id][mid];
				right = mid - 1;
			}
			else
				left = mid + 1;
		}
		ans += (x - temp);
		temp = x % lens;
	}
	printf("%lld\n", ans);
	return 0;
}

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

 using namespace std;
 typedef long long ll;

 int main() {
   int A, B, K;
   cin >> A >> B >> K;

   for (int i = 1; i <= K; i ++) {
     if (i % 2 == 1) {
       int tmp;
       tmp = A - A / 2 - A % 2;
       B = B + A / 2;
       A = tmp;
     }
     else {
       int tmp;
       tmp = B - B / 2 - B % 2;
       A = A + B / 2;
       B = tmp;
     }
   }

   cout << A << " " << B << endl;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define el endl
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define sz size()
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define nn " " 
#define bg begin()
#define en end()
#define mod 1000000007
using namespace std;

int main()
{
    ll n;
    cin>>n;
    ll h[n],i,j,dp[n];
    for(i=0;i<n;i++)
        cin>>h[i];
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]);
    for(i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
#define MOD 1000000007
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
int main(){
    string s;cin>>s;
    vector<vector<ll>> vec(s.size(),vector<ll>(13));
    if(s.at(s.size()-1)=='?'){
        For(i,10){
            vec.at(s.size()-1).at(i)++;
        }
    }
    else{
        vec.at(s.size()-1).at((s.at(s.size()-1))-'0')++;
    }
    ll m=1;
    for(ll i=s.size()-2;i>-1;i--){
        m=(m*10)%13;
        if(s.at(i)=='?'){
            For(j,10){
                For(k,13){
                    vec.at(i).at((k+j*m)%13)+=vec.at(i+1).at(k)%MOD;                    
                }
            }
        }
        else{
            For(k,13){
                vec.at(i).at((k+(s.at(i)-'0')*m)%13)+=vec.at(i+1).at(k)%MOD;                    
            }            
        }
    }
    /*For(i,s.size()){
        For(j,13){
            cout<<vec.at(0).at(j)%MOD<<" ";
        }
        cout<<endl;
    }*/
    cout<<vec.at(0).at(5)%MOD<<endl;
}


Measured memory_bytes: 13696
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
int N, A, B, C, D, E;
int graph[51][51];

struct Node{
    int from, to, cost;
};

int F[101][11], P[101][11];
void solve(){
    int ans=-(1<<30);
    for(int msk=1; msk<(1<<10); ++msk){
        int sum=0;
        for(int i=0; i<N; ++i){
            int cnt=0;
            for(int j=0; j<10; ++j){
                if((msk & (1<<j))&& F[i][j]==1) cnt++;     
            }
            sum += P[i][cnt];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}
int main() {
    cin >> N;
    for(int i=0; i<N; ++i) for(int j=0; j<10; ++j) cin >> F[i][j];
    for(int i=0; i<N; ++i) for(int j=0; j<11; ++j) cin >> P[i][j];         
    solve();
	return 0;
}

Measured memory_bytes: 256
/*
author : seryu
title : ABC169D_"Div Game"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
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; }
ll MOD = 1000000007;
int INF = 1001001001;

//prime factor o(sqrt(n))
struct prime_factor
{
	map<ll, int> primes;
	prime_factor(ll n = 1)
	{
		for(ll i = 2; i * i <= n; i++)
		{
			int cnt = 0;
			while (n % i == 0)
			{
				n /= i;
				cnt++;
			}
			if(cnt > 0)primes[i] = cnt;
		}
		if(n > 1)primes[n]++;
	}

	ll get_prod()
	{
		ll res = 1;
		for(auto e : primes)
		{
			res *= ll(pow(e.first, e.second));
		}
		return res;
	}

	void show_factor()
	{
		for(auto e : primes)
		{
			cout << "(" << e.first << ", " << e.second << ")" << endl;
		}
	}
};

int order_to_prime(ll n, ll p)
{
	int res = 0;
	while (n % p == 0)
	{
		n /= p;
		res++;
	}
	return res;
}

void solve()
{
	ll n;
	cin >> n;
	prime_factor pf(n);
	int ans = 0;
	for (auto e:pf.primes)
	{
		int i = 0;
		while (true)
		{	
			if(i*(i+1) <= 2*e.second && 2*e.second < (i+1)*(i+2))
			{
				ans += i;
				break;
			}
			i++;
		}
	}
	cout << ans << endl;
	return;	
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int n;
  	cin >> n;
  	int oddeight = 0;
  	for(int i=1;i<=n;i++){
    	int a=i;
      	if(a%2 == 1){
        	int cou=0;
          	for(int j=1;j<=a;j++){
            	if(a%j==0) cou++;              
            }
          	if(cou==8) oddeight++;
        }
    }
  	cout << oddeight << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) for(int i=0;i<n;i++)
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vlai=valarray<int>;

struct Team{
    int id,ac,pn;
    vi wa=vi(11);
};

int main(void){
    int t,p,r;
    while(cin>>t>>p>>r,t){
        vector<Team> team(t+1);
        rep(i,t)team[i+1].id=i+1;
        rep(i,r){
            int id,num,tm;
            string stat;
            cin>>id>>num>>tm>>stat;
            if(stat=="CORRECT"){
                team[id].ac++;
                team[id].pn+=team[id].wa[num]*1200+tm;
            }else{
                team[id].wa[num]++;
            }
        }
        sort(all(team), [](Team a,Team b){return a.ac>b.ac || (a.ac==b.ac&&(a.pn<b.pn || (a.pn==b.pn&&a.id<b.id))); });
        rep(i,t+1){
            if(team[i].id) cout<<team[i].id<<" "<<team[i].ac<<" "<<team[i].pn<<endl;
        }
    }
}

Measured memory_bytes: 3180
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        // Your code here!
        
        int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int N = a[0]; //コマの数
        int M = a[1]; //区間の数
        int[] array = Console.ReadLine().Split(' ').Select(y => int.Parse(y)).ToArray();
        Array.Sort(array);
        int[] d = new int[100010];
        
        for(int i = 0; i < M - 1; i++)
        {
            d[i] = array[i + 1] - array[i];
        }
        
        Array.Sort(d);
        Array.Reverse(d);
        int sum = 0;
        for(int i = 0; i < N - 1; i++)//区切りの数(コマの数 - 1)分まわす
        {
            sum += d[i];
        }
        
        Console.WriteLine((array[array.Length - 1] - array[0]) - sum);
        /*
        for(int i = 0; i < M - 1; i++)
        {
            Console.WriteLine(d[i]);
        }
        */
    }
}

Measured memory_bytes: 20704
def Qb():
    s = input()
    t = input()

    ans = len(t)
    for v in range(len(s) - len(t) + 1):
        a = [t[i] != x for i, x in enumerate(s[v:len(t)+v])]
        if sum(a) < ans:
            ans = sum(a)
    print(ans)


if __name__ == '__main__':
    Qb()


Measured memory_bytes: 9036
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());

    let (n, m): (usize, usize) = (io.read(), io.read());
    let mut g: Vec<Vec<usize>> = vec![Vec::new(); n];
    for _ in 0..m {
        let (a, b): (usize, usize) = (io.read(), io.read());
        g[a - 1].push(b - 1);
        g[b - 1].push(a - 1);
    }

    let mut g = G {
        n: n,
        m: m,
        g: g,
        cnt: 0,
    };
    g.dfs(0, 0);

    io.writeln(g.cnt);
}
struct G {
    n: usize,
    m: usize,
    g: Vec<Vec<usize>>,
    cnt: usize,
}
impl G {
    fn dfs(&mut self, mut visited: usize, now: usize) {
        visited |= 1 << now;
        if visited.count_ones() == self.n as u32 {
            self.cnt += 1;
            return;
        }
        let gg = self.g.clone();
        for &to in gg[now].iter() {
            if visited >> to & 1 == 1 {
                continue;
            }
            self.dfs(visited, to);
        }
    }
}

static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll x,y; cin>>x>>y;
    if(x%y==0) cout<<-1<<endl;
    else cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 3632