akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
W, a, b = map(int, input().split())

a_l = a
a_r = a + W
b_l = b
b_r = b + W

if b_r < a_l:
    print(abs(b_r - a_l))
elif a_r < b_l:
    print(abs(a_r - b_l))
else:
    print(0)


Measured memory_bytes: 9160
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int n;ll A, B; ll sum=0;
	cin >> n;
	int i;
	ll mi=INF;
	for (i = 0; i < n; i++) {
		cin >> A >> B;
		sum += B;
		if (B - A <0&&B<mi) {
			mi = B;
		}
	}
	if (mi == INF) {
		cout << 0 << endl;
	}
	else {
		sum -= mi;
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 256
use proconio::*;
use proconio::marker::Chars;

fn run() {
    input! {
        mut s: Chars,
    }
    for i in 0..s.len() {
        if s[i] == '?' {
            s[i] = 'D';
        }
    }
    let ans: String = s.into_iter().collect();
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 3280
import java.util.*;
import java.util.stream.*;
import java.util.function.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int c = sc.nextInt();
        
        int[] b = IntStream.range(0, m)
                        .map(i -> sc.nextInt())
                        .toArray();
        
        int count = 0;
        
        for(int i = 0; i < n; i++) {
            int[] a = IntStream.range(0, m)
                        .map(j -> sc.nextInt())
                        .toArray();
            int tmp = c;
            for(int j = 0; j < m; j++) {
                tmp += (a[j] * b[j]);
            }
            // System.out.println(tmp);
            if(tmp > 0) {
                count++;
            }
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 28368
#include <iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int nijyou(int i ){return i*i;}
int main() {
	while(1){
	int a[3];
	cin>>a[0] >>a[1]>>a[2];
	if(a[0]==0&&a[1]==0&&a[2]==0){break;}
	sort(a,a+3);
	int n;
	cin>>n;
	double y = sqrt(nijyou(a[0])+nijyou(a[1]));
	for(int i = 0;i<n;i++){
		double k;
		cin>>k;
		if(k*2>y){cout<<"OK"<<endl;}
		else{cout<<"NA"<<endl;}
	}
	}
	return 0;
}

Measured memory_bytes: 1232
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
               float d=scan.nextInt();
               float t=scan.nextInt();
               float s=scan.nextInt();
               if((d/s)<=t){
                   System.out.print("Yes");
               }else{
                   System.out.print("No");
               }
    }
}


Measured memory_bytes: 27064
#include <stdio.h>
int main(){
  int i,n,j,max,r[200000];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&r[i]);
  max=r[1]-r[0];
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      if(r[i]>r[j]){
	i=j;
	continue;
      }
      if(r[j]-r[i]>max)max=r[j]-r[i];
    }
  }
  printf("%d\n",max);
  return 0;
}



Measured memory_bytes: 3536
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<numeric>
#include<utility>
#include<tuple>
#include<queue>
#include<map>
using tp = std::tuple<int,int,int>;
class unionfind {
    std::vector<int> par, rank, size_;//速度ではなくメモリ効率を考えるならrankのかわりにsizeを使う
public:
    unionfind(int n) :par(n), rank(n), size_(n, 1) {
        std::iota(par.begin(),par.end(), 0);
    }
    int find(int x) {
        if (par[x] == x)return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y)return;
        if (rank[x] < rank[y])std::swap(x, y);
        par[y] = x;
        size_[x] += size_[y];
        if (rank[x] == rank[y])rank[x]++;
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return size_[find(x)];
    }
};

int main(){
    int N;
    std::cin >> N;
    std::vector<tp>point,xst,yst;
    for(int idx = 0; idx < N; ++idx){
        int x,y; std::cin >> x >> y;
        point.emplace_back(x,y,idx);
        xst.emplace_back(x,y,idx);
        yst.emplace_back(y,x,idx);
    }
    std::sort(xst.begin(), xst.end());
    std::sort(yst.begin(), yst.end());
    std::priority_queue<tp,std::vector<tp>,std::greater<>>que;
    std::map<std::pair<int,int>,int> dic;
    for(int i = 0; i + 1 < xst.size(); ++i){
        int ax,ay,ai,bx,by,bi;
        std::tie(ax,ay,ai) = xst[i];
        std::tie(bx,by,bi) = xst[i + 1];
        que.emplace(std::abs(ax - bx),std::min(ai,bi),std::max(ai,bi));
    }
    for(int i = 0; i + 1 < yst.size(); ++i){
        int ax,ay,ai,bx,by,bi;
        std::tie(ay,ax,ai) = yst[i];
        std::tie(by,bx,bi) = yst[i + 1];
        que.emplace(std::abs(ay - by),std::min(ai,bi),std::max(ai,bi));
    }
    int edge = 0;
    long long sum = 0;
    auto uf = unionfind(N + 1);
    while(edge < N - 1){
        int cost,i,j;
        std::tie(cost,i,j) = que.top();
        que.pop();
        if(not uf.same(i,j)){
            uf.unite(i, j);
            ++edge;
            sum += cost;
        }
    }
    std::cout << sum << std::endl;
}




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

typedef long long int ll;

int main(){
    cin.sync_with_stdio(false);
    cin.tie(0);
    ll n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    for(ll i=n; i<=m; i++){
        if(i%k == 0)
            ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  int a, b, c;
  string s, t;
  cin >> a;
  b = a%10;
  if(b == 2 || b == 4 || b == 5 || b == 7 || b == 9) cout << "hon"<<endl;
  else if(b == 3) cout << "bon" <<endl;
  else cout << "pon" <<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
using namespace std;

string s;
int q,t,a;
char ch;
bool ok = true;
deque< char > ans;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> s;
    for( auto l:s ) ans.push_back( l );

    cin >> q;
    while( q-- ){
        cin >> t;
        if( t==1 ){
           ok ^= true;
        }else{
            cin >> a >> ch;
            if( a==1 ){
                if( ok ){
                    ans.push_front( ch );
                }else{
                    ans.push_back( ch );
                }
            }else{
                if( ok ){
                    ans.push_back( ch );
                }else{
                    ans.push_front( ch );
                }
            }
        }
    }

    if( ok ){
        while( !ans.empty() ) cout << ans.front() , ans.pop_front();
    }else{
        while( !ans.empty() ) cout << ans.back() , ans.pop_back();
    }

    return 0;
}


Measured memory_bytes: 976
import java.util.*;

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

        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        int max = 0;

        if(a < k){
            max += a*1;
            if(b <= k-a){
                max += b*0;
                if(c <= k - a - b){
                    max += c*(-1);
                }else{
                    max += (k - a - b)*(-1);
                }
            }else if(b > k-a){
                max += (k-a)*b;
            }
        }else{
            max += k*1;
        }

        System.out.println(max);
    }
}

Measured memory_bytes: 27016
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <unordered_map>

using namespace std;


struct Dice{
    int a;
    int b;
    int c;
    int d;
    int e;
    int f;
};

int main() {
    

    Dice dice;
    cin >> dice.a >> dice.b >> dice.c >> dice.d >> dice.e >> dice.f;
    string s;
    cin >> s;
    for (int i=0;i<s.length();i++){
        if(s[i] == 'N'){
            int t = dice.a;
            dice.a = dice.b;
            dice.b = dice.f;
            dice.f = dice.e;
            dice.e = t;
        }else if(s[i] == 'S'){
            int t = dice.a;
            dice.a = dice.e;
            dice.e = dice.f;
            dice.f = dice.b;
            dice.b = t;
        }else if(s[i] == 'E') {
            int t = dice.a;
            dice.a = dice.d;
            dice.d = dice.f;
            dice.f = dice.c;
            dice.c = t;
        }else{
            int t = dice.a;
            dice.a = dice.c;
            dice.c = dice.f;
            dice.f = dice.d;
            dice.d = t;
        }
    }
    cout << dice.a << endl;



}


Measured memory_bytes: 3232
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1000000007;

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

ll modpow(ll x, ll n){
    ll res = 1, r = x;
    while(n){
        if(n % 2) res = res * r % MOD;
        r = r * r % MOD;
        n /= 2;
    }
    return res;
}

int main()
{
    int n;
    cin >> n;
    map<P, ll> mp;
    int k = 0;
    for(int i = 0; i < n; i++){
        ll a, b;
        cin >> a >> b;
        if(a == 0 && b == 0){
            k++;
            continue;
        }
        ll g = gcd(a, b);
        a /= g; b /= g;
        mp[P(a, b)]++;
        mp[P(-a, -b)]++;
    }
    ll ans = 1;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        P p = itr->first;
        P q = P(p.second, -p.first);
        ans = ans * ((modpow(2, mp[p]) + modpow(2, mp[q]) + MOD - 1) % MOD) % MOD;
        mp.erase(p);
        mp.erase(P(-p.first, -p.second));
        mp.erase(q);
        mp.erase(P(-q.first, -q.second));
    }
    ans = (ans + k - 1 + MOD) % MOD;
    cout << ans << endl;
}


Measured memory_bytes: 28572
import java.util.*;

class Main {
	public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int count = sc.nextInt();
    int maxCount = 0;
    int currentCount = 0;
    int previousHeight = 0;
    
    for (int i = 0; i < count; i++) {
      if (i == 0) {
        previousHeight = sc.nextInt();
        continue; 
      }
      
      int currentHeight = sc.nextInt();
      if (previousHeight >= currentHeight) {
        currentCount++;
      } 
      else {
        maxCount = Math.max(maxCount, currentCount);
        currentCount = 0;
      }
      previousHeight = currentHeight;
    }
    
    System.out.println(Math.max(maxCount, currentCount));
	}
}


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

signed main(){
    int n,x;
    cin >> n >> x;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    for(int i = 0; i < n; i++){
        a[i] = abs(a[i] - x);
    }
    int f = a[0],g = a[1];
    for(int i = 0; i < n - 1; i++){
        int b = 4,g = a[i + 1];
        if(f < g)
        swap(f,g);
        while(b){
            b = f % g;
            f = g;
            g = b;
        }

    }
    cout << f << endl;
}

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

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

    string ans = "Yes";
    rep(i, S.size()) {
        if (i%2 == 0 && S.at(i) == 'L') ans = "No";
        if (i%2 == 1 && S.at(i) == 'R') ans = "No";
    }
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import itertools
sx,sy,tx,ty = list(map(int,input().split(" ")))
diffX = tx - sx
diffY = ty - sy
ans = ""
ans+=diffY*"U"
ans+=diffX*"R"
ans+=diffY*"D"
ans+=diffX*"L"
ans+="L"
ans+=(diffY+1)*"U"
ans+=(diffX+1)*"R"
ans+="D"

ans+="R"
ans+=(diffY+1)*"D"
ans+=(diffX+1)*"L"
ans+="U"
print(ans)

Measured memory_bytes: 3064
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
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 LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    r = I()
    if r < 1200:
        return 'ABC'
    if r < 2800:
        return 'ARC'
    return 'AGC'


print(main())


Measured memory_bytes: 5712
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,k,cnt = 1;
	string s;
	cin >> n >> k >> s;
	for(int i = 1;i < n;i++){
		if(s[i] != s[i - 1]) cnt++;
	}
	cnt = max(1ll,cnt - k * 2);
	cout << n - cnt << endl;
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;



int main(){

  ll k;cin>>k;
  queue<ll>qu;

  rep(i,1,10)qu.push(i);

  while(--k){
    ll n=qu.front();
    qu.pop();
    if(n%10-1>=0)qu.push(10*n+n%10-1);
    qu.push(10*n+n%10);
    if(n%10+1<10)qu.push(10*n+n%10+1);
  }
  out(qu.front());

  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>  
#include <cstring>  
#include <algorithm>  
#include <queue>  
#include <iostream>  
#include <string>  
#include <cmath>  
#include <vector>  
#include <set>  
#include <map>  
#include <bitset>  
#include <stack>  
using namespace std;  
  
#define REP(i,n) for ( int i=1; i<=int(n); i++ )    
#define MP make_pair  
#define PB push_back  
#define SZ(x) (int((x).size()))  
#define ALL(x) (x).begin(), (x).end()  
#define X first  
#define Y second  
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }  
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }  
  
typedef long long LL;  
typedef long double LD;  
const int INF = 0x3f3f3f3f;
typedef pair<int, int> pii;


int dis[110][110];
int mp[110][110];
int main() {
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i ++) memset(dis[i], 0x3f, sizeof(dis[i]));
	for(int i = 1; i <= m; i ++) {
		int u, v, w;
		scanf("%d %d %d", &u, &v, &w);
		dis[u][v] = dis[v][u] = mp[u][v] = w;
	}
	for(int k = 1; k <= n; k ++)
		for(int u = 1; u <= n; u ++)
			for(int v = 1; v <= n; v ++) {
				dis[u][v] = min(dis[u][v], dis[u][k] + dis[k][v]);
			}
	int ans = 0;
	for(int i = 1; i <= n; i ++)
		for(int j = 1; j <= n; j ++) 
			if(mp[i][j] > dis[i][j]) ans ++;
	printf("%d\n", ans);
}


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

using namespace std;

using ld = long double;
using Point = std::complex<ld>;

const ld eps = 1e-9, pi = acos(-1.0);

namespace std
{
bool operator<(const Point &lhs, const Point &rhs)
{
    if (lhs.real() < rhs.real() - eps)
        return true;
    if (lhs.real() > rhs.real() + eps)
        return false;
    return lhs.imag() < rhs.imag();
}
} // namespace std

Point input_point()
{
    string s;
    cin >> s;
    int index = -1;
    int n = s.size();
    for (int i = 0; i < n; i++)
    {
        if (s[i] == ',')
        {
            index = i;
            break;
        }
    }
    assert(index != -1);
    string x = s.substr(0, index);
    string y = s.substr(index + 1);
    return Point(stold(x), stold(y));
}

bool eq(ld a, ld b)
{
    return (abs(a - b) < eps);
}

ld dot(Point a, Point b)
{
    return real(conj(a) * b);
}

ld cross(Point a, Point b)
{
    return imag(conj(a) * b);
}

// CCW::counter clockwise
int ccw(Point a, Point b, Point c)
{
    b -= a;
    c -= a;
    if (cross(b, c) > eps)
        return 1; // a,b,c : counter-clockwise
    if (cross(b, c) < -eps)
        return -1; // a,b,c : clockwise
    if (dot(b, c) < 0)
        return 2; // c,a,b : on a line
    if (norm(b) < norm(c))
        return -2; // a,b,c : on a line
    return 0;      // a,c,b : on a line
}

class Circle
{
public:
    Point p;
    ld r;
    Circle() : p(Point(0, 0)), r(0) {}
    Circle(Point p, ld r) : p(p), r(r) {}
};

// c1, c2 の交点
std::vector<Point> is_cc(Circle c1, Circle c2)
{
    std::vector<Point> res;
    ld d = abs(c1.p - c2.p);
    ld rc = (d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
    ld dfr = c1.r * c1.r - rc * rc;
    if (abs(dfr) < eps)
        dfr = 0.0;
    else if (dfr < 0.0)
        return res; // no intersection
    ld rs = sqrt(dfr);
    Point diff = (c2.p - c1.p) / d;
    res.emplace_back(c1.p + diff * Point(rc, rs));
    if (dfr != 0.0)
        res.emplace_back(c1.p + diff * Point(rc, -rs));
    return res;
}

int main()
{
    int n;
    while (cin >> n, n)
    {
        vector<Circle> cs;
        for (int i = 0; i < n; i++)
        {
            auto p = input_point();
            cs.emplace_back(p, 1.0);
        }
        vector<Point> ps;
        for (int i = 0; i < n; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                auto pp = is_cc(cs[i], cs[j]);
                for (const auto &p : pp)
                {
                    ps.emplace_back(p);
                }
            }
        }
        int ret = 1;
        for (const auto &p : ps)
        {
            int tmp = 0;
            for (int i = 0; i < n; i++)
            {
                if (abs(cs[i].p - p) < 1.0 + eps)
                {
                    tmp++;
                }
            }
            ret = max(ret, tmp);
        }
        cout << ret << endl;
    }
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, c;

    cin >> a >> b >> c;

    if (a == b) cout << c << '\n';
    else if (a == c) cout << b << '\n';
    else if (b == c) cout << a << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    vector<vector<int>> A(a,vector<int>(b));
    for(int i = 0;i<a;i++){
        for(int j = 0;j<b;j++){
            cin >> A.at(i).at(j);
        }
    }
    double dis;
    int count = 0;
    for(int i = 0;i<a;i++){
        for(int j = i+1;j<a;j++){
            double dis = 0;
            for(int s = 0;s<b;s++){
                dis += pow(A.at(i).at(s) - A.at(j).at(s),2);
            }
            double M = sqrt(dis);
            if(fmod(M,1) == 0)
                count++;
        }
    }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

double solve(int a, int b, int x)
{
    int maxVolume = a * a * b;

    if (x >= maxVolume / 2)
    {
        double volume = maxVolume - x;

        double tArea = volume / static_cast<double>(a);
        double c1 = a;
        double c2 = (tArea * 2.0) / c1;
        double angle = atan(c2 / c1) * 180.0 / M_PI;
        return angle;
    }
    else
    {
        double volume = x;

        double tArea = volume / static_cast<double>(a);
        double c1 = b;
        double c2 = (tArea * 2.0) / c1;
        double angle = 90.00 - (atan(c2 / c1) * 180.0 / M_PI);
        return angle;
    }
}

int main() {
    fast_io();

    int a = fetch<int>();
    int b = fetch<int>();
    int x = fetch<int>();
    std::cout << std::setprecision(12) << solve(a, b, x) << std::endl;

    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n, m, i;
    vector <int> v, w, z1, z2;
    
    scanf("%d %d", &n, &m);
    
    for (i = 0; i < m; i++) {
        int x;
        
        scanf("%d", &x);
        
        if (x % 2 == 0) {
            v.push_back(x);
        } else {
            w.push_back(x);
        }
    }
    
    if (w.size() > 2) {
        puts("Impossible");
        
        return 0;
    }
    
    if (w.size() == 0) {
        z1 = v;
        
        z2.push_back(v[0] - 1);
        for (i = 1; i < v.size(); i++) z2.push_back(v[i]);
        z2.push_back(1);
    } else if (w.size() == 1) {
        z1.push_back(w[0]);
        for (i = 0; i < v.size(); i++) z1.push_back(v[i]);
        
        if (w[0] > 1) z2.push_back(w[0] - 1);
        for (i = 0; i < v.size(); i++) z2.push_back(v[i]);
        z2.push_back(1);
    } else {
        z1.push_back(w[0]);
        for (i = 0; i < v.size(); i++) z1.push_back(v[i]);
        z1.push_back(w[1]);
        
        if (w[0] > 1) z2.push_back(w[0] - 1);
        for (i = 0; i < v.size(); i++) z2.push_back(v[i]);
        z2.push_back(2);
        if (w[1] > 1) z2.push_back(w[1] - 1);
    }
    
    for (i = 0; i < z1.size(); i++) {
        if (i > 0) putchar(' ');
        
        printf("%d", z1[i]);
    }
    puts("");
    
    printf("%d\n", z2.size());
    for (i = 0; i < z2.size(); i++) {
        if (i > 0) putchar(' ');
        
        printf("%d", z2[i]);
    }
    puts("");
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
const int INF = 100100100;
int main(){
    int n; cin >> n;
    int x[n];
    vector<P> v;
    int s[n*n];
    rep(i,n*n) s[i]=INF;
    rep(i,n){
        cin >> x[i];
        x[i]--;
        s[x[i]]=i;
        v.push_back({x[i],i});
    }
    sort(v.begin(),v.end());
    int st=0;
    rep(i,v.size()){
        P d=v[i];
        rep(i,d.se){
            if(s[st]==INF) s[st]=d.se;
            else{
                st++;
                i--;
            }
            if(st>=n*n){
                cout << "No" << endl;
                break;
            }
        }
    }
    int ss=0;
    rep(i,v.size()){
        P d=v[i];
        rep(i,n-d.se-1){
            if(s[ss]==INF) s[ss]=d.se;
            else{
                ss++;
                i--;
            }
        }
        if(ss>=n*n){
            cout << "No" << endl;
            break;
        }
    }
    //判定は
    int cnt[n];
    rep(i,n+1) cnt[i]=0;
    rep(i,n*n){
        cnt[s[i]]++;
        if(i==x[s[i]] && cnt[s[i]]!=s[i]+1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    rep(i,n*n) cout << s[i]+1 << " ";
    
    
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int cnt = 0;
  while(a >= b)
  {
    b *= 2;
    cnt++;
  }
  while(b >= c)
  {
    c *= 2;
    cnt++;
  }
  cout << (cnt <= k ? "Yes" : "No");
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
//#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINT(fm, ...) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout << "DEBUG PRINT ";std::printf(fm, __VA_ARGS__);}while(0)
#define DEBUG_VAL(a, b) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout <<"DEBUG VAL " << a << ":" << b << endl;}while(0)
#else
#define DEBUG_PRINT(...)do{}while(0);
#define DEBUG_VAL(a, b)do{}while(0);
#endif

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    ll M = 0;
    rep(i, n){
        ll A;
        cin >> A;
        if(M > A){
            ans += (M -A);
        }
        M = max(M, A);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
#!/usr/bin/env python
# -*- coding:utf-8 -*-

from __future__ import division, print_function, absolute_import, unicode_literals

N = int(input())
a = list(map(int, input().split()))

cnt = 0
for i in range(N):
    # print(i+1, a[a[i]-1]+1)
    if i+1 == a[a[i]-1]:
        cnt += 1
print(cnt // 2)


Measured memory_bytes: 14068
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>

#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define maxn 5005
#define mod 998244353
using namespace std;


int main(){
int a,b;
cin>>a>>b;
cout<<a*b<<endl;

}

Measured memory_bytes: 3636
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

#ifdef EBUG
#define debug(x) cout << "\033[31m" << #x << ": " << x << "\033[0m\n";
#else
#define debug(x)
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

vector<ll> pf;
map<ll, ll> pfm;
ll ans;

void prime_fac(ll n) {
  ll i = 2;
  while (i <= sqrt(n)) {
    if (n % i == 0) {
      pf.push_back(i);
      pfm[i]++;
      n /= i;
    } else {
      i++;
    }
  }
  pf.push_back(n);
  pfm[n]++;
}

int main() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << "0" << endl;
    return 0;
  }
  prime_fac(n);
  sort(pf.begin(), pf.end());
  pf.erase(unique(pf.begin(), pf.end()), pf.end());
  //
  // rep(i, pf.size()) {
  //   cout << pf[i] << endl;
  //   cout << pfm[pf[i]] << endl;
  // }
  //
  rep(i, pf.size()) {
    for (int j = 1; j <= pfm[pf[i]]; j++) {
      ans++;
      pfm[pf[i]] -= j;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3688
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#include <tuple>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
#define MOD (1e9+7)
#define INF (1e9)
#define LLINF (4e18)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename... R> void input(string& f, R&... r) { cin >> f; input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion

int main() {
    int N; input(N);
    vector<pair<ll,ll>> a(N);
    REP(i, N) {
        input(a[i].second, a[i].first);
    }
    sort(ALL(a));
    ll sum = 0;
    REP(i, N) {
        sum += a[i].second;
        if (sum > a[i].first) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    getchar(); getchar();
}

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

int main(){
	ll N, K;
	cin >> N >> K;
	vector<ll> A(N);
	for(auto&a : A) cin >> a;
	sort(A.begin(), A.end());
	A.push_back(1e9+5);

	ll ok = 1e18, ng = -1e18;
	while(ok - ng > 1) {
		ll mid = (ok + ng) / 2;
		ll eq_and_less_than_mid_num = 0;
		for(ll i=0;i<N-1;i++) {
			if(A[i] < 0) {
				// j > iについてA[i]との積がmidよりも小さくなるA[j]の数
				ll left = i;
				ll right = N;
				while(right - left > 1) {
					ll upper_mid = (left + right) / 2;
					if(A[i] * A[upper_mid] <= mid) right = upper_mid;
					else left = upper_mid;
				}
				eq_and_less_than_mid_num += (N - right);
			}else {
				ll left = i;
				ll right = N;
				while(right - left > 1) {
					ll upper_mid = (left + right) / 2;
					if(A[i] * A[upper_mid] <= mid) left = upper_mid;
					else right = upper_mid;
				}
				eq_and_less_than_mid_num += (left - i);
			}

		}
		if(eq_and_less_than_mid_num >= K) ok = mid; else ng = mid;
	}
	cout << ok << endl;
}

Measured memory_bytes: 4608
/*  -*- coding: utf-8 -*-
 *
 * 1592.cc: Curling Puzzle
 */

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

/* constant */

const int MAX_H = 16;
const int MAX_W = 16;
const int WBITS = 1 << MAX_W;
const int MAX_N = MAX_H * MAX_W;
const int MAX_NN = MAX_N * MAX_N;
const int dxs[] = { 1, 0, -1, 0 }, dys[] = { 0, -1, 0, 1 };

/* typedef */

typedef queue<int> qi;

/* global variables */

char s[MAX_W + 4];
int xs[MAX_N], ys[MAX_N];
bool used[MAX_NN];

/* subroutines */

inline int xy2p(int x, int y) { return (y << 4) | x; }
inline void p2xy(int p, int &x, int &y) { x = p & 0xf; y = (p >> 4) & 0xf; }

inline int xy2p2(int x0, int y0, int x1, int y1) {
  int p0 = xy2p(x0, y0), p1 = xy2p(x1, y1);
  if (p0 > p1) swap(p0, p1);
  return (p0 << 8) | p1;
}

inline void p2xy2(int p2, int &x0, int &y0, int &x1, int &y1) {
  p2xy((p2 >> 8), x0, y0), p2xy((p2 & 0xff), x1, y1);
}

void move(int di, int &x0, int &y0, int x1, int y1, int w, int h) {
  const int &dx = dxs[di], &dy = dys[di];

  for (;;) {
    int x = x0 + dx, y = y0 + dy;
    if (x < 0 || x >= w || y < 0 || y >= h ||
	(x == x1 && y == y1)) break;
    x0 = x, y0 = y;
  }
}

/* main */

int main() {
  int h, w;
  scanf("%d%d", &h, &w);

  int gx, gy, n = 0;
  for (int y = 0; y < h; y++) {
    scanf("%s", s);
    for (int x = 0; x < w; x++) {
      if (s[x] == '@') gx = x, gy = y;
      else if (s[x] == 'o') xs[n] = x, ys[n] = y, n++;
    }
  }
  //printf("n=%d\n", n);

  if (n == 1) {
    if ((gx == xs[0] && (gy == 0 || gy == h - 1)) ||
	(gy == ys[0] && (gx == 0 || gx == w - 1)) ||
	((gx == 0 || gx == w - 1) && (gy == 0 || gy == h - 1))) {
      puts("yes");
      return 0;
    }
  }
  else if (h == 1 || w == 1) {
    if (w == 1) {
      w = h; gx = gy;
      memcpy(xs, ys, sizeof(ys));
    }

    int i1 = upper_bound(xs, xs + n, gx) - xs, i0 = i1 - 1;
    int x0 = (i0 >= 0) ? xs[i0] : -1;
    int x1 = (i1 < n) ? xs[i1] : w;
    if (x0 + (n - 1 - i0) >= gx || x1 - i1 <= gx) {
      puts("yes");
      return 0;
    }
  }
  else if (n == 2) {
    int st = xy2p2(xs[0], ys[0], xs[1], ys[1]);
    used[st] = true;
    qi q;
    q.push(st);

    while (! q.empty()) {
      int u = q.front(); q.pop();
      int ux0, uy0, ux1, uy1;
      p2xy2(u, ux0, uy0, ux1, uy1);
      if ((ux0 == gx && uy0 == gy) || (ux1 == gx && uy1 == gy)) {
	puts("yes");
	return 0;
      }

      for (int di = 0; di < 4; di++) {
	int x = ux0, y = uy0;
	move(di, x, y, ux1, uy1, w, h);
	int v0 = xy2p2(x, y, ux1, uy1);
	if (! used[v0]) {
	  used[v0] = true;
	  q.push(v0);
	}

	x = ux1, y = uy1;
	move(di, x, y, ux0, uy0, w, h);
	int v1 = xy2p2(x, y, ux0, uy0);
	if (! used[v1]) {
	  used[v1] = true;
	  q.push(v1);
	}
      }
    }
  }
  else {
    puts("yes");
    return 0;
  }

  puts("no");
  return 0;
}



Measured memory_bytes: 3216
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		while (true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int p = sc.nextInt();
			if ((n | m | p) == 0)
				break;
			m--;
			int o = 0;
			double money = 0;
			for (int i = 0; i < n; i++) {
				int k = sc.nextInt();
				if (i == m) {
					o += k;
				}
				money += k * 100;
			}

			money = money * (100 - p) / 100;
			if (o == 0) {
				System.out.println("0");
			} else {
				System.out.println((int)(money / o));
			}
		}
	}

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

Measured memory_bytes: 25996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18
ll GCD(ll a,ll b){
    ll hoge;
    do{
        hoge=a%b;
        a=b;
        b=hoge;
    }while(hoge!=0);
    return a;
}
ll LCM(ll a,ll b){
    return a*b/GCD(a,b);
}
int main(){
	string s,t;
	ll a,b;
	cin>>a>>b;
	cin>>s>>t;
	bool flag=false;
	ll lcm=LCM(a,b);
	ll gcd=GCD(a,b);
	ll j=0,cnt_a=0,cnt_b=0;
	for(ll i=0;i<=lcm;i+=lcm/a){
		for(;j<=lcm;j+=lcm/b){
			if(i<j)break;
			if(i==j){
				if(s[i/(b/gcd)]!=t[j/(a/gcd)]){
					flag=true;
				}
			}
		}
	}
	if(flag){
		cout<<-1<<endl;
	}
	else{
		cout<<lcm<<endl;
	}
	
}


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

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

    int n, m;
    cin >> n >> m;
    
    map<pair<int, int>, int> mp1;
    map<int, vector<int>> mp2;
    vector<int> P(m), Y(m);
    for(int i = 0; i < m; i++){
        int p, y;
        cin >> p >> y;
        P[i] = p;
        Y[i] = y;

        mp2[p].push_back(y);
    }

    for(auto& x : mp2){
        sort(x.second.begin(), x.second.end());
    }

    for(auto x : mp2){
        int idx = 0;
        for(auto z : x.second){
            mp1[{x.first, z}] = idx;
            idx++;
        }
    }

    for(int i = 0; i < m; i++){
        string ans = "";
        string tmp = to_string(P[i]);
        for(int j = 0; j < max(0, 6 - (int)tmp.size()); j++){
            ans += '0';
        }
        ans += tmp;
        string t = to_string(mp1[{P[i], Y[i]}] + 1);
        for(int j = 0; j < max(0, 6 - (int)t.size()); j++){
            ans += '0';
        }
        ans += t;
        cout << ans << endl;
    }




    return 0;
}

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

int cc[1001];

int main()
{
    int n, t;
    cin >> n >> t;
    rep(i, n) {
        int c, ta;
        cin >> c >> ta;
        if(ta <= t) cc[c]++;
    }
    bool x = true;
    rep(i, 1001) {
        if(x && cc[i] == 1) {
            cout << i << endl;
            x = false;
        }
    }
    if(x) cout << "TLE" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys,copy

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	H,W = MI()
	maze = [[-1 for _ in range(W)] for _ in range(H)]
	for i in range(H):
		S = IS()
		for j,s in enumerate(S):
			if s == '#':
				maze[i][j] = '#'

	def bfs(sx,sy):
		from collections import deque
		que = deque()
		dist_map = copy.deepcopy(maze)
		dist_map[sy][sx]=0
		que.append((sx,sy))
		res = 0
		while len(que) > 0:
			x,y=que.popleft()
			for dx,dy in [(-1,0),(1,0),(0,1),(0,-1)]:
				nx = x+dx
				ny = y+dy
				if(0<=nx<W and 0<=ny<H):
					if(dist_map[ny][nx]==-1):
						dist_map[ny][nx] = dist_map[y][x]+1
						res = max(res, dist_map[ny][nx])
						que.append((nx,ny))
		return res

	ans = -1
	for i in range(H):
		for j in range(W):
			if(maze[i][j]==-1):
				dist = bfs(j,i)
				if(dist > ans):
					ans = dist
	print(ans)

main()

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

char f(char a, char b){
    if(a=='T' && b=='F') return 'F';
    return 'T';
}

int main(){
    int N; cin >> N;
    char cur; cin >> cur;
    for(int i=0; i<N-1; i++){
        char p; cin >> p;
        cur = f(cur, p);
    }
    
    cout << cur << endl;
    return 0;
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ll n;
	cin>>n;
	cout<<n*n*n<<endl;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void _main() {
        ll n; cin >> n;
        map<ll, int> pf;
        for (ll div = 2; div * div <= n; div++) {
                while (n % div == 0) {
                        pf[div]++;
                        n /= div;
                }
        }

        if (n > 1) pf[n]++;


        int ans = 0;
        for (auto &it: pf) {
                int i = 1;
                while (it.second - i >= 0) {
                        ans++;
                        it.second -= i++;
                }
        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

int main() {
  // std::cout << std::fixed << std::setprecision(10);

  ll N;
  scanf("%lld", &N);

  map<ll, ll> m;

  vector<ll> a_list(N + 5);
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);

    ll index = i + 1;
    a_list[index] = v;
    ll point = index - v;
    m[point] += 1;

    // cout << point << endl;
  }

  ll ans = 0;

  for (ll i = 1; i <= N; i++) {
    ll v = a_list[i];
    ll point = i - v;

    m[point] -= 1;

    ll find = v + i;

    ans += m[find];
  }

  cout << ans << endl;
}


Measured memory_bytes: 20216
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> A(M);
  rep(i, M) cin >> A[i];

  int l = lower_bound(all(A), X) - A.begin();
  int r = M - l;

  cout << min(l, r) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(void) {
    
    string s;
    cin>>s;
    int n=s.size();
    vvll dp(n+1,vll(13,0));
    dp[0][0]=1;
    rep(i,n){
        if(s[i]=='?') {
            for(int now=0;now<=9;now++) {
                rep(j,13){
                    int next = (j*10+now)%13;
                    dp[i+1][next] += dp[i][j];
                    dp[i+1][next]%=MOD;
                }
            }
        } else {
            int now = s[i]-'0';
            rep(j,13){
                int next = (j*10+now)%13;
                dp[i+1][next] += dp[i][j];
                dp[i+1][next]%=MOD;
            }
        }
    }
    cout<<dp[n][5]<<endl;

    
}

Measured memory_bytes: 13696
/**
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 2019-11-22:18:13:33
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

constexpr int64 INF = 1e15;

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

  int n, W; cin >> n >> W;
  vector<int64> w(n), v(n);
  for (int i = 0; i < n; ++i) cin >> w[i] >> v[i];

  // dp[i][j] : i 個目まで見て価値の総和が j のときの重さの最小値
  vector<vector<int64>> dp(n + 5, vector<int64>(101010, INF));

  dp[0][0] = 0LL;
  
  for (int i = 0; i < n; ++i) {
    for (int64 j = 0; j <= 100010; ++j) {
      if (j - v[i] >= 0){
        dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
      } else {
        dp[i + 1][j] = dp[i][j];
      }
    }
  }

  int ans = 0;
  for (int i = 0; i <= 100010; ++i) {
    if (dp[n][i] <= W) {
      ans = max(ans, i);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 84224