akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
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; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

//--------------入力受け取る場所----------------------------------------------------

string s,t;

void input_var(){
    cin >> s;

}
//-------------------------------------------------------------------------------


signed main(){
    cout << fixed << setprecision(10);
    input_var();
    cout << s[0] << s[1] << s[2] << endl;
    return 0;
}


Measured memory_bytes: 3640
import math
li = [int(input()) for _ in range(5)]
ans = 0
m = 0
for x in li:
  if x % 10 == 0:
      t = 0
  else:
      t = 10 - x % 10
  ans += x + t

  m = max(m,t)

print(ans-m)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
bool indf(int n)
{
	int m;
	for(int i=1;i<=n;i++)
    {
    	cin>>m;
    	if(m%2==0)
	    	if(m%3==0||m%5==0)
	    		continue;
	    	else
	    		return false;
	}
	return true;
} 
int main()
{
	int n;
	cin>>n;
	if(indf(n))
		cout<<"APPROVED";
	else
		cout<<"DENIED";
	return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll A, B;
    cin >> A >> B;

    ll ans = 0;

    if(A == B){
        cout << 2*A << endl;
        return 0;
    }
    if(A > B){
        cout << 2*A-1 << endl;
    }
    else{
        cout << 2*B-1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin>>a>>b;
    if((a+b)%2==0) cout<<(a+b)/2<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    std::string s;
    std::cin >> s;
    int count = 0;
    if (s[0] == '2') {
        count++;
    }
    if (s[1] == '2') {
        count++;
    }
    if (s[2] == '2') {
        count++;
    }
    if (s[3] == '2') {
        count++;
    }

    std::cout << count << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lowbit(a) ((a) & -(a))
#define clean(a, b) memset(a, b, sizeof(a))
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 9;
typedef pair<int,int>P;

int _;

//========================================================================
int a[maxn];
//========================================================================
int main()
{
    ll x,k,d;
    scanf("%lld%lld%lld",&x,&k,&d);
    ll now=abs(x)/d;
    if(k<=now) printf("%lld\n",abs(x)-k*d);
    else 
    {
        ll a=now%2;
        ll b=k%2;
        if(a==b) printf("%lld\n",abs(x)-now*d);
        else printf("%lld\n",(now+1)*d-abs(x));
    }
    return 0;
}


Measured memory_bytes: 3836
#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;

int main(){
    int n,r,minv,maxv=INT_MIN;
    cin>>n>>r;
    minv=r;
    for(int i=1;i<n;++i){
        cin>>r;
        maxv=max(maxv,r-minv);
        minv=min(minv,r);
    }
    cout<<maxv<<endl;
    return 0;
}


Measured memory_bytes: 3136
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>
#include <complex>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;

/*-----------------------------------------------------------------------------
　幾何学ライブラリ
 -------------------------------------------------------------------------------*/
/* 基本要素 */
typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
const D EPS = 1e-9;    // 許容誤差。問題によって変える
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)
namespace std {
  bool operator<(const P a, const P b) {
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}

/*-----------------------------------------------------------------------------
　メイン
 -------------------------------------------------------------------------------*/
template<class T>
int divCnt(T N, int div)
{
	int res = 0;
	while (N) {
		N /= div;
		if (N != 0)	res++;
	}
	return res;
}

/* 階乗 */
template<class T>
T power(int base, int powNum)
{
	T ans = 1;
	for (int i = 0; i < powNum; i++) {
		ans *= base;
	}
	return ans;
}

int main()
{
	int N;
	cin >> N;
	
	int ans = INF;
	for (int i = 0; i <= N; i++) {
		int cnt = 0;
		int nSub = i;
		while (0 < nSub) {
			int cnt6 = divCnt<int>(nSub, 6);
			int pow6 = power<int>(6, cnt6);
			nSub -= pow6;
			cnt++;
			if (nSub < 6) {
				cnt += nSub;
				break;
			}
		}
		nSub = N - i;
		while (0 < nSub) {
			int cnt9 = divCnt<int>(nSub, 9);
			int pow9 = power<int>(9, cnt9);
			nSub -= pow9;
			cnt++;
			if (nSub < 9) {
				cnt += nSub;
				break;
			}
		}
		ans = min(ans, cnt);
	}

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


Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE OverloadedStrings #-}
-- {-# LANGUAGE BangPatterns #-}
-- {-# LANGUAGE ViewPatterns #-}
-- {-# LANGUAGE TupleSections #-}

import           System.IO hiding (char8)
import           Control.Applicative
import           Control.Monad
import           Data.List
import           Data.Tuple
import           Data.Int
import           Data.Char
import           Data.Function (on)
import           Data.Array
-- import           Data.Array.Unboxed
-- import           Data.Array.IArray
-- import           Data.Array.ST
-- import           Data.Array.MArray
-- import           Data.Array.Unsafe
import           Data.Ix
import           Data.Maybe
import           Data.Monoid hiding ((<>))
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BL
import           Data.ByteString.Builder
-- import           Data.Vector.Unboxed ((//), (++), (!), (!?))
-- import qualified Data.Vector.Unboxed as U
-- import           Data.IntSet (IntSet)
-- import qualified Data.IntSet as S
-- import           Data.IntMap.Strict (IntMap)
-- import qualified Data.IntMap.Strict as M
-- import           Data.Sequence ((|>), (<|), (><),ViewR((:>)), ViewL((:<)))
-- import qualified Data.Sequence as S
-- import           Debug.Trace

main :: IO ()
main = do
  (n,_) <- readInt2 <$> BS.getLine
  ds <- map head . words <$> getLine
  print $ solve n ds

solve :: Int -> String -> Int
solve n ds = go n where
  go n' = if p n' then n' else go $ succ n' where
    p n'' = not . any (`elem` ds) $ show n''
--  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --

readInt1 :: BS.ByteString -> Int
readInt1 = fst . fromJust . BS.readInt

readInt2 :: BS.ByteString -> (Int,Int)
readInt2 = toTuple . readIntN

readInt3 :: BS.ByteString -> (Int,Int,Int)
readInt3 = toTriple . readIntN

readIntN :: BS.ByteString -> [Int]
readIntN =  map readInt1 . BS.words

readInt641 :: BS.ByteString -> Int64
readInt641 = fromIntegral . fst . fromJust . BS.readInteger

readInt642 :: BS.ByteString -> (Int64,Int64)
readInt642 = toTuple . readInt64N

readInt643 :: BS.ByteString -> (Int64,Int64,Int64)
readInt643 = toTriple . readInt64N

readInt64N :: BS.ByteString -> [Int64]
readInt64N =  map readInt641 . BS.words

readInteger1 :: BS.ByteString -> Integer
readInteger1 = fst . fromJust . BS.readInteger

readInteger2 :: BS.ByteString -> (Integer,Integer)
readInteger2 = toTuple . readIntegerN

readInteger3 :: BS.ByteString -> (Integer,Integer,Integer)
readInteger3 = toTriple . readIntegerN

readIntegerN :: BS.ByteString -> [Integer]
readIntegerN =  map readInteger1 . BS.words

toTuple :: [a] -> (a, a)
toTuple [x, y] = (x, y)

toTriple :: [a] -> (a, a, a)
toTriple [x, y, z] =(x, y, z)

fromTuple :: (a, a) -> [a]
fromTuple (x, y) = [x, y]

fromTriple :: (a, a, a) -> [a]
fromTriple (x, y, z) = [x, y, z]

-- if not applying, use "const"

applyTuple :: (a -> a') -> (b -> b') -> (a, b) -> (a', b')
applyTuple f g (x, y) = (f x, g y)

applyTriple :: (a -> a') -> (b -> b') -> (c -> c') -> (a, b, c) -> (a', b', c')
applyTriple f g h (x, y, z) = (f x, g y, h z)


Measured memory_bytes: 892
s = gets.chomp
m = s.size
p (?a..?z).map{|c|
  x = (0...m).select{|i| s[i] == c}
  if x[0]
    #p [x[0], m-x[-1]-1, *x.each_cons(2).map{|y,z| z-y-1}]
    #p [-1, *x, m].each_cons(2).map{|y,z| z-y-1}
    [-1, *x, m].each_cons(2).map{|y,z| z-y-1}.max
  else
    1e9
  end
}.min


Measured memory_bytes: 1788
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int w = sc.nextInt();
    int h = sc.nextInt();
    int n = sc.nextInt();

    int[] x = new int[n];
    int[] y = new int[n];
    int[] a = new int[n];

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

    int x1 = 0;
    int x2 = w;
    int y3 = 0;
    int y4 = h;

    for (int i = 0; i < n; i++) {
      if (a[i] == 1) x1 = Math.max(x1,x[i]);
      if (a[i] == 2) x2 = Math.min(x2,x[i]);
      if (a[i] == 3) y3 = Math.max(y3,y[i]);
      if (a[i] == 4) y4 = Math.min(y4,y[i]);
    }

    int ans = (x2-x1)*(y4-y3);
    if (x1 > x2 || y3 > y4) {
      System.out.println(0);
    } else {
      System.out.println(ans);
    }

  }

}


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

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    int ans = 0;
    for (int i = 0; i < n;) {
        int j = i;
        while (j < n && a[i] == a[j]) j++;
        ans += j - i >> 1;
        i = j;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,K,X,H,W;
ll total;
ll A[100001];
const ll M = 1000000007;
vector<ll> fac(500001); //n!(mod M)
vector<ll> ifac(500001); //k!^{M-2} (mod M)
ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main(){
    cin >> N >> K;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A,A+N);
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<500000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    for(int i=0;i<N-K+1;i++){
        total = (total + (A[i+K-1]*comb(i+K-1,K-1))%M)%M;
        total = (total - (A[i]*comb(N-i-1,K-1))%M)%M;
    }
    if(total<0){
        total += M;
    }
    cout <<total<< endl;
    
}

Measured memory_bytes: 8832
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

signed main() {
    i64 n,k,s;
    cin>>n>>k>>s;
    i64 mx = 1000000000;

    if( k==0 ){
        if(s != mx){
            REP(i,n){ cout<<mx<<" "; }
        } else {
            REP(i,n){ cout<<mx-1<<" "; }
        }
        cout<<endl;
        return 0;
    }
    if( k== 1 ){
        cout<<s<<" ";
        if(s != mx){
            REP(i,n-1){ cout<<mx<<" "; }
        } else {
            REP(i,n-1){ cout<<mx-1<<" "; }
        }
        cout<<endl;
        return 0;
    }


    if( n==k ){
        REP(i,n){
            cout<<s<<" ";
        }
        cout<<endl;
        return 0;
    }

    if( s==1 ){
        REP(i,k){
            cout<<1<<" ";
        }
        REP(i,n-k){
            cout<<10000<<" ";
        }
        return 0;
    }


    if(1){
        REP(i,k+1){
            if(s%2==0){
            cout<<s/2<<" ";
            } else {
                if(i%2==0){
                    cout<<s/2<<" ";
                } else {
                    cout<<s/2+1<<" ";
                }
            }
        }
        if(s != 1000000000){
                REP(i,n-k-1){ cout<<1000000000<<" "; }
        } else {
                REP(i,n-k-1){ cout<<1000000000-1<<" "; }
        }
    }
    

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

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#define sz(x) (int)(x).size()
/* --- */
void cant() {
	printf("-1 -1 -1\n");
	exit(0);
}

int main() {
	int n, Y, x = 0, y = 0, z, k;
	scanf("%d%d", &n, &Y);
	Y /= 1000;
	if (n > Y) cant();
	z = Y;
	k = Y - n;
	while (k >= 4 && z >= 5) {
		y += 1;
		z -= 5;
		k -= 4;
	}
	while (k >= 1 && y >= 2) {
		x += 1;
		y -= 2;
		k -= 1;
	}
	if (k > 0) cant();
	else printf("%d %d %d\n", x, y, z);
}



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

int main(){
	int a,b,c,p;
	while(cin >> a >> b >> c){
		p=0;
		for(int i=0;i<10;i++){
			if( (i+1)!=a && (i+1)!=b && (i+1)!=c){
				if(a+b+(i+1)<=20){
					p++;
				}
			}
		}
		if(p>3){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};
vector<vector<edge> > g(100010);
int main(){
    ll V,E,r; cin >> V >> E >> r;
    vector<ll> dist(V,INF);
    for (int i = 0; i < E; i++){
        ll s,t,d; cin >> s >> t >> d;
        g[s].push_back({t,d});
    }
    queue<ll> que;
    dist[r] = 0;
    que.push(r);
    while (que.size()){
        ll now = que.front();
        que.pop();
        for (auto e : g[now]){
            if (dist[e.to] > dist[now] + e.cost){
                dist[e.to] = dist[now] + e.cost;
                que.push(e.to);
            }
        }
    }
    for (int i = 0; i < V; i++){
        if (dist[i] == INF) cout << "INF" << endl;
        else cout << dist[i] << endl;
    }
}


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

#define int long long
#define double long double
#define pq priority_queue
#define pb push_back
#define mp make_pair

int root(int dsu[],int x)
{
  while(dsu[x]!=x)
  {
    dsu[x]=dsu[dsu[x]];
    x=dsu[x];
  }
  return x;
}

void init(int dsu[], int n)
{
  for(int i=0;i<=n;i++)
  {
    dsu[i]=i;
  }
}

void un(int dsu[],int x,int y)
{
  int a=root(dsu,x);
  int b=root(dsu,y);
  dsu[a]=dsu[b];
}

void printprecise(double l,int precision){
    std::cout << std::fixed;
    std::cout << std::setprecision(precision);
    std::cout << l <<endl;
}

int gcd(int x,int y)
{
  if(x==0)
  {
    return y;
  }
  else
  {
    return gcd(y%x,x);
  }
}

int lcm(int x,int y)
{
  return (x*y)/gcd(x,y);
}

main() 
{
  
  
  int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  int cst[n];
  cst[0]=0;
  for(int i=1;i<n;i++)
  {
    if(i-1>=0)
    {
      cst[i]=cst[i-1]+abs(arr[i]-arr[i-1]);
    }
    if(i-2>=0)
    {
      cst[i]=min(cst[i],cst[i-2]+abs(arr[i-2]-arr[i]));
    }
  }
  cout<<cst[n-1];
}

  // #ifndef ONLINE_JUDGE
  // cout << "\nTime Elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  // #endif
// }
// #ifndef ONLINE_JUDGE
// cout << "\nTime Elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
// #endif

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define num(a) a-'0'
#define maxs(a,b) if(b>a)a=b
#define mins(a,b) if(b<a)a=b;
#define debug(x) cout<<#x<<":"<<x<<" "
#define all(a) (a).begin(), (a).end()
#define vi vector<int>
#define vl vector<long long int>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"	
typedef long long int ll;
typedef long double ld;
typedef double d;
using namespace std;
ll modF=1e9+7;
ll INF=1e18;

void solve(){
	int n,k;
	scanf("%d%d",&n,&k);
	vi a(n);
	for(int i = 0;i < n;i ++){
		scanf("%d",&a[i]);
	}
	int ans = 1 + (n - k)/(k - 1);
	if((n - k) % (k - 1) != 0){
		ans ++;
	}
	printf("%d",ans);
}

int main(){
	boost_io;
	solve();
	return 0;
}

Measured memory_bytes: 3816
//压行课次
#include<bits/stdc++.h>
#define LL long long
#define LD double
using namespace std;
const int mod=998244353;
char s[200];
int read(){int sss=0,fff=1;char ccc=getchar();while(ccc<'0'||ccc>'9'){if(ccc=='-') fff=-1;ccc=getchar();}while(ccc>='0'&&ccc<='9'){sss=sss*10+ccc-'0';ccc=getchar();}return sss*fff;}
void solve()
{
	scanf("%s",s);
	int len=strlen(s);
	bool flag=false;
	for(int i=0;i<len;i++)
	{
		if(s[i]=='C') flag=true;
		else if(flag&&s[i]=='F') 
		{
			printf("Yes\n");
			return ;
		}
	}
	printf("No\n");
}
int main()
{
//	freopen("123.in","r",stdin);
//	freopen("123.out","w",stdout);
	int T=1;
	while(T--)
		solve();
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける





//   a/b mod c
ll moddiv(ll a,ll b){
	ll x0=MOD,x1=b,x2,n0=0LL,n1=1LL,n2,t=a%b,m,ans;
	if (t==0) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=(n0-m*n1)%MOD;
      if (x2==1){
        ans=(n2+MOD)%MOD;
        break;
      }
      x0=x1;x1=x2;
      n0=n1;n1=n2;
    }
	return (a+((t*ans)%MOD)*b-t)/b;
}
//剰余の割ざん




ll n,k,x,y;

int main(){

  ll ans=0;
  cin >> n >> k;
  vi a(n),csum(n+1,0);
  REP(i,n) cin>>a[i];
  sort(a.begin(), a.end());

  //累積和
  REP(i,n) csum[i+1]=(csum[i]+(a[i]+MOD)%MOD)%MOD;

  ll ncl=1;
  ll r=1;
  for(int i=k-1;i<n;i++){
    ll ml=((csum[n]-csum[i]+MOD)-csum[n-i]+MOD)%MOD;
    ans+=ml*ncl%MOD;
    ans%=MOD;
    ncl=(ncl*(ll)i)%MOD;
    ncl=moddiv(ncl,r);
    r++;
  }

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

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

#define rep(i, N) for (int i = 0; i < (N); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back

using ll = long long;
using i_i = tuple<int, int>;

const int MOD = 998244353;

int main() {
    int N; cin >> N;
    vector<int> d(N);
    rep(i, N) cin >> d[i];
    vector<int> a(N);
    rep(i, N) a[d[i]]++;
    if (d[0] == 0 && a[0] == 1);
    else {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    for (int k = 1; k < N; k++)
        rep(t, a[k])
            ans = ans * a[k - 1] % MOD;
    cout << ans << endl;
}


Measured memory_bytes: 1024
N,M=map(int,input().split(' '))

x=[]
y=[]
z=[]
for _ in range(N):
  _x,_y,_z=map(int,input().split(' '))
  x.append(_x)
  y.append(_y)
  z.append(_z)

def argmin(l):
  m=min(l)
  for i in range(len(l)):
    if l[i]==m:
      return i

def f(sign_x, sign_y, sign_z):
  l=[]
  for i in range(N):
    s=x[i]*sign_x + y[i]*sign_y + z[i]*sign_z
    l.append(s)
    if len(l)>M:
      del l[argmin(l)]
  return sum(l)


res=0
for x_s in [1,-1]:
  for y_s in [1,-1]:
    for z_s in [1,-1]:
      score = f(x_s, y_s, z_s)
      if score>res:
        res=score

print(res)




Measured memory_bytes: 3188
Q = int(input())
lr = [list(map(int, input().split())) for _ in range(Q)]

N = 10 ** 5 + 1
L = [1] * N

L[0] = 0
L[1] = 0

for i in range(2, N // 2):
  if L[i] == 1:
    for j in range(i * 2, N, i):
      L[j] = 0

S = [0] * N
for i in range(3, N, 2):
  S[i] = S[i - 2]
  if L[i] and L[(i + 1) // 2]:
    S[i] += 1

for l, r in lr:
  print(S[r] - S[max(l - 2, 1)])

Measured memory_bytes: 29804
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  int n,ta;
  vector<int> c(100),t(100);

  cin>>n>>ta;
  for(int i=0;i<n;i++) cin>>c.at(i)>>t.at(i);

  int cost=10000,tt;
  for(int i=0;i<n;i++)
  {
    if(t.at(i)<=ta)
    {
      if(c.at(i)<=cost)
      {
        cost=c.at(i);
        tt=i;
      }
    }
  }
  if(cost==10000)
  cout<<"TLE"<<endl;
  else
  cout<<cost<<endl;
}

Measured memory_bytes: 256
#include <map>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

const int MAXN = 100000;

vector<int>G[MAXN + 5];
map<ll, int>mp;

int siz[MAXN + 5];

ll check(int x) {
	ll ret = 0;
	for(int i=0;i<G[x].size();i++) {
		int to = G[x][i];
		ret += check(to) + siz[to];
	}
	return ret;
}

int main() {
	int n; scanf("%d", &n);
	for(int i=1;i<=n;i++) {
		ll D; scanf("%lld", &D);
		mp[D] = i, siz[i] = 1;
	}
	map<ll, int>::reverse_iterator rt;
	for(map<ll, int>::reverse_iterator it=mp.rbegin();it!=mp.rend();it++) {
		if( siz[it->second] == n ) {
			rt = it;
			break;
		}
		int x = it->second;
		ll k = it->first + siz[x] - (n - siz[x]);
		if( k < it->first && mp.count(k) ) {
			int p = mp[k];
			siz[p] += siz[x];
			G[p].push_back(x);
		}
		else {
			puts("-1");
			return 0;
		}
	}
	if( check(rt->second) == rt->first ) {
		for(int i=1;i<=n;i++) {
			for(int j=0;j<G[i].size();j++)
				printf("%d %d\n", i, G[i][j]);
		}
	}
	else puts("-1");
}

Measured memory_bytes: 15872
import java.util.Scanner;
import java.lang.Math;
import java.util.Random;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
//		Random rnd = new Random();
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		for(int i=0; i<values.length; i++){
			values[i] = i+1;
		}
		for(int i=0; i<n; i++){
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;
			int x = values[a];
			values[a] = values[b];
			values[b] = x; 
		}

		for(int i=0; i<values.length; i++){
			System.out.println(values[i]);
		}

	}
}

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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* alias */
using ll = long long;

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)



signed main() {
    string S; cin >> S;
    ll ans = 0;
    ll i = 0;
    char prv = '-';
    while(i < S.length()) {
        if (prv == '-') {
            ans++;
            prv = S[i];
            i++;
        } else {
            if (S[i] == prv) {
                ans++;
                prv = '-';
                i++;
                i++;
                if (i == S.length()+1) {
                    ans--;
                }
            } else {
                ans++;
                prv = S[i];
                i++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 720
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>

typedef long long ll;
using namespace std;

#define mod 1000000007
#define INF 1000000000 //(int)1e9
#define LLINF 8000000000000000000 //(ll)2e18
#define PI  3.1415926536

#define SIZE 100000

int main(){
    ll a;
    
    cin >> a;
    
    int ans = 0;
    
    while(a>0){
        ans ++;
        a/=2;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b + c >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
}

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

int main() {
    string s;
    cin >> s;
    int len = s.length();

    for(int i = 0; i < (len + 1) / 2; i++) {
        if(s[2 * i + 1] == 'R') {
            cout << "No" << endl;
            return 0;
        }
        if(s[2 * i] == 'L') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;



void dfs(vector<bool> &seen, const vector<vector<int>> &graph, int now) {
	seen[now] = true;
	for(int i=0; i<graph[now].size(); i++) {
		int tgt = graph[now][i];
		if(seen[tgt]) continue; // 探索済みなら飛ばす
		dfs(seen, graph, tgt);
	}
}

int main() {
	int N, M;
	cin >> N >> M;

	vector<vector<int>> graph(N);
	rep(i, M) {
		int x, y, z;
		cin >> x >> y >> z;
		x--;
		y--;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}

	vector<bool> seen(N, false);
	int ans = 0;
	rep(i, N) {
		if(seen[i]) continue;
		dfs(seen, graph, i);
		ans++;
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;
using ll = long long;


const int MOD = 998244353;

class Edge{
public:
    ll from,to, value;
    Edge(int f,int t, int c){
        from = f;
        to = t;
        value = c;
    }
};

int main(){
    int r;cin >> r;
    cout<<r*r<<endl;
}


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

int main()
{
	int n;
    cin >> n;
  	if(n&1)
    {
    	cout << ((n-1)/2)*((n+1)/2) << "\n";
    }
  	else
    {
     	cout << (n/2)*(n/2) << "\n";
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int i,j,p,n,b,f,r,v;
  int a[4][3][10]={};
  scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%d %d %d %d",&b,&f,&r,&v);
      a[b-1][f-1][r-1]=a[b-1][f-1][r-1]+v;
    }
    for(i=0;i<4;i++){
      for(j=0;j<3;j++){
	for(p=0;p<10;p++){
	  printf(" %d",a[i][j][p]);
	}
	printf("%c",'\n');
      }
if(i!=3)
      printf("####################\n");
      
    }
    return 0;
}   

Measured memory_bytes: 612
#include <stdio.h>

int main(){
    int n=0, N, point;
    char t[100000];
    
    scanf("%s", t);
    
    for (n=0; n<100000; n++){
        if (t[n] == 0) break;
    }
    N = n;

    for (n=0; n<N; n++){
        //a[n] = (n % 2 == 0)? 'g' : 'p';
        if (n % 2 == 0 && t[n] == 'p') point--;
        if (n % 2 == 1 && t[n] == 'g') point++;
    }
    
    printf("%d\n", point);
    
    return 0;
}


Measured memory_bytes: 256
def linear(A, B, C, K):
    s = 0
    if K <= A:
        return K

    s += A
    K -= A


    if K <= B:
        return s

    K -= B

    return s - K

if __name__ == "__main__":
    A, B, C, K = map(int, input().split())
    print(linear(A, B, C, K))


Measured memory_bytes: 9180
#include<stdio.h>
int main(void) {
	long long int a, b, lcm, ab, tmp;
	while (scanf("%lld %lld", &a, &b) != EOF)
	{
		ab = a*b;
		if (a < b) { tmp = a; a = b; b = tmp; }
		tmp = a%b;
		while (tmp != 0)
		{
			a = b; b = tmp; tmp = a%b;
		}
		lcm = ab / b;
		printf("%lld %lld\n", b, lcm);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, 0, n) cin >> h[i];
    int ans = 0;
    int cnt = 0;
    rep(i, 0, n - 1){
        if(h[i] >= h[i + 1]){
            cnt++;
        }else{
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りではない別回答
 */
public class Main {

	/** 白のコマ */
	private static final char WHITE = '.';

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int h = scanner.nextInt(), w = scanner.nextInt();
			boolean[][] s = new boolean[h][w];
			IntStream.range(0, h).forEach(i -> Arrays.fill(s[i], false));
			int whiteCount = 0;
			for (int i = 0; i < h; i++) {
				char[] l = scanner.next().toCharArray();
				for (int j = 0; j < w; j++) {
					s[i][j] = (l[j] == WHITE);
					if (s[i][j]) {
						whiteCount++;
					}
				}
			}
			int[][] v = new int[h][w];
			IntStream.range(0, h).forEach(i -> Arrays.fill(v[i], Integer.MAX_VALUE));
			v[0][0] = 1;
			calcResult(0, 0, s, v);
			System.out.println((v[h - 1][w - 1] < Integer.MAX_VALUE) ? whiteCount - v[h - 1][w - 1] : -1);
		}
	}

	/**
	 * @param x X座標
	 * @param y Y座標
	 * @param s マスの状態の配列
	 * @param v (0,0)からそれぞれのマスへ移動する場合の通過マスの数の最小値
	 */
	private static void calcResult(int x, int y, final boolean[][] s, final int[][] v) {
		int h = s.length, w = s[0].length;
		if (((h - 1) == x) && ((w - 1) == y)) {
			// 終点の場合、終了
			return;
		}
		if ((x > 0) && s[x - 1][y] && (v[x][y] + 1 < v[x - 1][y])) {
			v[x - 1][y] = v[x][y] + 1;
			calcResult(x - 1, y, s, v);
		}
		if ((y > 0) && s[x][y - 1] && (v[x][y] + 1 < v[x][y - 1])) {
			v[x][y - 1] = v[x][y] + 1;
			calcResult(x, y - 1, s, v);
		}
		if ((x < h - 1) && s[x + 1][y] && (v[x][y] + 1 < v[x + 1][y])) {
			v[x + 1][y] = v[x][y] + 1;
			calcResult(x + 1, y, s, v);
		}
		if ((y < w - 1) && s[x][y + 1] && (v[x][y] + 1 < v[x][y + 1])) {
			v[x][y + 1] = v[x][y] + 1;
			calcResult(x, y + 1, s, v);
		}
	}
}


Measured memory_bytes: 42648
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

int border[] = {599, 799, 999, 1199, 1399, 1599, 1799, 1999};

void solve(int cn) {
    int N; cin>>N;
    auto kyu = border+8-lower_bound(border, border+8,N);
    cout<<kyu<<endl;
}


#define SINGLE
int main() {
#ifdef SINGLE
    solve(1);
#else
    int N;
    cin>>N;
    for(int i=0;i<N;++i){
        solve(i);
    }
#endif
    return 0;
}


Measured memory_bytes: 3636
def pfact(m):
	pf = {}
	for i in range(2,int(m**0.5)+1):
		while m%i == 0:
			pf[i] = pf.get(i,0) + 1
			m //= i
	if m>1 : pf[m]=1
	return pf

n = int(input())
pl = pfact(n).values()
ans = 0
for i in pl:
	k = i
	for j in range(1,41):
		k -= j
		if k < 0:
			break
		ans += 1
print(ans)

Measured memory_bytes: 9492
#include <stdio.h>
#include <string.h>

int main () {
	char s[200005], t[200005];
	int  count = 0;
	scanf("%s", &s);
	scanf("%s", &t);
	int len = strlen(s);
	for (int i = 0; i < len; i++) {
		if (s[i] != t[i]) {
			count++;
		}
	}
	
	printf("%d", count);
	
	return 0;
}

Measured memory_bytes: 2116
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 3e3+5;
const lli INF = 1e18;
const lli MOD = 1e9+7;

vi m;
vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	m = vi(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

lli SUM(lli a, lli b, lli mod=MOD){
	return (a+b+mod)%mod;
}

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

// ---- コーディングはここから！ ('-')7

void solve(){
	int n,k; cin>>n>>k;
	vvi v(n+1);
	fore(i,0,k){
		int a,b; cin>>a>>b;
		v[a].pb(b);
	}
	vi h(n+1,0);
	auto f=[&](auto f, int u)->void{
		for(auto i:v[u]){
			if(h[i])continue;
			f(f,i);
		}
		h[u]=1;
		for(auto i:v[u])h[u]=max(h[u],h[i]+1);
	};
	int mx=0;
	fore(i,0,n+1){
		if(h[i]==0)f(f,i);
		mx=max(mx,h[i]);
	}
	cout<<mx-1<<ENDL;
}

int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


Measured memory_bytes: 13128
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<int,int> P;


int a,b,c;
int t;
int main(){
  int N,A,B;
  string s;
  cin >> N >> A >> B;
  cin >> s;
  for(int i=0;i<N;i++){
    if(s[i] == 'a'){
      if(t < A+B){
        t++;
        a++;
        cout << "Yes" << endl;
      }
      else{
        cout << "No" << endl;
      }
    }
    else if(s[i] == 'b'){
      if(t < A+B && b < B){
        t++;
        b++;
        cout << "Yes" << endl;
      }
      else{
        cout << "No" << endl;
      }
    }
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define INF 1e18
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
#define MAX 1000
#define ll long long
#define P pair<int,int>
using namespace std;
const int mod = 1000000007;
//char c[MAX][MAX];
int step[MAX][MAX];
int H,W,N; 
int vy[4] ={1,-1,0,0}, vx[4] = {0,0,-1,1}; //up,down,left,right 
int n,m,q; 
vector<int> a,b,c,d;
int ans;

void dfs(vector<int> A){
    //cout << endl;
    //cout << A.size() << " : ";
    //rep(i,A.size()) cout << A[i] << ",";
    if (A.size() == n+1) {
        int now = 0;
        rep(i,q){   // 点数の計算
            if(A[b[i]] - A[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans,now); // 今までの値と比べ、最大値を格納
        return;
    }
    A.push_back(A.back());
    while (A.back() <= m){
        dfs(A);
        A.back()++;
    }
}

signed main(){
    cin >> n >> m >> q;
    a.resize(q); b.resize(q); c.resize(q); d.resize(q);
    rep(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int> (1,1));
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;

const ll INF=0x7fffffff;


int main(){
	ll ans=1;
	int n,k;
	cin>>n>>k;
	while(n--){
		if(ans<k){
			ans*=2;
		}
		else ans+=k;
	}
	cout<<ans<<endl;
	return 0;
} 
	
	
	

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

int main()
{
    int N, M;
    double comp = 999999999, tmp = 0;
    cin >> N >> M;
    vector<vector<double>> g(N, vector<double>(2));
    vector<vector<double>> p(M, vector<double>(2));

    for (int i = 0; i < N;i++){
        for (int j = 0; j < 2;j++){
            cin >> g.at(i).at(j);
        }
    }
    for (int i = 0; i < M; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            cin >> p.at(i).at(j);
        }
    }
    for (int i = 0; i < N;i++){
        for (int j = 0; j < M;j++){
            
            if (comp > abs(g.at(i).at(0) - p.at(j).at(0)) + abs(g.at(i).at(1) - p.at(j).at(1))){
                comp = abs(g.at(i).at(0) - p.at(j).at(0)) + abs(g.at(i).at(1) - p.at(j).at(1));
                tmp = j+1;
            }
            //cout << abs(g.at(i).at(0) - p.at(j).at(0)) + abs(g.at(i).at(1) - p.at(j).at(1)) << endl;
        }
        cout << tmp << endl;
        comp = 999999999;
    }
}

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

int main(){
  string s;
  int k;
  cin >> s >> k;
  int n = sz(s);
  for (int i = 0; i < n; i++) {
    int c = (int)(s[i] - 'a');
    int dif = (26 - c) % 26;
    if (i == n-1 && k > 0) {
      s[i] = (c + k) % 26 + 'a';
    } else if (dif <= k) {
      s[i] = (c + dif) % 26 + 'a';
      k -= dif;
    }
  }
  cout << s << endl;
  return 0;
} 

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n;
  cin >> n;
  vll a(n);
  rep(i,n) cin >> a[i];

  ll a_sum = 0;
  rep(i,n) a_sum += a[i];
  ll a_half = a_sum/2;

  ll ans = INFLL;
  
  vll sl(n-1);
  sl[0] = a[0];
  rep(i,n-2) {
    sl[i+1] = sl[i] + a[i+1];
  }
  //debug(a_sum);
  //rep(i,sl.size()) printf("%d%c", sl[i], i==sl.size()-1?'\n':' ');

  rep(i,n-1) {
    ll d = abs(sl[i] - (a_sum - sl[i]));
    ans = min(ans, d);
  }

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

Measured memory_bytes: 3328
n=int(input())
l=list(map(int,input().split()))
ans=0
import bisect
l.sort()
for i in range(n-2):
    for j in range(i+1,n-1):
        tmp= bisect.bisect_left(l,l[i]+l[j])
        ans+=tmp-j-1
        
print(ans)        
        

Measured memory_bytes: 3188