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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

int main()
{
    int n;
    cin >> n;
    double s = 0;
    for(int i = 0;i < n;i++){
        double a;
        cin >> a;
        s = s + 1/a;
    }
    cout << fixed << setprecision(9) << 1/s << "\n";

}



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

object Main {
    def main(args: Array[String]){
        val r = readLine.split(" ").map(_.toInt)
        val n = readLine.toInt
        
        val q = r(0)
        val h = min(q * 2, r(1))
        val s = min(h * 2, r(2))
        val d = min(s * 2, r(3))
        
        val _d = n / 2
        val _s = (n % 2)
        
        printf("%s\n", _d * d + _s * s)
    }
    
    def min(a: Long, b: Long): Long = {
        if (a > b) {
            b
        } else {
            a
        }
    }
}

Measured memory_bytes: 26816
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  string N;
  cin >> N;
  int ans = 0;
  rep(i,sz(N)){
    if(N[i] == '2') ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int k = sc.nextInt();
        Set<String> set = new HashSet<>();
        int len = s.length();
        // i : start数
        for (int i = 0; i < len; i++) {
            for (int j = 1; j <= k; j++) {
                if (i + j > len) {
                    continue;
                }
                String tmp = s.substring(i, i + j);
                set.add(tmp);
            }
        }
        List<String> str = new ArrayList<>(set);
        Collections.sort(str);
        System.out.println(str.get(k - 1));
        sc.close();
    }
}


Measured memory_bytes: 24528
A = []
for _ in range(3):
  A += list(map(int,input().split()))
n = int(input())
ans = [0]*9
for _ in range(n):
  b = int(input())
  if b in A:
    i = A.index(b)
    if i != -1:
      ans[i] = 1
bingo = [0b111000000,0b000111000,0b000000111,0b100100100,0b010010010,0b001001001,0b100010001,0b001010100]
f = 0
sheet = 0
for i in range(9):
  sheet += ans[i] * 2 ** (8 - i)
for i in range(8):
  ansb = sheet & bingo[i]
  if (ansb & bingo[i]) in bingo:
    f = 1
    break
if f == 1:
  print('Yes')
else:
  print('No')

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

int a,b,c;
int i;
int main()
{
	cin>>a>>b>>c;
	for(i=1;i<=1000;i++)
	{
		if(a*i%b==c){cout<<"YES"<<endl;return 0;}
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
std::string S;
long table[100000+1][13];
long MOD=1000000000+7;
void solve()
{
    for(long i=1;i<S.length();i++){
        char num_S=S[i];
        for(long j=0; j<13; j++){
            if(num_S!='?'){
                long num=num_S-'0';
                table[i][(num+10*j)%13]+=table[i-1][j];
                table[i][(num+10*j)%13]%=MOD;
            }else{
                for(long k=0; k<=9; k++){
                    table[i][(k+10*j)%13]+=table[i-1][j];
                    table[i][(k+10*j)%13]%=MOD;
                }
            }
        }
    }
}

void init()
{
    for(long i=0; i<100000+1;i++){
        for(long j=0; j<13; j++){
            table[i][j]=0;
        }
    }
    if(S[0]=='?'){
        for(long i=0; i<=9; i++){
            table[0][i]=1;
        }
    }else{
        table[0][S[0]-'0']=1;
    }
}

int main(void){
    std::cin >> S;
    init();
    solve();
    std::cout << table[S.length()-1][5] << std::endl;
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int ans=0;
  for(int i=0;i<s.size()/2;i++){
    if(s.at(i)!=s.at(s.size()-i-1))
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <ctype.h>
#include <vector>
#include <algorithm>

using namespace std;

int l;
char s[10001];

int dfs(void){
	int i, ret = 0;
	vector<int> v;
	if(isdigit(s[l + 1])){
		l++;
		while(isdigit(s[l])){
			ret = 0;
			for(i = l;isdigit(s[i]);i++)
				ret = (ret * 10) + s[i] - '0';
			v.push_back(ret);
			l = i + 1; // i番目は']'
			if(isdigit(s[l + 1]))
				l++;
		}
		sort(v.begin(),v.end());
		ret = 0;
		for(i = 0;i < (v.size() + 1) / 2;i++){
			ret += (v[i] + 1) / 2;
		}
		l++;
		return ret;
	}
	else{
		while(s[l] == '['){
			l++;
			v.push_back(dfs());
		}
		sort(v.begin(),v.end());
		for(i = 0;i < (v.size() + 1) / 2;i++){
			ret += v[i];
		}
		l++;
		return ret;
	}
}

int main(void){
	int n, i;
	scanf("%d%*c",&n);
	for(i = 0;i < n;i++){
		scanf("%s",s);
		l = 0;
		printf("%d\n",dfs());
	}
	return 0;
}

Measured memory_bytes: 1096
//A,Elebereth Gilthoniel mantae!
//For Temeria!
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<cstdio>
#include<map>
#include<stack>
#include<queue>
#include<cstring> 
using namespace std;
long long ans;long long mod=1000000007;
int main()
{
 	//freopen("","r",stdin);
	//freopen("","w",stdout);
	long long n;cin>>n;
	string s1,s2;cin>>s1>>s2;long long bef=-1;//1=aa,2=a
	                 //                     bb   a
	for(long long i=0;i<s1.size();i++)
	{
		if(s1[i]==s2[i])
		{
			if(bef==1) ans=ans*1;
			else if(bef==2) ans=ans*2;
			else if(bef==-1)ans=3;
			bef=2;ans=ans%mod;
		}
		if(s1[i]!=s2[i])
		{
			i++;
			if(bef==1) ans*=3;
			else if(bef==2) ans*=2;
			else if(bef==-1) ans=6;
			bef=1;ans=ans%mod;
		} 
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * b / g;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}



const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, k; cin >> n >> k;
	VE a(n); rep(i, n)cin >> a[i];
	int ans = 0;
	rep(i, n+1) {
		rep(j,n+1) {
			if (i + j > n || i + j > k)continue;
			
			VE tmp;
			rep(l, i) {
				//cout << l << " ";
				tmp.push_back(a[l]);
			}
			//cout << endl;
			rep(l, j) {
				//cout << n - l - 1 << " ";
				tmp.push_back(a[n - l - 1]);
			}
			//cout << endl;
			sort(ALL(tmp));
			int now = 0;
			rep(l, tmp.size())now += tmp[l];
			rep(l, min(k - i - j, (int)tmp.size())) {
				if (tmp[l] < 0) {
					now -= tmp[l];
				}
			}
			//cout << now << endl;
			chmax(ans, now);
		}
	}
	cout << ans << endl;
	return 0;
}

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

ll fn(int n)
{
    if(n==0)return 2;
    else if(n==1)return 1;
    else return fn(n-1)+fn(n-2);
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    //cout<<fn(n);
    if(n==0)cout<<2;
    else if(n==1)cout<<1;
    else{
        ll c=0,a=2,b=1;
        for(int i=2;i<=n;i++){
            c=a+b;
            a=b;b=c;
        }
        cout<<c;
    }
}


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

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD =  1000000007;

LL fact[100001];

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  fact[0] = 1;
  FOR(i,1,100001) fact[i] = i * fact[i-1] % MOD;

  int N, T; cin >> N >> T;
  VI d(N); REP(i,N) cin >> d[i];
  SORT(d);

  vector<LL> dp(N, 0);
  dp[0] = 1;
  FOR(i,1,N){
	int idx = lower_bound(ALL(d), d[i]-T) - d.begin();
	dp[i] = dp[i-1] * (i - idx + 1) % MOD;
  }
  cout << dp[N-1] << endl;

  return 0;
}

Measured memory_bytes: 3108
#include <stdio.h>

int main()
{
  int i, j, A[100], N, v, minj, count=0;

  scanf("%d",&N);
  for(i=0; i<N; i++){
    scanf("%d",&A[i]);
  }

  for(i=0; i<=N-1; i++){
    minj=i;
    for(j=i; j<=N-1; j++){
      if(A[j]<A[minj]){
        minj=j;
      }
    }
    v=A[i];
    A[i]=A[minj];
    A[minj]=v;
    if(A[i]<A[minj]) count++;
  }
  for(i=0; i<N; i++){
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n%d\n",count);
  return 0;
}

Measured memory_bytes: 604
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;

signed main(){
    int n;
    cin >> n;
    int sum = 0;
    int a[1000];
    rep(i,n){
        
        cin >> a[i];
        sum += a[i];
    }
    double ave = sum/(1.0*n);
    int ans = 0;
    double ansv = 100000;
    rep(i,n){
        if(ansv > abs(a[i]-ave)){
            ansv = abs(a[i]-ave);
            ans = i;
        }
    }
    cout << ans << endl;
    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 256
/*
 * 0201.cc: Wrought Gold Master
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;
const int INF = 1 << 30;

/* typedef */

typedef vector<int> vi;
typedef map<string,int> msi;

/* global variables */

string is[MAX_N];
msi imap;
int ps[MAX_N], cache[MAX_N];
vi chlds[MAX_N];
bool used[MAX_N];

/* subroutines */

int rec(int k) {
  if (cache[k] >= 0) return cache[k];
  if (used[k]) return ps[k];
  if (chlds[k].size() == 0) return (cache[k] = ps[k]);

  used[k] = true;
  int sum = 0;
  for (int i = 0; i < chlds[k].size(); i++)
    sum += rec(chlds[k][i]);
  used[k] = false;

  return (cache[k] = min(sum, ps[k]));
}

/* main */

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (n == 0) break;

    imap.clear();
    memset(cache, -1, sizeof(cache));
    memset(used, false, sizeof(used));
    
    for (int i = 0; i < n; i++) {
      cin >> is[i] >> ps[i];
      imap[is[i]] = i;
      chlds[i].clear();
    }

    int m;
    cin >> m;

    for (int i = 0; i < m; i++) {
      string si;
      int ki;
      cin >> si >> ki;
      int x = imap[si];

      for (int j = 0; j < ki; j++) {
	string sj;
	cin >> sj;
	chlds[x].push_back(imap[sj]);
      }
    }

    string gl;
    cin >> gl;

    int ans = rec(imap[gl]);

    //for (int i = 0; i < n; i++) {
    //  cout << is[i];
    //  printf(" %d (%d)\n", cache[i], ps[i]);
    //}
    printf("%d\n", ans);
  }

  return 0;
}

Measured memory_bytes: 1252
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int a, b, c;
  	cin >> a >> b >> c;
	int ans;
  	((b/a) > c) ? ans = c : ans = b/a;
  	cout << ans << endl;
	return;
}

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

Measured memory_bytes: 256
import Control.Monad (replicateM)

main :: IO ()
main = do
    (n,t) <- readIntPair
    cts <- readIntPairs n
    putStrLn $ solve t cts

readIntPair :: IO (Int, Int)
readIntPair = pair . map read . words <$> getLine
  where
    pair [x,y] = (x,y)

readIntPairs :: Int -> IO [(Int, Int)]
readIntPairs n = replicateM n readIntPair

solve :: Int -> [(Int, Int)] -> String
solve t = maybe "TLE" show . minimumCost t

minimumCost :: Int -> [(Int, Int)] -> Maybe Int
minimumCost t cts
  | null costs = Nothing
  | otherwise  = Just $ minimum costs
  where
    costs = [ci | (ci,ti) <- cts, ti <= t]


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

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int n, bool visited[nmax]) {
	bool all_visited = true;

	for (int i = 0; i < n; i++) {
		if (!visited[i]) {
			all_visited = false;
			break;
		}
	}

	if (all_visited) {
		return 1;
	}

	int ret = 0;

	for (int i = 0; i < n; i++) {
		if (!graph[v][i])continue;
		if (visited[i])continue;

		visited[i] = true;
		ret += dfs(i, n, visited);
		visited[i] = false;
	}
	return ret;
}

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

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		graph[a - 1][b - 1] = graph[b - 1][a - 1] = true;
	}

	bool visited[nmax];
	for (int i = 0; i < n; i++) {
		visited[i] = false;
	}

	visited[0] = true;
	cout << dfs(0, n, visited) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector <ll>
#define vii vector <int>
#define vpii vector <pii>
#define vpll vector <pll>
#define ff first
#define ss second
#define matrix vector <vll>
#define all(v) v.begin(),v.end()
#define PQ priority_queue
using namespace std;
int main()
{
	//ios::sync_with_stdio(0);
	//cin.tie(0);
  		int x,y,z;
  		cin >> x >> y >> z;
  		swap(x,y);
  		swap(x,z);
 		cout <<x << " " << y << " " << z <<"\n";
	return 0;
}


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

int main(void){
    string s;
    cin >> s;
    if (s[0] != s[1] && s[1] != s[2] && s[2] != s[3]) {
        cout << "Good" << endl;
    } else {
        cout << "Bad" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    if(s=="abc") cout<<"Yes";
    else cout<<"No";
    return 0;
    
  
}

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

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

int main()
{
    long long N;
    cin >> N;

    long long tmp = N;
    // M の約数でかつ M 以下の素数を列挙
    vector<long long> prime;
    for(long long p = 2; p*p <= N; ++p){
        if(tmp%p == 0){
            while(tmp%p == 0) tmp /= p;
            prime.push_back(p);
        }
    }
    if(tmp > 1) prime.push_back(tmp);

    int ans = 0;
    for(auto p: prime){
        long long div = p;
        while(N%div == 0){
            N /= div;
            div *= p;
            ++ans;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#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>;

ll gcd(ll a, ll b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

ll lcm(ll a, ll b){
   return a * b / gcd(a, b);
}

ll f(ll n,ll c,ll d){
    return n - (n/c+n/d-n/lcm(c,d));
}

int main() {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = f(b,c,d) - f(a-1,c,d);
    cout << ans << endl;
}

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

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

#define RFOR(i, b, a) for (int(i) = (b); (i) >= (a); (i)--)
#define RREP(i, n) FOR((i), (n), 0)

#define pb push_back
#define mp make_pair

using namespace std;

const int INF = INT_MAX / 4;
const int MOD = 1000000007;
const double EPS = 1e-14;

const bool debug_flag = true;

void debug(string str)
{
    if (debug_flag)
    {
        cout << str;
    }
}

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.precision(10);

    string a, b;
    cin >> a >> b;
    a=a+b;
    if (sqrt(stoi(a)) == int(sqrt(stoi(a)))){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


int main()
{
	string s;
	cin >> s;
	if(s == "Sunny")
		cout << "Cloudy" << endl;
	else if (s == "Cloudy")
		cout << "Rainy" << endl;
	else
		cout << "Sunny" << endl;
	return 0;
}

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

int main(){
    int ans=0;
    int MAX,MIN;
    int n;
    cin >> n;
    int data[n];

    for (int i = 0; i < n; i++)cin>>data[i];
    
    for (int i = 1; i < n-1; i++){
        MAX=max(max(data[i-1],data[i]),data[i+1]);
        MIN=min(min(data[i-1],data[i]),data[i+1]);

        if(data[i+1]==data[i] || data[i]==data[i-1] || data[i+1]==data[i-1]){
            if(data[i]==MIN)ans++;
        }else{
            if(data[i]!=MAX && data[i]!= MIN)ans++;
        }
    
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vvi v(3, vi(3));
	REP(i, 3)REP(j, 3)cin >> v[i][j];
	REP(i, 101) {
		REP(j, 101) {
			REP(k, 101) {
				vi a(3), b(3);
				a[0] = i; a[1] = j; a[2] = k;
				b[0] = v[0][0] - i; b[1] = v[1][1] - j; b[2] = v[2][2] - k;
				int f = 1;
				REP(r, 3) {
					REP(c, 3) {
						if (v[r][c] != a[r] + b[c])f = 0;
					}
				}
				if (f) {
					cout << "Yes" << endl;
					return 0;
				}

			}
		}
	}
	cout << "No" << endl;
}


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

int main() {
  int N,K,Q;
  cin >> N>>K>>Q;
  
  vector<int> vec(N);
  
for (int i = 0; i < N; i++) {
   vec.at(i) = 0;
}
  int x;
  for (int i = 0; i < Q; i++) {
    cin >> x;
    vec.at(x-1) +=1;
  }

 for (int i = 0; i < N; i++) {
   if(vec.at(i) > Q-K){
     cout << "Yes" << endl;
   }
   else{
    cout << "No" << endl;
   }
 }
    

}


Measured memory_bytes: 1024
n = int(input())
d_list = list(map(int, input().split()))
level_count_dic = {}
mid = int(n/2)
flag = True

for d in d_list:
    if d in level_count_dic:
        level_count_dic[d] += 1
    else:
        level_count_dic[d] = 1

sorted_level_count_dic = sorted(level_count_dic.items(), key=lambda x:x[0])

abc_count = 0
abc_max = 0

for k, v in sorted_level_count_dic:
    abc_count += v

    if abc_count == mid:
        abc_max = k+1
        break
    elif abc_count > mid:
        flag = False
        break


if flag:
    ans = 0
    while True:
        ans += 1
        if abc_max in level_count_dic:
            break
        abc_max += 1

    print(ans)
else:
    print(0)

Measured memory_bytes: 15712
n,k=map(int, input().split())
ans=-1
for i in range(n+1):
    for j in range(n-i+1):
        if k-(10000*i+5000*j)==(n-i-j)*1000:
            print(i,j,n-i-j)
            ans=1
            break
    if ans==1:
        break
if ans==-1:
    print(ans,ans,ans)


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

        int main() {
          int N; 
          cin>> N ;
          ll P = 1000*1000*1000+7;
          
          // A=1, G=2, C=3, T=4として5進数でencode
          // 最後の３文字と場合の数を保持
          vector<vector<ll>> dp(N+2, vector<ll>(125,0)); 
          dp.at(0).at(0)=1;
          
          for(int i=0; i<=N-1; i++){
              for(int j=0; j<125; j++){
                  for(int k=1; k<5; k++){
                      if( k==3 && (j%5)==2 && (j/25)==1 ){
                          // A*GC
                      }else if( (5*j+k)%125==38 || (5*j+k)%125==58 || (5*j+k)%125==42 ){
                          // *AGC, *GAC, *ACG型  
                      }else if( k==3 && (j/25)==1 && ((j/5)%5)==2 ){
                          // AG*C 
                      }else{
                          dp.at(i+1).at( (5*j+k)%125 ) = (dp.at(i+1).at( (5*j+k)%125 ) + dp.at(i).at(j) )%P ;
                      }
                  }
              }
          }
          
          ll counter =0; 
          for(int j=0; j<125; j++){
                  counter += dp.at(N).at(j); 
          }
          cout<< (counter %P) << endl;
        }

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

main(){
  int i, j, N, K;
  int len, max, temp;
  string S;
  cin >> N >> K >> S;
  vector<int> seq0(N), seq1(N);
  S += 'e';
  seq0[0] = 0;
  seq1[0] = 0;
  i = 0;
  j = 0;
  while(S[i]!='e'){
    while(S[i] == '1'){
      seq1[j] ++ ;
      i++;
    }
    while(S[i] == '0'){
      seq0[j] ++ ;
      i++;
    }
    j++;
    seq1[j] = 0;
    seq0[j] = 0;
  }
  len = j;
  ////////////
  /*for(i=0;i<len+1;i++) cout << seq1[i] ;
  cout << endl;
  for(i=0;i<len+1;i++) cout << seq0[i] ;*/
  ////////////
  max = 0;
  if(len <= K){
    cout << N << endl;
    return 0;
  }
  for(i=0;i<K;i++){
    max += seq1[i];
    max += seq0[i];
  }
  max += seq1[K];
  temp = max;
  ////////////
  //cout << max << " ";
  for(i=K;i<len;i++){
    temp -= seq1[i-K];
    temp -= seq0[i-K];
    temp += seq1[i+1];
    temp += seq0[i];
    /////////////
    //cout << temp << " " ;
    if(max < temp) max = temp;
  }
  cout << endl;
  cout << max << endl;
  return 0;
}

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

int main() {
  	int N;
    string S;
  	cin >> N >> S;
  	
  	int L = S.size();
  	int ans = 1;
  	for(int i = 0; i < L - 1; i++) {
	  if(S.at(i) != S.at(i + 1)) {
        ans ++;      
      }
    }
  
  	cout << ans;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] order = new int[n];
		int[] points = new int[n];
		int[] extra = new int[n-1];
		for(int i = 0;i<n;i++) {
			order[i]=sc.nextInt();
		}
		for(int i = 0;i<n;i++) {
			int temp = sc.nextInt();
			points[i] = temp;
		}
		for(int i = 0;i<n-1;i++)extra[i]=sc.nextInt();
		//for(int i = 0;i<n;i++)System.out.print(points[order[i]-1]+" ");
		int output = points[order[0]-1];
		for(int i = 1;i<n;i++) {
			output+= points[order[i]-1];
		}
		for(int i = 1;i<n;i++) {
			if(order[i]-1==order[i-1])output+=extra[order[i-1]-1];
		}
		System.out.println(output);
	}

}


Measured memory_bytes: 22612
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

string istos(vector<int>& v)
{
	string s;
	for (auto& i : v)
	{
		s += i;
	}
	return s;
}

int main()
{
	cout << fixed << setprecision(10);
	int n;
	cin >> n;
	vector<int> p(n), q(n);
	REP(i, n)
	{
		cin >> p[i];
	}
	REP(i, n)
	{
		cin >> q[i];
	}
	vector<int> v(n);
	iota(v.begin(), v.end(), 1);
	vector<string> sv;
	do
	{
		sv.push_back(istos(v));
	} while (next_permutation(v.begin(), v.end()));     // 次の順列を生成

	SORT(sv);
	string ps = istos(p);
	string qs = istos(q);
	int pi = 0;
	int qi = 0;
	REP(i, sv.size())
	{
		if (sv[i] == ps)pi = i;
		if (sv[i] == qs)qi = i;
	}
	cout << abs(pi - qi);
	return 0;
}

Measured memory_bytes: 2424
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int ans=0;
  int now=0;
  rep(i,3){
    if(s[i]=='R') now++;
    else now=0;
    ans=max(ans,now);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3636
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long inf = 1ll << 61;
const long long mod = 1000000007;
struct edge {int to, cost;};
typedef pair<int, int> P;
int a[3000000];
int res[500005];
int upd[500005];
vector<int>G[500005];
signed main() {
	string s1, t; cin >> s1 >> t;
	string s=s1+s1;
	while (s.size() < 1000000) {
		s += s1;
	}
	s = t + s;
	a[0] = s.size();
	int i = 1, j = 0;
	while (i < s.size()) {
		while (i + j < s.size() && s[j] == s[i + j])j++;
		a[i] = j;
		if (!j) {
			i ++; continue;
		}
		int k = 1;
		while (i + k < s.size() && k + a[k] < j)a[i + k] = a[k], k++;
		i += k; j -= k;
	}
	for (int i = t.size(); i < t.size()+s1.size(); i++) {
		if (a[i] >= t.size()) {
			G[i - t.size()].push_back(i%s1.size());
		}
	}
	rep(j, 5) {
		rep(i, s1.size()) {
			if (G[i].size()) {
				int x = G[i][0];
				if (res[i] + 1 > res[x]) {
					res[x] = res[i] + 1;
					upd[x] ++;
				}
			}
		}
	}
	int ans = 0;
	rep(i, s1.size()) ans = max(ans, res[i]);
	rep(i,s1.size())if (upd[i]>3)ans = -1;
	cout << ans << endl;
	
}

Measured memory_bytes: 55672
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

#include <bits/stdc++.h>
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;
        break;
    }
    a-=d;
    if(a<=0){
        cout << "No" << endl;
        break;
    }
  }
  
  return 0;
}

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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int main(){
  int s,w;
  cin>>s>>w;
  if(w >= s){
    cout << "unsafe" << endl;
  }else{
    cout << "safe" << endl;
  }
  return 0;
}



Measured memory_bytes: 3636
A, B = map(int,input().split())

A = int(A)
B = int(B)
#print(str(A)+" "+str(B))

ans = 0

for i in range(2):

    if A > B:
        ans += A
        A -= 1
        
    else:
        ans += B
        B -= 1

print(ans)



Measured memory_bytes: 2940
#include<stdio.h>
#include<stdbool.h>

int map[50][50];
bool FindIsland(int, int, int, int);

void main()
{
	int h, w, i, j;
	int count;
	
	while(1)
	{
		count = 0;
		
		scanf("%d%d", &w, &h);
		
		if(w == 0 && h == 0) break;
		
		for(i = 0; i < h; i++)
		{
			for(j = 0; j < w; j++)
			{
				scanf("%d", &map[i][j]);
			}
		}
		
		for(i = 0; i < h; i++)
		{
			for(j = 0; j < w; j++)
			{
				if(FindIsland(i, j, h, w))
				{
					count++;
				}
			}
		}
		
		printf("%d\n", count);
	}
}

bool FindIsland(int cH, int cW, int maxH, int maxW)
{
	int i, j;
	int ccH, ccW;
	bool result = map[cH][cW] == 1;
	map[cH][cW] = -1;
	
	if(result)
	{
		for(i = 0; i < 3; i++)
		{
			for(j = 0; j < 3; j++)
			{
				ccH = cH - 1 + i;
				ccW = cW - 1 + j;
				if((i != 1 || j != 1) && ccH > -1 && ccW > -1 && ccH < maxH && ccW < maxW)
				{
					FindIsland(ccH, ccW, maxH, maxW);
				}
			}
		}
	}
	
	return result;
}

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

int main() {
  int flag=1;
  string S,T;
  cin>>S>>T;
  if(S.size()+1!=T.size())flag=0;
  for(int i=0;i<S.size();i++){
    if(S[i]!=T[i]){
      flag=0;break;
    } 
  }
  if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

//nに対して素因数分解
vector<pair<ll, ll>> prime_fact(ll n) {
	vector<pair<ll, ll>> res;
	for (ll p = 2; p * p <= n; p++) {
		if (n % p != 0) continue;
		int num = 0;
		while (n % p == 0) {
			num++;
			n /= p;
		}
		res.push_back(make_pair(p, num));
	}
	if (n != 1) res.push_back(make_pair(n, 1));
	return res;
}

const int MAX = 210000;
ll fac[MAX], finv[MAX], inv[MAX];

//テーブル
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

//組み合わせ
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

	COMinit();
	auto vec = prime_fact(m);

	ll res = 1LL;
	for (auto pa : vec) {
		int num = pa.second;
		ll tmp = COM(num + n - 1, n - 1); //(num(指数)+N-1) C (N-1)
		res = (res * tmp) % MOD; //求めたCombinationを掛ける
	}

	cout << res << endl;
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;
typedef pair<double, double> PDD;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}

double dist(PDD p1, PDD p2) {
    double x = p1.first - p2.first;
    double y = p1.second - p2.second;

    double ret = x*x + y*y;
    return sqrt(ret);
}

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


    int n; cin >> n;
    vector<PDD> a(n);
    vector<int> v;

    for (int i=0; i<n; i++) {
        cin >> a[i].first >> a[i].second;
        v.push_back(i);
    }

    double fact = 1;
    for (int i=2; i<=n; i++) {
        fact = fact * (double)i;
    }
    double sum = 0;

    do {
        for (int i=0; i<n-1; i++) {
            sum += dist(a[v[i]], a[v[i+1]]);
        }
    } while (next_permutation(v.begin(), v.end()));

    double ans = sum / fact;

    cout << fixed << setprecision(8) << ans;

    return 0;
}


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

int main() {
    int N, K;
    cin >> N;
    cin >> K;
    

    int x = 1;
    for (int i = 0; i < N; i++){
        int p_1 = x * 2;
        int p_2 = x + K;
        
        if (p_1 < p_2){
            x *= 2;
        }
        else {
            x += K;
        }
    }
    cout << x << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PAIR pair<int,int>
#define L(__) (__ << 1)
#define R(__) (L(__)|1)
#define oo (1<<30)
#define N 200005
using namespace std;
vector<int> G[N];
set<PAIR> S;
PAIR C[N];
int n,m,a[N],A[4*N],B[4*N];
int minself(int x,int y)
{
	return a[x]>a[y] ? y : x;
}
void build(int t,int l,int r)
{
	int mid=(l+r)>>1;
	if(l==r){
		A[t]=B[t]=0;
		if(l&1) A[t]=l;
		else B[t]=l;
		return ;
	  }
	build(L(t),l,mid);
	build(R(t),mid+1,r);
	A[t]=minself(A[L(t)],A[R(t)]);
	B[t]=minself(B[L(t)],B[R(t)]);
}
int RMQ(int t,int l,int r,int l1,int r1,int *X)
{
	int mid=(l+r)>>1;
	if(l>r1 || r<l1) return 0;
	if(l>=l1&&r<=r1) return X[t];
	return minself(RMQ(L(t),l,mid,l1,r1,X),RMQ(R(t),mid+1,r,l1,r1,X));
}
int solve(int l,int r)
{
	int p,u,v,z;
	if(l>r) return 0;
	p=++m;
	if(l&1){
		u=RMQ(1,1,n,l,r,A);
		v=RMQ(1,1,n,u,r,B);
	  }
	else{
		u=RMQ(1,1,n,l,r,B);
		v=RMQ(1,1,n,u,r,A);
	  }
	C[p]=PAIR(a[u],a[v]);
	if(z=solve(l,u-1)) G[p].push_back(z);
	if(z=solve(u+1,v-1)) G[p].push_back(z);
	if(z=solve(v+1,r)) G[p].push_back(z);
	return p;
}
int main()
{
	int i; a[0]=oo;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	build(1,1,n);
	solve(1,n);
	S.insert(PAIR(C[1].first,1));
	while(!S.empty()){
		int z=(*(S.begin())).second;
		S.erase(S.begin());
		printf("%d %d ",C[z].first,C[z].second);
		for(i=0;i<G[z].size();i++)
			S.insert(PAIR(C[G[z][i]].first,G[z][i]));
	  }
	return 0;
}


Measured memory_bytes: 24192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define vec vector
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << a << endl
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()


template<typename T>
struct BIT {
  int n;
  vector<T> dat;
  BIT(int n) : n(n), dat(n+1,0){}
  void add(int i,T x) {
    for (++i; i<=n; i+=(i&-i)) dat[i] += x;
  }
  T sum(int i) {
    T res = 0;
    for (++i; i>0; i-=(i&-i))
      res += dat[i];
    return res;
  }
  T range_sum(int l,int r) { //[l,r]
    return sum(r)-sum(l-1);
  }
};


int main() {
  string S,T;
  cin >> S >> T;
  int slen = S.size(), tlen = T.size();
  BIT<int> s(slen),t(tlen);
  rep(i,slen) {
    s.add(i,(S[i]=='A')?1:2);
  }
  rep(i,tlen) {
    t.add(i,(T[i]=='A')?1:2);
  }
  int Q;
  cin >> Q;
  rep(i,Q) {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    a--; b--;
    c--; d--;
    print(((s.range_sum(a,b)%3==t.range_sum(c,d)%3)?"YES":"NO"));
  }
  return 0;
}

Measured memory_bytes: 4316
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    divisors=divisors[::-1]
    return divisors
n,m=map(int,input().split())

divisors=make_divisors(m)

for i in divisors:
    if i<=m/n:
        print(i)
        exit()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N;
  cin >> N;

  cout << N / 3 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr(i,a,n) for(ll i=a;i<n;i++)
#define YES cout<<"YES"<<endl
#define all(v) v.begin(),v.end()
#define NO cout<<"NO"<<endl
#define pb(x) emplace_back(x)
#define fastio std::ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define mi map<ll,ll>
#define pi pair<ll,ll>
#define what(x) cout<<#x<<" ="<<x<<endl;
using namespace std;
using ll =long long;


int main()
{
    fastio;
    ll n;
vector<ll>m(2000005);
    cin>>n;
    ll gcd=0;
    ll p=0;
    fr(i,0,n)
    {
        ll x;
        cin>>x;

        gcd=__gcd(gcd,x);
        bool prime=true;
        //if(x%2==0)if(m[2]>=1)p=1;else m[2]++;
        for(ll k=2;k*k<=x;k++)
        {
            if(x%k==0)
            {
            prime=false;
            m[k]++;
            //what(m[k]);
            if(k!=x/k) m[x/k]++;

            if(m[k]>1 || m[x/k]>1){ p=1; break;}

        }
        }
       // what(x);
            if(prime && x!=1)
            {
                m[x]++;
                if(m[x]>1){p=1;}
            }
    }

        if(p==0)cout<<"pairwise coprime"<<endl;
        else
        if(gcd==1)cout<<"setwise coprime"<<endl;

        else cout<<"not coprime"<<endl;


}




























Measured memory_bytes: 18712
n,m = map(int,input().split())
*X, = map(int,input().split())
*Y, = map(int,input().split())
mod = 10**9+7

x,y=[],[]
for i,u in enumerate(X[:-1]):
    x.append(X[i+1]-u)
for i,v in enumerate(Y[:-1]):
    y.append(Y[i+1]-v)
wx = [(i+1)*(n-i-1)%mod for i in range(n-1)]
wy = [(i+1)*(m-i-1)%mod for i in range(m-1)]
print((sum([wx[i]*x[i] for i in range(n-1)])%mod)*(sum([wy[i]*y[i] for i in range(m-1)])%mod)%mod)

Measured memory_bytes: 32536
#include <stdio.h>
#include <cmath>
using namespace std;
int main(){
  double a, b, C;
  scanf("%lf %lf %lf", &a, &b, &C);
  printf("%lf\n", a*b*sin(C*M_PI/180)/2);
  printf("%lf\n", a+b+sqrt(a*a+b*b-2*a*b*cos(C*M_PI/180)));
  printf("%lf\n", b*sin(C*M_PI/180));
}


Measured memory_bytes: 2856
n = str(input())
strk = 0
a = 0
for i in range(3):
    if n[i]==n[i+1]:
        strk += 1
    else:
        a = strk
        strk = 0
a = max(a,strk)
if a >= 2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main(){
  ll a;
  string b;
  cin>>a>>b;

  ll bb = 0;
  for(int i=b.size()-1,j=0;i>=0;i--){
    if(b[i] == '.') continue;
    bb += (b[i]-'0')*pow(10,j++);
  }
  ll ans= a*bb/100;
  cout<<ans<<endl;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
    const int MAX =200002;
const int MOD =1000000007;

     signed main(){
     int n;
     cin>>n;
     int a[n],ma=0,ans=0;
     for(int i=0;i<n;i++){
         cin>>a[i];
         if(ma>a[i])ans+=ma-a[i];
         else ma=a[i];
     }
     cout<<ans<<endl;

     }


 


 






    





      

        


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

int main() {
  long long int n, ans =0;
  cin >> n;
  vector<int> a(n+1),b(n);
  for (int i=0; i<n+1; i++) cin >> a[i];
  for (int i=0; i<n; i++) cin >> b[i];
  
  for (int i=0; i<n; i++){
    if (a[i]+a[i+1]>=b[i]){
      ans += b[i];
      if (b[i] -a[i]>=0){
        a[i+1] = a[i+1] - (b[i]-a[i]);
        a[i] = 0;
      }
      else{
        a[i] = a[i] -b[i];
      }
      b[i]=0;
    }
    else{
      ans += a[i]+a[i+1];
      b[i] -= a[i]+a[i+1];
      a[i] = 0;
      a[i+1] = 0;
    }
  }
  
  cout << ans << endl;
  return 0;
  
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  ll x,y;
  cin>>x>>y;
  if(abs(x-y)<2)
    cout<<"Brown"<<endl;
  else
    cout<<"Alice"<<endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);

		int N=sc.nextInt();
		String S=sc.next();

		int[] white=new int[N+1];
		int[] black=new int[N+1];

		white[0]=black[0]=0;

		for(int i=0;i<N;i++) {
			if(S.charAt(i)=='.') {
				white[i+1]=white[i]+1;
				black[i+1]=black[i];
			}else {
				white[i+1]=white[i];
				black[i+1]=black[i]+1;
			}
		}

		int ans=N;

		for(int i=0;i<N+1;i++) {
			int temp=(white[N]-white[i])+black[i];
			ans=Math.min(ans, temp);
		}

		System.out.println(ans);

		sc.close();
	}

}


Measured memory_bytes: 30256