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

using namespace std;

string backtrack(vector<vector<int>> & dp, string & s, string & t, 
				 int i, int j){
	if(i == 0 || j == 0) return "";
	if(s[i] == t[j])
		return backtrack(dp, s, t, i - 1, j - 1) + s[i];
	if(dp[i][j - 1] > dp[i - 1][j])
		return backtrack(dp, s, t, i, j - 1);
	return backtrack(dp, s, t, i - 1, j);
}

int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

	string s;
	string t;
	cin >> s >> t;
	int n = s.length();
	int m = t.length();

	s = '-' + s;
	t = '-' + t;

	vector<vector<int>> dp(n + 2, vector<int>(m + 2, 0));
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= m; ++j){
			if(s[i] == t[j]){
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}else{
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}

	string res = backtrack(dp, s, t, n, m);
	cout << res;

    return 0;
}


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

bool is_prime(int n){
  if(n%2 == 0) return false;
  for(int i = 2; i*i <= n; i++){
    if(n%i == 0) return false;
  }
  return n != 1;
}

vector<int> divisor(int n){
  vector<int> res;
  for(int i = 1; i*i <= n; i++){
    if(n%i == 0){
      res.emplace_back(i);
      if(i != n/i) res.emplace_back(n/i);
    }
  }
  return res;
}

map<long long, long long> prime_factor(long long n){
  map<long long, long long> res;
  for(long long i = 2; i*i <= n; i++){
    while(n%i == 0){
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}

vector<int> sieve(int n){
  vector<int> res;
  vector<bool> is_prime(n+1, true);
  is_prime[0] = false;
  is_prime[1] = false;
  for(int i = 2; i <= n; i++){
    if(!is_prime[i]) continue;
    res.emplace_back(i);
    for(int j = 2*i; j <= n; j += i) is_prime[j] = false;
  }
  return res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a, b;
  cin >> a >> b;
  long long g = __gcd(a, b);
  cout << prime_factor(g).size() + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
s=int(input())
ans=0
mod=10**9+7
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

for i in range(1,s//3+1):
    ans+=(combinations_count(s-3*i+i-1,s-3*i))%mod
print(ans%mod)

Measured memory_bytes: 68196
from collections import deque

def rectangle(n, hs): #n:?¨????hs: ???????????°??????
    stack = deque() # stack = (j, h) ????????¨?????????????´??????????
    ans = 0
    for i, h in enumerate(hs):
        j = -1
        while stack and stack[-1][1] > h:
            j, h2 = stack.pop()
            ans = max(ans, (i-j) * h2)
            
        if not stack or stack[-1][1] < h: #stack?????????????????????stack?????????????????????"??????h"?????????????????°?????????????????????????°????????????°???????£???¨??????stack????????????
            stack.append( (i if j == -1 else j, h))
        
    ans = max(ans, max((n-j) * h2 for j, h2 in stack))
    
    return ans
    
H, W = map(int, input().split())
hs = [0] * W
result = 0

for i in range(H):
    ht = list(map(int, input().split()))
    hs = list(map(lambda x, y: (x+1) * abs(y-1), hs, ht)) #???????????°???????????????
    result = max(result, rectangle(W, hs))
    
print(result)

Measured memory_bytes: 8200
//atcoder.jp abc 120 d
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define fst first
#define scd second
using namespace std;
inline ll read() {
	ll f=1,x=0;
	char ch=getchar();
	while(!isdigit(ch)){
	   if(ch=='-')
	      f=-1;
	   ch=getchar();
	}
	while(isdigit(ch)){
	   x=x*10+ch-'0';
	   ch=getchar();
	}
	return x*f;
}
const int MAXN=1e5+5;
int n,m,fa[MAXN];

struct EDGE {
	int u,v;
}e[MAXN];

ll ans[MAXN],sz[MAXN];

int get_fa(int x) {
	if(x==fa[x]) return x;
	return fa[x]=get_fa(fa[x]);
}

int main() {
    //freopen("","r",stdin);
    //freopen("","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);/*syn加速*/
	
	n=read();
	m=read();
	
	for(int i=1;i<=m;++i) {
		e[i].u=read(); 
		e[i].v=read();
	}
	
	for(int i=1;i<=n;++i) 
	   fa[i]=i,sz[i]=1;
	
	ans[m]=(ll)n*(n-1)/2;   //c(n,2)
	
	for(int i=m;i>=1;--i) {
		int u=get_fa(e[i].u),v=get_fa(e[i].v);
		if(u==v) 
		    ans[i-1]=ans[i];
		else {
			ans[i-1]=ans[i]-sz[v]*sz[u];
			sz[v]+=sz[u]; fa[u]=v;
		}
	}
	
	for(int i=1;i<=m;++i) 
	   cout<<ans[i]<<endl;
	return 0;
}

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

const int MAXN = 200005;

int n;
ll d, a, st[4 * MAXN];
vector<ll> G;
pii in[MAXN];

void init(int l, int r, int id) {
	if (l == r) {
		st[id] = in[l].second;
	}else {
		int m = (l + r) >> 1, lson = 2 * id + 1, rson = 2 * id + 2;
		init(l, m, lson);
		init(m + 1, r, rson);
		st[id] = 0;
	}
}

ll query(int l, int r, int id, int x) {
	if (l == r && l == x) return st[id];
	int m = (l + r) >> 1, lson = 2 * id + 1, rson = 2 * id + 2;
	if (m >= x) return st[id] + query(l, m, lson, x);
	else return st[id] + query(m + 1, r, rson, x);
}

void modify(int l, int r, int id, int xl, int xr, ll x) {
	if (l > xr || r < xl) return;
	else if(xl <= l && r <= xr) {
		st[id] += x;
		return;
	}
	int m = (l + r) >> 1, lson = 2 * id + 1, rson = 2 * id + 2;
	modify(l, m, lson, xl, xr, x);
	modify(m + 1, r, rson, xl, xr, x);
}

int main(){
	ios::sync_with_stdio(0),cin.tie(0);
	ll res;
	int l, r;
	while (cin >> n >> d >> a) {
		G.clear();
		res = 0;

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

		sort(in, in + n);
		sort(G.begin(), G.end());
		G.resize(unique(G.begin(), G.end()) - G.begin());

		init(0, n-1, 0);

		for (int i = 0; i < n; ++i) {
			ll cnt, tmp = query(0, n-1, 0, i);
			if (tmp <= 0) continue;

			cnt = tmp / a;
			if (tmp % a) cnt++;

			l = lower_bound(G.begin(), G.end(), in[i].first) - G.begin();
			r = lower_bound(G.begin(), G.end(), in[i].first + 2 * d) - G.begin();
			while (G[r] > in[i].first + 2 * d) r--;
			//cout << l << ' ' << in[i].first - d << ' ' << r << ' ' << in[i].first + d << '\n';
			modify(0, n - 1, 0, l, r, -1ll * cnt * a);
			res += cnt;
		}
		cout << res << '\n';
	}
	return 0;
}


Measured memory_bytes: 10096
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define deb(x) cout<<#x<<" is "<<x<<endl;
typedef long long ll;
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<ll>a(n);
    for(int i=0;i<n;i++)   
        cin>>a[i];

    ll dp[n][n][2];
    for(int i=n-1;i>=0;i--)
    {
        for(int j=i;j<=n-1;j++)
        {
            if(i==j)
            {
                dp[i][j][0]=a[i];
                dp[i][j][1]=-a[i];
            }
            else
            {
                //consider range a[i...j]
                //take "i", or take "j" and maximise or minimise according to your objective
                dp[i][j][0]=max(a[i]+dp[i+1][j][1],a[j]+dp[i][j-1][1]);
                dp[i][j][1]=min(-a[i]+dp[i+1][j][0],-a[j]+dp[i][j-1][0]);    
            }

            // cout<<i<<" "<<j<<" "<<dp[i][j][0]<<" "<<dp[i][j][1]<<endl;
        }
    }
    cout<<dp[0][n-1][0]<<endl;
}

Measured memory_bytes: 85436
import java.util.*;

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

    String str;
    char word[] = new char[1200];
    int num=0;

    int i=0;
    str = sc.next();

    while(i<1200){
      if(i==str.length()){
        System.out.printf("\n");
        break;
      }
      word[i] = str.charAt(i);
      num=(int)word[i];

      if(num>=65 && num<=90) word[i]=(char)(num+32);
      else if(num>=97 && num<=122) word[i]=(char)(num-32);
      System.out.print(word[i]);
      i++;
    }

  }
}



Measured memory_bytes: 26740
from collections import Counter
def soinsu(n, lists):
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return soinsu(n // i, lists + [i])
    return lists + [n]
    
    
N = int(input())
if N == 1:
    print(0)
    exit()

a = soinsu(N, [])
ans = 0
    
tmp = Counter(a)

for i in tmp.values():
    s = 1
    counts = 1
    while True:
        counts += 1
        if i >= s:
            ans += 1
            s += counts
        else:
            break

print(ans)


Measured memory_bytes: 9732
#include<iostream>
#include<vector>
int main() {
	std::vector<int> v;
	while(1){
	int n;
	int x = 0;
	std::cin >> n;
	if (n == 0)
		break;
	std::vector<int>a(n / 4);
		for (int i = 0;i < n / 4;++i) {
			std::cin >> a[i];
			x += a[i];
		}
		v.push_back(x);
	}
	for (int i = 0;i < v.size();++i) {
		std::cout << v[i] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
int main(void)
{
 int n,i,ai,min,max;
 long sum;
 
 sum=0;
 
 min=1000000;
 
 max=-1000000;
 
 scanf("%d",&n); 
 
 for(i=1;i<=n;i++){
 
  scanf("%d",&ai);
  
  sum+=ai;
  
  if(min>ai){
  
   min=ai;
   
   }
  
 if(max<ai){
 
  max=ai;
  
  }
  
 }
 printf("%d %d %lld\n",min,max,sum);
 
 return 0;
 
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

typedef long long ll;

ll sol(int c[40], int n, ll k, int x) {
    if (x == -1) {
        return 0;
    }

    if (k == -1) {
        return (1ll << x) * max(c[x], n - c[x]) + sol(c, n, -1, x - 1);
    }

    ll ret;
    if (k >= (1ll << x)) {
        ret = (1ll << x) * c[x] + sol(c, n, -1, x - 1);
        ret = max(ret, (1ll << x) * (n - c[x]) + sol(c, n, k - (1ll << x), x - 1));
    } else {
        ret = (1ll << x) * c[x] + sol(c, n, k, x - 1);
    }
    return ret;
}

int main() {
    int n;
    ll k;
    cin >> n >> k;
    int c[40];
    memset(c, 0, sizeof(c));
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        for (int j = 0; j < 40; j++) {
            c[j] += a % 2;
            a /= 2;
        }
    }

    cout << sol(c, n, k, 39) << endl;

    return 0;
}


Measured memory_bytes: 256
import math

n = int(input())
k = math.log10(n)
if k < 1:
    ans = n
elif k < 2:
    ans = 9
elif k < 3:
    ans = n - 90
elif k < 4:
    ans = 900 + 9
elif k < 5:
    ans = 900 + 9 + n - 9999
else:
    ans = 90909
print(ans)


Measured memory_bytes: 2940
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	a--
	b--

	g := [100][100]string{}
	for i := 0; i < 100; i++ {
		for j := 0; j < 100; j++ {
			c := "."
			if i > 50 {
				c = "#"
			}
			g[i][j] = c

			if i%2 == 0 && j%2 == 0 {
				if a > 0 && i >= 52 {
					g[i][j] = "."
					a--
				}
				if b > 0 && i < 48 {
					g[i][j] = "#"
					b--
				}
			}
		}
	}

	fmt.Println(100, 100)
	for i := 0; i < 100; i++ {
		for j := 0; j < 100; j++ {
			fmt.Printf("%s", g[i][j])
		}
		fmt.Println()
	}
}


Measured memory_bytes: 896
# -*- coding: utf-8 -*-
n = str(input())
b = n[:2]
a = n[2:]
be = int(b)
af = int(a)
if 13<=be<=99 and 1<=af<=12:
    print("YYMM")
elif 1<=be<=12 and 13<=af<=99:
    print("MMYY")
elif 1<=be<=12 and 1<=af<=12:
    print("AMBIGUOUS")
elif be==0 and 1<=af<=12:
    print("YYMM")
elif 1<=be<=12 and af==0:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3064
// https://atcoder.jp/contests/abc112/tasks/abc112_b
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, n) for (int i = 0; i < n; i++)
#define EACH(i, n) for (auto &i: n)

void solv(int n, int t) {
  int ans = 10000;

  FOR(i, n) {
    int cc, tt;
    cin >> cc >> tt;
    if (tt <= t && ans > cc) {
      ans = cc;
    }
  }
  if (ans == 10000) {
    cout << "TLE" << endl;
  } else {
    cout << ans << endl;
  }
}

int main() {
  int n, t;

  while (cin >> n >> t) {
    solv(n, t);
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  int a[3][3], n, b[9];
  scanf("%d %d %d", &a[0][0], &a[0][1], &a[0][2]);
  scanf("%d %d %d", &a[1][0], &a[1][1], &a[1][2]);
  scanf("%d %d %d", &a[2][0], &a[2][1], &a[2][2]);
  scanf("%d", &n);
  // printf("%d %d %d\n", a[0][0], a[0][1], a[0][2]);
  // printf("%d %d %d\n", a[1][0], a[1][1], a[1][2]);
  // printf("%d %d %d\n", a[2][0], a[2][1], a[2][2]);
  for (size_t i = 0; i < n; i++) {
    scanf("%d", &b[i]);
    for (size_t j = 0; j < 3; j++) {
      for (size_t k = 0; k < 3; k++) {
        if (b[i] == a[j][k]) a[j][k] = 0;
      }
    }
  }
  for (size_t i = 0; i < 3; i++) {
    if (a[i][0] == 0) {
      if (a[i][1] == 0) {
        if (a[i][2] == 0) {
          puts("Yes");
          return 0;
        }
      }
    }
  }
  for (size_t i = 0; i < 3; i++) {
    if (a[0][i] == 0) {
      if (a[1][i] == 0) {
        if (a[2][i] == 0) {
          puts("Yes");
          return 0;
        }
      }
    }
  }
  if (a[0][0] == 0)
    if (a[1][1] == 0)
      if (a[2][2] == 0) {
        puts("Yes");
        return 0;
      }
  if (a[0][2] == 0)
    if (a[1][1] == 0)
      if (a[2][0] == 0) {
        puts("Yes");
        return 0;
      }
  puts("No");
  return 0;
}


Measured memory_bytes: 128
use std::io::*;
use std::str::FromStr;

#[test]
fn test() {
    // apend to test here
//    assert_eq!();
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
            .bytes()
            .map(|c| c.expect("failed to read char") as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
    token.parse().ok().expect("failed to parse token")
}

fn func(n: u32) -> u32 {
    let mut ans: u32 = 1;
    for _i in 0..3 {
       ans = ans * n; 
    }
    ans
}
fn main() {
    // Add variable
    let n: u32 = read();
    let ans;

    ans = func(n);
    println!("{}", ans);
}



Measured memory_bytes: 4352
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<stack>
#include<queue>
#include<set>
#include<cctype>
#include<bitset> 
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;
typedef long long int ll;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;
const ll INF = (ll)1e12;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{
    int A,B,Q ; cin >> A >> B >> Q;

    vector<ll> s(A+2),t(B+2),x(Q);
    s[0] = t[0] = -INF;
    s[A+1] = t[B+1] = INF;

    REP(i,A) cin >> s[i+1];
    REP(i,B) cin >> t[i+1];
    REP(i,Q) cin >> x[i];

    REP(i,Q) {
        int b = lower_bound(s.begin(),s.end(),x[i]) - s.begin();
        int a = b -1;
        int d = lower_bound(t.begin(),t.end(),x[i]) - t.begin();
        int c = d -1;

        ll left_s = s[a];
        ll right_s = s[b];
        ll left_t = t[c];
        ll right_t = t[d];
//        cout << a << ":" << b << ":" << c << ":"  << d << endl;
//        cout << left_s << ":" << right_s << ":" << left_t << ":"  << right_t << endl;

        ll d1=abs(left_s-left_t)+min(abs(x[i]-left_s),abs(x[i]-left_t));
        ll d2=abs(right_s-right_t)+min(abs(x[i]-right_s),abs(x[i]-right_t));
        ll d3=abs(left_s-right_t)+min(abs(x[i]-left_s),abs(x[i]-right_t));
        ll d4=abs(right_s-left_t)+min(abs(x[i]-right_s),abs(x[i]-left_t));
//        cout << d1 << ":" << d2 << ":" << d3 << ":"  << d4 << endl;

        x[i] = min(min(d1,d2),min(d3,d4));
   }

   REP(i,Q) pl(x[i])
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>

#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
int32_t main()
{
   fastio
   int n,k;
   cin>>n>>k;
   map<pair<int,int>,int>m1;
   int canRemove=((n-2)*(n-2+1))/2;
   if(k>canRemove){cout<<"-1"<<endl;exit(0);}
   for(int i=1;i<=n-1;i++)
     for(int j=i+1;j<=n;j++)
       m1[{i,j}]=1;
   int flag=0;
   for(int i=1;i<=n-2 && k;i++)
     for(int j=i+1;j<=n-1 && k;j++)
       k--,m1[{i,j}]=0;
     int c=0;
     vector<pi >res;
     for(int i=1;i<=n;i++)
     {
       for(int j=i+1;j<=n;j++)
       {
         if(m1[{i,j}]==1)
         {
           c++;
           res.pb(mkp(i,j));
         }
       }
     }
   cout<<c<<endl;
   rep(i,res.size())cout<<res[i].ff<<" "<<res[i].ss<<endl;
   return 0;
}


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

using namespace std;

int main(){
  int n;
  string str;
  string apple = "apple";
  string peach = "peach";
  string::iterator i, j;

  getline(cin, str);

  i = str.begin();
  j = str.begin();
  while(1){
    i = search(i, str.end(), apple.begin(), apple.end());
    j = search(j, str.end(), peach.begin(), peach.end());
    if(i == str.end() && j == str.end()) break;

    if(i < j){
      i = str.erase(i, i+apple.size());
      str.insert(i, peach.begin(), peach.end());
    }else{
      j = str.erase(j, j+peach.size());
      str.insert(j, apple.begin(), apple.end());
    }
  }

  cout << str << endl;
  return 0;
}

Measured memory_bytes: 0
//     THE ONLY WAY IS UP
 
#include<bits/stdc++.h>
 
#define ll              long long int
#define ld              long double
#define f1(i, a, b)     for(ll i = a; i < b; i++)
#define f2(a, b)        for(auto a : b)
#define ar(v, i)        v[i]
#define ar_(v, i, j)    v[i][j]
#define in_(x)          ll x; cin >> x;
#define ino_(type, x)   type x; cin >> x;
#define pb              push_back
#define nl              "\n"
#define tcase(t)        ll t; cin >> t; f1(z, 0, t)
using namespace std;

int main(){
    ino_(ld, x);
    ld a = 100;
    ld b = log(x/a);
    ll res = b / log(1.01);
    ll v = 100; ll count = 0;
    while(true){
        // cout << res << " " << ceil(pow(1.01, res)) << nl;
        // if(pow(1.01,res) >= x/100)
        //     break;
        // else
        //     res++;
        if(v >= x){
            break;
        }else{
            v= v*1.01;
        }
        count++;
    }
    cout << count << nl;
}

Measured memory_bytes: 3752
#include <iostream>
#include<bits/stdc++.h>
#include <string>
#include <stdlib.h>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<fstream>
#include<typeinfo>
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define repi(i,a,b)  for(ll i=a;i<b;i++)
#define repj(j, a, b) for (ll j = a; j < b;j++)
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector< pii >
#define mod 1000000007
#define lim 100001
 
using namespace std;
ll factorial(ll n){return (n==1 || n==0) ? 1: n * factorial(n - 1); }
int max3(int a,int b,int c){ return max(a, max(c, b));}
int gcd(int a,int b){if(a==0){return b;}else{return gcd(b % a, a);}}
ll power(ll a, ll n){if(n==1) return a; else if(n==0) return 1; else{ ll r = power(a, n / 2); if(n%2==0) return r * r; else return r * a * r;}}
ll nCr(ll n, ll r) { return ((factorial(n)) / (factorial(n - r) * factorial(r))); }
void dfs(vector< vector<int > >& v,vi& check,int start){check[start - 1] = 1;repj(j, 0, v[start-1].size()){if(!check[v[start-1][j]-1]){dfs(v, check, v[start - 1][j]);}}}
bool isPrime(ll n) { if (n <= 1) return false;if (n <= 3)return true; if (n % 2 == 0 || n % 3 == 0)return false; for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }
//works under 2 till 1e12
 
int i, j;
 
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int t;
   cin >> t;
   vi arr(100001);
   for(int i=0;i<t;i++){
       int num;
       cin>>num;
       arr[num]++;
   }
   ll sum=0;
   for(int j=0;j<100001;j++){
           sum+= arr[j]*j;
    }
   int q;
   cin>>q;
   for(int i=0;i<q;i++){
       int b,c;
       cin>>b>>c;
       ll num = arr[b]*(c-b);
       sum+=num;
       arr[c] += arr[b];
       arr[b] = 0;
       cout<<sum<<endl;
   }
   return 0;
}



Measured memory_bytes: 3696
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


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

    ll a, b, c;
    cin >> a >> b >> c;
    if(b * c >= a) cout << "Yes" << endl;
    else cout << "No" << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

int main() {
long long n;
cin >> n;
long long sum=0,sum1=0;
for(long long i =1;i<=n;i++){
if(i%3 == 0 || i%5 ==0){
	sum1+=i;
}
sum +=i;
}
cout << sum - sum1 << endl;

return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x,y,a,b,c,i,j;
    cin>>x>>y>>a>>b>>c;
    vector<ll>p(a);
    vector<ll>q(b);
    vector<ll>r(c);
    for(i=0;i<a;++i)
        cin>>p[i];
    for(i=0;i<b;++i)
        cin>>q[i];
    for(i=0;i<c;++i)
        cin>>r[i];
    sort(p.begin(),p.end());
    sort(q.begin(),q.end());
    // sort(r.begin(),r.end());
    ll sum=0;
   for(i=0;i<x;++i)
    r.push_back(p[a-1-i]);
    for(i=0;i<y;++i)
    r.push_back(q[b-1-i]);
    sort(r.rbegin(),r.rend());
       for(i=0;i<x+y;++i)
       sum+=r[i];
    cout<<sum;

}

Measured memory_bytes: 6512
N,K = map(int, input().split())
S=0
for k in range(K,N+2):
    a1 = (k-1)*k / 2
    aN = (N-k+1 + N) * k/2
    S += (aN - a1+1)
S = S % (10**9+7)
print(int(S))

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

vector<int> primes={2,3,5,7};
int primes_extend(int calc_from, int calc_to);

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

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

	sort(a.begin(),a.end());

	primes_extend(10,100);
	primes_extend(100,10000);
	primes_extend(10000,1000000);

	vector<bool> ng(1000000+1);
	for (int i=0;i<=1000000;++i)
	{
		ng[i]=false;
	}

	for (int i=0;i<primes.size();++i)
	{
	//	ng[primes[i]]=true;
	}
#ifdef NEVER_DEFINED
	for (int i=1;i<30;++i)
	{
		fprintf(stderr,"%d %d\n",i,(int)ng[i]);
	}
#endif

	int count=0;
	int maxa=a[n-1];
	for (int i=0;i<n;++i)
	{
		//fprintf(stderr,"i %d a[i] %d\n",i,a[i]);
		if ((i+1<n)&&(a[i]==a[i+1]))
		{
			// do nothing
		}
		else
		{
			if (ng[a[i]]==false)
			{
				//fprintf(stderr,"count++\n");
				++count;
			}
		}

		if ((i>0)&&(a[i]==a[i-1]))
		{
			continue;
		}

		for (int aa=a[i];aa<=maxa;aa+=a[i])
		{
			ng[aa]=true;
		}
	}
	cout << count << endl;
}

int primes_extend(int calc_from, int calc_to)
{

	for (int i=calc_from;i<=calc_to;++i)
	{
		int j;
		int loop_max=sqrt(i);
		for (j=0;(primes[j]<=loop_max)&&(j<primes.size());++j)
		{
			if ((i%primes[j])==0)
			{
				// not prime...
				break;
			}
		}
		if ((j>=primes.size())||(primes[j]>loop_max))
		{
			primes.push_back(i);
		}
	}
	//fprintf(stderr,"count: %d\n",primes.size());

	return 0;
}







Measured memory_bytes: 4768
#include <bits/stdc++.h>
#define pb push_back

using namespace std;

int main(){
  int x1,x2,x3,x4,y1,y2,y3,y4,xx,yy;
  cin >> x1 >> y1 >> x2 >> y2;
  xx=x1-x2; //cout << xx << endl;
  yy=y1-y2; //cout << yy << endl;
  y3=y2-xx;
  x3=x2+yy;
  y4=y3+yy;
  x4=x3+xx;
  printf("%d %d %d %d\n",x3,y3,x4,y4);
  return 0;
}


Measured memory_bytes: 256
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


tailrec fun gcd(a: Long, b: Long): Long {
    if (b == 0L) return a
    return gcd(b, a%b)
}

fun solve() {
    val (N, K) = rd.readIntArray()
    val A = rd.readLongArray().sorted()

    if (N == 1) {
        if (K.toLong() == A[0]) {
            println("POSSIBLE")
        } else {
            println("IMPOSSIBLE")
        }
        return
    }

    if (A.contains(K.toLong())) {
        println("POSSIBLE")
        return
    }

    val AMAX = A.last()
    if (AMAX < K) {
        println("IMPOSSIBLE")
        return
    }

    var cd = A[0]
    for (i in 1 until N) {
        cd = gcd(cd, A[i])
    }

    val ans = if (K.toLong()%cd == 0L) "POSSIBLE" else "IMPOSSIBLE"
    println(ans)
}


//val rd = debug.Reader("agc", "018", "a", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!!
    } catch (e: Exception) { throw e }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


Measured memory_bytes: 58516
from heapq import heappush, heappop

input = raw_input
x,y,a,b,c = map(int, input().split())

p_vals = []
ps = map(int, input().split(" "))
for p in ps:
    heappush(p_vals, -p)

q_vals = []
qs = map(int, input().split(" "))
for q in qs:
    heappush(q_vals, -q)

r_vals = []
rs = map(int, input().split(" "))
for r in rs:
    heappush(r_vals, -r)

# large to small
for _ in range(x):
    val = -heappop(p_vals)
    heappush(r_vals, -val)

for _ in range(y):
    val = -heappop(q_vals)
    heappush(r_vals, -val)

#p_vals2 = [-heappop(p_vals) for _ in range(x)]
#q_vals2 = [-heappop(q_vals) for _ in range(y)]

out = 0
for _ in range(x+y):
    val = -heappop(r_vals)
    out += val


print(out)

Measured memory_bytes: 76872
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <math.h>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <numeric>
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vector<int>>;

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

vb seen;
vi k;
vi d;
vi f;

int dfs(const Graph &G, int v, int t) {
    seen[v] = true;
    d[v] = t;
    REP(i, k[v]) {
        int next_v = G[v][i];
        if (seen[next_v]) continue;
        t = dfs(G, next_v, t+1);
    }
    t += 1;
    f[v] = t;
    return t;
}

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

    int n; cin >> n;
    Graph G(n);
    REP(i, n) {
        int u; cin >> u;
        int tmp; cin >> tmp;
        k.push_back(tmp);
        REP(j, tmp) {
            int v; cin >> v;
            G[i].push_back(v-1);
        }
    }

    seen.assign(n, false);
    d.assign(n, 0);
    f.assign(n, 0);

    int t = 0;
    REP(i, n) {
        if (seen[i]) continue;
        t = dfs(G, i, t+1);
    }

    REP(i, n) {
        cout << (i+1) << " " << d[i] << " " << f[i] << "\n";
    }
}


Measured memory_bytes: 3196
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<int> p(N);
    for(int i=0; i<N; i++) cin >> p[i];

    int ans = 0;
    for(int i=1; i+1<N; i++) {
        int cnt = 0;
        cnt += (p[i] < p[i+1]);
        cnt += (p[i] < p[i-1]);
        if(cnt == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }

    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        int b, m, e;
        cin >> b >> m >> e;
        int k;
        k = e - b;
        if(k == 0) {}
        else k--;
        int p;
        p = b + ((k+(e-m)) % (e-b));
        rotate(v.begin()+b, v.begin()+m, v.begin()+e);
    }

    for(int i = 0; i < v.size()-1; i++){
        cout << v[i] << " ";
    }
    cout << v[v.size()-1] << endl;
}


Measured memory_bytes: 3164
for e in iter(input,'0 0 0'):
 N,M,S=map(int,e.split());N*=N
 d=[[0]*-~S for _ in[0]*-~N];d[0][0]=1
 for i in range(1,N+1):
  for j in range(i,S+1):
   d[i][j]+=d[i][j-i]+d[i-1][j-i]-(M+1<=j and d[i-1][j-M-1])
 print(d[N][S]%10**5)


Measured memory_bytes: 11972
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <cmath>

using namespace std;

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

	int** v = new int*[n];
	int tmp;
	for (int i = 0; i < n; i++) {
		v[i] = new int[d];
		for (int j = 0; j < d; j++) {
			scanf("%d", &v[i][j]);
		}
	}

	int ans = 0;

	for (int i = 1; i < n; i++) {
		for (int j = 0; j < i; j++) {
			tmp = 0;
			for (int k = 0; k < d; k++) {
				tmp += (v[i][k] - v[j][k])*(v[i][k] - v[j][k]);
			}
			if (((int)sqrt(tmp))*((int)sqrt(tmp)) == tmp) ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

const string ok = "Yes", ng = "No";

string solve()
{
    int h,w;
    cin >>h >>w;

    int ct[26]={};
    rep(i,h)
    {
        string s;
        cin >>s;
        rep(j,w) ++ct[s[j]-'a'];
    }

    vector<vector<bool>> done(h,vector<bool>(w));

    int c[5]={};
    rep(i,h)rep(j,w)if(!done[i][j])
    {
        set<pi> s;
        s.insert(pi(i,j));
        s.insert(pi(i,w-1-j));
        s.insert(pi(h-1-i,w-1-j));
        s.insert(pi(h-1-i,j));

        int S = s.size();
        ++c[S];
        for(const auto &p:s) done[p.fi][p.se]=true;
    }

    while(c[1]>0)
    {
        bool found = false;
        rep(j,26)
        {
            if(ct[j]>0&&ct[j]%2==1)
            {
                --ct[j];
                --c[1];
                found = true;
                break;
            }
        }
        if(!found) break;
    }

    while(c[2]>0)
    {
        bool found = false;
        rep(j,26)
        {
            if(ct[j]>0&&ct[j]%4!=0 && ct[j]%2==0)
            {
                ct[j]-=2;
                --c[2];
                found = true;
                break;
            }
        }
        if(!found)
        {
            rep(j,26)
            {
                if(ct[j]>0&&ct[j]%2==0)
                {
                    ct[j]-=2;
                    --c[2];
                    found = true;
                    break;
                }
            }
        }

        if(!found) break;
    }

    while(c[4]>0)
    {
        bool found = false;
        rep(j,26)
        {
            if(ct[j]>0&&ct[j]%4==0)
            {
                ct[j]-=4;
                --c[4];
                found = true;
                break;
            }
        }
        if(!found) break;
    }

    // printf("%d %d %d\n", c[1],c[2],c[4]);
    // rep(i,5) printf("ct[%d] %d\n", i,ct[i]);
    rep(i,5)if(c[i]>0) return ng;
    rep(i,26)if(ct[i]>0) return ng;
    return ok;
}

int main()
{
    cout << solve() << endl;
    return 0;
}


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

int main(){
	int n = 4;
	cin >> n;
	char s[n];
	for(int i = 0; i < n; i++)
		cin >> s[i];
	
	int redCnt = 0;
	int blueCnt = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == 'R') redCnt++;
		else blueCnt++;
	}
	if(redCnt > blueCnt) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll, ll> PLL;
#define chmax(x, y) do { x = max(x, y); } while(0)
#define chmin(x, y) do { x = min(x, y); } while(0)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<ll>(a); i < static_cast<ll>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;

signed main() {
  map<ll, ll> mp;
  ll N;
  cin >> N;
  vector<ll> a(N);
  rep(i, N)
    cin >> a[i];

  ll ans = 0;
  rep(i, N) {
    ans += mp[i - a[i]];
    mp[i + a[i]]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 27388
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long int lli;
int main(){
	int n,k;
	cin >> n >> k;
	
	vector<lli> x(n), y(n);
	for(int i=0; i<n; i++){
		cin >> x[i] >> y[i];
	}
	
	lli ans = 6*1e18;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			for(int s=0; s<n; s++){
				for(int t=s+1; t<n; t++){
					lli xmax = max(x[i], x[j]);
					lli xmin = min(x[i], x[j]);
					lli ymax = max(y[s], y[t]);
					lli ymin = min(y[s], y[t]);
					int count = 0;
					for(int c=0; c<n; c++){
						if(xmin <= x[c] && x[c] <= xmax &&
						ymin <= y[c] && y[c] <= ymax){
							count++;
						}
					}
					if(count >= k){
						ans = min(ans, (xmax-xmin)*(ymax-ymin));
					}
				}
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
        int A[] = new int[3];
        for(int i = 0; i < 3; i++){
            A[i] = Integer.parseInt(input[i]);
        }
        Arrays.sort(A);

        int n = Integer.parseInt(br.readLine());
        while(n-- > 0)  A[2] = A[2]*2;
        System.out.println(A[0]+A[1]+A[2]);
    }
}

Measured memory_bytes: 21076
#include<iostream>
#include<functional>
#include<iomanip>
#include<algorithm>
#include<vector>

using namespace std;
using ll = long long;

#define rep(i,n) for(int i = 0; i <(n); ++i)
#define ALL(n) (n).begin(),(n).end()
#define pb push_back
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}

int main(){
  int a,b; cin >> a >> b;
  if(b%a == 0)
    cout << b + a << endl;
  else
    cout << b - a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

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

int main(int argc, char **argv)
{
	ll A, B; cin >> A >> B;
	ll g = gcd(A, B);
	// std::cout << g << std::endl;

	ll res{0};
	for (ll i = 2; i*i <= g; ++i)
	{
		if (g%i == 0)
		{
			++res;
			while (g%i==0)
			{
				g/=i;
			}
		}
	}
	if (g != 1) ++res;
	std::cout << 1+res << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<tuple>
#include<cassert>
using namespace std;


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

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

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

const int mod = pow(10, 9) + 7;



int main(){
  ll n;
  cin >> n;
  ll a, b;
  ll sqrtn = sqrt(n);
  ll ans = LLONG_MAX;
  for(ll i = 1; i * i <= n; ++i){
    if(n % i) continue;
    ll j = n / i;

    ans = min(ans, i + j);
  }

  cout << ans - 2 << endl;
}

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

int main(){
    int H,W;
    cin >> H >> W;
    char s[100][100];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> s[i][j];
        }
    }

    bool ans = true;
    int checkSum = 0;
    for(int i = 0; i < H; i++){
        if(!ans) break;
        int up = i - 1;
        int down = i + 1;
        for(int j = 0; j < W; j++){
            checkSum = 0;
            int right = j + 1;
            int left = j - 1;
            // cout << s[i-1][j-1] << s[i-1][j] << s[i-1][j+1] << endl << s[i][j-1] << "C" << s[i][j+1] << endl << s[i+1][j-1] << s[i+1][j] << s[i+1][j+1] <<endl << endl;;
           
            if(s[i][j] == '#'){
                // if(up > 0){
                    if(s[up][j] == '#'){
                        checkSum++;
                    }
                // }
        
                // if(left > 0){
                    if(s[i][left] == '#') checkSum++;
                // }
               
                // if(down < H){
                    if(s[down][j] == '#') checkSum++;
                // }
                
                // if(right < W){
                    if(s[i][right] == '#') checkSum++;
                // }
                // cout << s[i-1][j-1] << s[i-1][j] << s[i-1][j+1] << endl << s[i][j-1] << s[i][j] << s[i][j+1] << s[i+1][j-1] << s[i+1][j] << s[i+1][j+1] <<endl;
                if(checkSum==0){
                    ans = false;
                    break;
                }
            }

        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main(){
  int X;
  cin >> X;
  int ma=1;
  for(int i=2;i<=X;i++){
    for(int j=2;;j++){
      int bp=pow(i,j);
      if(bp<=X){
        if(ma<bp){
          ma=bp;
        }
      }else{
        break;
      }
    }
  }
  cout << ma << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;

int main(void)
{
	int n,m;
	cin>>n>>m;
	vector<ll> x(n),y(m);
	n-=1;
	m-=1;
	ll prev;
	cin>>prev;
	for (int i = 1; i <=n; i++) {
		cin>>x[i];
		int t=x[i];
		x[i]-=prev;
		prev=t;
	}
	cin>>prev;
	for (int i = 1; i <=m; i++) {
		cin>>y[i];
		int t=y[i];
		y[i]-=prev;
		prev=t;
	}
	ll sum=0;
	for (int i = 1; i <= m; i++){
		sum=(sum+y[i]*i*(m-i+1))%MOD;
	}
	ll sum1=0;
	for (int i = 1; i <= n; i++){
		sum1=(sum1+x[i]*i*(n-i+1))%MOD;
	}
	sum=(sum*sum1)%MOD;
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

#define f first
#define s second
#define rep(i, n) for(int i = 0 ; i < n ; i++)

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

int main(){
  int N, M;
  while(cin >> N >> M, N|M){
    vector<PP> v(M);
    rep(i, M) cin >> v[i].f >> v[i].s.f >> v[i].s.s;
    
    sort(v.begin(), v.end());
    
    bool infected[20010];
    memset(infected, false, sizeof(infected));
    infected[1] = true;
    
    rep(i, M){
      int from, to;
      from = v[i].s.f, to = v[i].s.s;
      if(infected[from]) infected[to] = true;
    }
    
    int ans = 0;
    
    for(int i = 1 ; i <= N ; i++){
      if(infected[i]) ans++;
    }
    cout << ans << endl;

  }
  return 0;
}

Measured memory_bytes: 1544
#include <bits/stdc++.h>
using namespace std;
long long lb(long long n){
	long long low=1,high=n;
	long long ans;
	while(low<=high){
		long long mid=(low+high)/2;
		long long val=(mid*(mid+1))/2;
		if(val==n){ans=mid;break;}
		else if(val<n){ans=mid; low=mid+1;}
		else{ high=mid-1;}
	}
	return ans;
}
int main() {
	long long n;cin>>n;
	vector<long long> fact;
	for(long long i=2;i<sqrt(n);i++){
		if(!(n%i)){
			long long cnt=0;
			while(!(n%i)){n/=i;cnt++;}
			fact.push_back(cnt);
		}
	}
	if(n!=1){fact.push_back(1);}
	long long ans=0;
	for(int i=0;i<fact.size();i++){
		ans+=lb(fact[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
   // freopen("input.txt", "r", stdin);
    SPEED
    int n;
    cin >> n;
    FOR(a, 1, 10) {
        if (n % a) continue;
        int b = n / a;
        if (b < 10 && b >= 1) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */

Measured memory_bytes: 256