akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using P = std::pair<int, int>;

void count(std::string s, int l, int r, int m, std::vector<int> &v) {
    for (int i=l; i<=m; ++i) {
        if ((m - i) % 2) ++v[m+1];
        else ++v[m];
    }
    for (int i=m+1; i<=r; ++i) {
        if ((r - i) % 2) ++v[m];
        else ++v[m+1];
    }
}

void solve(std::string s) {
    int left = 0, right = 0;
    int n = s.size();
    int mid;
    std::vector< int > vec(n, 0);
    while (right < n) {
        while (s[right] == 'R') ++right;
        mid = right - 1;
        while (right < n && s[right] == 'L') ++right;
        count(s, left, right-1, mid, vec);
        left = right;
    }
    for (int i=0; i<n; ++i) std::cout << vec[i] << (i == n-1 ? '\n' : ' ');
}

int main() {
    std::string S;
    std::cin >> S;

    solve(S);
    return 0;
}



Measured memory_bytes: 1152
a,b,c=input().split()
d,e,f=input().split()
g,h,i=input().split()
n=int(input())
l=[]
for _ in range(n):
   l.append(input())
if e in l:
    if i in l and a in l or b in l and h in l or c in l and g in l or d in l and f in l:
        print('Yes')
    else:
        print('No')
elif a in l:
    if d in l and g in l or b in l and c in l:
        print('Yes')
    else:
        print('No')
elif i in l:
    if c in l and f in l or g in l and h in l:
        print('Yes')
    else:
        print('No')
else:
    print('No')



Measured memory_bytes: 3064
import java.util.Scanner;

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

        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();

        int[] black = new int[n];
        for (int i = 1; i < n; i++) {
            black[i] = black[i-1] + (s[i-1] == '#' ? 1 : 0);
        }
        
        int[] white = new int[n];
        for (int i = n-2; i >= 0; i--) {
            white[i] = white[i+1] + (s[i+1] == '.' ? 1 : 0);
        }
        
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            min = Math.min(min, black[i] + white[i]);
        }
        
        System.out.println(min);
    }
}


Measured memory_bytes: 31256
#include<iostream>
#include<stdlib.h>
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
	string a,b;
	cin>>a>>b;
	int d=stoi(a+b);
	for(int i=0;i<=330;i++){
		if(i*i==d){
			printf("Yes");
			return 0;
		}
	}
	printf("No");
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.NoSuchElementException;
import java.util.SortedSet;
import java.util.TreeSet;

class Scanner {
    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() {
        return hasNextByte() ? buffer[ptr++] : -1;
    }

    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    private void skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    }

    public boolean hasNext() {
        skipUnprintable();
        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 int nextInt() {
        return (int) nextLong();
    }

    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 class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner();
		int n = sc.nextInt();
		SortedSet<Integer> a = new TreeSet<Integer>();
	    for (int i = 0; i < n; ++i)
	    {
	    	int x = sc.nextInt();
	    	a.add(x);
	    }

	    int m = sc.nextInt();
	    HashSet<Integer> b = new HashSet<Integer>();
	    for (int i = 0; i < m; ++i)
	    {
	    	int y = sc.nextInt();
	    	b.add(y);
	    }
	    a.addAll(b);
//
//	    while (!a.isEmpty())
//	    {
//	    	System.out.println(a);
//	    }

	    a.forEach(System.out::println);
	}

}



Measured memory_bytes: 102940
# -*- coding: utf-8 -*-
a = (input())
#a,b,c = map(int,input().split())

if a[-1] == '3':
    print("bon")
elif a[-1] == '0' or a[-1] == '1' or a[-1] == '6' or a[-1] == '8':
    print("pon")
else:
    print("hon")



Measured memory_bytes: 9032
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

ll h, w;
int n;
int dx[3] = {0, -1, -2}, dy[3] = {0, -1, -2};

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> h >> w >> n;
	map<P, ll> mp;
	FOR(i, n) {
		int a, b;
		cin >> a >> b;
		FOR(ix, 3) {
			FOR(iy, 3) {
				int nx = a + dx[ix], ny = b + dy[iy];
				if (nx > 0 && nx <= h-2 && ny > 0 && ny <= w-2) mp[P(nx,ny)]++;	
			}
		}
	}
	int cnt[10];
	fill(cnt, cnt+10, 0);
	for (auto itr = mp.begin(); itr != mp.end(); itr++) {
		cnt[itr->second]++;
	}
	
	cout << (ll)((h-2)*(w-2)-mp.size()) << endl;
	for (int i = 1; i < 10; i++) cout << cnt[i] << endl;
	
	return 0;
}

Measured memory_bytes: 56576
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
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/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll 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;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

int main() {
  ll n,k,s;
  cin>>n>>k>>s;
  ll i=0;
  for(;i<k;i++){
    cout<<s<<" ";
  }
  for(ll j=k;j<n;j++){
    cout<<INF-1<<" ";
  }
  cout<<endl;
}

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

int main()
{
	int n;
	scanf("%d", &n);
	long long int Fraction = 1;
	for(int i = 0; i < n; i++){
		Fraction *= n-i;
	}
	printf("%lld\n", Fraction);
	return 0;
}

Measured memory_bytes: 3044
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>

using namespace std;

int main()
{
	string s;
	cin >> s;
	
	for (int i = 0; i < 3; i++)
	{
		if (s[i] == '7')
		{
			cout << "Yes";
			return 0;
		}
	}

	cout << "No";
	return 0;

}

Measured memory_bytes: 3632
N = int(input())
X = [int(x) for x in input().split()]
p = 10 ** 9 + 7
P = [1 for _ in range(N + 1)]
for i in range(N):
  P[i + 1] = P[i] * (i + 1) % p
T = [N - 1] * N
pos = 0
for i in range(N):
  if 2 * i + 1 - X[i] >= 2 * pos + 1:
    T[pos] = i
    pos += 1
cnt = 1
for i, t in enumerate(T):
  cnt *= t + 1 - i
  cnt %= p
print(cnt)

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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int n,a[N],f[N],d[N],s[N],p[N],res[N];
vector<pair<int,int> >v;
vector<int>m[N];
void dfs(int now,int pre,int dep){
	d[now]=dep;
	for(auto k: m[now]){
		if(k==pre)continue;
		dfs(k,now,dep+1);
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<n;i++){
		int S,t;
		cin>>S>>t;
		v.pb({S,t});
		m[S].pb(t);
		m[t].pb(S);
	}
	dfs(1,0,1);
	for(int i=1;i<=n;i++)f[i]=s[i]=i;
	sort(s+1,s+1+n,[](int A,int B){return d[A]<d[B];});
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(f+1,f+1+n,[](int A,int B){return a[A]>a[B];});
	for(int i=1;i<=n;i++){
		p[s[i]]=a[f[i]];
		res[s[i]]=a[f[i]];
	}
	LL ans=0;
	for(auto k:v)ans+=min(p[k.fi],p[k.se]);
	cout<<ans<<endl;
	for(int i=1;i<=n;i++)cout<<res[i]<<' ';
	return 0;
}

Measured memory_bytes: 9472
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    string s;
    cin>>s;
    ll n=s.size();
    string ans="";
    for(ll i=0;i<n;i++)
        ans+='x';
    cout<<ans;
}


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

int main(){
  long long n,ans=0;cin>>n;
  vector<long long> x(5,0);
  REP(i,n){
    string s,m="MARCH";cin>>s;
    REP(j,5) if(s.at(0)==m.at(j)) x.at(j)++;
  }
  for(int i=0;i<3;i++){
    for(int j=i+1;j<4;j++){
      for(int k=j+1;k<5;k++){
        ans+=x.at(i)*x.at(j)*x.at(k);
      }
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};

struct UnionFind{
    vector<ll> par;

    UnionFind(ll N) : par(N){
        rep(i,N){
            par[i]=i;
        }
    }

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

    void unite(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx==ry) return;
        par[rx] = ry;
    }

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


int main() {
    while(1){
    ll N;
    cin >> N;
    if(N==0) break;
    vector<tuple<ld,ll,ll>> S;
    vector<ld>x(N);
    vector<ld>y(N);
    vector<ld>z(N);
    vector<ld>r(N);


    rep(i,N){
        cin >>x[i]>>y[i]>>z[i]>>r[i];
    }

    rep(i,N){
        rep3(j,i+1,N){
            ld d = sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j])) - r[i] - r[j];
            //cout<<d<<endl;
            if(d<0.0){
                d=0.0;
            }
            S.pb(make_tuple(d,i,j));
        }
    }

    sort(all(S));
    UnionFind tree(N);

    double ans = 0;
    rep(i,S.size()){
        ll x = get<1>(S[i]);
        ll y = get<2>(S[i]);
        if(!tree.same(x,y)){
            tree.unite(x,y);
            ans += get<0>(S[i]);

        }
        
    }





    cout << std::fixed << std::setprecision(3) << ans << endl;
    }
    
    return 0;
    

}



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


struct mint {
    long long x;
    static const int MOD = 1000000007;
    mint(long long x=0): x(x%MOD) {}

    void operator=(const long long n) {
        x = n % MOD;
    }
    mint operator+(const mint n) {
        mint ret;
        ret.x = (x + n.x) % MOD;
        return ret;
    }
    mint operator-(const mint n) {
        mint ret;
        ret.x = (x - n.x + MOD) % MOD;
        return ret;
    }
    mint operator*(const mint n) {
        mint ret;
        ret.x = (x * n.x) % MOD;
        return ret;
    }
    mint operator/(const mint n) {
        mint ret;
        ret.x = (x * n.inv().x) % MOD;
        return ret;
    }

    mint inv() const {
        mint ret;
        long long a = x, b = MOD, u = 1, v = 0;
        while(b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        ret.x = u;
        return ret;
    }
};

mint mpow(mint a, int n) {
    mint ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * a;
        a = a * a;
        n >>= 1;
    }
    return ret;
}

void factorial(vector<mint>& fact) {
    for (int i = 0; i < fact.size(); i++) {
        if (i == 0 || i == 1) fact[i] = 1;
        else fact[i] = fact[i-1] * i;
    }
}

mint c(int n, int a, vector<mint>& fact) {
    return fact[n]/(fact[a]*fact[n-a]);
}

void p(int n, int max_a, vector<mint>& perm) {
    for (int i = 0; i <= max_a; i++) {
        if (i == 0) perm[i] = 1;
        else perm[i] = perm[i-1] * (n-i+1);
    }
}

ostream& operator<<(ostream& os, const mint& n)
{
    os << n.x;
    return os;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);


    int n;
    int a[3][3];
    int m[3][3] = {};

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }
    cin >> n;
    for (int i = 0; i < n; i++) {
        int b;
        cin >> b;
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (a[j][k] == b) {
                    m[j][k] = 1;
                }
            }
        }
    }

    if ((m[0][0] && m[0][1] && m[0][2]) || (m[1][0] && m[1][1] &&m[1][2]) || (m[2][0] && m[2][1] &&m[2][2]) || (m[0][0] && m[1][0] &&m[2][0]) || (m[0][1] && m[1][1] &&m[2][1]) || (m[0][2] && m[1][2] &&m[2][2]) || (m[0][0] && m[1][1] &&m[2][2]) || (m[0][2] && m[1][1] &&m[2][0]))
        cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

#define mod 1000000007

class RMQ
{
    private:
        long long int elemnum;
        vector<long long int> result;

    public:
        RMQ(long long int n){
            elemnum = n;
            result = vector<long long int>(2 * n, 0);
        }

        void update(long long int x, long long int value)
        {
            result[x + elemnum] += value;
            int tmp = (x + elemnum) / 2;
            while(tmp > 0){
                result[tmp] = result[tmp * 2] + result[tmp * 2 + 1];
                tmp = tmp / 2;
            }
        }

        long long int getsum(long long int targetl, long long int targetr, long long int nownum, long long int nowl, long long int nowr)
        {
            // cout << nowl << " " << nowr << endl;
            if(min(targetr, nowr) < max(targetl, nowl)) return 0;
            else if(targetl <= nowl && targetr >= nowr) return result[nownum];
            else {
                long long int tmp1 = getsum(targetl, targetr, 2 * nownum, nowl, (nowl + nowr) / 2);
                long long int tmp2 = getsum(targetl, targetr, 2 * nownum + 1, (nowl + nowr) / 2 + 1, nowr);
                return tmp1 + tmp2;
            }
        }

        void printresult()
        {
            for(int i = 1; i < 2 * elemnum; i++){
                cout << result[i] << " ";
            }
            cout << endl;
        }

        int getelemnum()
        {
            return elemnum;
        }
};

int main()
{
    int n, q;
    cin >> n >> q;
    int tmp = 1;
    while(tmp < n) tmp = tmp * 2;
    RMQ ans = RMQ(tmp);
    for(int i = 0; i < q; i++){
        long long int com, x, y;
        cin >> com >> x >> y;
        if(com == 0){
            x--;
            ans.update(x, y);
        } else {
            x--;
            y--;
            cout << ans.getsum(x, y, 1, 0, ans.getelemnum() - 1) << endl;
        }
        // ans.printresult();
    }
}

Measured memory_bytes: 7108
program main
  implicit none
  integer(8) i,N,ans
  !read(*, *) (L(i), i = 1,N)
  read(*, *) N
  ans = 0
  do i = 1,N
    if (i<=9) then
      ans = ans + 1
    elseif (i>=100 .and. i<1000) then
      ans = ans + 1
    elseif (i>=10000 .and. i<100000) then
      ans = ans + 1
    end if
  end do

  write(*, *) ans
end program main


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

long d;
long c[26];
long s[365][26];
long t[365];
// long last[27];
// long t[365];/

long nowAns;

long calcMinus(int day,long* last);
long calcScore();

int main(){
    nowAns = 0;
    cin >> d;
    for(int i=0;i<26;i++)cin >> c[i];
    for(int i=0;i<d;i++){
        for(int j=0;j<26;j++){
            cin >> s[i][j];
        }
    }
    
    for(int i=0;i<d;i++)cin >> t[i];
    


    //C固有
    int m;
    cin >> m;
    for(int i=0;i<m;i++){
        int dd,qq;
        cin >> dd >> qq;
        t[dd-1] = qq;
        long tmp = calcScore();
        cout << tmp << endl;
    }

    
}


long calcMinus(int day,long* last){

    long ans = 0;
    for(int i=0;i<26;i++){
        ans -= c[i] * (day - last[i]);
    }

    return ans;
}

long calcScore(){
    long ans = 0;

    long last[26];
    for(int i=0;i<26;i++){
        last[i] = -1;
    }

    for(int i=0;i<d;i++){
        last[t[i]-1] = i;
        ans += s[i][t[i]-1];
        ans += calcMinus(i,last);
    }
    return ans;
    
}

Measured memory_bytes: 3728
#include <iostream>
#include <queue>
#include <set>
using namespace std;
int H, W, K;
char A[801][801];
int vstd[801][801];

int f(queue<pair<int, int>>& que) {
  int ret = 0x7fffffff;
  while (!que.empty()) {
    pair<int, int> p = que.front();
    //    cout<<"y="<<p.first<<"x="<<p.second<<endl;
    que.pop();
    int tmp =
        min(min(p.first, H - p.first - 1), min(p.second, W - p.second - 1));
    tmp = tmp / K + (tmp % K > 0);
    ret = min(ret, tmp);

    int nxt = vstd[p.first][p.second] - 1;
    if (nxt) {
      if (p.first - 1 >= 0 && A[p.first - 1][p.second] == '.' &&
          !vstd[p.first - 1][p.second]) {
        vstd[p.first - 1][p.second] = nxt;
        que.push(make_pair(p.first - 1, p.second));
      }

      if (p.first + 1 < H && A[p.first + 1][p.second] == '.' &&
          !vstd[p.first + 1][p.second]) {
        vstd[p.first + 1][p.second] = nxt;
        que.push(make_pair(p.first + 1, p.second));
      }

      if (p.second - 1 >= 0 && A[p.first][p.second - 1] == '.' &&
          !vstd[p.first][p.second - 1]) {
        vstd[p.first][p.second - 1] = nxt;
        que.push(make_pair(p.first, p.second - 1));
      }

      if (p.second + 1 < W && A[p.first][p.second + 1] == '.' &&
          !vstd[p.first][p.second + 1]) {
        vstd[p.first][p.second + 1] = nxt;
        que.push(make_pair(p.first, p.second + 1));
      }
    }
  }

  /*
  for(int i=0;i< H;i++){
    for(int j=0;j<W;j++){
      cout<<vstd[i][j]<<"\t";
    }
    cout<<endl;
  }
  */
  
  return ret;
}

int main(void) {
  cin >> H >> W >> K;
  pair<int, int> s;
  queue<pair<int, int>> que;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A[i][j];
      if (A[i][j] == 'S') {
        A[i][j] = '.';
        s.first = i;
        s.second = j;
      }
    }
  }

  que.push(s);
  vstd[s.first][s.second] = K + 1;

  cout << f(que) + 1 << endl;

  return 0;
}


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

const long long M=1000000000000000000;

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

  if(A[0]==0){
    cout << 0 << endl;
  }else{  
    long long x=1;
    for(int i=0; i<N; i++){
      if(M/x<A[i]){
        cout << -1 << endl;
        return 0;
      }else{
        x*=A[i];
      }
    }
    cout << x << endl;
  }
}

Measured memory_bytes: 4052
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = next().toInt()
    val A = nextIntList()
    val B = A.map { if (it % 4 == 0) 2 else if (it % 2 == 0) 1 else 0 }.toCountMap()
    val c2 = B[2] ?: 0
    val c1 = B[1] ?: 0
    println(if (c2 * 2 + 1 + (c1 / 2) * 2 >= N) "Yes" else "No")
}

fun <T> List<T>.toCountMap(): Map<T, Long> {
    return this.groupBy { it }.mapValues { it.value.size.toLong() }
}

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

int main() {
  ll a, b, c, k, cnt = 0;
  cin >> a >> b >> c >> k;

  while (a >= b) b *= 2, cnt++;
  while (b >= c) c *= 2, cnt++;
  cout << (cnt <= k ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>

int main() {
	
	int tinggibngt;
	int alasaja;
	int miringnih;
	int hasilnyanih;
	
	scanf("%d %d %d", &tinggibngt, &alasaja, &miringnih);
	hasilnyanih = tinggibngt * alasaja / 2;
	printf("%d", hasilnyanih);
	
	return 0;
}

Measured memory_bytes: 1732
// https://atcoder.jp/contests/agc003/tasks/agc003_b

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, m, ans = 0, before = 0;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> m;
        // 値が1小さい前回の残り枚数からペアを作る
        if (before > 0) {
            if (before >= m) {
                ans += m;
                m = 0;
            } else {
                ans += before;
                m -= before;
            }
        }
        // 同じ値同士でペア作成
        int t = m / 2;
        ans += t;
        before = m - t * 2;
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
$line == 0;
while(<>) {
    chomp;
    if ($line == 0) {
        $n = $_;
    } elsif ($line == 1) {
        $k = $_;
    } else {
        @x = split /\s+/, $_;
    }
    $line++;
}

foreach (@x) {
    $d1 = $_;
    $d2 = abs($k - $_);
    if ($d1 < $d2) {
        $total += $d1 * 2;
    } else {
        $total += $d2 * 2;
    }
}

print "$total\n";


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  map<int, int> M;
  for (int i = 0; i < N; i++){
    M[a[i] - 1]++;
    M[a[i]]++;
    M[a[i] + 1]++;
  }
  int ans = 0;
  for (auto P : M){
    ans = max(ans, P.second);
  }
  cout << ans << endl;
}

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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 (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,c,k;
cin>>n>>c>>k;
vector<int>t(n);
rep(i,n)cin>>t[i];
sort(t.begin(),t.end());
ll cnt=0;
int i=0;
while(i<n){
    int limit_t=t[i]+k;
    int tmp_cnt=0;
    reps(j,c+1,1){
        tmp_cnt++;
        if(i+j<n && t[i+j]>limit_t){
            break;
        }
    }
    if(tmp_cnt>1)i+=tmp_cnt;
    else i++;
    cnt++;
}
cout<<cnt<<endl;
return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;

namespace ABC139_D
{
    class Program
    {
        static void Main(string[] args) {
            long n = long.Parse(Console.ReadLine());

            long ans = 0;
            ans = n * (n - 1) / 2;

            
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
N = int(input())
H = list(map(int, input().split()))

ans = 0
now=0

for i in range(N):
    if now+1>=N:
        break
    _ans = 0
    if H[now]>=H[now+1]:
        for g in range(1145141919):
            if now+1+g>=N:
                now+=g+1
                break
            if H[now+g]>=H[now+1+g]:
                _ans+=1
            else:
                now+=g+1
                break
    else:
        now+=1
    ans = max(ans, _ans)

print(ans)

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

#define REP(i,n) for(int i=0;i<(n);i++)
//#define int long long

typedef pair<int, int> P;

int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };
char A[55][55];
bool vis[55][55];
bool black[55][55], white[55][55];
int H, W;
void bfs_B(int x, int y) {
	queue<P>que;
	que.push({ x,y });
	REP(i, H)REP(j, W)vis[i][j] = false;
	while (!que.empty()) {
		P p = que.front(); que.pop();
		//cout<<p.first<<" "<<p.second<<" B"<<endl;
		REP(k, 4) {
			int nx = p.first + dx[k], ny = p.second + dy[k];
			if (nx >= 0 && nx<H&&ny >= 0 && ny<W && !vis[nx][ny] && A[nx][ny] == '.') {
				black[nx][ny] = true;
				que.push({ nx,ny });
				vis[nx][ny] = true;
			}
		}
	}
}
void bfs_W(int x, int y) {
	queue<P>que;
	que.push({ x,y });
	REP(i, H)REP(j, W)vis[i][j] = false;
	while (!que.empty()) {
		P p = que.front(); que.pop();
		//cout<<p.first<<" "<<p.second<<" W"<<endl;
		REP(k, 4) {
			int nx = p.first + dx[k], ny = p.second + dy[k];
			if (nx >= 0 && nx<H&&ny >= 0 && ny<W && !vis[nx][ny] && A[nx][ny] == '.') {
				white[nx][ny] = true;
				que.push({ nx,ny });
				vis[nx][ny] = true;
			}
		}
	}
}
void solve() {
	cin >> W >> H;
	if (W == 0)exit(0);
	REP(i, H) {
		REP(j, W) {
			cin >> A[i][j];
		}
	}
	REP(i, H)REP(j, W) {
		vis[i][j] = false;
		black[i][j] = false;
		white[i][j] = false;
	}
	// REP(i,H){
	//     REP(j,W)cout<<A[i][j];
	//     cout<<endl;
	// }
	REP(i, H) {
		REP(j, W) {
			if (A[i][j] == 'W')bfs_W(i, j);
			else if (A[i][j] == 'B')bfs_B(i, j);
		}
	}
	//cout << "done" << endl;
	int cB = 0, cW = 0;
	REP(i, H) {
		REP(j, W) {
			if (A[i][j] == '.'&&black[i][j] && !white[i][j]) {
				cB++;
			}
			else if (A[i][j] == '.' && !black[i][j] && white[i][j]) {
				cW++;
			}
		}
	}
	cout << cB << " " << cW << endl;
}

signed main() {
	while (true)solve();
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long A,B,C,K;
    cin >> A >> B >> C >> K;
    
    if((A>B?A-B:B-A)> 1e18){
        cout << "Unfair" << endl;
    }else{
        cout << (A-B)*( K%2==0 ? 1 : -1 ) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main() {
    string k;
    int d;
    cin >> k >> d;
    reverse(k.begin(), k.end());

    int n = k.length();
    ll dp[n + 1][d][2];
    fill(dp[0][0], dp[n + 1][0], 0);
    dp[0][0][0] = dp[0][0][1] = 1;

    for (int m = 1; m <= n; ++m) {
        for (int i = 0; i < 10; ++i) {
            for (int j = 0; j < d; ++j) {
                dp[m][(i + j) % d][0] += dp[m - 1][j][0];
                dp[m][(i + j) % d][0] %= MOD;
            }
        }

        int p = k[m - 1] - '0';
        for (int i = 0; i < p; ++i) {
            for (int j = 0; j < d; ++j) {
                dp[m][(i + j) % d][1] += dp[m - 1][j][0];
                dp[m][(i + j) % d][1] %= MOD;
            }
        }

        for (int j = 0; j < d; ++j) {
            dp[m][(p + j) % d][1] += dp[m - 1][j][1];
            dp[m][(p + j) % d][1] %= MOD;
        }
    }

    cout << (dp[n][0][1] + MOD - 1) % MOD << endl;
}


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

int main(){
    int n, a[10000];
    cin >> n;
    for(int i=0; i<n; i++){
    cin >> a[i];
    }

    long long min, max, total;

    min=a[0];
    max=a[0];
    total=a[0];

    for(int j=1; j<n; j++){
        if(min > a[j]){min=a[j];}
        else if (max < a[j]){max=a[j];}
        total+=a[j];
    }

    cout << min << " " << max << " " << total << endl;

    return 0;
}


Measured memory_bytes: 3124
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const ll G = 2000005;
ll a,k,mod = 1e9+7;
ll fac[G], inv_fac[G];

ll binpow(ll x, ll K){
    x%=mod;
    if(K<2) return K ? x : 1;
    return (binpow(x*x, K/2)*(K&1 ? x : 1))%mod;
}

ll modinv(ll c){
    return binpow(c, mod-2);
}

ll CizNpoK(ll N, ll K){
    ll o = fac[N]*inv_fac[K];
    o %= mod;
    return (o*inv_fac[N-K])%mod;
}

int main() {
    fast;
    fac[0] = 1;
    inv_fac[0] = modinv(fac[0]);
    for(ll q=1; q<G; q++) fac[q] = (fac[q-1]*q)%mod;
    inv_fac[G-1] = modinv(fac[G-1]);
    for(ll q=G-2; q>0; q--){
        inv_fac[q] = (inv_fac[q+1]*(q+1))%mod;
    }
    cin>>k;
    str t; cin>>t; a = t.size();
    k += a;
    ll all = binpow(26, k), pidori = 0;
    for(ll q=0; q<a; q++){
        pidori += CizNpoK(k, q)*binpow(25, k-q);
        pidori %= mod;
    }
    cout<<(all-pidori+mod)%mod;
}

Measured memory_bytes: 35528
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<deque>
using namespace std;
int main() {

	//A
	int x;
	cin >> x;
	if (x == 1) {
		cout << 0;
	}
	else {
		cout << 1;
	}
	cout << endl;
	return 0;


}

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

public class Main {
	static int gcd(int a, int b) 
	{ 
	    if (a == 0) 
	        return b; 
	    return gcd(b%a, a); 
	} 
	  

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int max=Integer.MIN_VALUE;
		int min=Integer.MAX_VALUE;
		int ar[]=new int[n];
		for(int i=0;i<n;i++)
		{
			int cur=scan.nextInt();
		ar[i]=cur;	
		}
		int gcd=gcd(ar[0],ar[1]);
		for(int i=2;i<n;i++)
		{
			gcd=gcd(ar[i],gcd);
		}
		System.out.println(gcd);
}	
}


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

long double pi =3.1415926535898;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll a,b,h,m;
	cin>>a>>b>>h>>m;
	long double hour_angle = (0.50) * (h * 60 + m);  
    long double minute_angle = 6 * m;  
    long double angle = abs(hour_angle - minute_angle);  
    angle = min(360 - angle, angle);  
    //cout<<angle<<"\n";
    long double ans = a*a + b*b - 2*a*b*cos((angle*pi)/180);
    ans = sqrt(ans);
    cout<<fixed<<setprecision(20)<<ans;
}

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

int main() {
    int N, x; cin >> N >> x;
    vector<long long> A(N);
    for(int i=0; i<N; ++i) cin >> A[i];
    
    long long res = 0;
    for(int i=0; i+1<N; ++i) {
        if(A[i] + A[i + 1] <= x) continue;
        long long c = A[i] + A[i + 1] - x;
        res += c;
        if(A[i + 1] >= c) A[i + 1] -= c;
        else A[i + 1] = 0;
    }
    cout << res << endl;
}

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

int main(void) {
    int N; cin >> N;
    int cnt=0;
    for(int i=0; i<N; i++) {
        int d1,d2; cin >> d1 >> d2;
        if(d1==d2) cnt++;
        else cnt=0;
        if(cnt==3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3632
import sys
from itertools import starmap
readline = sys.stdin.readline
EPS = 1e-9
ONLINE_FRONT = -2
CLOCKWISE = -1
ON_SEGMENT = 0
COUNTER_CLOCKWISE = 1
ONLINE_BACK = 2
class Segment(object):
    __slots__ = ('fi', 'se')
    def __init__(self, fi, se):
        self.fi = fi
        self.se = se
def cross(a, b):
    return a.real * b.imag - a.imag * b.real
def dot(a, b):
    return a.real * b.real + a.imag * b.imag
def norm(base):
    return abs(base) ** 2
def project(s, p2):
    base = s.fi - s.se
    r = dot(p2 - s.fi, base) / norm(base)
    return s.fi + base * r
def reflect(s, p):
    return p + (project(s, p) - p) * 2.0
def ccw(p1, p2, p3):
    a = p2 - p1
    b = p3 - p1
    if cross(a, b) > EPS: return 1
    if cross(a, b) < -EPS: return -1
    if dot(a, b) < -EPS: return 2
    if norm(a) < norm(b): return -2
    return 0
def intersect4(p1, p2, p3, p4):
    return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 and
			ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0)
def intersect2(s1, s2):
    return intersect4(s1.fi, s1.se, s2.fi, s2.se)
def getDistance(a, b):  return abs(a - b)
def getDistanceLP(l, p):
    return abs(cross(l.se - l.fi, p - l.fi) / abs(l.se - l.fi))
def getDistanceSP(s, p):
    if dot(s.se - s.fi, p - s.fi) < 0.0: return abs(p - s.fi)
    if dot(s.fi - s.se, p - s.se) < 0.0: return abs(p - s.se)
    return getDistanceLP(s, p)
def getDistances(s1, s2):
    if intersect2(s1, s2): return 0.0
    return min(getDistanceSP(s1, s2.fi), getDistanceSP(s1, s2.se),
               getDistanceSP(s2, s1.fi), getDistanceSP(s2, s1.se))
def getCrossPoint(s1, s2):
	base = s2.se - s2.fi
	d1 = abs(cross(base, s1.fi - s2.fi))
	d2 = abs(cross(base, s1.se - s2.fi))
	t = d1 / (d1 + d2)
	return s1.fi + (s1.se - s1.fi) * t
n = int(readline())
for _ in [0] * n:
    p0, p1, p2, p3 = starmap(complex, zip(*[map(int, input().split())] * 2))
    p = getCrossPoint(Segment(p0, p1), Segment(p2, p3))
    print("{0:.10f} {1:.10f}".format(p.real, p.imag))

Measured memory_bytes: 7924
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Union-Find -- START --
class UnionFind():
  def __init__(self,sz):
    self.sz=sz
    self.data=[-1]*sz

  def unite(self,x,y):
    x=self.find(x)
    y=self.find(y)
    if x==y:
      return False
    if self.data[x]>self.data[y]:
      x,y=y,x
    self.data[x]+=self.data[y]
    self.data[y]=x
    return True

  def find(self,k):
    if self.data[k]<0:
      return k
    self.data[k]=self.find(self.data[k])
    return self.data[k]

  def size(self,k):
    return -self.data[self.find(k)]
# Union-Find --- END ---

def main():
  n,m=LI()
  uf=UnionFind(n)
  for _ in range(m):
    a,b,c=LI()
    a-=1
    b-=1
    uf.unite(a,b)

  checked=[False]*n
  ans=0
  for i in range(n):
    a=uf.find(i)
    if checked[a]==False:
      checked[a]=True
      ans+=1

  return ans

# main()
print(main())


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 40;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

map<ll, int>  prime_factorization_map(ll x) {
  map<ll, int> res;
  ll lim = sqrt(x);
  for(ll i = 2; i <= lim; ++i) {
    while(x % i == 0) {
      if(res.find(i) == res.end()) res[i] = 0;
      ++res[i];
      x /= i;
    }
  }
  if(x != 1) res[x] = 1;

  return res;
}

int main()
{
  ll n; cin >> n;
  auto primes = prime_factorization_map(n);
  ll ans = 0;
  vector<ll> num(1001);
  for(int i = 1; i <= 1000; ++i) num[i] = i*(i+1)/2;
  for(auto x : primes) {
    auto it = upper_bound(ALL(num), x.second);
    --it;
    ans += distance(num.begin(), it);
  }
  cout << ans << endl;
}


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

ll x[30];

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	ll all = 0;
	f(i, 0, n){
		int a, b;
		scanf("%d%d", &a, &b);
		if ((k & a) == a)all += b;
		for (int j = 29; j >= 0; --j)if (k >> j & 1){ if (!(a >> j & 1))x[j] += b; }
		else if (a >> j & 1)break;
	}
	ll an = all;
	f(i, 0, 30)an = max(an, x[i]);
	printf("%lld\n", an);
}

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

int main()
{
   long long int i,ans=0,n,count=0;
   cin>>n;
  for(i=1;i*i<=n;i++){
    if(n%i==0){
            ans+=(n/i-1)*2;
    }
    else{
            ans+=(n/i)*2;
    }
    count+=i*2-1;
  }
  if((i-1)*(i-1)==n)count--;
  printf("%lld\n",ans-count);
    return 0;
}


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


int main(){
  double N,T,A; cin>>N>>T>>A;
  vector<double> H(N);
  rep(i,N) cin>>H[i];
  
  int ans;
  double tem=1e9;
  for(int i=0; i<N; i++){
    if(tem > abs(A-(T-0.006*H[i]))){
      tem = abs(A-(T-0.006*H[i]));
      ans = i;
    }
  }
  
  cerr << A <<endl;
  cout << ans+1 << endl;
}


Measured memory_bytes: 3812
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var DX = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var D = DX[0];
            var X = DX[1];
            var A = new int[N].Select(x => int.Parse(Console.ReadLine())).ToArray();
            var answer = N + X + A.Sum(x => (D - 1) / x);
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13396
from operator import itemgetter


N, M = map(int, input().split(" "))
AB = [list(map(int, input().split(" "))) for _ in range(N)]
AB = sorted(AB, key=itemgetter(0))

now = 0
ans = 0
for a, b in AB:
    ans += a * min(M-now, b)
    now += min(M-now, b)
    if now == M:
        break
print(ans)


Measured memory_bytes: 29736
function main()
	s = sort(collect(chomp(readline())))
	x = 97
	flg = 0
	if Int(s[1]) >97
		print("a")
	else
		for i in 2:length(s)
			if Int(s[i])-Int(s[i-1]) > 1
				print(Char(Int(s[i-1])+1))
				flg = 1
				break
			end
		end
		if flg == 0
			if Int(s[length(s)]) < 122
				print(Char(Int(s[length(s)])+1))
			else
				print("None")
			end
		end
	end
end
main()

Measured memory_bytes: 121708
#include <iostream>
#include <vector>
#include <stack>
#include <map>
#include <cmath>
#include <algorithm>
#include <array>

constexpr int getStride(int nStates){
    --nStates;
    int stride = 0;
    while(nStates != 0){
        ++stride;
        nStates >>= 1;
    }
    return stride;
}
constexpr int nStates = 4;
constexpr int stride = getStride(nStates);

constexpr int nElements = 3;
using State = std::array<int, nElements>;

using T = int;
T toID(const State &S){
    T id = 0;
    for(int i=0; i<nElements; ++i){
        id <<= stride;
        id |= S[i];
    }
    return id;
}
State toState(T id){
    State S;
    for(int i=0; i<nElements; ++i){
        S[nElements-1 - i] = id&((1<<stride)-1);
        id >>= stride;
    }
    return S;
}

int main(int argc, char *argv[]){
    constexpr long long mod = 1000000000LL + 7LL;
    constexpr std::array<State, 3> allBanned = {State{0,1,2},State{1,0,2},State{0,2,1}};
    constexpr std::array<State, 16> cBanned =  {State{0,0,1},State{1,0,1},State{2,0,1},State{3,0,1},
                                                State{0,0,1},State{0,1,1},State{0,2,1},State{0,3,1},
                                                State{0,1,0},State{0,1,1},State{0,1,2},State{0,1,3},
                                                State{0,1,0},State{1,1,0},State{2,1,0},State{3,1,0}};
    constexpr std::array<State, 4> gBanned =   {State{0,0,2},State{1,0,2},State{2,0,2},State{3,0,2}};

    int N;
    std::cin >> N;

    static long long dp[128][64];
    for(int j=0; j<64; ++j){
        auto S = toState(j);
        if(std::find(allBanned.begin(),allBanned.end(),S) == allBanned.end()){
            dp[2][j] = 1LL;
        }
    }

    for(int i=3; i<N; ++i){
        for(int j=0; j<64; ++j){
            auto S = toState(j);
            for(int k=0; k<4; ++k){
                auto id = toID(State{S[1],S[2],k});
                bool isBanned = false;
                switch(k){
                case 1:
                    if(std::find(gBanned.begin(),gBanned.end(),S) != gBanned.end()){
                        isBanned = true;
                    }
                    break;
                case 2:
                    if(std::find(cBanned.begin(),cBanned.end(),S) != cBanned.end()){
                        isBanned = true;
                    }
                    break;
                }
                dp[i][id] += isBanned ? 0LL : dp[i-1][j];
                dp[i][id] %= mod;
            }
        }
    }

    long long sum = 0LL;
    for(int i=0; i<64; ++i){
        sum += dp[N-1][i];
        sum %= mod;
    }

    std::cout << sum << std::endl;

    return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
	
	int d,t,s; cin>>d>>t>>s;
	int num = t*s;
	if(d<=num){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	int A, B;
	int a[4] = {0, 0, 0, 0};

	cin >> A >> B;
	a[A] = 1;
	a[B] = 1;

	for (int i = 1; i <= 3; i++) {
		if (a[i] == 0) {
			cout << i << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $fiveHundred);
fscanf(STDIN, "%d", $oneHundred);
fscanf(STDIN, "%d", $fifty);
fscanf(STDIN, "%d", $allMoney);
$ans = 0;

for($i=0; $i<=$fiveHundred; $i++){
    for($j=0; $j<=$oneHundred; $j++){
        for($k=0; $k<=$fifty; $k++){
            if(($allMoney - (500*$i + 100*$j + 50*$k))==0){
                $ans++;
            };
        }
    }
}

echo $ans;

Measured memory_bytes: 4856
#include <stdio.h>

int main(void) {
	char table[100000][2];
	long int n,m,i,c;
	char buf;
	while(scanf("%ld",&n)){
		if(n == 0)break;
		for(i = 0; n > i; i++){
			getchar();
			scanf("%c",&table[i][0]);
			getchar();
			scanf("%c",&table[i][1]);
		}
		scanf("%ld",&m);
		for(i = 0; m > i; i++){
			getchar();
			scanf("%c",&buf);
			for(c = 0; n > c; c++)if(buf == table[c][0]) {buf = table[c][1];break;}
			printf("%c",buf);
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 1012