akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

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

//想定解答との絶対誤差または相対誤差が 10−6以下の場合+1以上だしておく。適当に15とかでもおｋ．
//cout << fixed << setprecision(15);
vector<ll> memo;
ll M;
ll N;
vector<bool> broken;
ll fac(ll n) {
    if (n == N) return 1;
    if (n > N) return 0;
    if (broken[n]) return 0;
    if (memo[n]!=-1) return memo[n];
    ll res1 = fac(n+1);
    ll res2 = fac(n+2);
    return memo[n] = (res1+res2) % MOD;
}

int main() {
    cin >> N >> M;
    broken.resize(N + 1, false);
    vl a(M);
    rep(i, 0, M) {
        cin >> a[i];
    }
    rep(i, 0, M) {
        broken[a[i]] = true;
    }
    memo.resize(N+1, -1);
    cout << fac(0) << endl;
    return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define MAX 1000005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define vll vector<ll>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
 
ll gcd(ll n1,ll n2){
	if(n2==0)
		return n1;
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent)
{
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
vi v[MAX];
int dp[MAX];
void DFS(int node,int p)
{
	if(v[node].size()==1&&node!=1)
	{
		dp[node]=1;
		return;
	}
	int now=0;
	for(int i=0;i<v[node].size();i++)
	{
		int child=v[node][i];
		if(child!=p)
		{
			DFS(child,node);
			now^=dp[child];
		}
	}
	//cout<<node<<" "<<dp[node]<<endl;
	dp[node]=now+1;
}
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	DFS(1,-1);
	if(dp[1]!=1)
		cout<<"Alice"<<endl;
	else
		cout<<"Bob"<<endl;
	//cout<<dp[1]<<endl;
	/*ll n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	if(b<a)
		swap(a,b);
	ll maxa=a,mina=a;
	for(int i=0;i<n-2;i++)
	{
		maxa+=d;
		mina+=c;
	}
	cout<<mina<<" "<<maxa<<endl;
	if(b<=maxa&&b>=mina)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;*/
}

Measured memory_bytes: 36864
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int n;
ll f[1005];
int main(){
	scanf("%d",&n);
	f[0]=2;
	for(int i=1;i<=n;i++)f[i]=f[i-1]*2+2;
	printf("%lld\n",f[n]);
	return 0;
}


Measured memory_bytes: 256
//IT IS ONLY A TEST, DON'T CONSIDER IT SERIOUSLY!
#include <bits/stdc++.h>
#define N 100010
using namespace std;
int num[N]={},dp[N]={},n,m,x,y;
vector<int> ft[N];
stack<int> s;
int main(){
	int i,j;
	cin>>n>>m;
	for(i=0;i<m;i++)
	{
		cin>>x>>y;
		x--;
		y--;
		ft[x].push_back(y);
		num[y]++;
	}
	for(i=0;i<n;i++)
	{
		if(num[i]==0)
		{
			s.push(i);
		}
	}
	while(s.size())
	{
		x=s.top();
		s.pop();
		for(i=0;i<ft[x].size();i++)
		{
			dp[ft[x][i]]=max(dp[ft[x][i]],dp[x]+1);
			num[ft[x][i]]--;
			if(num[ft[x][i]]==0)
			{
				s.push(ft[x][i]);
			}
		}
	}
	cout<<*max_element(dp,dp+n)<<endl;
	return 0;
}

Measured memory_bytes: 6528
<?php
fscanf(STDIN, "%d", $q);
for ($i = 0; $i < $q; $i++) {
	fscanf(STDIN, "%d %d", $l[], $r[]);
}
$m = max($r);
$n[1] = 0;
$ps[2] = 1;
for ($i = 3; $i <= $m; $i += 2) {
	$n[$i] = $n[$i-2];
	$sq = sqrt($i);
	foreach ($ps as $p => $d) {
		if ($p > $sq) break;
		if ($i % $p == 0) continue 2;
	}
	$ps[$i] = 1;
	$j = ($i + 1) / 2;
	if (isset($ps[$j])) {
		$n[$i]++;
		$f[$i] = 1;
	}
}
for ($i = 0; $i < $q; $i++) {
	$x[] = $n[$r[$i]] - $n[$l[$i]] + isset($f[$l[$i]]) * 1;
}
echo implode("\n", $x);

Measured memory_bytes: 26612
#include<iostream>
#include<vector>

using namespace std;

typedef unsigned int uint;

uint xor128(void) { 
  static uint x = 123456789;
  static uint y = 362436069;
  static uint z = 521288629;
  static uint w = 88675123; 
  uint t;
 
  t=x^(x<<11);
  x=y; y=z; z=w;
  return w=(w^(w>>19))^(t^(t>>8)); 
}

int n,k,ans[1001],card[501][1001];
	
bool ok(void){

	for(int i=0;i<k;i++){
		int sum=0;
		for(int j=0;j<n/2;j++)sum+=ans[card[i][j]-1];
		
		if(sum<n/8 || 3*n/8<sum)return false;
	}
	return true;
}

int main(void){
	
	cin >> n >> k;
	
	for(int i=0;i<k;i++){
		for(int j=0;j<n/2;j++){
			cin >> card[i][j];
		}
	}
	
	while(true){
		for(int j=0;j<n;j++)ans[j]=xor128()%2;
		
		if(ok()){
			for(int j=0;j<n;j++)cout << ans[j];
			cout << endl;
			break;
		}
	}
	
return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i< (n); i++)
int main(){
long long int a=0, b=0, c=0;
cin >> a >> b >> c;
if(c-a-b<=0) cout << "No" << endl;
else if (4*a*b<(c-a-b)*(c-a-b)) cout << "Yes" << endl;
else cout << "No" << endl;
}
/*
int main(){
long long int a=0, b=0, c=0;
cin >> a >> b >> c;
long double aa=0, bb=0, cc=0;
aa=pow(a, 0.5);
bb=pow(b, 0.5);
cc=pow(c, 0.5);
if (aa + bb < cc) cout << "Yes" << endl;
else cout << "No" << endl;
}
*/


Measured memory_bytes: 256
n = int(input())
t = [list(map(int,input().split())) for _ in range(n)]
t.insert(0,[0,0,0])
for i in range(1,n+1):
    d_sec = t[i][0] - t[i-1][0]
    d_x = abs(t[i][1]- t[i-1][1])
    d_y = abs(t[i][2]- t[i-1][2])
    d_xy = d_x + d_y
    if (d_sec < d_xy) | (d_sec%2 != d_xy%2):
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 27136
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] s = saori.nextHayami().split("");
		int a = 0;
		int z = 0;
		for(int i = 0;i < s.length;i++){
			if(s[i].equals("A")){
				a = i;
				break;
			}
		}
		for(int i = s.length-1;i >=0;i--){
			if(s[i].equals("Z")){
				z = i;
				break;
			}
		}
		System.out.println(z-a+1);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 39268
#include <stdio.h>

int main()
{
   int n, i, j, min, e, f;
   int b[1000], c[1000], A[1000][1000];
   int wa = 0;

   scanf("%d", &n);

   for ( i = 0; i < n; i++ ) {
      b[ i ] = 0;
      c[ i ] = 1000;
      for ( j = 0; j < n; j++ ) {
         scanf("%d", &A[ i ][ j ]);
      }
   }
   c[0] = 0;
   for ( i = 1; i < n; i++ ) {
      min = 1000;
      for ( j = 0; j < n; j++ ) {
         if ( c[ j ] < min && b[ j ] == 0 ) {
            min = c[ j ];
            e = j;
         }
      }
      b[ e ] = 1;
      for ( f = 0; f < n; f++ ) {
         if ( A[ e ][ f ] < c[ f ] && A[ e ][ f ] != -1 && b[ f ] == 0 ) {
            c[ f ] = A[ e ][ f ];
         }
      }
   }
   for ( i = 0; i < n; i++ ) {
      wa += c[ i ];
   }
   printf("%d\n", wa);
   return 0;
}

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

int main(){
    int n,T,i,f=0;
    cin >> n >> T;
    int c[n+1],t[n+1];
    for (i=1;i<=n;i++){
        cin >> c[i] >> t[i];
        if (t[i] > T){
            c[i] = 1001;
            f++;
        }
    }
    if (f == n){
        cout << "TLE";
        return 0;
    }

    int route = 1;
    for (i=1;i<=n;i++){
        if (c[i] < c[route]){
            route = i;
        }
    }
    cout << c[route];
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

#define DELICIOUS 100
#define DONUTS DELICIOUS

int D, O, N, U, T, S;

int e[110], c[110], h[110], a[110];

int dp1[110][110], dp2[110], dp3[110][110];

int main() {
	cin >> S >> T >> U >> N >> O >> D;
	
	for (int i=0; i<T; i++) cin >> e[i] >> c[i];
	for (int i=0; i<N; i++) cin >> h[i] >> a[i];
	
	memset(dp1, -1, sizeof(dp1));
	dp1[0][0] = 0;
	for (int i=0; i<T; i++) {
		for (int j=U-1; j>=0; j--) {
			for (int k=0; k<=S; k++) {
				if (dp1[j][k] < 0) continue;
				if (k+e[i]<= S) dp1[j+1][k+e[i]] = max(dp1[j+1][k+e[i]], dp1[j][k] + c[i]);
			}
		}
	}
	
	memset(dp2, 0, sizeof(dp2));
	for (int i=0; i<N; i++) {
		for (int j=0; j<=DONUTS * U; j++) {
			if (j + a[i] <= DONUTS * U) dp2[j + a[i]] = max(dp2[j + a[i]], dp2[j] + h[i]);
		}
	}
	
	memset(dp3, -1, sizeof(dp3));
	dp3[0][S] = 0;
	for (int i=0; i<D; i++) {
		for (int j=0; j<=S; j++) {
			if (dp3[i][j] < 0) continue;
			for (int k=0; k<=j; k++) {
				if (dp1[U][k] < 0) continue;
				int nxj = min(j-k+O, S);
				dp3[i+1][nxj] = max(dp3[i+1][nxj], dp3[i][j] + dp2[ dp1[U][k] ]);
			}
		}
	}
	
	int ans = -1;
	for (int i=0; i<=S; i++) ans = max(ans, dp3[D][i]);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1268
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
public class Main {
	static FastScanner stdIn=new FastScanner();
	public static void main(String[] args) {
		int A=stdIn.nextInt();
		int B=stdIn.nextInt();
		int C=stdIn.nextInt();
		long ans=0;
		ans+=B;
		B+=A;
		if(C<=B+1){
			System.out.println(ans+C);
		}
		else
			System.out.println(ans+B+1);
	}
}


Measured memory_bytes: 21076
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

s=get_nsp
q=gets.to_i
q.times do
  query=get
  a=query[1].to_i
  b=query[2].to_i
  case query[0]
  when "replace" then
    s_=query[3].split("")
    for i in a..b
      s[i]=s_[i-a]
    end
  when "reverse" then
    m=b-a+1
    (m/2).times do|i|
      s[a+i],s[b-i]=s[b-i],s[a+i]
    end
  when "print" then
    puts s[a..b].join("")
  end
end


Measured memory_bytes: 6936
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
}

int main(){
    long long h;
    cin>>h;
    long long count=0,i=1;
    while(h>1)
    {
        //count++;
        for(int j=0;j<i;j++)
        count++;

        i*=2;
        h/=2;

    }
    cout<<count+i;
    
return 0;
}


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

int main(){
    int n,k;
    cin >> n >> k;
    ll ans=k;
    rep(i,n-1) ans*=k-1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>

const int Maxv = 1000010; 
int Head[Maxv], nHead[Maxv], vis[Maxv], book[Maxv], dist[Maxv], cnt, cnt1, n, m; 
std::vector< std::pair<int, int> > g[Maxv]; 
std::vector<int> ng[Maxv], cg[Maxv]; 
std::queue<int> q; 

struct Node{
    int v, c, next; 
}e[Maxv], ne[Maxv]; 

inline int read(){
    int x = 0, f = 1; 
    char ch = getchar(); 
    while (ch < '0' || ch > '9') {
        if (ch == '-') {
            f = -1; 
        }
        ch = getchar(); 
    }
    while (ch >= '0' && ch <= '9') {
        x = (x << 3) + (x << 1) + ch - '0'; 
        ch = getchar(); 
    }
    return x * f; 
}

void bfs(){
    int wow = n; 
    for (int i = 0; i < Maxv; i++) {
        if (cg[i].empty()) {
            continue; 
        }
        for (int j = 0; j < cg[i].size(); j++) {
            int v = cg[i][j]; 
            if (vis[v] == i) {
                continue; 
            }
            q.push(v); 
            vis[v] = i; 
            while (!q.empty()) {
                int tmp = q.front(); 
                q.pop(); 
                while (book[tmp] < g[tmp].size()) {
                    int c = g[tmp][ book[tmp] ].first; 
                    if (c != i) {
                        break; 
                    }
                    int u = g[tmp][ book[tmp] ].second; 
                    if (vis[u] != i) {
                        vis[u] = i; 
                        q.push(u); 
                    }
                    book[tmp]++; 
                }
                ng[tmp].push_back(wow); 
                ng[wow].push_back(tmp); 
            }
            wow++; 
        }
    }
    for (int i = 0; i < Maxv; i++) {
        dist[i] = -2; 
    }
    q.push(0); 
    dist[0] = 0;
    while (!q.empty()) {
        int tmp = q.front(); 
        q.pop(); 
        for (int i = 0; i < ng[tmp].size(); i++) {
            int u = ng[tmp][i]; 
            if (dist[u] == -2) {
                dist[u] = dist[tmp] + 1; 
                q.push(u); 
            }
        }
    }
}

int main(){
    n = read(); 
    m = read(); 
    for (int i = 1; i <= m; i++) {
        int u, v, c; 
        u = read(); 
        v = read(); 
        c = read(); 
        u--; 
        v--; 
        g[u].push_back(std::make_pair(c, v)); 
        g[v].push_back(std::make_pair(c, u)); 
        cg[c].push_back(u);
        cg[c].push_back(v); 
    }
    for (int i = 0; i < n; i++) {
        std::sort(g[i].begin(), g[i].end()); 
        vis[i] = -1; 
    }
    bfs(); 
    printf("%d\n", dist[n - 1] / 2); 
    return 0; 
}

Measured memory_bytes: 99712
#include "bits/stdc++.h"
using namespace std;
using namespace std;
int context[15][15];
void init(){
  for(int i=0;i<15;i++){
    for(int j=0;j<15;j++){
      context[i][j]=0;
    }
  }
}
int main(){
  int n,nowx,nowy;
  while(cin>>n,n){
    init();
    nowx=n/2; nowy=n/2+1;
    context[nowy][nowx]=1;
    for(int i=2;i<=n*n;i++){
      nowx++; nowy++;
      while(true){
	if(nowx>=n) nowx=0;
	if(nowx<0) nowx=n-1;
	if(nowy>=n) nowy=0;
	if(context[nowy][nowx]!=0) nowx--,nowy++;
	if(context[nowy][nowx]==0 && 0<=nowx && nowx<n && 0<=nowy && nowy<n) break;
      }
      context[nowy][nowx]=i;
      //      printf("(%d,%d)\n",nowy,nowx);
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	printf("%4d",context[i][j]);
      }
      cout<<endl;
    }
  }
}

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

int main() {
    string s;
    cin >> s;
    int len = s.length();
    for(int i = 0; i < len - 1; i++) {
        if(s[i] == s[i + 1]) {
            cout << i + 1<< " " << i + 1 + 1;
            return 0;
        }
    }
    for(int i = 0; i < len - 2; i++) {
        if(s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 2 + 1;
            return 0;
        }
    }
    cout << -1 << " " << -1;
}

Measured memory_bytes: 512
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main(){
	string a, b;
	cin >> a >> b;
	if (a == "H" && b == "D") {
		cout << "D" << endl;
		return 0;
	}
	if (a == "D" && b == "H") {
		cout << "D";
		return 0;
	}
	cout << "H";
}


Measured memory_bytes: 256
from copy import deepcopy
from collections import deque
import sys

M = []
H = 0
W = 0
qx = deque()
qy = deque()
qc = deque()

def main():
    global M,H,W
    H,W = map(int, input().split())  
    for i in range(H):
        M.append(list(input()))

    startX = 0
    startY = 0
    mx = 0
    for i in range(H):
        for j in range(W):
            if M[i][j]=='.':
                rv =  bfs(i,j)
                if rv > mx:
                    mx = rv


    print(mx)

def bfs(y,x):
    global M,H,W
    Mtemp = deepcopy(M)
    Mtemp[y][x] = '#'
    qx.append(x)
    qy.append(y)
    qc.append(0)
    cnt = 0

    while len(qx) !=0:
        x =  qx.popleft()
        y =  qy.popleft()
        cnt = qc.popleft()

        if x-1>=0:
            if Mtemp[y][x-1] == '.':
                Mtemp[y][x-1] = '#'
                qx.append(x-1)
                qy.append(y)
                qc.append(cnt+1)
        if x+1<W:
            if Mtemp[y][x+1] == '.':
                Mtemp[y][x+1] = '#'
                qx.append(x+1)
                qy.append(y)
                qc.append(cnt+1)
        if y-1>=0:
            if Mtemp[y-1][x] == '.':
                Mtemp[y-1][x] = '#'
                qx.append(x)
                qy.append(y-1)
                qc.append(cnt+1)
        if y+1<H:
            if Mtemp[y+1][x] == '.':
                Mtemp[y+1][x] = '#'
                qx.append(x)
                qy.append(y+1)
                qc.append(cnt+1)

    return cnt




if __name__ == '__main__':
    main()



Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> ans(n, 0);
    rep(i, n - 1) {
        ll a;
        cin >> a;
        a--;
        ans[a]++;
    }
    rep(i, n) printf("%lld\n", ans[i]);
    return 0;
}


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

using namespace std;

const int maxn = 1e5*3;
int n, a[maxn], ans[maxn];


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for (int i = 0; i < n*3; i++) cin >> a[i];
    ans[0] = a[0]; ans[1] = a[1]; ans[2] = a[2];
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            int curr = a[i*3+j];
            if (j == 0) ans[i*3+j] = max(curr+ans[(i-1)*3+1],curr+ans[(i-1)*3+2]);
            else if (j == 1) ans[i*3+j] = max(curr+ans[(i-1)*3],curr+ans[(i-1)*3+2]);
            else ans[i*3+j] = max(curr+ans[(i-1)*3+1],curr+ans[(i-1)*3]);
        }
    }
    cout << max(max(ans[(n-1)*3],ans[(n-1)*3+1]),ans[(n-1)*3+2]);
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define debug(a) cout << "["; rep(i,a.size()) cout << a.at(i) << ", "; cout<<"]"<< endl;

const ll mod = 1000000007;

int main() {
    ll n; cin >> n;
    vector<ll> cnt(n);
    for(ll i = 1; i <= n; i++){
        ll d = 1;
        while(i * d <= n){
            cnt.at(i * d - 1)++;
            d++;
        }
    }
    ll ans = 0;
    rep(i,n){
        ans += (i+1) * cnt.at(i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 81412
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, 0, n) cin >> h[i];

    vector<int> dp(n);
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);

    rep(i, 2, n)
    {
        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=200005;
//i_am_noob
int n,a[maxn],dp[maxn][3],sum,ans=-4e18;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n;
	rep(n) cin >> a[i];
	if(n%2==0){
		sum=0;
		rep(n/2) sum+=a[i*2];
		ans=max(ans,sum);
		rep3(i,n/2-1,0){
			sum+=a[i*2+1]-a[i*2];
			ans=max(ans,sum);
		}
		print1(ans);
		return 0;
	}
	rep1(j,3) dp[0][j]=a[j];
	rep2(i,1,n/2) rep1(j,3){
		dp[i][j]=-4e18;
		rep1(k,j+1) dp[i][j]=max(dp[i][j],dp[i-1][k]+a[2*i+j]);
	}
	rep1(j,3) ans=max(ans,dp[n/2-1][j]);
	print1(ans);
	return 0;
}

Measured memory_bytes: 7524
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

  static int n;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    n = Integer.parseInt(in[0]);

    br.close();

    out.println((1000 - n % 1000) % 1000);

    out.flush();

  }
}

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

int main(){
    int n;
    cin>>n;
    int x[10],y[10];
    rep(i, n) cin>>x[i]>>y[i];
    double ans=0;
    int sum=0;
    int pro=1;
    rep(i,n){
        sum+=i;
        pro*=i+1;
    }
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            ans+=sqrt(pow((x[j]-x[i]),2)+(pow((y[j]-y[i]),2)));
        }
    }
    ans*=pro*(n-1)/sum;
    while(n>0) {
        ans/=n;
        n--;
    }
    cout<<fixed<<setprecision(12)<<ans<<endl;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL N; cin >> N;

	LL ans = (N-30)/2;


	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3212
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  n += 1;
  cout << (n & (-n)) << endl;
}

Measured memory_bytes: 3184
n,k = map(int,input().split())
A = [0]+list(map(int,input().split()))
visited = [False for _ in range(n+1)]
pos = 1
x = []
flg = False
for i in range(k):
    if visited[pos] == False:
        x.append(pos)
        visited[pos] = True
        pos = A[pos]
    else:
        flg = True
        pre = x.index(pos)
        loop = x[pre:]
        break
if not flg:
    print(pos)
else:
    print(loop[(k-pre)%len(loop)])

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

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

using namespace std;

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

typedef long long ll;
const int mod=1000003;
vector<int> to[50000];

void Merge(int a[2][2],int b[2][2],int (&c)[2][2]){
	REP(i,2)
		REP(j,2)
			c[i][j]=(ll(a[i][0])*b[1][j]+ll(a[i][1])*b[0][j])%mod;
}

void Calc(int l,int r,int (&dst)[2][2]){
	dst[0][0]=1;
	dst[0][1]=0;
	dst[1][0]=0;
	dst[1][1]=1;
	if(l+1==r)
		return;
	int buf[2][2],tmp[2][2];
	FOR(i,1,(int)to[l].size()){
		Calc(to[l][i-1],to[l][i],buf);
		Merge(dst,buf,tmp);
		memcpy(dst,tmp,sizeof(dst));
		dst[1][1]=(dst[1][1]+dst[0][0])%mod;
	}
	if(to[l].back()<r){
		Calc(to[l].back(),r,buf);
		Merge(dst,buf,tmp);
		memcpy(dst,tmp,sizeof(dst));
	}
}

int main(){
	while(1){
		int n=read(),m=read();
		if(!n)
			return 0;
		REP(i,n)
			to[i].clear();
		REP(i,n-1)
			to[i].PB(i+1);
		to[0].PB(n-1);
		REP(i,m){
			int a=read()-1,b=read()-1;
			to[min(a,b)].PB(max(a,b));
		}
		REP(i,n)
			sort(to[i].begin(),to[i].end());
		int ans[2][2];
		Calc(0,n-1,ans);
		printf("%d\n",ans[1][1]);
	}
}

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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
//const int MOD = 1e9+7;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int x = max({a,b,c});
    int s = a+b+c;

    if(x%2 != s%2)
        x++;
    
    cout << (3*x - s)/2;
}


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

#ifdef _LOCAL_DEBUG
#include "templates/debug.h"
#else
#define debug(...) 
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    cout << (n < 30 ? "No\n" : "Yes\n");
    return 0;
}

Measured memory_bytes: 3560
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
ans=float('inf')
l=0
for i in range(n):
    tmp=abs(a-(t-h[i]*0.006))
    if tmp<ans:
        l=i+1
    ans=min(ans,tmp)
print(l)

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

int main() {
  int a, b, c, k;
  scanf("%d %d %d %d", &a, &b, &c, &k);

  int ans = 0;
  if (k <= a)
    ans = k;
  else if (k <= a + b)
    ans = a;
  else
    ans = a - (k - a - b);

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main() {
  string s;
  cin>>s;
  int n=s.size();
  
  ll ans=0;
  ll bla=0;
  rep(i,n){
    if(s[i]=='B')bla++;
    else ans+=bla;
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
count = 0
for _ in range(0,N):
    if B[_] >= A[_]:
        count += A[_]
        B[_] -= A[_]
        A[_] = 0
        if B[_] >= A[_ + 1]:
            count += A[_ + 1]
            A[_ + 1] = 0
            B[_] = 0
        else:
            A[_ + 1] -= B[_]
            count += B[_]
            B[_] = 0
    else:
        count += B[_]
        A[_] -= B[_]
        B[_] = 0
print(count)

Measured memory_bytes: 20724
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll h,w;
    cin >> h >> w;
    ll a = min(w,h);
    ll b = max(w,h);
    ll sa,sb,sc;
    ll answer = 10000000000;
    FOR(i,1,b){
        sa = a*i;
        sb = (b-i)*(a/2);
        sc = (b-i)*(a-(a/2));
        ll smax = max({sa,sb,sc});
        ll smin = min({sa,sb,sc});
        if(smax-smin < answer){
            answer = smax-smin;
        }
        if(answer == 0)
            break;
    }
    FOR(i,1,b){
        sa = a*i;
        sb = a*((b-i)/2);
        sc = a*((b-i)-((b-i)/2));
        ll smax = max({sa,sb,sc});
        ll smin = min({sa,sb,sc});
        if(smax-smin < answer){
            answer = smax-smin;
        }
        if(answer == 0)
            break;
    }
    
    swap(a,b);

    FOR(i,1,b){
        sa = a*i;
        sb = (b-i)*(a/2);
        sc = (b-i)*(a-(a/2));
        ll smax = max({sa,sb,sc});
        ll smin = min({sa,sb,sc});
        if(smax-smin < answer){
            answer = smax-smin;
        }
        if(answer == 0)
            break;
    }
    FOR(i,1,b){
        sa = a*i;
        sb = a*((b-i)/2);
        sc = a*((b-i)-((b-i)/2));
        ll smax = max({sa,sb,sc});
        ll smin = min({sa,sb,sc});
        if(smax-smin < answer){
            answer = smax-smin;
        }
        if(answer == 0)
            break;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    long int N, K;
    cin >> N >> K;
    vector<long int> h(N);
    for (long int i = 0; i < N; i++) {
        cin >> h[i];
    }
    long int can_ride_num = 0;
    for (long int i = 0; i < N; i++) {
        if (h[i]>=K) {
            can_ride_num++;
        }
    
    }

    cout << can_ride_num << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
int main(void){
    string s;cin>>s;
    int a=s[0]-0x30;int b=s[1]-0x30;int c=s[2]-0x30;int d=s[3]-0x30;
    int x=a*10+b;int y=c*10+d;
    if((x==0||x>12)&&(y>=1&&y<=12))cout<<"YYMM"<<endl;
    else if((x>=1&&x<=12)&&(y==0||y>12))cout<<"MMYY"<<endl;
    else if((x>=1&&x<=12)&&(y>=1&&y<=12))cout<<"AMBIGUOUS"<<endl;
    else cout<<"NA"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

////////////////////////////////////////////////////////

map<ll, ll> fact;

void PrimeFactorization(ll n){
    Rep(i, 2, sqrt(n)){
        while(n%i == 0){
            fact[i]++;
            n /= i;
        }
        if(n == 1) break;
    }
    if(n != 1) fact[n]++;
}

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

    ll ans = 0;
    for(auto m : fact){
        // cout << m.fi << " " << m.se << endl;
        ll b = m.se;
        ll n = 1;
        while(b >= n){
            b -= n;
            n++;
            ans++;
        }
    }
    co(ans);

    return 0;
}


Measured memory_bytes: 3688
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] nums=new int[100001];
        for(int i=0;i<n;i++){
            nums[sc.nextInt()]++;
        }
        int odd=0;
        int even=0;
        int fk = 0;
        for(int i=0;i<100001;i++){
            if(nums[i]%2==1){
            	odd++;
            }
            else if(nums[i]>0){
            	even++;
            }
        }
        if(even%2==0){
        	fk = even;
        }else{
        	fk = even-1;
        }
        System.out.println(odd+fk);
    }
}

Measured memory_bytes: 51032
#include <cassert>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;

// BIT 1-origin
class BIT {
private:
	int size;
	vector<long long> bit;

public:
	BIT(int n = 0):size(n), bit(n + 1, 0) {}

	void add(int i, long long x) {
		while(i <= size) {
			bit[i] += x;
			i += i & -i;
		}
	}

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

/*
 * 区間に対する処理．
 * 2つのBITを使用する．
 */
class BIT_segment {
private:
	BIT bit0, bit1;

public:
	BIT_segment(int n):bit0(n), bit1(n) {}

    /*
	 * [l, r]の要素にxを加える．
	 */
	void add(int l, int r, long long x) {
		++l;
		++r;
		bit0.add(l, -x * (l - 1));
		bit1.add(l, x);
		bit0.add(r + 1, x * r);
		bit1.add(r + 1, -x);
	}

	/*
	 * [l, r]の総和を求める．
	 */
	long long query(int l, int r) const {
		++l;
		++r;
		long long res = 0;
		res += bit0.sum(r) + bit1.sum(r) * r;
		res -= bit0.sum(l - 1) + bit1.sum(l - 1) * (l - 1);
		return res;
	}
};

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

	for(int q, limit; cin >> q >> limit, q;) {
		int next = 0;
		unordered_map<int, int> convert;
		deque<int> deq;
		BIT_segment bit(q);

		for(int i = 0; i < q; ++i) {
			int query, x;
			cin >> query >> x;

			switch(query) {
			case 0: // append
			{
				convert[x] = next;
				bit.add(next, next, deq.size());
				deq.emplace_back(x);
				++next;

				if(static_cast<int>(deq.size()) > limit) {
					convert.erase(deq.front());
					deq.pop_front();
					bit.add(0, next - 1, -1);
				}

				break;
			}
			case 1: // delete idx = x
			{
				--x;
				const int target = deq[x];
				deq.erase(deq.begin() + x);
				bit.add(convert[target] + 1, next - 1, -1);
				convert.erase(target);
				break;
			}
			case 2: // print
			{
				cout << deq[x - 1] << endl;
				break;
			}
			case 3: // delete num = x
			{
				const int tmp = convert[x];
				const int idx = bit.query(tmp, tmp);
				deq.erase(deq.begin() + idx);
				bit.add(tmp, next - 1, -1);
				convert.erase(x);
				break;
			}
			default:
				assert(false);
			}
		}

		cout << "end" << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 11060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=1005;
int x[N],y[N];
bool vis[2];
char ans[35];
int main(){
	int n=read();
	For(i,1,n){
		x[i]=read(); y[i]=read();
		vis[(x[i]+y[i])&1]=1;
	}
	if(vis[0]&&vis[1]){
		puts("-1");  return 0;
	}
	int m=31;
	cout<<m+vis[0]<<endl;
	For(i,0,m-1)wri(1<<i);
	if(vis[0]){
		m++;
		For(i,1,n)x[i]--; puts("1");
		ans[31]='R';
	}
	For(i,1,n){
		Rep(j,30,0){
			int t=1<<j;
			if(x[i]>=t){x[i]-=t; ans[j]='R';}
			else if(x[i]<=-t){x[i]+=t; ans[j]='L';}
			else if(y[i]>=t){y[i]-=t; ans[j]='U';}
			else if(y[i]<=-t){y[i]+=t; ans[j]='D';}
			else if(abs(x[i])>=abs(y[i])){
				if(x[i]>0){x[i]-=t; ans[j]='R';}
				else {x[i]+=t; ans[j]='L';}
			}else{
				if(y[i]>0){y[i]-=t; ans[j]='U';}
				else {y[i]+=t; ans[j]='D';}
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,m,i,x,a[1000005][2],ans=1,cnt1=0,cnt2=0,sum=0;
const ll mod=1e9+7;
int main()
{
	scanf("%lld%lld",&n,&m);
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&x);
		a[x][0]++;
	}
	for(i=1;i<=m;i++)
	{
		scanf("%lld",&x);
		a[x][1]++;
	}
	for(i=n*m;i>0;i--)
	{
		if(a[i][0]>1||a[i][1]>1)
		{
			printf("0\n");
			return 0;
		}
		if(a[i][0]==0)
		{
			if(a[i][1]==0)
			{
				if(sum>0)ans=ans*sum%mod;
				else
				{
					printf("0\n");
					return 0;
				}
			}
			else
			{
				if(cnt1>0)ans=ans*cnt1%mod;
				else
				{
					printf("0\n");
					return 0;
				}
			}
		}
		else
		{
			if(a[i][1]==0)
			{
				if(cnt2>0)ans=ans*cnt2%mod;
				else
				{
					printf("0\n");
					return 0;
				}
			}
		}
		if(a[i][0])cnt1++,sum+=cnt2;
		if(a[i][1])cnt2++,sum+=cnt1;
		sum--;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2176
h, w, k = list(map(int, input().split()))
cake = []
no_strawberry_row = '.' * w
no_strawberry_rows = set()
for i in range(h):
    row = input()
    if row == no_strawberry_row:
        no_strawberry_rows.add(i)
    cake.append(row)

ans = [[0] * w for _ in range(h)]
pending = []
previous_row = -1
p = 1
for i, row in enumerate(cake):
    if i in no_strawberry_rows:
        if previous_row != -1:
            ans[i] = ans[previous_row]
        else:
            pending.append(i)
        continue

    prev_berry = False
    for j, c in enumerate(row):
        if c == '#':
            if prev_berry:
                p += 1
            prev_berry = True
        ans[i][j] = p

    if pending:
        for k in pending:
            ans[k] = ans[i]
        pending = []
    previous_row = i
    p += 1

for row in ans:
    print(*row)


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

#define MAX 100002

using namespace std;

int memo[MAX];

int main(void){

  int n;
  cin >> n;
  while(n--){
    int a, b;
    cin >> a >> b;
    memo[a]++;
    memo[b + 1]--;
  }
  int now = 0, ans = 0;
  for(int i = 2 ; i < MAX ; i++){
    now += memo[i];
    if(now >= i - 1) ans = i - 1;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1548
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,m,k,ans=0;
    
    cin>>n>>m;
    k=m-1;
    int s[m+5];
    int t[m+5];
    for(int i=0;i<m;i++){
        cin>>s[i];
    }
    sort(s,s+m);
    for(int j=0;j<k;j++){
        t[j]=s[j+1]-s[j];
    }
    sort(t,t+k);
    for(int h=0;h<(k-n+1);h++){
        ans+=t[h];
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    string S;
    cin >> N >> A >> B >> S;
    int passed = 0, b = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'a' && passed < A + B) {
            cout << "Yes" << endl;
            passed++;
        }
        else if (S[i] == 'b') {
            b++;
            if (passed < A + B && b <= B) {
                cout << "Yes" << endl;
                passed++;
            }
            else cout << "No" << endl;
        }
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 848