akhauriyash/Code-Regression huggingface dataset:
open Batteries

(* purpose
        ある地点の住所Pと全住人の住所リストから全住人の住所からpにかけての距離の総和を求める
   - detail of data
        P:
                detail: 全住人からの距離が最小と成る点
                condition: 1 <= P <= 100
        N, M:
                detail: Pが存在する範囲の始点と終点
                condition: 1 <= N <= 100
                           1 <= M <= 100
                           N <= M

   amount_of_calculation <= O(N^2)
   => O(N)
*)
(* - function type
        solver: int -> int list -> int

   - I/O example
        input    -> output
        1 [1; 2] -> 1
        1 [1]    -> 0
        1 []     -> 0
*)
let rec solver p lst =
        match lst with
                  [] -> 0
                | first :: rest -> 
                        ((first - p) * (first - p)) + (solver p rest)

(* - purpose
       任意の住所のリストと全住人の住所のリストから住人の住所からリストに含まれる任意の住所までの距離の全住人についての総和の最小値を求める

   - detail of data
        住所:
                detail: 全住人からの距離が最小と成る点
                condition: 1 <= 住所 <= 100

   amount_of_calculation <= O(N^2)
*)
(* - function type
        solver2: int list -> int list -> int(acm) -> int

   - accumulator(option)
   	minsum: (調べ終わった総和のうち最小の値を格納) 
*)
let rec solver2 rlst lst minsum = 
        match rlst with
                  [] -> minsum
                | first :: rest -> 
                        let sum = solver first lst in
                                if sum < minsum then
                                        solver2 rest lst sum
                                else
                                        solver2 rest lst minsum

let test1 = (
        solver2 [] [] max_int
        =
        max_int
)
let test2 = (
        solver2 [1] [1] max_int
        =
        0
)
let test3 = (
        solver2 [1; 2] [1; 2] max_int
        =
        1(* or 2 *)
)

let lst =
        Scanf.sscanf (read_line ()) "%d" (
                fun _ -> 
                        Str.split (Str.regexp " ") (read_line ())
                        |> List.map int_of_string 
        )

let maxval = List.max lst
let minval = List.min lst

let () =
        solver2 (List.range minval `To maxval) lst max_int
        |> Printf.printf "%d\n"


Measured memory_bytes: 3072
using System;

public class Example
{
   public static void Main()
   {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);
        int count = 0;
        for (int i = a; i <= b; i++) {
            if (c % i == 0) count++;
        }
        Console.WriteLine(count);
   }
}

Measured memory_bytes: 9212
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
module Main (main) where
import           Control.Applicative
import           Control.Monad
import qualified Data.ByteString       as BS
import qualified Data.ByteString.Char8 as B8
import           Data.List
import           Data.Maybe
import           Data.Vector           ((!))
import qualified Data.Vector           as V
import qualified Data.Vector.Mutable   as MV
getInts :: IO [Int]
getInts = unfoldr (B8.readInt . B8.dropWhile (==' ')) <$> BS.getLine

data Edge = Edge {to :: !Int,revIx :: !Int,capIx :: !Int}
  deriving (Show,Eq)
type Graph = V.Vector (V.Vector Edge)

getGraph :: IO (Graph,MV.IOVector Int)
getGraph = do
  v:e:_ <- getInts
  cap <- MV.new (e*2)
  g <- MV.replicate v []
  forM_ [0..e-1] $ \i -> do
    u:v:c:_ <- getInts
    MV.write cap i c
    MV.write cap (i + e) 0
    us <- MV.read g u
    vs <- MV.read g v
    MV.write g u $ Edge v (e+i) i: us
    MV.write g v $ Edge u i (e+i): vs
    return ()
  g' <- V.map (V.fromList . reverse) <$> V.freeze g
  return (g', cap)

main :: IO ()
main = do
  (g,cap) <- getGraph
  r <- maxFlow 0 (V.length g - 1) g cap
  print r
  return ()

{-# INLINE untilJustM #-}
untilJustM :: Monad m => (a -> m (Maybe b)) -> V.Vector a -> m (Maybe b)
untilJustM act xs
  | V.null xs = return Nothing
  | otherwise = let v = V.head xs
                in do
      x <- act v
      case x of
        Nothing -> untilJustM act (V.tail xs)
        Just _  -> return x

maxFlow :: Int -> Int -> Graph -> MV.IOVector Int -> IO Int
maxFlow s t g cap = loop 0
  where
    loop f = do
      used <- MV.replicate (V.length g) False
      df <- dfs maxBound s t g cap used
      if df == 0
        then return f
        else loop (f + df)

dfs :: Int -> Int -> Int -> Graph
  -> MV.IOVector Int
  -> MV.IOVector Bool
  -> IO Int
dfs f v t g cap used
  | v == t = return f
  | otherwise = do
      MV.write used v True
      fromMaybe 0 <$> untilJustM act (g ! v)
  where
    act :: Edge -> IO (Maybe Int)
    act e@Edge {to = to,capIx = ci, revIx = ri} = do
      c <- MV.read cap ci
      isUsed <- MV.read used to
      if c > 0 && not isUsed
      then do
        d <- dfs (min f c) to t g cap used
        if d > 0
        then do
          modifyCap cap e d
          return (Just d)
        else return Nothing
      else return Nothing

modifyCap :: MV.IOVector Int -> Edge -> Int -> IO ()
modifyCap cap Edge {capIx = ci, revIx = ri} d
  = do
  cv <- MV.read cap ci
  cr <- MV.read cap ri
  MV.write cap ci $ cv - d
  MV.write cap ri $ cr + d

Measured memory_bytes: 6828
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    
    int a, b, c;
    cin>> a >> b >> c;
    vector<int> vec;
    vec.push_back(a);
    vec.push_back(b);
    vec.push_back(c);
    
    sort(vec.begin(), vec.end());
    
    cout << vec[0] << " " << vec[1] << " " << vec[2] << endl;
    

    return 0;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll D,T,S;
    cin>>D>>T>>S;
    ll t=D/S;
    if(D%S!=0){
        t+=1;
    }
    if(t>T){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 3612
import sys
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))


def a():
	n = int(inp()); arr = read()
	dp = [0 for i in range(n)]
	dp[0] = 0
	dp[1] = abs(arr[1]-arr[0])
	for i in range(2, n):
		dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]))
	print(dp[n-1])




if __name__ == "__main__":
	a()

Measured memory_bytes: 13976
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}

const ll mod = 1e9 + 7;

int main(){
    string s;
    cin >> s;
    int ans = 0;
    int cnt = 0;
    for (int i = 0;i < s.size();i++){
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
            cnt++;
            ans = max(ans,cnt);
        }
        else cnt = 0;
    }

    cout << ans << endl;
}

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

int main(void){
    int N, A, B;
    cin >> N >> A >> B;
    int suma = N * A;
    int sumb = B;
    if(suma <= sumb)
        cout << suma << endl;
    if(suma > sumb)
        cout << sumb << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <set>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;
template<class In>
void print_array(In begin, In end) {
  cout << (*begin);
  begin++;
  for (; begin != end; begin++)
  {
    cout << " " << (*begin);
  }
  cout << endl;
}
int main()
{
  ll N;
  cin >> N;
  vector<ll> as(N);
  for (auto i = 0; i < N; i++)
    cin >> as[i];

  ll num_swap = 0;
  bool issorted = false;
  while (!issorted) {
    issorted = true;
    for (auto i = N - 1; i > 0; i--)
    {
      if (as[i-1] > as[i]) {
        ll tmp = as[i];
        as[i] = as[i - 1];
        as[i - 1] = tmp;
        num_swap++;
        issorted = false;
      }
    }
  }
  print_array(as.begin(), as.end());

  cout << num_swap << endl;

  return 0;
}



Measured memory_bytes: 3108
import heapq

ans = []

T = int(input())
for i in range(T):
    N,A,B,C,D = map(int,input().split())
    Q = {}
    queue = []
    for i in range(N,N+1):
        Q[i] = abs(i-N)*D
        heapq.heappush(queue,-i)
    while 1:
        q = -heapq.heappop(queue)
        if q == 0:
            break
        a = q//2
        b = q//3
        c = q//5
        a_V = min(Q[q]+A+D*(q%2),Q[q]+(q-a)*D)
        b_V = min(Q[q]+B+D*(q%3),Q[q]+(q-b)*D)
        c_V = min(Q[q]+C+D*(q%5),Q[q]+(q-c)*D)
        a_2 = (q+1)//2
        b_2 = (q+2)//3
        c_2 = (q+4)//5
        a_V_2 = min(Q[q]+(a_2*2-q)*D+A,Q[q]+abs(q-a_2)*D)
        b_V_2 = min(Q[q]+(b_2*3-q)*D+B,Q[q]+abs(q-b_2)*D)
        c_V_2 = min(Q[q]+(c_2*5-q)*D+C,Q[q]+abs(q-c_2)*D)
        
        if a in Q:
            if Q[a] > a_V:
                Q[a] = a_V
        else:
            heapq.heappush(queue,-a)
            Q[a] = a_V
        
        if b in Q:
            if Q[b] > b_V:
                Q[b] = b_V
        else:
            heapq.heappush(queue,-b)
            Q[b] = b_V        
        
        if c in Q:
            if Q[c] > c_V:
                Q[c] = c_V
        else:
            heapq.heappush(queue,-c)
            Q[c] = c_V

        if a_2 in Q:
            if Q[a_2] > a_V_2:
                Q[a_2] = a_V_2
        else:
            heapq.heappush(queue,-a_2)
            Q[a_2] = a_V_2
        
        if b_2 in Q:
            if Q[b_2] > b_V_2:
                Q[b_2] = b_V_2
        else:
            heapq.heappush(queue,-b_2)
            Q[b_2] = b_V_2
        
        if c_2 in Q:
            if Q[c_2] > c_V_2:
                Q[c_2] = c_V_2
        else:
            heapq.heappush(queue,-c_2)
            Q[c_2] = c_V_2

        
        #print(q,Q,c_2,c_V_2)
    #print(Q[0])
    ans.append(Q[0])
for i in ans:
    print(i)

Measured memory_bytes: 98496
#include<stdio.h>
int main(void){
    int a,b,c,d;
    scanf("%d%d%d",&a,&b,&c);
    for(a;a<=b;a++){
        if(c%a==0){
            d++;
        }
    }
    printf("%d\n",d);
    return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{   
    string a,b;
    cin >> a >> b;
    string ret = a<b ? "<" :
                 a>b ? ">" : "=";
    cout << ret << endl;
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll X, Y, Z;
  IN(X,Y,Z);
  swap(X,Y);
  swap(X,Z);
  printf("%lld %lld %lld\n", X, Y, Z);

  return 0;
}

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

const int _ = 2e5 + 3;
int A[_] , B[_] , N;
struct cmp{bool operator ()(int x , int y){return A[x] > A[y];}};
multiset < int , cmp > pos;

int main(){
	ios::sync_with_stdio(0); cin >> N;
	for(int i = 1 ; i <= N ; ++i) cin >> B[i];
	for(int i = 1 ; i <= N ; ++i){cin >> A[i]; pos.insert(i);}
	long long stp = 0;
	while(!pos.empty()){
		int t = *pos.begin(); pos.erase(pos.begin());
		if(A[t] < B[t]){puts("-1"); return 0;}
		if(A[t] > B[t]){
			int num = A[t == 1 ? N : t - 1] + A[t == N ? 1 : t + 1];
			if(A[t] % num == B[t] % num){stp += (A[t] - B[t]) / num; A[t] = B[t];}
			else{
				if(A[t] < num){puts("-1"); return 0;}
				stp += A[t] / num; A[t] %= num;
				if(A[t] < B[t]){puts("-1"); return 0;}
				pos.insert(t);
			}
		}
	}
	printf("%lld\n" , stp);
	return 0;
}


Measured memory_bytes: 13184
n,x = map(int,input().split())
a = list(map(int,input().split()))
su = 0
for i in range(n-1):
  j,k = a[i],a[i+1]
  if j+k>x:
    t = (j+k)-x
    if k>=t:
      k -= t
      su += t
      a[i+1] = k
    else:
      k = 0
      j -= t-k
      su += t
      a[i+1] = 0
      a[i] = j
print(su)

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

using namespace std;

int main(){
  int N; cin >> N; vector<int> H(N);
  
  for(int i = 0; i < N ; i++){cin >> H[i];}
  
  int sum = H[0];
  
  if( N == 1){cout << sum << endl; }
  else{
  for(int j = 0; j < N - 1 ; j++){ // N >= 2の時にしかこの操作はできないはず
    if(H[j+1] > H[j]){ sum+= H[j+1] - H[j];}
    else{continue;}}
  cout << sum <<endl;}
  
  return 0;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    string s,t;cin>>s>>t;
    vector<vector<int>>ss(26);
    vector<vector<int>>tt(26);
    int n = s.size();
    rep(i,n){
        ss[s[i]-'a'].push_back(i);
        tt[t[i]-'a'].push_back(i);
    }
    bool f = true;
    rep(i,n){
        if(ss[s[i]-'a'].size()!=tt[t[i]-'a'].size())f = false;

    }
    cout<<(f?"Yes":"No");
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

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

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

using namespace std ;

int w ,h ,n ;
int sx ,sy ,gx ,gy ;

struct P
{
	int x ;
	int y ;
} ;

bool came[ 110 ][ 110 ] ;

int map[ 110 ][ 110 ] ;

void high( int x ,int y ,int c )
{
	for( int i = 0 ; i < 4 ; i++ )
	{
		for( int j = 0 ; j < 2 ; j++ )
			map[ y + i ][ x + j ] = c ;
	}

	return ;
}

void wide( int x ,int y ,int c )
{
	for( int i = 0 ; i < 2 ; i++ )
	{
		for( int j = 0 ; j < 4 ; j++ )
			map[ y + i ][ x + j ] = c ;
	}

	return ;
}

int main()
{
	while( cin >> w >> h )
	{
		if( w == h && !w )
			return 0 ;
		cin >> sx >> sy >> gx >> gy >> n ;
	memset( came ,false ,sizeof came ) ;
	memset( map ,0 ,sizeof map ) ;

	stack< P > st ;

	int c ,d ,x ,y ;
	int d1 ,d2 ;
	for( int k = 0 ; k < n ; k++ )
	{
		cin >> c >> d >> x >> y ;
		d ? high( x ,y ,c ) : wide( x ,y ,c ) ;
		/*if( d )
		{
			d1 = 2 ;
			d2 = 4 ;
		}
		else
		{
			d1 = 4 ;
			d2 = 2 ;
		}
		for( int i = 0 ; i < d1 ; i++ )
		{
			for( int j = 0 ; j < d2 ; j++ )
				map[ y + i ][ x + j ] = c ;
		}*/
	}
/*
for( int i = 0 ; i <= h + 1 ; i++ )
{
	for( int j = 0 ; j <= w + 1 ; j++ )
		cout << map[ i ][ j ] ;
	cout << endl ;
}
*/
	if( map[ sy ][ sx ] != map[ gy ][ gx ] )
	{
		printf( "NG\n" ) ;
		continue ;
	}

	c = map[ gy ][ gx ] ;

	for( int i = 1 ; i <= h ; i++ )
	{
		for( int j = 1 ; j <= w ; j++ )
		{
			if( c == map[ i ][ j ] )
				came[ i ][ j ] = true ;
		}
	}

	d = 1 ;
	P l ;
	l.x = sx ;
	l.y = sy ;
	st.push( l ) ;

	came[ sy ][ sx ] = false ;

	while( !st.empty() )
	{

		P p = st.top() ;
		st.pop() ;

		if( p.x == gx && p.y == gy )
		{
			d = 0 ;
			break ;
		}
		for( int i = 0 ; i < 4 ; i++ )
		{
			int mx[] = { 1 ,0 ,0 ,-1 } ;
			int my[] = { 0 ,1 ,-1 ,0 } ;
			int xx = p.x + mx[ i ] ;
			int yy = p.y + my[ i ] ;
			if( xx > 0 && x <= w && yy > 0 && yy <= h && came[ yy ][ xx ] )
			{
				came[ yy ][ xx ] = false ;
				l.x = xx ;
				l.y = yy ;
				st.push( l ) ;
			}
		}
	}
	d ? printf( "NG\n" ) : printf( "OK\n" ) ;

	}
}

Measured memory_bytes: 3060
n,y = map(int, input().split())
y /= 1000
for i in range(int(y//10+1)):
    for j in range(int((y-i*10)//1+1)):
        c = n-i-j
        if c >= 0 and 10 * i + 5 * j + 1 * c == y:
            print(i,j,c)
            exit()
print(-1,-1,-1)

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

int fib(int n, map<int, int>& fib_mp)
{
    auto itr = fib_mp.find(n);
    if (fib_mp.end() != itr) return itr->second;
    return fib_mp[n] = fib(n - 1, fib_mp) + fib(n - 2, fib_mp);
}

int main()
{
    int n;
    cin >> n;
    map<int, int> fib_mp;
    fib_mp[0] = fib_mp[1] = 1;
    cout << fib(n, fib_mp) << endl;
    return 0;
}

Measured memory_bytes: 3096
function main(arg) {
	arg = arg.split("\n")[0].split(" ")
	var A = Number(arg[0]) // - 
	var B = Number(arg[1]) // + 
	var C = Number(arg[2]) // + *

	if ( A + B >= C) {
		console.log(B + C)
		return
	} else {
		var tmp = A + B
		console.log(B + tmp + 1)
		return
	}

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

const int inf = 1e9;
const ll linf = 1e18;

map<ll, int> factorize(ll n)
{
    map<ll, int> mp;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            mp[i]++; n /= i;
        }
    }
    if (n != 1) mp[n] = 1;
    return mp;
}

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

    int n; cin >> n;
    auto f = factorize(n);
    cout << n << ":";
    for (auto &e: f) {
        for (int i = 0; i < e.second; i++) {
            cout << " " << e.first;
        }
    }
    cout << endl;
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(3));
	for (int i = 0; i < n; i++) cin >> a[i][0] >> a[i][1] >> a[i][2];

	vector<vector<int>> dp(n, vector<int>(3));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 3; j++)
			dp[i][j] = 0;
	for (int i = 0; i < 3; i++) dp[0][i] = a[0][i];
	for (int i = 1; i < n; i++) {
		dp[i][0] = max(a[i][0] + dp[i - 1][1], a[i][0] + dp[i - 1][2]);
		dp[i][1] = max(a[i][1] + dp[i - 1][0], a[i][1] + dp[i - 1][2]);
		dp[i][2] = max(a[i][2] + dp[i - 1][0], a[i][2] + dp[i - 1][1]);
	}
	cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}) << endl;
}


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

// 再帰関数
static void Sub_QuickSort(int* pnData, int nFirst, int nLast);
// クイックソート
void QuickSort(int* pnData, int nNumOf)
{
    Sub_QuickSort(pnData, 0, nNumOf - 1);
}

int main(void){
    // Your code here!
    
    int n;
    while(1){
        cin >> n;
        if(n==0){
            break;
        }else{
            int a[n];
            for(int i=0;i<n;i++){
                cin >> a[i];
            }
            
            QuickSort(a,n);
            int min = 1000000;
            
            for(int i=1;i<n;i++){
                if(a[i]-a[i-1]<min) min = a[i]-a[i-1];
            }
            cout << min << endl;
        }
        
    }
    

    return 0;
}

// 再帰関数
// nFirst : ブロックの最初のインデックス
// nLast  : ブロックの最後のインデックス
static void Sub_QuickSort(int* pnData, int nFirst, int nLast)
{
    int iLess    = nFirst;  // 前半のインデックス
    int iGreater = nLast;   // 後半のインデックス
    int x;                  // 「ある値」

    // 「ある値」は両端の要素の平均値にする
    x = (pnData[nFirst] + pnData[nLast]) / 2;

    // 交換ループ
    // 位置が逆になると終了
    while(iLess < iGreater)
    {
        // x より小さい要素は無視
        while(pnData[iLess] < x)
            iLess++;
        // x より大きい要素は無視
        while(pnData[iGreater] > x)
            iGreater--;

        // 位置がちゃんとしているときは交換し、
        // iLess と iGreater を１つずつ進める
        if(iLess < iGreater)
            swap(pnData[iLess++], pnData[iGreater--]);
    }
    // iLess == iGreater で終わった時は、
    // iGreater < iLess になるようにする
    if(iLess == iGreater)
    {
        if(pnData[iLess] < x)
            iLess++;
        else if(pnData[iLess] > x)
            iGreater--;
    }

    // 次のブロックのサイズが２以上の時は再帰
    if(iLess >= nFirst + 2)
        Sub_QuickSort(pnData, nFirst, iLess - 1);
    if(iGreater <= nLast - 2)
        Sub_QuickSort(pnData, iGreater + 1, nLast);
}


Measured memory_bytes: 3072
let () =
  Scanf.scanf "%s %s" (fun a b -> match String.compare a b with
  | _ when String.length a < String.length b -> "LESS"
  | _ when String.length a > String.length b -> "GREATER"
  | -1 -> "LESS"
  | 1 -> "GREATER"
  | _ -> "EQUAL") |> print_endline


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

#define ARRAY_MAX 101



/*素因数分解*/
map<ll,ll> prime_factorization(ll m){

    map<ll,ll> tmp;
    for(ll i = 2;i * i <= m;i++){
        while (m % i == 0) {
            tmp[i]++;
            m /= i;
        }
    }
    if(m != 1){
        tmp[m] = 1;
    }
    return tmp;
}

int main(){

    ll n;
    cin >> n;
    map<ll,ll> mp;
    mp = prime_factorization(n);

    map<ll,ll>::iterator ite;
    cout << n << ":";

    for(ite = mp.begin();ite != mp.end();ite++){
        for(int i = 0;i < ite->second;i++){
            cout << " " << ite->first;
        }
    }
    cout << endl;


    return 0;
}


Measured memory_bytes: 3136
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>

#define long long ll

using namespace std;

int N;

int main()
{
    cin >> N;
    if ((N % 1000) % 111 == 0 || (N / 10) % 111 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
  int n,ans,a;
  cin>>n;
  while(ans<n){
    ans=111*a;
    a++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		double x1=s.nextDouble(),y1=s.nextDouble(),x2=s.nextDouble(),y2=s.nextDouble();
		s.close();
		System.out.println(Math.hypot(x2-x1, y2-y1));
	}
}


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

int main(){
    int N, K;  cin >> N >> K;
    vector<int> x(N), y(N);
    for(int i=0; i<N; i++){
        char c;
        cin >> x[i] >> y[i] >> c;
        if(c=='W') y[i] += K;
        x[i] = x[i]%(2*K);
        y[i] = y[i]%(2*K);
    }

    vector<vector<int>> cnt = vector<vector<int>>(5*K+1, vector<int>(5*K+1, 0));
    for(int i=0; i<N; i++){
        cnt[max(0, x[i]-K+1)][max(0, y[i]-K+1)]++;
        cnt[max(0, x[i]-K+1)][y[i]+1]--;
        cnt[x[i]+1][max(0, y[i]-K+1)]--;
        cnt[x[i]+1][y[i]+1]++;

        cnt[x[i]+K+1][max(0, y[i]-K+1)]++;
        cnt[x[i]+K+1][y[i]+1]--;
        cnt[x[i]+K+K+1][max(0, y[i]-K+1)]--;
        cnt[x[i]+K+K+1][y[i]+1]++;

        cnt[max(0, x[i]-K+1)][y[i]+K+1]++;
        cnt[x[i]+1][y[i]+K+1]--;
        cnt[max(0, x[i]-K+1)][y[i]+K+K+1]--;
        cnt[x[i]+1][y[i]+K+K+1]++;

        cnt[x[i]+1][y[i]+1]++;
        cnt[x[i]+1][y[i]+K+1]--;
        cnt[x[i]+K+1][y[i]+1]--;
        cnt[x[i]+K+1][y[i]+K+1]++;

        cnt[x[i]+2*K+1][y[i]+1]++;
        cnt[x[i]+2*K+1][y[i]+K+1]--;
        cnt[x[i]+K+2*K+1][y[i]+1]--;
        cnt[x[i]+K+2*K+1][y[i]+K+1]++;

        cnt[x[i]+1][y[i]+2*K+1]++;
        cnt[x[i]+1][y[i]+K+2*K+1]--;
        cnt[x[i]+K+1][y[i]+2*K+1]--;
        cnt[x[i]+K+1][y[i]+K+2*K+1]++;

        cnt[x[i]+K+1][y[i]+K+1]++;
        cnt[x[i]+K+1][y[i]+K+K+1]--;
        cnt[x[i]+K+K+1][y[i]+K+1]--;
        cnt[x[i]+K+K+1][y[i]+K+K+1]++;
    }

    for(int i=1; i<=5*K; i++) for(int j=0; j<=5*K; j++) cnt[i][j] += cnt[i-1][j];
    for(int i=0; i<=5*K; i++) for(int j=1; j<=5*K; j++) cnt[i][j] += cnt[i][j-1];

    // for(int i=0; i<=4*K; i++) {
    //     for(int j=1; j<=4*K; j++){
    //         cout << cnt[i][j] << " ";
    //     }cout << "\n";
    // }

    int ans = 0;
    for(int i=0; i<=5*K; i++) for(int j=0; j<=5*K; j++) ans = max(ans, cnt[i][j]);

    cout << ans << endl;
}


Measured memory_bytes: 98944
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#include <stdlib.h>
#include <time.h>
#include <chrono>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll d;
vector<ll> c(26 + 1, 0);
vector<vector<ll>> s(365 + 1, vector<ll>(26 + 1, 0));

ll scoring(vector<int> t)
{
    ll ans = 0;
    vector<ll> last(26 + 1, 0);

    for (int i = 1; i <= d; i++)
    {
        ans += s[i][t[i]];
        ans -= c[t[i]] * (i - last[t[i]]) * (i - last[t[i]] - 1) / 2;
        last[t[i]] = i;
    }

    for (int i = 1; i <= 26; i++)
    {

        ans -= c[i] * (d - last[i] + 1) * (d - last[i]) / 2;
    }

    return ans;
}

int main(void)
{
    srand(time(NULL));
    cin >> d;

    for (int i = 1; i <= 26; i++)
    {
        cin >> c[i];
    }

    for (int i = 1; i <= d; i++)
    {
        for (int j = 1; j <= 26; j++)
        {
            cin >> s[i][j];
        }
    }

    vector<int> BestT(d + 1, 1);

    for (int i = 1; i <= d; i++)
    {
        BestT[i] = rand() % 26 + 1;
    }

    double BestScore = scoring(BestT);
    double score;

    auto start = chrono::system_clock::now();
    vector<int> t(d + 1, 1);

    double T0 = 1e6;
    double T1 = 1e4;
    double TL = 1980;

    ll count = 0;

    while (1)
    {
        ll msec;

        msec = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - start).count();

        if (msec >= TL)
        {
            break;
        }

        double T = powf(T0, 1 - msec / TL) * powf(T1, msec / TL);

        t = BestT;

        t[rand() % d + 1] = rand() % 26 + 1;

        score = scoring(t);

        double p = exp((score - BestScore) / T);

        if (p > 0.5)
        {
            BestT = t;
            BestScore = score;
        }

        count++;
    }

    for (int i = 1; i <= d; i++)
    {
        printf("%d\n", BestT[i]);
    }
}


Measured memory_bytes: 4408
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, l;
  
  cin >> n >> l;
  vector<string> vec;
  string s;
  REP(i,n){
      cin >> s;
      vec.push_back(s);
  }
  SORT(vec);

  REP(i,n){
      cout << vec[i];
  }
  cout << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int d[] = {3, 5, 7};

int dfs(ll N, ll cur, int used) {
  if (cur > N) return 0;
  int res = 0;
  if (used == ((1 << 3) - 1)) {
    ++res;
  }
  for (int i = 0; i < 3; i++) {
    res += dfs(N, cur * 10 + d[i], used | (1 << i));
  }
  return res;
}

int main() {
  ll N;
  while (cin >> N) {
    cout << dfs(N, 0, 0) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	ans := make([]int, n+12345)
	left, right := n/2, n/2+1
	for i := 0; i < n; i++ {
		if n%2 == i%2 { // nとiの偶奇が一致する場合は後ろに足す
			ans[right] = a[i]
			right++
		} else { // そうでない場合は前に足す
			ans[left] = a[i]
			left--
		}
	}
	for i := left + 1; i < right; i++ {
		fmt.Print(ans[i], " ")
	}
	fmt.Println()
}


Measured memory_bytes: 8576
//ABC092
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)

int main(){
    string S;
    cin >> S;
    int ans = 700;
    if(S[0] == 'o') ans += 100;
    if(S[1] == 'o') ans += 100;
    if(S[2] == 'o') ans += 100;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;

#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()

typedef long long ll;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;

const int maxn = 1e5 + 228;

int dp[maxn], last[maxn];


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;
    for (int i = 1; i < maxn; i++) {
        dp[i] = maxn;
    }
    set <pair<int, int> > st;
    st.insert({0, 0});
    string s;
    cin >> s;
    for (int i = 1; i <= n; i++) {
        if (s[i] == '1')
            continue;
        int x = i - m;
        while (len(st) && abs(st.begin()->second) < x) st.erase(st.begin());
        if (len(st)) {
            dp[i] = st.begin()->first + 1;
            last[i] = i - abs(st.begin()->second);
            st.insert({dp[i], i});
        }
    }
    if (dp[n] == maxn) {
        cout << -1;
        return 0;
    }
    vector <int> ans;
    while (n) {
        ans.pb(last[n]);
        n -= last[n];
    }
    reverse(all(ans));
    for (auto it : ans)
        cout << it << " ";



    return 0;
}


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

  const int MOD = 1000000007;
  const int INF = 1e9;

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

  //for
  #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
  #define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
  #define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

  //最大公約数 
  ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b,a%b);
  }

  //最小公倍数
  ll lcm(ll a,ll b){
  ll g = gcd(a,b);
  return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
    unsigned r;
    while ((r=a%b)) {
      a = b;
      b = r;
    }
    return b;
  } 


  //  int X[8]={-1, 0, 1, -1, 1, -1, 0, 1};
  //  int Y[8]={1, 1, 1, 0, 0, -1, -1, -1};




int main() {
string S;
cin >> S;
ll N = S.size();

ll black = 0;
ll black_first = 0;
REP(i, N){
  if(S.at(i) == 'B') {
    black++;
    black_first += i;
  }
}
ll black_second = 0;
for(int i = N - 1; i >= 0 ; i--){
  if(black) {
    black--;
    black_second += i;
  }
}
ll ans = black_second - black_first;
print(ans);

}


Measured memory_bytes: 640
N = int(input())
s = input()
memo = {s:1}
flag = True
for i in range(N-1):
  t = input()
  if s[-1] != t[0]:
    flag = False
  if t not in memo:
    memo[t] = 1
  else:
    flag = False
  s = t
print('Yes' if flag else 'No')

Measured memory_bytes: 3060
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""
d,t,s = m()

if t < d/s:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 65160
N, x = input().split(' ')
N = int(N)
x = int(x)
a = input().split(' ')
a = [int(a[i]) for i in range(N)]
a = sorted(a)
count = 0
for i in range(N):
  if x - a[i] < 0:
    x -= a[i]
    break
  else:
    x -= a[i]
    count += 1
if x > 0:
  count -= 1

print(count)

Measured memory_bytes: 9136
n, a, b = map(int, input().split())

n_div_ab = n // (a+b)
n_mod_ab = n % (a+b)
if a == 0:
    res = 0
elif n_mod_ab // a > 0:
    res = a
else:
    res = n_mod_ab

print(n_div_ab * a + res)

Measured memory_bytes: 2940
#!/usr/bin/env python

import sys
import argparse
import logging

logging.basicConfig(filename='logger.log', level=logging.DEBUG)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)


def f(x: int) -> str:
    '''
    >>> f(-40)
    'No'
    >>> f(-1)
    'No'
    >>> f(0)
    'No'
    >>> f(29)
    'No'
    >>> f(30)
    'Yes'
    >>> f(31)
    'Yes'
    >>> f(40)
    'Yes'
    '''
    if x >= 30:
        return "Yes"
    else:
        return "No"


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument(
            '--doctest', action='store_true', default=False)
    args = parser.parse_args()
    if args.doctest:
        import doctest
        doctest.testmod(verbose=True)
        sys.exit()

    x = int(sys.stdin.readline().rstrip())
    print(f(x))

Measured memory_bytes: 11892
using System;

class Program
{
    static void Main()
    {
        for (; ; )
        {
            var line = Console.ReadLine().Split(' ');
            int H = int.Parse(line[0]);
            int W = int.Parse(line[1]);
            if (H == 0 && W == 0) break;
            for (var i = 1; i <= H; i++)
            {
                if (i%2!= 0) PrintReciprocalLine("#", ".", W);
                else PrintReciprocalLine(".", "#", W);
            }
            Console.WriteLine();
        }
    }

    static void PrintReciprocalLine(string firstStr , string secondStr, int n) 
    {
        for (var i = 1; i <= n; i++) Console.Write("{0}", i % 2 != 0 ? firstStr: secondStr);
        Console.WriteLine();
    }
    
}
    


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

int main(){
    string s; cin >> s;
    string ans;
    for(int i=0; i<s.size(); i++){
        if(s[i]!='B') ans += s[i];
        else if(ans != "") ans.pop_back();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include<string>
#include <cassert>
#include <algorithm>
#include <functional>
#include<stdio.h>

using namespace std;

int main() {
	int N;
	int flag = 0;
	string S;
	string str1;
	string str2;
	cin >> N;
	cin >> S;
	int i = 0;
	int j = N / 2;
	if (N % 2 == 1) {
		cout << "No" << endl;
	}
	else if (N % 2 == 0) {
		for (i = 0; i<S.size() / 2; ++i) {
			str1 += S[i];
		}
		for (i = j; i < S.size(); ++i) {
			str2 += S[i];
		}
		if (str1 == str2) {
			cout << "Yes" << endl;
		}
		else if (str1 != str2) {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 256
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let n = nextInt()
    let p = nextIntArray()
    let cnt = 0
    for(let i = 0; i<p.length; i++){
        if(p[i] == i+1){
            if(i != n){
                let tmp = p[i+1]
                p[i+1] = p[i]
                p[i] = tmp
            }
            cnt++
        }
    }
    console.log(cnt)
}
Main()



Measured memory_bytes: 38724
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  n := nextInt()

  a := nextInt()
  b := nextInt()

  sum := 0
  for i := 1; i <= n; i++ {
	  if a <= i && i <= b && i < 10{
		sum = sum + i
	  } else {
		partSum := 0
        for _, v := range strconv.Itoa(i) {
         v, _ := strconv.Atoi(string(v))
         partSum = partSum + v
        }
	    if a <= partSum && partSum <= b {
		  sum = sum + i
		}
	  }
  }
  fmt.Println(sum)

}

func nextString() (string) {
	sc.Scan()
	v := sc.Text()
	return v
}

func nextInt() (int) {
	sc.Scan()
	v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}

func nextFloat() (float64) {
	sc.Scan()
	v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}


Measured memory_bytes: 768
import sys

input = sys.stdin.readline

N, M = map(int, input().split())
A = list(map(int, input().split()))
op = [list(map(int, input().split())) for _ in range(M)]

cards = sorted(A)
op.sort(key=lambda x: -x[1])

i = 0

for m in range(M):
    b, c = op[m]
    for _ in range(b):
        if cards[i] < c:
            cards[i] = c
            i += 1
            if i >= N:
                break
        else:
            break
    else:
        continue
    break

print(sum(cards))


Measured memory_bytes: 36864
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000001
using namespace std;
typedef long long ll;

int main(){
  int d, g; cin >> d >> g;
  vector<int> p(d), c(d);
  rep(i, 0, d){
    cin >> p[i] >> c[i];
  }
  int ans = 1e9;
  for(int i=0; i<1<<d; i++){
    int cnt = 0;
    int score = 0;
    for(int j=0; j<d; j++){
      if(i>>j & 1){
        cnt += p[j];
        score += p[j]*(j+1)*100;
        score += c[j];
      }
    }
    for(int j=d-1; j>=0; j--){
      if(~i>>j&1){
        for(int k=0; k<p[j] && score < g; k++){
          score += (j+1)*100;
          cnt++;;
        }
      }
    }
    if(score >= g){
      ans = min(ans, cnt);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

int main() {

    FAST_IO;

    char ch;
    cin >> ch;

    ++ch;
    cout << ch << endl;
    
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

answer = 0
C = Counter (A)
C_taple = C.most_common()
for c in C_taple:
    if c[0] > c[1]:
        answer += c[1]
    elif c[1] > c[0]:
        answer += (c[1]-c[0])
print(answer)

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

int main(int argc, char const *argv[])
{
    int n;cin>>n;
    vector<int> a(n),f(n),b(n);
    for (int i=0;i<n;i++)cin>>a[i];
    
    for (int i=0;i<n;i++){
        if(i==0){
            f[i]=a[0];
            b[n-i-1]=a[n-1];
        }
        else{
            f[i]=max(f[i-1],a[i]);
            b[n-i-1]=max(b[n-i],a[n-i-1]);
        }
    }
    int ret;
    for(int i=0;i<n;i++){
        if(i==0)ret = b[1];
        else if(i==n-1)ret = f[n-2];
        else ret = max(f[i-1],b[i+1]);
        cout << ret << endl;
    }
    return 0;
}


Measured memory_bytes: 3968
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(n-1):
        a[i+1] += a[i]
    b = []
    for i in range(-1, n-1):
        for j in range(i+1, n):
            if i == -1:
                b.append(a[j])
            else:
                b.append(a[j]-a[i])
    ans = 0
    for i in reversed(range(51)):
        cnt = 0
        for v in b:
            if ans & v == ans and (1<<i) & v != 0:
                cnt += 1
        if k <= cnt:
            ans += (1<<i)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 25004
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 998244353
using namespace std;
int main() {
    int a, b, m;
    cin >> a >> b >> m;
    vector<ll> A(a), B(b);
    for(int i = 0; i < a; i++) {
        cin >> A[i];
    }
    for(int i = 0; i < b; i++) {
        cin >> B[i];
    }
    vector<ll> ans(m);
    for(int i = 0; i < m; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        ans[i] = A[x - 1] + B[y - 1] - c;
    }
    cout << min(*min_element(all(ans)),
                *min_element(all(A)) + (*min_element(all(B))))
         << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& w : a) cin >> w;
  map<int, int> cnt;
  for (auto&& w : a) cnt[w]++;
  int ans = 0;
  for (auto&& w : cnt) {
    if (w.second >= w.first) {
      ans += w.second - w.first;
    } else {
      ans += w.second;
    }
  }
  cout << ans << endl;

  
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
int n,c;
int d[40][40];
vector<pair<int,int> > pos[3];
int co[600][600];
int daijia[3][40];
int cl[3];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>c;
	for(int i=1;i<=c;i++){
		for(int j=1;j<=c;j++)
			cin>>d[i][j];
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>co[i][j];
			pos[(i+j)%3].push_back(make_pair(i,j));
		}
	}
	for(int i=0;i<3;i++){
		for(int j=1;j<=c;j++){
			for(int k=0;k<pos[i].size();k++){
				daijia[i][j]+=d[co[pos[i][k].first][pos[i][k].second]][j];
			}
		}
	}
	int res=1e9;
	for(cl[0]=1;cl[0]<=c;cl[0]++){
		for(cl[1]=1;cl[1]<=c;cl[1]++){
			for(cl[2]=1;cl[2]<=c;cl[2]++){
				if(cl[0]!=cl[1]&&cl[0]!=cl[2]&&cl[1]!=cl[2]){
					res=min(res,daijia[0][cl[0]]+daijia[1][cl[1]]+daijia[2][cl[2]]);
				}
			}
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3620