akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut s = HashMap::new();
    for i in 0..n {
        let mut ss = read::<String>().chars().collect::<Vec<_>>();
        ss.sort();
        *s.entry(ss).or_insert(0) += 1;
    }

    let mut ans = 0i64;
    for &v in s.values() {
        ans += v * (v - 1) / 2;
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 13980
#include <algorithm>
#include <cmath>
#include <cstdio>

#define int long long
#define dotimes(i, n) for (int i : range(n))

using namespace std;

class range {
  class iterator {
    int i, s;
  public:
    iterator(int i, int s): i(i), s(s) {}
    int& operator*() {
      return i;
    }
    void operator++() {
      i += s;
    }
    bool operator!=(iterator const& that) {
      return i < that.i;
    }
  };
  iterator b, e;
public:
  range(int e): b({0, 1}), e({e, 1}) {}
  range(int b, int e): b({b, 1}), e({e, 1}) {}
  range(int b, int e, int s): b({b, s}), e({e, s}) {}
  iterator begin() {
    return b;
  }
  iterator end() {
    return e;
  }
};

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

void wint(int n) {
  printf("%lld\n", n);
}

template<typename T>
inline int size(T container) {
  return static_cast<int>(container.size());
}

template<typename T>
inline bool maxs(T& a, T const& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
inline bool mins(T& a, T const& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  const int k = rint();
  int rf[8] = {}, p[8 - k];
  bool cf[8] = {};
  dotimes(i, k) {
    int r = rint();
    int c = rint();
    rf[r] = c + 1;
    cf[c] = true;
  }
  for (int i = 0, j = 0, c = 0; i < 8; i++)
    if (!rf[i]) {
      while (cf[c])
        c++;
      p[j++] = ++c;
    }
  int a[8];
  for (;; next_permutation(p, p + 8 - k)) {
    for (int i = 0, j = 0; i < 8; i++)
      a[i] = rf[i] ? rf[i] : p[j++];
    dotimes(i, 8)
      dotimes(j, i)
        if (abs(a[j] - a[i]) == abs(j - i))
          goto failed;
    break;
  failed:
    ;
  }
  dotimes(i, 8) {
    dotimes(j, 8)
      putchar(a[i] == j + 1 ? 'Q' : '.');
    putchar('\n');
  }
  return 0;
}



Measured memory_bytes: 2680
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::*;
use std::ops::*;
use std::*;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused)]
fn rl() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused)]
fn rw<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|word| T::from_str(word).unwrap())
        .collect()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

#[allow(unused)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        {
            let entries = &[
                $((
                    &stringify!($arg).to_string() as &fmt::Debug,
                    &($arg) as &fmt::Debug,
                )),*
            ];
            eprintln!("{:?}", DebugMap(entries));
        }
    };
}

#[allow(unused)]
struct DebugMap<'a>(&'a [(&'a fmt::Debug, &'a fmt::Debug)]);

impl<'a> std::fmt::Debug for DebugMap<'a> {
    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
        let mut m = fmt.debug_map();
        for &(key, value) in self.0.iter() {
            m.entry(key, value);
        }
        m.finish()
    }
}

// -----------------------------------------------
// Polyfill
// -----------------------------------------------

#[derive(PartialEq, Eq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

#[allow(unused)]
macro_rules! eprintln {
    ($($arg:expr),*) => { _eprintln(format_args!($($arg),*)) }
}

fn _eprintln(args: fmt::Arguments) {
    let err = std::io::stderr();
    let mut err = err.lock();
    err.write_fmt(args).unwrap();
    err.write(b"\n").unwrap();
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn main() {
    let w = rw::<i32>();
    let (a, b) = (w[0], w[1]);
    println!("{}", (b - a) * (b - a - 1) / 2 - a);
    return;
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_ok() {
        assert_eq!(7, 1 + 2 * 3);
    }
}


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

long long n, a, b, d;
int main() {
	cin>> n>> a>> b;
	d = b - a;
	cout<< (d%2? min(a-1, n-b) + 1 + (d-1)/2 : d/2);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
    	Scanner sn = new Scanner(System.in);
      	int n = sn.nextInt();
      	int x[] = new int[n];
      	for(int i = 0; i < n; i++) {
        	x[i] = sn.nextInt();
        }
      	Long res = 0L;
      	int max = x[0];
      	for(int i = 1; i < n; i++) {
        	if( max > x[i]) {
            	res = res + max - x[i]; 
            } else {
            	max = x[i];
            }
        }
      	System.out.println(res);
    }
}

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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define endl '\n'
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<'\n';
#define mxn 100005
using namespace std;

int main()
{
    FLASH
    int k;
    string s;
    cin >> k >> s;
    for(int i = 0; i < k && i < s.size(); i++)
        cout << s[i];
    if(s.size() > k)
        cout <<"...";

    return 0;
}


Measured memory_bytes: 3600
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var M = cin.ReadInt;

            var ans = 0;

            if (N >= 2) ans += N *( N - 1) / 2;
            if (M >= 2) ans += M * (M - 1) / 2;

            WriteLine(ans);
        }

    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }


        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

string S[50];

int main()
{
	int H, W, cnt;

	cin >> H >> W;
	rep(i, H) cin >> S[i];

	rep(i, H) {
		rep(j, W) {
			if (S[i][j] == '#') continue;

			cnt = 0;

			for (int h = -1; h <= 1; h++) {
				for (int w = -1; w <= 1; w++) {
					if ((0 <= i + h && i + h < H) &&
						(0 <= j + w && j + w < W) &&
						(S[i + h][j + w] == '#')) cnt++;
				}
			}

			S[i][j] = '0' + cnt;
		}
	}

	rep(i, H) cout << S[i] << endl;

	return 0;
}


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

int main() {

  long N;
  long long W;
  cin >> N >> W;
  
  long long w[N],v[N];
  for (int i = 0; i < N; i++) {
    cin >> w[i] >> v[i];
  }
  
  long long dp[N+1][100005];
  for (int i = 0; i <= N; i++) {
    for (int sumV = 0; sumV < 100005; sumV++) {
      dp[i][sumV] = 1LL << 60;
    }
  }
  dp[0][0]=0;
  
  for (int i = 0; i < N; i++) {
    for (int sumV = 0; sumV < 100005; sumV++) {
      if (sumV-v[i] >= 0 ){
        dp[i+1][sumV] = min(dp[i+1][sumV], dp[i][sumV-v[i]]+w[i]);
      }
      dp[i+1][sumV]= min(dp[i+1][sumV],dp[i][sumV]);
    }
  }

  int ans = 0;
  for (int sumV = 100004; sumV >= 0; sumV--) {
    if(dp[N][sumV]<=W){
      ans = sumV;
      break;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 79104
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- 整数の入力
    a <- getLine
    -- 出力
    putStrLn $ "ABC" ++ a


Measured memory_bytes: 380
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
#define MAXN 100000
long long Sum[MAXN+5],n,Ans=0;
int main(){
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&Sum[i]);
    for(int i=1;i<=n;i++){
        Ans+=Sum[i]/2;
        Sum[i]%=2;
        if(i<n&&Sum[i]>0&&Sum[i+1]>0){
            Ans++;
            Sum[i]--;
            Sum[i+1]--;
        }
    }
    printf("%lld\n",Ans);
    return 0;
}

Measured memory_bytes: 1024
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, ns().split()))
ns = lambda: stdin.readline()

a, b = na()

ans = 0
if (a > 0 and a < 10) and (b > 0 and b < 10):
    ans = a * b
else:
    ans = -1    

print(ans)


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

int main() {
  string s; cin>>s;
  int count=0;
  
  for(int i=0; i<4; ++i){
    for(int j=i+1; j<4; ++j){
      if(s[i]==s[j]){
        count++;
      }
    }
  }
  if(count==2){
    cout << "Yes" <<endl;
  }else{
    cout << "No" << endl;
  }
}
        

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	char board[a][b];
	for(int i=0 ; i<a ; i++)
	{
		getchar();
		for(int j=0 ; j<b ; j++)
		{
			scanf("%c",&board[i][j]);
		}
	}
	for(int i=0 ; i<b+2 ; i++)printf("#");
	printf("\n");
	for(int i=0 ; i<a ; i++)
	{
		printf("#");
		for(int j=0 ; j<b ; j++)printf("%c",board[i][j]);
		printf("#\n");
	}
	for(int i=0 ; i<b+2 ; i++)printf("#");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<float.h>
using namespace std;


int main() {
    int a, b,c,d;
    cin >> a>>b;
    if (a*b % 2 == 0) {
        cout << "Even" << endl;
  }
    else cout << "Odd" << endl;
    
  
    return 0;
}

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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n-1; i >= a; i--)
#define pb              push_back
#define lb              lower_bound
#define ub              upper_bound
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod;  }

const ll inf = 1e17;
const int nax = 1e4 + 5;

bool cmp(const pll&a,const pll &b)
{
	if(a.first*b.second > b.first*a.second)
	{
		return 1;
	}
	else if(a.first*b.second < b.first*a.second)
	{
		return 0;
	}
	else
	{
		return a.second<b.second;
	}
}
vector<pll>v;
ll n;

ll dp[nax];

ll solve(ll h)
{
	if(h<=0)
		return 0;

	if(dp[h]!=-1)
		return dp[h];

	ll ans = inf;
	forn(i,0,n)
	{
		ans=min(ans,solve(h-v[i].first)+v[i].second);
	}
	dp[h] = ans;
	return dp[h];
}

int main()
{
	speedup_IO;
	ll h;
	cin>>h>>n;

	ll a,b;
	
	//ll mini = inf;
	//ll mini2 = inf;
	forn(i,0,n)
	{
		cin>>a>>b;
		//mini = min(mini,a);
		//mini2 = min(mini2,b);
		v.pb({a,b});
	}
	forn(i,0,h+1)
	{
		dp[i] = -1;
	}

	//sort(all(v),cmp);
	// for(auto x:v)
	// {
	// 	cout<<x.first<<" "<<x.second<<endl;
	// 	cout<<((1.0)*x.first/x.second)<<endl;
	// }

	// ll ans = 0;

	// while(h>0)
	// {
	// 	forn(i,0,n)
	// 	{
	// 		if(v[i].first<=h)
	// 		{
	// 			//cout<<v[i].second<<endl;
	// 			h-=v[i].first;
	// 			ans+=v[i].second;
	// 			break;
	// 		}
	// 	}

	// 	if(h<mini && h!=0)
	// 	{
	// 		ans+=mini2;
	// 		break;
	// 	}
	// }

	cout<<solve(h)<<endl;
	// forn(i,0,h+1)
	// cout<<dp[i]<<" ";
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
long long h,w,ans;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>h>>w;
    if (h==1 || w==1){
        cout<<1;
        return 0;
    }
    if (w%2==0 || h%2==0){
        ans=w;
        ans*=h;
        ans/=2;
        cout<<ans;
    }
    else {
        ans=w;
        ans*=(h-1)/2;
        ans+=(w+1)/2;
        cout<<ans;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

int main(){
    double px,py,r,x1,y1,x2,y2,x3,y3,n;
    double a1,b1,c1,a2,b2,c2;

    scanf("%lf", &n);
    for(int i = 0; i < n; i++){
        scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);

        // (x-a)^2+(y-b)^2=r^2$KFM$C9~$`$+?

        a1 = 2 * ( x2 - x1 );
        b1 = 2 * ( y2 - y1 );
        c1 = pow(x1,2) - pow(x2,2) + pow(y1,2) - pow(y2,2);

        a2 = 2 * ( x3 - x1 );
        b2 = 2 * ( y3 - y1 );
        c2 = pow(x1,2) - pow(x3,2) + pow(y1,2) - pow(y3,2);

        px = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
        py = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
        r = sqrt( pow((px - x1),2) + pow((py - y1),2) );
        printf("%.3f %.3f %.3f\n", px, py, r);
    }

    return 0;
}

Measured memory_bytes: 1084
#include <stdio.h>

int main() {
  int x, a, b;
  int dA, dB;
  
  scanf("%d %d %d", &x, &a, &b);
  dA = x - a;
  dB = x - b;
  if(dA < 0) dA = -dA;
  if(dB < 0) dB = -dB;
  
  if(dA > dB) printf("B\n");
  else printf("A\n");
  
  return 0;
}
  

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    double a,b,t;cin>>a>>b>>t;
    co((int)(b*floor((t+0.5)/a)));
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	string A, B;
	cin >> A >> B;

	int N = max(SZ(A), SZ(B));

	string sA, sB;
	while (SZ(A) + SZ(sA) < N)sA += '0';
	while (SZ(B) + SZ(sB) < N)sB += '0';

	A = sA + A;
	B = sB + B;

	rep(i, 0, N)
	{
		if (A[i] < B[i])
		{
			cout << "LESS" << endl;
			return 0;
		}
		if (A[i] > B[i])
		{
			cout << "GREATER" << endl;
			return 0;
		}
	}

	cout << "EQUAL" << endl;

	return 0;
}

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

using namespace std;


int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int turnA = c / b + (c % b == 0 ? 0 : 1);
    int turnB = a / d + (a % d == 0 ? 0 : 1);
    
    if (turnB >= turnA)
    {
        cout << "Yes" << endl;
    }
    else
    { 
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>   //???????????£???ver ??§????????°????????¨atoi????????????ASCII????????§??????????????£??????
#include<stdlib.h>
int main(){
    int sum = 0, suuti = 0, i, n;
    char num[1001] = {};
    for( i = 0;; i++){
        scanf("%c",&num[i]);
        if( num[0] == '0' ){
            break;
        }
        suuti = atoi( &num[i] );

        sum += suuti;

        if( num[i] == '\n' ){
            printf("%d\n", sum);
            sum = 0;
            for( n = 0; n <= i; n++ ){
                num[n] = 0;
            }
            i = -1;
        }

    }
    return 0;
}

Measured memory_bytes: 552
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int  n;
  long long cnt;
  string S;
  cin >> n >> S;
  cnt = 0;
  vector<int> r(n), g(n), b(n), fr(n), fg(n), fb(n);
  
  if(S[0] == 'R'){
    r[0]++;
    fr[0]=1;
  }else if(S[0] == 'G'){
    g[0]++;
    fg[0]=1;
  }else{
    b[0]++;
    fb[0]=1;
  }
  
  for(int i = 1; i < n; i++){
    if(S[i] == 'R'){
      r[i] = r[i-1] + 1;
      g[i] = g[i-1];
      b[i] = b[i-1];
      fr[i] = 1;
    }else if(S[i] == 'G'){
      g[i] = g[i-1] + 1;
      r[i] = r[i-1];
      b[i] = b[i-1];
      fg[i] = 1;
    }else{
      b[i] = b[i-1] + 1;
      g[i] = g[i-1];
      r[i] = r[i-1];
      fb[i] = 1;
    }
  }
  
  
 
  for(int i=0; i<n-1; i++){
    for(int j = i+1; j<n; j++){
      if(fr[i]*fg[j]==1 || fg[i]*fr[j]==1){
       
        if(2*j-i <= n-1 && fb[2*j-i]==1 && b[n-1]!=b[j]){
          cnt += b[n-1]-b[j]-1;
        }else if(!(2*j-i <= n-1 && fb[2*j-i]==1)){
          
          cnt += b[n-1] -b[j];
        }
      }else if(fr[i]*fb[j]==1 || fb[i]*fr[j]==1){
        if(2*j-i <= n-1 && fg[2*j-i]==1 && g[n-1]!=g[j]){
          cnt += g[n-1]-g[j]-1;
        }else if(!(2*j-i <= n-1 && fg[2*j-i]==1)){
          cnt += g[n-1] -g[j];
        }
      }else if(fg[i]*fb[j]==1 || fb[i]*fg[j]==1){
        if(2*j-i <= n-1 && fr[2*j-i]==1 && r[n-1]!=r[j]){
          cnt += r[n-1]-r[j]-1;
        }else if(!(2*j-i <= n-1 && fr[2*j-i]==1)){
          cnt += r[n-1] -r[j];
        }
      }
      
    }
  }
  
  cout << cnt <<endl;
}


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

long long f[10000007] = {0};
using namespace std;

int main() {
    int n;
    cin >> n;
    for (int i = 1; i < 10000007; i++) {
        for (int j = i; j < 10000007; j += i) {
            f[j]++;
        }
    }
    long long QAQ = 0;
    for (int i = 1; i <= n; i++) QAQ += i * f[i];
    cout << QAQ << endl;
    return 0;
}

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

// #define int long long

/* short */
#define pb push_back
#define print(Target) cout << Target << '\n'

/* REPmacro */
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}

/* const */
const int INF = INT_MAX;

signed main()
{
  ios::sync_with_stdio(false);
  int n, m;

  while (cin >> n >> m, n || m){
    int less = n, cnt = 0;
    bool t[1024];
    memset(t, true, sizeof(t));
    for (int i = 1;; i++){
      if (t[i]){
        if (cnt == m - 1){
          t[i] = false;
          less--;
          cnt = 0;
          // cout << "t[" << i << "]" << " is " << "nuke" << endl;
          if (less == 0){
            print(i);
            break;
          }
        }else {
          cnt++;
        }
      }
      if (i + 1 > n){
        i = 0;
      }
    }
  }
  
  return (0);
}

Measured memory_bytes: 1192
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */

    int n = sc.nextInt();
    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }

    Map<Integer, Integer> count = new HashMap<>();

    for (int i = 0; i < n; i++){
      count.put(a[i], count.getOrDefault(a[i], 0) + 1);
    }

    if (count.keySet().size() > 3) {
      os.println("No");
      return;
    }

    if (count.keySet().size() == 3) {
      Iterator<Integer> it = count.keySet().iterator();
      int first = it.next();
      int second = it.next();
      int third = it.next();
      if (second != xor(first, third)) {
        os.println("No");
        return;
      }

      int max = Integer.MIN_VALUE;
      int min = Integer.MAX_VALUE;

      for (int key : count.keySet()) {
        max = Math.max(max, count.get(key));
        min = Math.min(min, count.get(key));
      }
      if (Math.abs(max - min) == 0) {
        os.println("Yes");
      } else {
        os.println("No");
      }
    } else if (count.keySet().size() == 2) {
      Iterator<Integer> it = count.keySet().iterator();
      int first = it.next();
      int second = it.next();
      if (first != 0 && second != 0) {
        os.println("No");
        return;
      }
      if (first == 0) {
        first = second;
        second = 0;
      }
      if (count.get(first) == 2 * count.get(second)) {
        os.println("Yes");
      } else {
        os.println("No");
      }
    } else if (count.keySet().size() == 1) {
      if (count.containsKey(0)) {
        os.println("Yes");
      } else {
        os.println("No");
      }
    }
  }

  private static int xor(int a, int b) {
    int res = 0;

    for (int i = 0; i < 32; i++) {
      int mask = 1 << i;
      res += (mask & a) ^ (mask & b);
    }
    return res;
  }
}

Measured memory_bytes: 51232
#include <bits/stdc++.h>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using vec_i64 = vector<i64>;
using vvec_i64 = vector<vec_i64>;

int ctoi(const char c) {
    switch (c) {
        case '0': return 0;
        case '1': return 1;
        case '2': return 2;
        case '3': return 3;
        case '4': return 4;
        case '5': return 5;
        case '6': return 6;
        case '7': return 7;
        case '8': return 8;
        case '9': return 9;
        default: return -1;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    i64 const MOD = 1e9 + 7;

    string K;
    i32 D;
    cin >> K >> D;

    vector<i32> vec_K;
    i32 num_digits = K.size();
    for (int i = 0; i < num_digits; i++) {
        vec_K.emplace_back(ctoi(K.at(i)));
    }
    vvec_i64 dp(2, vec_i64(D, 0));
    dp.at(1).at(0) = 1;
    for (int i = 0; i < num_digits; i++) {
        i32 digit = vec_K.at(i);
        vvec_i64 next_dp(2, vec_i64(D, 0));
        for (int n = 0; n < 10; n++) {
            for (int d = 0; d < D; d++) {
                i32 next_reminder = (d + n) % D;
                if (n < digit) {
                    next_dp.at(0).at(next_reminder) += dp.at(0).at(d) + dp.at(1).at(d);
                }
                else if (n == digit) {
                    next_dp.at(0).at(next_reminder) += dp.at(0).at(d);
                    next_dp.at(1).at(next_reminder) += dp.at(1).at(d);
                }
                else {
                    next_dp.at(0).at(next_reminder) += dp.at(0).at(d);
                }
                next_dp.at(0).at(next_reminder) %= MOD;
                next_dp.at(1).at(next_reminder) %= MOD;
            }
        }
        dp = next_dp;
    }
    i64 res = (dp.at(0).at(0) + dp.at(1).at(0)) - 1;
    if (res < 0) {
        res += MOD;
    }
    cout << res << "\n";
}


Measured memory_bytes: 384
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)

int N,H;
int a[100000],b[100000];
priority_queue<int> q;
int A;
int main()
{
	cin>>N>>H;
	rep(i,N){
		cin>>a[i]>>b[i];
		A=max(a[i],A);
		q.push(b[i]);
	}
	int x;
	int ans=0;
	while(H>0){
		x=-1;
		if(q.empty()) break;
		x=q.top();
		if(x>A){
			H-=x;
			q.pop();
			ans++;
		}
		else{
			break;
		}
	}
	if(H>0){
		ans+=(H-1)/A+1;
	}
	cout<<ans<<endl;
}

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

int main() {
  int r,c,sum = 0;
  cin >> r >> c;
  vector<int>csum(c,0);
  vector<vector<int>>data(r,vector<int>(c));
  for(int i = 0;i < r;i++){
    int rsum = 0;
    for(int j = 0;j < c;j++){
      cin >> data[i][j];
      cout << data[i][j] << " ";
      rsum += data[i][j];
      csum[j] += data[i][j];
      sum += data[i][j];
    }
    cout << rsum << endl;
  }
  for(int i = 0;i < c;i++){
    cout << csum[i] << " ";
  }
  cout << sum << endl;
}



Measured memory_bytes: 3120
from functools import reduce

def gcd(a, b):

    if b == 0:
        return a
    else:
        return gcd(b, a % b)

def gcd_list(numbers):
    return reduce(gcd, numbers)

N, X = map(int, input().split(" "))
Xi = [int(a) for a in input().split()]

def minusX(a):
    return abs(a-X)

Xi = map(minusX, Xi)

d = gcd_list(Xi)
print (d)

Measured memory_bytes: 14748
package main

import "fmt"

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)
	if a > b {
		fmt.Println("0")
	} else if n == 1 {
		if a == b {
			fmt.Println("1")
		} else {
			fmt.Println("0")
		}
	} else {
		// 最大値: A + (N-1)*B
		// 最小値: A*(N-1) + B
		// 区間内の数: A +(N-1)*B - (A*(N-1)+B) + 1
		//        => (N-1)*(B-A) - (B-A) + 1
		//        => (N-2)*(B-A) + 1
		fmt.Println((n-2)*(b-a) + 1)
	}
}


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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define mk make_pair

typedef long long LL;
typedef pair<int,int> Interval;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){
    os << v.first <<" "<<v.second<<endl;
    return os;
}

vector<int> A;
int N;
const int inter = 2e4+5;

int main()
{
    cin >> N;
    _for(i,0,N){
        if(i) printf(" ");
        A.push_back(i*inter + 1);
        printf("%d",A[i]);
    }
    printf("\n");
    reverse(ALL(A));
    _for(i,0,N){
        int a;cin >> a;
        A[a-1] += i;
    }
    _for(i,0,N){
        if(i) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 768
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<vector>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#pragma GCC target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC diagnostic error "-std=c++14"

#define isNum(a) (a>='0'&&a<='9')
#define SP putchar(' ')
#define EL putchar('\n')
#define ri register int

template<class T>
inline void in(T&);
template<class T>
inline void out(const T&);

typedef long long ll;
using std::min;
using std::max;
using std::abs;
using std::sort;
using namespace std;

int n,a[105],ans=1e6+5;

int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    in(n);
    for (ri i=1;i<=n;++i) in(a[i]);
    for (ri x=1;x<=100;++x)
    {
    	int s=0;
    	for (ri i=1;i<=n;++i) s+=(x-a[i])*(x-a[i]);
    	ans=min(ans,s);
	}
    out(ans);EL;
    return 0;
}

template<class T>
void in(T &Re)
{
    T k=0;
    char ch=getchar();
    int flag=1;
    while (!isNum(ch))
	{
        if (ch=='-')
		{
            flag=-1;
        }
        ch=getchar();
    }
    while (isNum(ch))
	{
        k=(k<<1)+(k<<3)+ch-'0';
        ch=getchar();
    }
    Re=flag*k;
}

template<class T>
void out(const T &Wr)
{
    if (Wr<0)
	{
        putchar('-');
        out(-Wr);
    }
	else
	{
        if (Wr<10)
		{
            putchar(Wr+'0');
        }
		else
		{
            out(Wr/10);
            putchar((Wr%10)+'0');
        }
    }
}




Measured memory_bytes: 256
# 4/N = 1/h + 1/n + 1/w
# 4*h*n*w = N*(nw+hn+wh) = N*(h+n)*w + N*hn
# (4*h*n - N*(h+n))*w = N*hn

# 4*h*n > N*(h+n)

L=3501
N=int(input())
def solve():
    for h in range(1,L):
        for n in range(1,h):
            d = 4*h*n - N*(h+n)
            if d > 0 and N*h*n % d == 0:
                print(h,n,N*h*n // d)
                return
solve()


Measured memory_bytes: 38896
#include <stdio.h>
	
	int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	
	if(a==b && b==c){
		printf("1\n");
	} else if(a==b || b==c ||c==a){
		printf("2\n");
	} else{
		printf("3\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b,c,d;
  cin>>a>>b;
  if(a<=8 && b<=8) cout<<"Yay!"<<'\n';
  else cout<<":("<<'\n';
  return 0;
}


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

using namespace std;

int main()
{
    long long n,i,k,l;

    cin>>n;

    vector<long long>a(n);

    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a.begin(),a.end());

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

    queue<long long >q;
    for(i=0;i<n-1;i++)
    {
        if(a[i]==a[i+1])
        {
            q.push(a[i]);//so if we get 5 5 5 5 4 4 4 4 3 2 1 then for 2times 5 one will be on q,again 5 will come
            i++;//we will get one value of length though
        }
    }

    if(q.size()>=2)//we got best 2 values already a,b
    {
        k=q.front();//width

        q.pop();//without poping won't get the 2nd element

        l=q.front();//because of poping 2nd element is there
    }

    cout<<k*l<<endl;

    return 0;

}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  stack<int>S1;
  stack<pair<int,int> >S2;
  char ch;
  int sum=0;
  for(int i=0;cin>>ch;i++){
    if(ch=='\\')S1.push(i);
    else if(ch=='/' && S1.size()>0){
      int j=S1.top();
      S1.pop();
      sum+=i-j;
      int a=i-j;
      while(S2.size()>0 && S2.top().first>j){
	a+=S2.top().second;
	S2.pop();
      }
      S2.push(make_pair(j,a));
    }
  }
  
  vector<int>ans;
  int t=0;
  while(S2.size()>0){
    ans.push_back(S2.top().second);
    S2.pop();
  }
  reverse(ans.begin(),ans.end());
  cout<<sum<<endl;
  cout<<ans.size();
  for(int i=0;i<ans.size();i++){
    cout<<" ";
    t+=ans[i];
    cout<<ans[i];
  }
  cout<<endl;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); 
  int N;
  cin >> N;
  string S;
  cin >> S;
  int cnt=0;
  for(int i=0;i<N;i++){
    while(i+1<N && S[i]==S[i+1]){i++;}
    cnt++;
  }
  cout << cnt << endl;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(const T x,const T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}

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

const int MOD=1e9+7;
const int MAX=1e5+100;

string to_binary(ll a) {
  if (a==0) return "0";

  string res;
  while (a > 0) {
    a % 2 == 1 ? res.push_back('1') : res.push_back('0');
    a /= 2;
  }
  reverse(ALL(res));
  return res;
}

int main() {
  ll N;cin>>N;
  vector<ll> AS(N);
  REP(i,N) cin>>AS[i];

  ll ans = 0;
  REP(com,60) {
    ll COM=(1LL<<com);
    ll one=0;
    REP(i,N) if (AS[i]&COM) one++;
    ans += (one*(N-one)%MOD)*(COM%MOD);
    ans %= MOD;
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    string S;
    char T;
    int Q;
    int Query;
    int F;
    cin >> S;
    cin >> Q;
    bool Flag = true;
    REP(int,i,0,Q){
        cin >> Query;
        if ( Query == 1){
            if ( Flag ) Flag = false;
            else Flag = true;
        }
        if ( Query == 2 ){
            cin >> F >> T;
            if ( Flag ){
                if ( F == 1 ) S.insert(S.begin(),T);
                else S.push_back(T);
            }
            else{
                if ( F == 1 ) S.push_back(T);
                else S.insert(S.begin(),T);
            } 
        }
    }
    if ( Flag ){
        cout << S << endl;
    }
    else{
        for ( int i = S.size() - 1; i >= 0; i-- ){
            cout << S.at(i);
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 900
N = int(input())
A = list(map(int, input().split()))

print(' '.join(map(str, A)))

for i in range(1,N):
    v = A[i]
    j = i-1
    while v < A[j] and j >= 0:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(' '.join(map(str, A)))



Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;
const int MAXN = 200005;

vector<int> G[MAXN];
int cnt[MAXN];
bool visited[MAXN];

void dfs(int u) {
  visited[u] = true;
  for (int v: G[u]) {
    if (visited[v]) continue;
    cnt[v] += cnt[u];
    dfs(v);
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  int a, b;
  rep(i, n - 1) {
    cin >> a >> b;
    G[a - 1].push_back(b - 1);
    G[b - 1].push_back(a - 1);
  }
  int p, x;
  rep(i, q) {
    cin >> p >> x;
    cnt[p - 1] += x;
  }

  dfs(0);

  rep(i, n) {
    if (i) cout << " ";
    cout << cnt[i];
  }
  cout << endl;


  
  return 0;
}

Measured memory_bytes: 20608
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
  int n;
  while(cin>>n){
    int ans=n*n*n;
    cout<<ans<<endl;
  }
  return 0;
}




Measured memory_bytes: 256
N,L = map(int,input().split())
if L >=0:
    Aji = list(range(L+1,L+N))
    ans = sum(Aji)
    print(ans)
elif L<0 and L+N >= 1:
    Aji = list(range(L,L+N))
    ans = sum(Aji)
    print(ans)
else:
    Aji = list(range(L,L+N-1))
    ans = sum(Aji)
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

typedef long long ll;
ll n;
int mark[1000010], p[1000010], tot;

void euler() {
    rep(i, 2, 1000000) {
        if (!mark[i]) p[++tot] = i;
        for (int j = 1; j <= tot && i * p[j] <= 1000000; j++) {
            mark[i * p[j]] = 1;
            if (i % p[j] == 0) break;
        }
    }
}

int main() {
    cin >> n;
    if (n == 1) return puts("0"), 0;
    euler();
    int ans = 0;
    rep(i, 1, tot) {
        int j = p[i];
        if (n % j == 0) {
            // printf("%d !\n", j);
            int cnt = 0;
            while (n % j == 0) n /= j, cnt++;
            for (int k = 1; ; k++) {
                if (cnt < k) break;
                cnt -= k, ans++;
            }
        }
    }
    if (n > 1) ans++;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 8016
n = int(input())
s = input()
R = s.count("R")
G = s.count("G")
B = s.count("B")

total = R*G*B

for i in range(n-1):
    for j in range(i+1,n):
        if j*2-i < n:
            if s[i] != s[j] and s[j] != s[j*2-i] and s[i] != s[j*2-i]:
                total -= 1
        else:
            continue

print(total)

Measured memory_bytes: 9096
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>

using namespace std;


#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;


/*vectorの要素を全部確認するやつだよ。普通に拡張for文したほうがいいよ。

for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}

*/


/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}

*/


/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/




/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/


int main() {
	int n, a, b; cin >> n >> a >> b;

	cout << min(a * n, b) << endl;



	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_k
#include<iostream>
#include <cstdlib>
#include <algorithm>
#include <limits.h>
#include <vector>
#include <iomanip>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n,k;
	cin >> n >> k;
	int arr[n],sol[k+1];
	for(int i=0;i<n;i++)
		cin >> arr[i];
	for(int i=1;i<=k;i++)
	{
		int res=2;
		for(int j=0;j<n;j++)
		{
			if(i-arr[j]>=1)
			{
				if(sol[i-arr[j]]==2)
				{
					res=1;
					break;
				}
			}
			else if(i-arr[j]==0)
				res=1;
		}
		sol[i]=res;
	}
	if(sol[k]==1)
		cout << "First" << endl;
	else
		cout << "Second" << endl;
	return 0;
}

Measured memory_bytes: 3536
from collections import deque
N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(M)]
stack = deque([[1]])
seen = deque([])
c = 0
while stack:
  x = stack.pop()
  seen.append(x)
  if len(x)==N:
    c += 1
    continue
  p = x[-1]
  A = []
  for l in L:
    if l[0]==p:
      A.append(l[1])
    if l[1]==p:
      A.append(l[0])
  A = [a for a in A if a not in x]
  for a in A:
    if x+[a] in (seen or stack):
      continue
    else:
      stack.append(x+[a])
print(c)

Measured memory_bytes: 10784
import math
h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for i in range(h)]
lis = [[0,0] for i in range(h * w)]
num = [[0] * math.ceil((h * w) // d + 1) for i in range(d)]

for i in range(h):
    for j in range(w):
        lis[a[i][j]-1] = [i,j]

for i in range(h * w-d):
    num[i%d][i//d+1] = num[i%d][i//d]+abs(lis[i][0]-lis[i+d][0])+abs(lis[i][1]-lis[i+d][1])

q = int(input())
for _ in range(q):
    now,goal = map(int,input().split())
    if now % d == 0:
        print(num[now%d-1][(goal-now%d)//d-1]-num[now%d-1][(now-now%d)//d-1])
    else:
        print(num[now%d-1][(goal-now%d)//d]-num[now%d-1][(now-now%d)//d])

Measured memory_bytes: 25712
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

#define int long

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int n, a, b;
int h[100005];
int h1[100005];

int ok = INF;
int ng = 0;

long divCeil(long num1, long num2){
	return (num1+num2-1)/num2;
}

bool check(int in){
	int cnt = 0;
	for(int i = 0; i < n; i++){
		cnt += divCeil(std::max(0L, h[i] - b*in), a-b);
	}
	if(cnt > in){
		return false;
	}else{
		return true;
	}
}
	
signed main(){
	scanf("%ld %ld %ld", &n, &a, &b);
	for(int i = 0; i < n; i++){
		scanf("%ld", &h[i]);
	}
	while(std::abs(ok-ng) > 1){
		int mid = (ok + ng) / 2;
		if(check(mid)){
			ok = mid;
		}else{
			ng = mid;
		}
		//printf("%ld %ld\n", ng, ok);
	}
	printf("%ld\n", ok);
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 200010;
const int INF = 2147483600;

#define op first
#define ed second 
int N; int a[MAXN+1];
pair<int,int> s[MAXN+1]; int top;

inline bool check(int k){
	top=0; for(int i=1;i<=N;i++){
		int len=a[i];
		if(s[top].ed<len){
			s[++top]=make_pair(1,len);
			continue;
		}
		while(top>1&&s[top-1].ed>=len) --top;
		s[top].ed=min(s[top].ed,len);
		while(top&&s[top].op==k) --top;
		if(!top) return 0;
		int ps=s[top].ed,val=s[top].op;
		if(ps-1==s[top-1].ed) --top;
		if(ps>1) s[top].ed=ps-1;
		s[++top]=make_pair(val+1,ps); 
		if(len>ps) s[++top]=make_pair(1,len);
	} return 1;
}
int ans;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(); for(int i=1;i<=N;i++) a[i]=read();
	int l=1,r=N; while(l<=r){
		int mid=(l+r)>>1; if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	} printf("%d\n",ans);
	return 0;
}




Measured memory_bytes: 2560
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

a, b, c, d = map(int, input().split())
r = 0
bc = b // c
bd = b // d
bcd = b // lcm(c, d)
ac = -(-a // c)
ad = -(-a // d)
acd = -(-a // lcm(c, d))
print(b - a + 1 - bc + ac - 1 - bd + ad - 1 + bcd - acd + 1)


Measured memory_bytes: 3060
s = gets.chomp

(s.size - 1).times do |i|
	if s[i] == s[i + 1]
		puts "#{i + 1} #{i + 2}"
		exit
	elsif i < s.size - 2 && (s[i] == s[i + 2])
		puts "#{i + 1} #{i + 3}"
		exit
	end
end
puts "-1 -1"


Measured memory_bytes: 1916