akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args){

		solve_abc150_b();
	}
  
  	public static void solve_abc150_b(){
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		String S = sc.next();
		String keyword = "ABC";
		int count = 0;
		
		for(int i=0;i<N-(keyword.length()-1);i++){
			
			if(S.substring(i, i+keyword.length()).equals(keyword)){
				count++;
				i += keyword.length() - 1;
			}
		}
		
		System.out.println(count);
		sc.close();
		
	}
}

Measured memory_bytes: 22100
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n,m=gsmi

# 奇数右裏、偶数→表
if n==1&&m==1
  cnt=1
elsif n==1
  cnt=m-2
elsif m==1
  cnt=n-2
else
  cnt=(n-2)*(m-2)
end

puts cnt

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

#define int long long
signed main(){
  int n;
  int m;
  cin >> n >> m;
  vector<int> vec[100010];
  
  for(int i = 0;i < n;i++){
    int a, b;
    cin >> a >> b;
    vec[a].push_back(b);
  }
  
  priority_queue<int> que;
  
  int ans = 0;
  for(int i = 0;i <= m;i++){
    for(int j = 0;j < vec[i].size();j++){
      que.push(vec[i][j]);
    }
    
    if(!que.empty()){
	  ans += que.top();
      que.pop();
    }
  }
  
  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 5632
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
const long double PI = acos(-1);
using namespace std;
int main (){
    int a, b; 
    cin >> a >> b;
    while(a!=0&&b!=0){
        for(int i=0; i<a; i++){
             for(int j=0; j<b; j++){
                 if(i==0||i==a-1){
                     cout << "#"; continue;
                 } 
                 else if(j==0||j==b-1) cout << "#";
                 else cout << ".";
             }
            cout << endl;
        }
        cout << endl;
        cin >> a >> b;
    }
    return 0;
}


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

using namespace std;

long long Min , N;
vector<long long>vec;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> N;
    vec=vector<long long>(N);
    vector<long long>ans(N);
    for(int i=0; i<N; i++){
        cin >> vec[i];
    }
    ans[N-1] = 0;
    for(int i=N-2; i>=0; i--){
        if(i+2<N){
           ans[i] = min(abs(vec[i]-vec[i+1])+ans[i+1],abs(vec[i]-vec[i+2])+ans[i+2]);
        }
        if(i+1<N && i+2>=N){
            ans[i] = abs(vec[i]-vec[i+1])+ans[i+1];
        }
        //cout << ans[i] << endl;
    }
    cout << ans[0] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define ll long long
#define pp pair<int,int> 
const int INF = 1001001001;
//int 2×10の9乗

//vector<vector<int>> a(n, vector<int>(m));
  //rep(i,n) rep(j,m) cin >> a[i][j]; 
 
int main(){
  string s;
  cin >> s;
  int a=s[6]-'0';
  if(s[5]=='1') cout << "TBD" << endl;
  else if(a>4) cout << "TBD" << endl;
  else cout << "Heisei" << endl;
}    

Measured memory_bytes: 256
#include <stdio.h>

int A[1000000], n;

int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1; 
    if(key > A[mid]) left = mid + 1;
    else if(key < A[mid]) right = mid; 
  }
  return 0;
}

int main(void) {
  int i, q, k, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 2096
/*
 ____________________________________________________________
|                                                            |
|                   Author: ay2306                           |
|____________________________________________________________|

*/
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define ord_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
const ll maxn = 1e5;
V<V<PLL>> adj;
V<int> color;
V<bool> vis;

void dfs(int s = 0, int p = -1){
    vis[s] = true;
    for(auto &i: adj[s]){
        if(i.F == p)continue;
        if(i.S % 2 == 0)color[i.F] = color[s];
        else color[i.F] = 1-color[s];
        dfs(i.F,s);
    }
}

int main(){
    int n;
    cin >> n;
    adj = V<V<PLL>>(n,V<PLL>());
    color = V<int> (n,0);
    vis = V<bool> (n,false);
    loop(i,1,n){
        ll a,b,c;
        cin >> a >> b >> c;
        adj[a-1].pb(mp(b-1,c));
        adj[b-1].pb(mp(a-1,c));
    }
    dfs();
    loop(i,0,n){
        cout << color[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 10496
/*
h s, d't skp th si tll i's svedclTabCtrl
 * ABC141 E
 * ABC145 D
 * ABC147 F
 * ABC174 F
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
ll n,m,k;
cin>>n>>m>>k;
vector<ll> a,b;
ll x=0;
for(ll i=0;i<n;i++)
{
cin>>x;
a.push_back(x);
}
for(ll i=0;i<m;i++)
{
cin>>x;
b.push_back(x);
}
ll ans=n;
ll ps=n-1;
ll sm=0;
for(ll i=0;i<n;i++)
{
if(k>=sm+a[i])
{
sm+=a[i];
}
else
{
ps=i-1;
ans=i;
break;
}
}
for(ll i=0;i<m;i++)
{
if(k>=sm+b[i])
{
sm+=b[i];
ans=max(ans,ps+1+i+1);
}
else
{
if(ps>=0)
{
sm-=a[ps];
ps--;
i--;
}
else
{
break;
}
}
}
cout<<ans;
}
/*
 *||||

 */

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

int main() {
	int max,n;
	vector<int> id;
	vector<int> sum;
	vector<int> table;
	
	id.resize(4000);
	sum.resize(4000);
	table.resize(4000);
	
	while(cin>>n,n){
		int i,f;
		long long int a,b;
		max = 0;
		
		for(int j=0;j<4000;++j){
			id[j] = 0;
			sum[j] = 0;
			table[j] = 0;
		}
		
		for(;n;--n){
			cin>>i>>a>>b;
			
			if(table[i-1]==0){
				id[max]=i;
				table[i-1] = max+1;
				++max;
			}
			if(a*b>=1000000)sum[table[i-1]-1] = 1000000;
			else if(sum[table[i-1]-1]<1000000)sum[table[i-1]-1] += a*b;
			
		}
		f=0;
		for(int j=0;j<max;++j){
			if(sum[j]>=1000000){
				cout<<id[j]<<endl;
				f=1;
			}
		}
		if(!f)cout<<"NA"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1252
import Control.Applicative
import Control.Monad
import Data.List
import Data.List.Split (splitOn)

import Data.Time.Calendar

main :: IO ()
main = do
  s <- getLine
  unless (s == "#") $ do
    putStrLn $ solve s
    main

solve :: String -> String
solve s
  | length ds == 3 = intercalate "." $ map show $ ce_maya ds
  | otherwise = intercalate "." $ map show $ maya_ce ds
  where
    ds = map read $ splitOn "." s :: [Int]
    

ce_maya :: [Int] -> [Int]
ce_maya [cy, cm, cd] = g $ reverse $ f [] (fromIntegral td) [20 * 18 * 20 * 20, 20 * 18 * 20, 20 * 18, 20]
  where
    d = fromGregorian (fromIntegral cy) cm cd
    td = diffDays d (fromGregorian 2012 12 21)
    f ls d [x] = let (q, r) = divMod d x in (r : q : ls)
    f ls d (x:xs) = let (q, r) = divMod d x in
                     f (q:ls) r xs
    g (x:xs) = (x `mod` 13) : xs

maya_ce :: [Int] -> [Int]
maya_ce [b, ka, t, w, ki] = [fromIntegral cy, cm, cd]
  where
    td = ki + 20 * w + 20 * 18 * t + 20 * 18 * 20 * ka + 20 * 18 * 20 * 20 * b
    bst  = fromGregorian 2012 12 21
    (cy, cm, cd) = toGregorian (addDays (fromIntegral td) bst)



Measured memory_bytes: 4212
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <complex>
#include <iomanip>
using namespace std;
typedef complex<double> P;
const double EPS = 1e-10;

namespace std
{
bool operator<(P &a, P &b)
{
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
}
} // namespace std

double dot(P a, P b)
{
    return real(a) * real(b) + imag(a) * imag(b);
}

double cross(P a, P b)
{
    return real(a) * imag(b) - imag(a) * real(b);
}

int main(void)
{

    double a, b, c, d;
    cin >> a >> b >> c >> d;

    P p1(a, b);
    P p2(c, d);
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i)
    {
        double a, b;
        cin >> a >> b;
        P p(a, b);

        P x;
        x = p1 + dot(p - p1, p2 - p1) * (p2 - p1) / pow(abs(p2 - p1), 2.0);
        cout << fixed << setprecision(15) << x.real() << " " << x.imag() << endl;
    }
}


Measured memory_bytes: 3356
#![allow(dead_code, unused_variables, unused_imports)]
use proconio::marker::Chars;
use proconio::{fastout, input};
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet};

#[fastout]
fn main() {
    input! {
        n:usize,
        m:usize,
        x:usize,
    }

    let mut a = vec![];
    let mut c = vec![];
    for i in 0..n {
        input! {
            cc : usize,
            x : [usize;m],
        }
        a.push(x);
        c.push(cc);
    }

    let mut ans: usize = 1_000_000_000;
    for i in 0..(1 << n) {
        let mut tmp = vec![0; m];
        let mut cost = 0;
        for j in 0..n {
            if (i >> j) & 1 == 1 {
                cost += c[j];
                for k in 0..m {
                    tmp[k] += a[j][k];
                }
            }
        }
        let mut f = true;
        for e in tmp {
            if e < x {
                f = false;
                break;
            }
        }

        if f {
            ans = min(ans, cost);
        }
    }

    if ans == 1_000_000_000 {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 2136
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>

using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;

char s[4];
int a, b, c, d;
char opes[2] = { '+', '-' };

int main() {
  scanf("%s", s);
  a = s[0] - '0';
  b = s[1] - '0';
  c = s[2] - '0';
  d = s[3] - '0';
  rep(i, 2) {
    int ab = opes[i] == '+' ? a + b : a - b;
    rep(j, 2) {
      int abc = opes[j] == '+' ? ab + c : ab - c;
      rep(k, 2) {
        int abcd = opes[k] == '+' ? abc + d : abc - d;
        if (abcd == 7) {
          printf("%d%c%d%c%d%c%d=7\n", a, opes[i], b, opes[j], c, opes[k], d);
          return 0;
        }
      }
    }
  }
}


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

ll walk(vector<vector<ll>> &adj, ll n, ll K){

    ll dp[K+1][n][n];
    memset(dp, 0, sizeof(dp));
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            dp[1][i][j] = adj[i][j];

    for(int k=2; k<=K; k++){
        for(int z=0; z<n; z++)
            for(int i=0; i<n; i++)
                for(int j=0; j<n; j++){
                // No. of paths from i to j in 'k' steps +=
                // No. of paths from i to z in (k-1) steps *
                // No. of paths from z to j in (k-1) steps
                dp[k][i][j] = (dp[k][i][j] + (dp[k-1][i][z]*dp[k-1][z][j])%M)%M;
                }
    }

    ll ans = 0;
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            ans = (ans + dp[K][i][j])%M;
    return ans;
}

void multiply(vector<vector<ll>> &A, vector<vector<ll>> &B, ll n){

    // Multiply the matrices 'A' and 'B' and store the result in 'A' itself
    vector<vector<ll>> C(n, vector<ll>(n));
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++){
            C[i][j] = 0;
            for(int k=0; k<n; k++)
                C[i][j] = (C[i][j] + (A[i][k]*B[k][j])%M)%M;
        }

    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            A[i][j] = C[i][j];
}

void matrixExponentiation(vector<vector<ll>> &A, ll n, ll k){

    if(k <= 1)
        return;
    if(k%2 == 0){
        matrixExponentiation(A, n, k/2);
        multiply(A, A, n);
    }
    else{
        vector<vector<ll>> tempMatrix(A);
        matrixExponentiation(A, n, k-1);
        multiply(A, tempMatrix, n);
    }

}

ll walkOptimized(vector<vector<ll>> &adj, ll n, ll K){
    // 'adj' contains for each cell (i, j) the no. of ways to
    // reach from 'i' to 'j' in  1 step

    // Suppose If we have a matrix 'A', in which each cell
    // (i, j) denotes the number of paths from i to j in exactly 4 steps
    // Then if we multiply it with 'adj', then after multiplying we will get
    // a matrix in which for each cell (i, j) it stores the no. of ways
    // to reach from 'i' to 'j' in exactly 5 steps

    // Hence we just need to multiply 'adj' K times, i.e.
    // we need to find adj^K, then in the end take the sum of all values
    // in that matrix because the paths can start or end at any vertex

    // To quickly find this exponentiation, we can use matrix exponentiation

    matrixExponentiation(adj, n, K);

    ll ans = 0;
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            ans = (ans + adj[i][j])%M;
    return ans;
}

int main()
{
 ll n, k;
 cin>>n>>k;
 vector<vector<ll>> adj(n, vector<ll>(n));
 for(int i=0; i<n; i++)
    for(int j=0; j<n; j++)
        cin>>adj[i][j];
// ll ans = walk(adj, n, k);
 ll ans = walkOptimized(adj, n, k);
 cout<<ans;
 return 0;
}



Measured memory_bytes: 4852
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

struct BIT{
    ll N;
    vector<ll> bit;
    BIT(ll N) : bit(N+1),N(N){};

    ll sum(ll i){
        ll s = 0;
        while(i>0){
           s += bit[i];
           i -= i& -i;
        }
        return s;
    }

    void add(ll i,ll x){
        while(i <= N){
            bit[i] += x;
            i += i & -i;
        }
    }
};

//数列の値の範囲を[1,n]に変える
vector<ll> convert_array(vector<ll> z){
    ll n = z.size();
    vector<ll> temp = z;
    sort(all(temp));
    for(ll i = 0; i < n; i++){
        z[i] = lower_bound(all(temp), z[i]) - temp.begin() + 1;
    }
    return z;
}

//反転数を求める
ll inverse_number(vector<ll> z){
    ll n = z.size();
    ll inv_num = 0;
    //z = convert_array(z);

    BIT b(n);
    for(ll i = 0; i <= n; i++){
        b.bit[i] = 0;
    }

    for(ll i = 0; i < n; i++){
        inv_num += i - b.sum(z[i]);
        b.add(z[i],1);
    }

    return inv_num;
}

int main()
{
	string s;
	cin >> s;

	ll n = s.length();
	vector<vector<ll> > al_pos(26);  //initial position

	for(ll i = 0; i < n; i++){
		al_pos[s[i]-'a'].push_back(i);
	}

	ll odd_al = -1;
	for(ll i = 0; i < 26; i++){
		if(al_pos[i].size() % 2 != 0){
			if(odd_al >= 0){
				cout << -1 << endl;
				return 0;
			}else{
				odd_al = i;
			}
		}
	}

	if((odd_al>=0 && n%2==0) || (odd_al<0 && n%2!=0)){
		cout << -1 << endl;
		return 0;
	}

	ll al_now[26] = {0};

	for(ll i = 0; i < 26; i++){
		al_now[i]=0;
	}

	string front,back,center;
	for(ll i = 0; i < n; i++){
		if(n%2!=0 && al_now[s[i]-'a'] == al_pos[odd_al].size()/2 && s[i]-'a' == odd_al){
			center.push_back(s[i]);
			al_now[s[i]-'a']++;
			continue;
		}
		if(al_now[s[i]-'a']+1<= al_pos[s[i]-'a'].size() / 2){
			front.push_back(s[i]);
			al_now[s[i]-'a']++;
		}else{
			back.push_back(s[i]);
			al_now[s[i]-'a']++;
		}
	}

	// cout << n << endl;
	// cout << front.length() <<endl;
	// cout << center.length() << endl;
	// cout  << back.length() <<  endl;

	for(ll i = 0; i < 26; i++){
		al_now[i]=0;
	}

	vector<ll> kaibun_index;
	for(ll i = 0; i < front.length(); i++){
		//cout << front[i];
		kaibun_index.push_back(al_pos[front[i]-'a'][al_now[front[i]-'a']]);
		al_now[front[i]-'a']++;
	}
	// printf(" ");
	for(ll i = 0; i < center.length(); i++){
		// cout << center[i];
		kaibun_index.push_back(al_pos[center[i]-'a'][al_now[center[i]-'a']]);
		al_now[center[i]-'a']++;
	}
	// printf(" ");
	for(ll i = front.length()-1; i >= 0; i--){
		// cout<<front[i];
		kaibun_index.push_back(al_pos[front[i]-'a'][al_now[front[i]-'a']]);
		al_now[front[i]-'a']++;
	}
	// printf("\n");

	// cout << kaibun_index.size() << endl;
	for(ll i = 0; i < n; i++){
		kaibun_index[i]++;
		// cout << kaibun_index[i] << " ";
	}
	printf("\n");

	cout << inverse_number(kaibun_index) << endl;

	return 0;
}

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


int main(){
    int a,b;
    cin >> a >> b;
    cout << a*b;
    return 0;
}

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


int main(){
    int n;
    ll k;
    map<int,ll> m; 
    cin >> n >> k;
    rep(i,n){
        int a; ll b;
        cin >> a >> b;
        m[a]+=b;
    }
    for (auto w:m){
        k-= w.second;
        if (k <= 0){
            cout << w.first << endl;
            return 0;
        }
    }


    return 0;
}

Measured memory_bytes: 4224
import java.io.*;
import java.util.*;

public class Main {

    void solve() throws IOException {
        int n = ni();
        long[] a = nla(n);

        long ans = 1;
        long MOD = 1000000007;
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (2 * cnt + 1 <= a[i]) {
                cnt++;
            } else {
                ans = (ans * (cnt + 1)) % MOD;
            }
        }
        for (int i = cnt; i >= 2; i--) {
            ans = (ans * i) % MOD;
        }

        out.println(ans);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 36232
import java.util.Scanner;
 
public class Main{
 
	public static void main(String[] args) {
 
		Scanner scanner = new Scanner(System.in);
 
		int K = scanner.nextInt();
		int A = scanner.nextInt();
		int B = scanner.nextInt();
 
		int total = (B / K) * K;
		
		if (A <= total) {
			System.out.println("OK");
		} else {
			System.out.println("NG");
		}
		scanner.close();
     
	}
}

Measured memory_bytes: 35800
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long A = in.nextLong(), B = in.nextLong();

        long gcd = getGCD(A, B);
        System.out.println(primeFactorization(gcd));
    }

    public static int primeFactorization(long n) {
        Set<Integer> set = new HashSet<>();
        for (int i = 2; i < Math.sqrt((double) n); i++)
            while (n % i == 0) {
                set.add(i);
                n /= i;
            }
        if (n > 1) set.add((int) n);
        return set.size() + 1;
    }

    public static long getGCD(long A, long B) {
        while (A % B != 0) {
            long R = A % B;
            A = B;
            B = R;
        }
        return B;
    }
}


Measured memory_bytes: 23636
quit() = exit(0)
in_1() = parse(Int, readline())
in_a() = [parse(Int,s) for s in split(readline())]
in_t() = (in_a()...,)
yesno(b) = b ? "Yes" : "No"

function main()
  N = in_1()
  X = in_a()
  @assert length(X) == N
  ans = 2^50
  for p in 1:100
    tired = sum((x-p)^2 for x in X)
    ans = min(ans, tired)
  end
  ans |> println
end

isempty(ARGS) && main()


Measured memory_bytes: 113860
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    s = S()
    def f(s):

        for i in range(len(s)):
            if s[i] == s[-i - 1]:
                continue
            return False
        return True
    ans = f(s) and f(s[: (len(s) - 1) // 2]) and f(s[(len(s) + 3) // 2 - 1:])
    print("Yes" if ans else "No")
    return


#main
if __name__ == '__main__':
    solve()


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

vector<int> e[100000];
bool used[100000];

void dfs(int v) {
    used[v] = true;
    for (auto u: e[v]) if (!used[u]) {
        dfs(u);
    }
}

int main(void) {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++) {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        x--; y--;
        e[x].push_back(y);
        e[y].push_back(x);
    }

    int ans = 0;
    for (int i = 0; i < n; i++) if (!used[i]) {
        ans++;
        dfs(i);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 8960
for _ in range(int(input())):
    a,d,b,e,c,f=map(float,input().split())
    z=2*(b*f-c*e+c*d-a*f+a*e-b*d)
    x=((e-f)*(a**2+d**2)+(f-d)*(b**2+e**2)+(d-e)*(c**2+f**2))/z
    y=((c-b)*(a**2+d**2)+(a-c)*(b**2+e**2)+(b-a)*(c**2+f**2))/z
    print('{0:.3f} {1:.3f} {2:.3f}'.format(x,y,((a-x)**2+(d-y)**2)**0.5))

Measured memory_bytes: 7624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define rep3(i, x, n) for(int i = x; i > n; i--)
const long long MOD = 1e9+7;
const long long INF = 1e15;
const long long MOD2 = 998244353;
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    ll N;
    cin >> N;
    ll D[N];
    rep(i, N) cin >> D[i];
    if(D[0] != 0) cout << 0 << endl;
    else{
        ll cnt[N];
        fill_n(cnt, N, 0);
        rep(i, N){
            cnt[D[i]]++;
        }
        ll M;
        rep(i, N){
            if(cnt[i] > 0) M = i;
        }
        if(cnt[0] > 1) cout << 0 << endl;
        else{
            ll ans = 1;
            rep(i, M){
                rep(j, cnt[i+1]){
                    ans *= cnt[i];
                    ans %= MOD2;
                }
            }
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n;i>0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
//namespace mp = boost::multiprecision;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


int main()
{
    string s,x;
    cin>>s;
    for(char c:s){
        if(c=='B') x=x.substr(0,x.size()-1);
        else x+=c;
    }
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 256
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;
const int maxn = 2000100;



int main(){
        _
        int n,a,b;
        cin >> n >> a >> b;
        string s; cin >> s;
        map<char, int>cnt;
        map<int,int>bth;
        map<char,int>bthcnt;
        for(int i = 0; i<n; i++){
            if(s[i]=='b'){
                bthcnt[s[i]]++;
                bth[i+1] = bthcnt[s[i]];
            }
        }
        int pass =0;
        for(int i = 0; i<n; i++){
            if(s[i]=='a'){
                if(pass<(a+b)){
                    cout<<"Yes"<<endl;
                    pass++;
                }
                else cout<<"No"<<endl;
            }
            else if(s[i]=='b'){
                if(pass<(a+b) and bth[i+1]<=b){
                    cout<<"Yes"<<endl;
                    pass++;
                }
                else cout<<"No"<<endl;
            }
            else cout<<"No"<<endl;
        }

return 0;
}




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

int Cumulative_sum[100001];
int is_prime[100001];

int main() {

    for(int i=1; i<100001; i++){
        is_prime[i] = 1;
    }

    is_prime[0] = is_prime[1] = 0;

    for(int i=2; i*i<100001; i++){
        if(is_prime[i] == 1){
            for(int j=i*i; j<100001; j+=i){
                is_prime[j] = 0;
            }
        }
    }

    for(int i=1; i<100001; i++){
        if(is_prime[i] == 1 && is_prime[(i+1)/2] == 1 && i%2==1){
            Cumulative_sum[i]++;
        }
        Cumulative_sum[i] += Cumulative_sum[i-1];
    }

    int q;

    cin >> q;

    int l,r;

    for(int i=0; i<q; i++){
        cin >> l >> r;
        int ans = Cumulative_sum[r] - Cumulative_sum[l];
        if(is_prime[l] == 1 && is_prime[(l+1)/2] == 1){
            ans++;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int N, M;
    cin >> N >> M;
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> a_and_b;
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        a_and_b.push({b, a});
    }
    int ans = 0;
    while(!a_and_b.empty()){
        auto looking = a_and_b.top();
        a_and_b.pop();
        while(!a_and_b.empty()){
            if(a_and_b.top().second < looking.first){
                a_and_b.pop();
            }else{
                break;
            }
        }
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1400
import sys
read = sys.stdin.read
def main():
    a, b, m = map(int, input().split())
    al = tuple(map(int, input().split()))
    bl = tuple(map(int, input().split()))
    r = min(al) + min(bl)
    m = map(int, read().split())
    xyc = zip(m, m, m)
    for x, y, c in xyc:
        r = min(r, al[x-1] + bl[y-1] - c)
    print(r)

if __name__ == '__main__':
    main()

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

int main() {
  long long n, k, ans = 0;
  cin >> n >> k;
  vector<long long> enemy(n);
  
  for (int i = 0; i < n; i++){
    cin >> enemy[i];
  }
  
  sort (enemy.begin(), enemy.end());
  
  if (n <= k) {
    cout << 0 << endl;
  }
  else {
    for (int i = 0; i < n - k; i++) {
      ans += enemy.at(i);
    }
    cout << ans << endl;
  }

}

Measured memory_bytes: 1792
n = int(input())
A = [*map(int, input().split())]
q = int(input())
BC = [[*map(int, input().split())] for _ in range(q)]

s = 0
C = {}
for a in A:
    s += a
    if a in C: C[a] += 1
    else: C[a] = 1

for b, c in BC:
    if not b in C: C[b] = 0
    if not c in C: C[c] = 0
    s += (c - b) * C[b]
    C[c] += C[b]
    C[b] = 0
    print(s)


Measured memory_bytes: 39696
#include<cstdio>
#include<algorithm>
using namespace std;

const int INF=1000000000;

int main(){
	int a,b;
	int s[5002],t[5002];
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",&s[i]);
	}
	for(int i=0;i<b;i++){
		scanf("%d",&t[i]);
	}

	int memo[5002]; for(int i=0;i<b;i++)memo[i]=INF;

	int ret=0;
	for(int i=0;i<b-ret;i++){
		int p=0,q=i;
		int cnt=0;
		while(1){
			
			if(s[p]==t[q]){
				if(p>=memo[q])break;
				memo[q]=p;
				cnt++;
				p++;
				q++;
			}
			else {
				p++;
			}
			if(p==a){
				ret=max(ret,cnt);
				break;
			}
			if(ret>cnt+a-p)break;
		}
	}


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

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll dist(ll x, ll y, ll m){
	if(x <= y) return y - x;
	else return y+m-x;
}

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

    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    REP(i, n) a[i]--;

    vector<ll> dif(202020, 0);
    REP(i, n-1){
    	if(a[i] < a[i+1]){
    		dif[a[i]+1] -= 1;
    		dif[a[i+1]] += (a[i+1]-a[i]);
    		dif[a[i+1]+1] -= (a[i+1]-a[i]-1);
    	}else{
    		dif[a[i]+1] -= 1;
    		dif[a[i+1]+m] += (a[i+1]+m-a[i]);
    		dif[a[i+1]+m+1] -= (a[i+1]+m-a[i]-1);
    	}
    }
    REP(i, 202000){
    	dif[i+1] += dif[i];
    }
    /*
    REP(i, 2*m) cout << dif[i] << " ";
    cout << endl;
    */

    ll tmp = 0;
    REP(i, n-1){
    	tmp += min(dist(a[i], a[i+1], m), dist(0, a[i+1], m)+1);
    }

    ll mi = tmp;
    REP(i, m-1){
    	tmp += (dif[i] + dif[i+m]);
    	mi = min(mi, tmp);
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define int long long
#define N 1010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}

int n,m,A,B,D[N];
int calc(){
  vector<int> res;
  for(int i=0;i<n;i++)
    if(D[i]>=A)res.push_back(D[i]);
    else break;

  reverse(res.begin(),res.end());
  if(n - (int)res.size() < m)
    for(int i=0;i<(int)res.size();i++) 
      if(res[i] <= B)res.erase(res.begin()+i--);
      else break;
  return res.size();
}



signed main(){
  cin>>n>>m>>A>>B;
  for(int i=0;i<n;i++)cin>>D[i];
  cout<<calc()<<endl;
  return 0;
}

Measured memory_bytes: 3156
#!/usr/bin/env python3
import sys,collections
n = int(sys.stdin.readline())

def koch(p1,p2,n):
  if n == 0:
    return [p1,p2]
  ret = []
  #s = [(p2[0]-p1[0])/3.0+p1[0],]
  s = [(p2[0]+2*p1[0])/3.0,(p2[1]+2*p1[1])/3.0]
  #t = [2*(p2[0]-p1[0])/3.0+p1[0],]
  t = [(2*p2[0]+p1[0])/3.0,(2*p2[1]+p1[1])/3.0]
  u = [(t[0]+s[0]+1.73205*(s[1]-t[1]))/2.0,(1.73205*(t[0]-s[0])+t[1]+s[1])/2.0]
  if n == 1:
    return [p1,s,u,t,p2]
  for l in [[p1,s],[s,u],[u,t],[t,p2]]:
    ret += koch(l[0],l[1],n-1)[:-1]
  ret += [p2]
  return ret
# X-a = (1(x-a)-r3(y-b))/2
# X = (x+a+r3(b-y))/2
# X = (t[0]+s[0]+r3(s[1]-t[1]))/2
# Y-b = (r3(x-a)+(y-b))/2
# Y = (r3(x-a)+y+b)/2
# Y = (r3(t[0]-s[0])+t[1]+s[1])/2
print("\n".join([str(p1)+" "+str(p2) for p1,p2 in koch([0.0,0.0],[100.0,0.0],n)]))



Measured memory_bytes: 6992
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    int x[3][3];
    lol(i,3)lol(j,3)cin>>x[i][j];
    bool ok=true;
    for(int i=1;i<3;i++){
	int k=x[i][0]-x[0][0];
	for(int j=1;j<3;j++)if(k!=x[i][j]-x[0][j])ok=false;
    }
    cout<<(ok?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 256
N,K = map(int, input().split())

lista = []
for i in range(N):
  lista.append(i+1)
for i in range(K):
  d = int(input())
  a = list(map(int, input().split()))
  for j in range(len(a)):
    if a[j] in lista:
      lista.remove(a[j])

print(len(lista))

Measured memory_bytes: 9060
def main():
  ## IMPORT MODULE
  #import sys
  from collections import Counter

  #sys.setrecursionlimit(100000)
  #input=lambda :sys.stdin.readline().rstrip()

  #f_inf=float("inf")
  #MOD=10**9+7
  
  if 'get_ipython' in globals(): 
    ## SAMPLE INPUT
    n = 64

  else:
    ##INPUT 
    n =int(input())
    #a, b = map(int, input().split())

  ## SUBMITION CODES HERE
  def prime_fact(n):
    P = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            P.append(i)
            n //= i
    if n != 1:
        P.append(n)
    return P

  cnt = Counter(prime_fact(n))

  ans = 0
  for c in cnt.values():
    tmp = 1
    while c >= tmp:
      c -= tmp
      ans += 1
      tmp += 1
    
  print(ans)
    
main()

Measured memory_bytes: 9616
a = input().split()
N = int(a[0])
K = int(a[1])
p = 0

def n_over(a, k):
  n = 0
  while(a < k):
    a *= 2
    n += 1
  return n

n = 1
while(n <= N):
  kaisu = n_over(n, K)
  percent = (1/N) * (0.5**(kaisu))
  p += float(percent)
  n += 1

print(p)

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

int conv(char suit){
    switch(suit){
    case 'S': return 0;
    case 'H': return 1;
    case 'C': return 2;
    case 'D': return 3;
    }
    return -1;
}

char conv(int suit){
    switch(suit){
    case 0: return 'S';
    case 1: return 'H';
    case 2: return 'C';
    case 3: return 'D';
    }
    return -1;
}

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

    vector<vector<bool> > card(4, vector<bool>(14, false));
    for(int i=0; i<n; i++){
        char suit;
        int rank;
        cin >> suit >> rank;
        card[conv(suit)][rank] = true;
    }
    for(int i=0; i<4; i++){
        for(int j=1; j<=13; j++){
            if(!card[i][j]){
                cout << conv(i) << " " << j << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3108
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N, M = ZZ()
    cnt = [0] * (N + 1)
    for _ in range(M):
        a, b = ZZ()
        cnt[a] += 1
        cnt[b] += 1
    print('YES' if all([c%2 == 0 for c in cnt]) else 'NO')

    return

if __name__ == '__main__':
    main()


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

int main(){
 
	ios_base::sync_with_stdio(false) ,cin.tie(nullptr);
  	char inp ;
	cin >> inp ;
  if (inp >= 'A' && inp <= 'Z')
   cout << 'A' ;
 else 
   cout << 'a';
 return 0 ;
 }


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int (i)=int (a);i<=int (b);i++)
#define ff(i,a,b) for(int (i)=int (a);i<int (b);i++)
#define F(i,a,b) for(int (i)=int (a);i>=int (b);i--)
#define fi first
#define se second
#define ll long long
#define ld long double
const int N=100006,mod=1e9+7;
long long fact[500005], ifact[500005];
int h,w,a,b;
ll pw(int a,int b){
	ll ans=1;
	for(;b;b>>=1){
		if(b&1) ans=((ll)ans*a)%mod;
		a=((ll)a*a)%mod;
	}
	return ans;
}

ll C(int k,int n){
	if(n < k or k < 0)
	{
		return 0;
	}
	return fact[n]*pw(fact[k],mod-2)%mod*pw(fact[n-k],mod-2)%mod;
}
int main(){
	fact[0]=1;
	f(i,1,2*N){
		fact[i]=fact[i-1]*i%mod;
	}
	ll ans=0;
	cin>>h>>w>>a>>b;
	F(i,h-a,1){
		ans+=(C(i-1,i+b-2)*C(h-i,h-i+w-b-1))%mod;
		ans%=mod;
	}
	cout<<ans;
}

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

ll f_2(ll n)
{
	if (n == 1) return 0;
	return f_2(n / 2) + n / 2;
}

ll f_5(ll n)
{
	if (n <= 1) return 0;
	return f_5(n / 5) + n / 5;
}

signed main(void)
{
	ll n, ans;
	cin >> n;
	ans = 0;
	if (n % 2 == 0 && n != 0)
	{
		ans = min(f_2(n), f_5(n / 2));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void);

int main(void){
    
    int x, y, min, max;

    /*do{
        scanf("%d %d", &x, &y); 
        
        if(!(x == 0 && y == 0)){
            
            if(x <= y){
                min = x;
                max = y;
            } else {
                min = y;
                max = x;
            }
            
            printf("%d %d\n", min, max);
        }
    } while(!(x == 0 && y == 0));
    */
    
    while(1){
        scanf("%d %d", &x, &y); 
        
        if(x == 0 && y == 0){
            
            break;
            
        } else {
            
            if(x <= y){
                min = x;
                max = y;
            } else {
                min = y;
                max = x;
            }
            
            printf("%d %d\n", min, max);
        }
    }

    return 0;

}


Measured memory_bytes: 2024
#include <stdio.h>
#define N 10000
#define Q 500
main(){

  int s,t,c=0,i,j;
  int a[N],b[Q];
  scanf("%d",&s);
  for(i = 0; i < s; i++){
    scanf("%d",&a[i]);
  }
    scanf("%d",&t); 
   for(i = 0; i < t; i++){
      scanf("%d",&b[i]);
   }
      for(i = 0; i < t; i++){
	for(j = 0; j < s; j++){
	  if(b[i] == a[j]){
	    c++;
	    break;
	  }
	}
      }
  
printf("%d\n",c);
 return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

struct union_find{
    vector<ll> parent;
    vector<ll> nums;
    union_find(ll n){
        parent.resize(n);
        nums.resize(n, 1LL);
        rep(i, 0, n) parent[i] = i;
    }

    ll root(ll x){
        if(parent[x] == x) return x;
        parent[x] = root(parent[x]);
        return parent[x];
    }

    void unite(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx != ry){
            parent[rx] = ry;
            nums[ry] += nums[rx];
        }
    }

    bool same(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx == ry) return true;
        return false;
    }

    ll size(ll x){
        return nums[root(x)];
    }
};  

int main(){
    ll n, m;
    cin >> n >> m;
    struct union_find t(n);
    rep(i, 0, m) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        t.unite(a, b);
    }
    ll ans = 0;
    rep(i, 0, n) {
        ans = max(ans, t.size(t.root(i)));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12668
#include <iostream>
#include <cstdio>
#include<cstring>
using namespace std;
int  vj(int x){
    int newed,t,n;
    newed=0;
    n=x;
    do
        {
            newed=newed*10+x%10;
            x/=10;
        }while(x>0);
        if(n==newed)
           return 1;
        else
           return 0;

}
int main()
{
    int a,b;
    long long ans;
    cin>>a>>b;
    ans=0;
    for(int i=a;i<=b;i++)
        ans+=vj(i);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
M,D = map(int, input().split())

ans = 0
for m in range(1,M+1):
    for d in range(1,D+1):
        d = str(d)
        if len(d) == 1:
            continue
        if int(d[0]) < 2:
            continue
        if int(d[1]) < 2:
            continue

        if int(d[0]) * int(d[1]) == m:
            ans += 1
print(ans)

Measured memory_bytes: 3064
N, X = map(int, input().split())
blu = [[int(i) for i in input().split()] for _ in range(N)]

b_total = 0
dblu = []
for b, l, u in blu :
    dblu.append((u*X-(u-l)*b, b, l, u))
    b_total += b * l
dblu.sort(reverse=True)

s = [0] * (N + 1)
for i in range(1, N + 1) :
    s[i] = s[i-1] + dblu[i-1][0]

ret = float('inf')

def judge(mid) :
    q = mid // X
    r = mid % X
    for i in range(N) :
        d, b, l, u = dblu[i]

        if q < i :
            tmp = s[q]
        else :
            tmp = s[q+1] - d

        if r < b :
            tmp += r * l
        else :
            tmp += b * l + u * (r - b)

        if tmp >= b_total :
            return True
    return False

left, right = -1, N * X

while right - left > 1 :
    mid = (left + right) // 2
    
    if judge(mid) :
        right = mid
    else :
        left = mid

print(right)

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

int main() {
	int n,y;
	cin>>n>>y;
	bool flag=0;
	int a,b,c;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n-i;j++){
				int k=n-i-j;
				if(y==10000*i+5000*j+1000*k){
					a=i;
					b=j;
					c=k;
					flag=1;
					break;
				}
		}
		if(flag) break;
	}
	if(flag){
		cout<<a<<' '<<b<<' '<<c<<endl;
	}else{
		cout<<"-1 -1 -1"<<endl;
	}
	return 0;
}


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

using i32 = int_fast32_t;
using i64 = int_fast64_t;

int main() {
    string s;
    cin >> s;
    deque<char> dq(begin(s), end(s));
    i32 q;
    cin >> q;

    bool rev = false;
    for (i32 i = 0; i < q; i++) {
        i32 t;
        cin >> t;
        switch (t) {
        case 1:
            rev = !rev;
            break;
        case 2:
            i32 f;
            char c;
            cin >> f >> c;
            if (rev ^ (f == 1)) {
                dq.push_front(c);
            } else {
                dq.push_back(c);
            }
            break;
        }
    }

    cout << (rev ? string(rbegin(dq), rend(dq)) : string(begin(dq), end(dq))) << endl;
}


Measured memory_bytes: 1280
use proconio::*;
use proconio::marker::*;

fn run() {
    input! {
        s: Bytes,
        t: Bytes,
    }
    let ans = s.windows(t.len()).map(|s| {
        s.iter().zip(t.iter()).filter(|p| *p.0 != *p.1).count()
    }).min().unwrap();
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 2124