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

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

int main() {
    long long N;  cin >> N;
    long long ans = 0;
   
    for (auto e : prime_divisors(N)) {
        long long x = 1;
        while (true) {
            if (x * (x + 1) > 2 * e.second) break;
            ++x;
        }
        ans += x - 1;
    }
    cout << ans << endl;
}

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

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=55,MOD=1e9+7;
inline int mod(int x){return x<MOD?x:x-MOD;}
inline void add(int &x,int y){x=mod(x+y);}
int n,c[MAXN][MAXN],dp[MAXN][MAXN];
int main() {
	n=read();
	c[0][0]=1;for(int i=1;i<=n;++i){c[i][0]=1;for(int j=1;j<=i;++j)c[i][j]=mod(c[i-1][j-1]+c[i-1][j]);}
	dp[1][1]=dp[1][0]=n;
	for(int i=1;i<=n-1;++i){
		for(int j=0;j<=i;++j){
			for(int k=max(j,1);k<=n-i;++k){
				if((k-j)&1)continue;
				int y=(k-j)/2;
				for(int x=0;x<=k;++x){
					add(dp[i+k][abs(x-y)],(ll)dp[i][j]*c[n-i][k]%MOD*c[k][x]%MOD);
				}
			}
		}
	}
	cout<<dp[n][0]%MOD<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int K, X;
	cin >> K >> X;
	int sum = 500 * K;
	if (sum >= X)cout << "Yes";
	else cout << "No";
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;

int main() {
	ll n;
	vector<ll> v;

	cin >> n;

	REP(i, n) {
		ll a;
		cin >> a;
		v.push_back(a);
	}

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

	ll a, b;

	a = v[n - 1];

	ll x = INF;

	REP(i, n) {
		if (abs((a - v[i]) - v[i]) < x) {
			x = abs((a - v[i]) - v[i]);
			b = v[i];
		}
	}

	cout << a << " " << b << endl;
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String[] line = scan.nextLine().split(" ");

        int[] inputs = new int[2];
        int input;

        // -1,000 ≤ a, b ≤ 1,000
        for (int i = 0; i < line.length; i++) {
            input = Integer.parseInt(line[i]);
            if (input < -1000 || 1000 < input ) System.exit(-1);
            inputs[i] = input;
        }

        int a = inputs[0];
        int b = inputs[1];

        System.out.println("a " + (a < b ? "<": a > b ? ">" : "==") + " b" );

        scan.close();
    }

}



Measured memory_bytes: 26356
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a[3];
  rep(i,0,3) cin >> a[i];
  sort(a, a+3);
  if(a[0]==5 && a[1]==5 && a[2]==7) co("YES");
  else co("NO");
  
  return 0;
}

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

#define pb push_back
#define mp make_pair
#define inside sl<=l&&r<=sr
#define outside r<sl||sr<l
using namespace std;
typedef long long ll;

int main(){
	//freopen("stl.gir", "r", stdin);
	
	int n;
	cin >> n;
	vector<int> arr(n);
	for (int i = 0; i < n; i++) cin >> arr[i];
	vector<int> dp(n);
	dp[0] = 0;
	dp[1] = abs(arr[0]-arr[1]);
	for (int i = 2; i < n; i++){
		dp[i] = min(dp[i-1] + abs(arr[i]-arr[i-1]), dp[i-2] + abs(arr[i]-arr[i-2]));
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>


int main(){
  int R; std::cin >> R;
  if (R < 1200){
    std::cout << "ABC" << std::endl;
  }
  if (R >= 1200 && R < 2800){
    std::cout << "ARC" << std::endl;
  }
  if (R >= 2800){
    std::cout << "AGC" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll arr[100100],n,ans,temp,gcd,maxi,a,b,c,k,m,p,l,temp1,temp2;
string s;
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    maxi=arr[0];
    gcd=arr[0];
    for(int i=1;i<n;i++)
    {
        maxi=max(maxi,arr[i]);
        gcd=__gcd(arr[i],gcd);
    }
    if(k>maxi || k%gcd)
        cout<<"IMPOSSIBLE"<<endl;
    else
        cout<<"POSSIBLE"<<endl;
return 0;
}


Measured memory_bytes: 1024
from sys import stdin
input = stdin.readline

N, A = [int(x) for x in input().rstrip().split()]
x = [int(x) for x in input().rstrip().split()]

X = max(max(x), A)
# dp = [[[0]*(N*X+1) for _ in range(N+1)] for _ in range(N+1)]
# for j in range(N+1):
# 	for k in range(N+1):
# 		for s in range(N*X+1):
# 			if j == 0 and k == 0 and s == 0:
# 				dp[j][k][s] = 1
# 			elif j >= 1 and s < x[j-1]: # 探索先が総和より大きい
# 				dp[j][k][s] = dp[j-1][k][s]
# 			elif j >= 1 and k >= 1 and s >= x[j-1]:
# 				dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]]
# 			else:
# 				dp[j][k][s] = 0
# sum = 0
# for i in range(1, N+1):
# 	sum += dp[N][i][i*A]
# print(sum)

dp = [[0]*(2*N*X+1) for _ in range(N+1)]
y = [0] * len(x)
for i in range(len(x)):
	y[i] = x[i]-A

for j in range(N+1):
	for t in range(-N*X,N*X+1):
		if j == 0 and t == 0:
			dp[j][t] = 1
		elif j >= 1 and (t-y[j-1] < -N*X or t-y[j-1] > N*X):
			dp[j][t] = dp[j-1][t]
		elif j >= 1 and -N*X <= t-y[j-1] <= N*X:
			dp[j][t] = dp[j-1][t] + dp[j-1][t-y[j-1]]
		else:
			dp[j][t] = 0
print(dp[N][0]-1)


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

#define LL long long
#define RG register

using namespace std;
template<class T> inline void read(T &x) {
	x = 0; RG char c = getchar(); bool f = 0;
	while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') c = getchar(), f = 1;
	while (c >= '0' && c <= '9') x = x*10+c-48, c = getchar();
	x = f ? -x : x;
	return ;
}
template<class T> inline void write(T x) {
	if (!x) {putchar(48);return ;}
	if (x < 0) x = -x, putchar('-');
	int len = -1, z[20]; while (x > 0) z[++len] = x%10, x /= 10;
	for (RG int i = len; i >= 0; i--) putchar(z[i]+48);return ;
}
const int N = 18, Mod = 1e9 + 7;
int n, m, limit, cnt[1 << N];
LL fac[1 << N], ifac[1 << N], a[N];
LL f[N][1 << N];
LL fpow(LL a, int b) {
	LL res = 1;
	for (; b; b >>= 1, a = a * a % Mod) if (b & 1) res = res * a % Mod;
	return res;
}
LL C(int n, int m) {
	if (n < m) return 0;
	return fac[n] * ifac[m] % Mod * ifac[n - m] % Mod;
}
void pls(LL &x, LL y) {
	x += y;
	if (x >= Mod) x -= Mod;
	if (x < 0) x += Mod;
}
int main() {
	read(n), read(m);
	for (int i = 1; i <= m; i++) read(a[i]);
	sort(a + 1, a + 1 + m);
	limit = 1 << n; fac[0] = 1;
	for (int i = 1; i <= limit; i++) fac[i] = fac[i - 1] * i % Mod;
	ifac[limit] = fpow(fac[limit], Mod - 2);
	for (int i = limit; i >= 1; i--) ifac[i - 1] = ifac[i] * i % Mod;
	f[m + 1][0] = 1;
	for (int i = m; i; i--)
		for (int S = 0; S < limit; S++)
			if (f[i + 1][S]) {
				pls(f[i][S], f[i + 1][S]);
				int s = limit - S; //剩下的
				for (int j = 0; j < n; j++)
					if (!(S >> j & 1))
						pls(f[i][S | (1 << j)], f[i + 1][S] * C(s - a[i], (1 << j) - 1) % Mod * fac[1 << j] % Mod);
			}
	LL ans = 0;
	cnt[0] = 1; for (int i = 0; i < limit; i++) cnt[i] = (i & 1) ? -cnt[i >> 1] : cnt[i >> 1];
	for (int i = 0; i < limit; i++)
		pls(ans, f[1][i] * fac[limit - 1 - i] % Mod * cnt[i]);
	printf("%lld\n", ans * limit % Mod);
	return 0;
}


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

signed main() {
	int n;
	cin >> n;
	vector<int> w(n);
	rep(i, n) cin >> w[i];
	int ans = 99999;
	rep(t, n) {
		int a = 0; int b = 0;
		for (int j = 0; j <= t; j++) {
			a += w[j];
		}
		for (int k = t+1; k < n; k++) {
			b += w[k];
		}
		ans = min(ans, abs(a-b));
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false); 
    ll n;
    cin >> n;
    vector<ll>A(n);
    ll sum=0;
    REP(i,n){
        
        cin >> A[i];
        sum+= A[i];
    }
    ll x= round((double)sum/n);
    ll ans=0;
    REP(i,n){
        ans+= powl(abs(A[i]-x),2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<stdio.h>

int judge(char *a,char *b,int n){
    int i=0;
    while(i<n-2){
        if(*(a+i+1)=='o'){
            if(*(b+i)=='S'&&*(b+i+1)=='S'){
                *(b+i+2)='S';
            }else if(*(b+i)=='S'&&*(b+i+1)=='W'){
                *(b+i+2)='W';
            }else if(*(b+i)=='W'&&*(b+i+1)=='S'){
                *(b+i+2)='W';
            }else if(*(b+i)=='W'&&*(b+i+1)=='W'){
                *(b+i+2)='S';
            }
        }else{
            if(*(b+i)=='S'&&*(b+i+1)=='S'){
                *(b+i+2)='W';
            }else if(*(b+i)=='S'&&*(b+i+1)=='W'){
                *(b+i+2)='S';
            }else if(*(b+i)=='W'&&*(b+i+1)=='S'){
                *(b+i+2)='S';
            }else if(*(b+i)=='W'&&*(b+i+1)=='W'){
                *(b+i+2)='W';
            }
        }
        i++;
    }

    int sp=0;
    if(*(a+n-1)=='o'){
        if(*(b+n-1)=='S'){
            if(*(b+n-2)=='S'&&*b=='S'){
                sp++;
            }else if(*(b+n-2)=='W'&&*b=='W'){
                sp++;
            }
        }else{
            if(*(b+n-2)=='S'&&*b=='W'){
                sp++;
            }else if(*(b+n-2)=='W'&&*b=='S'){
                sp++;
            }
        }
    }else{
        if(*(b+n-1)=='S'){
            if(*(b+n-2)=='S'&&*b=='W'){
                sp++;
            }else if(*(b+n-2)=='W'&&*b=='S'){
                sp++;
            }
        }else{
            if(*(b+n-2)=='S'&&*b=='S'){
                sp++;
            }else if(*(b+n-2)=='W'&&*b=='W'){
                sp++;
            }
        }
    }

    if(*a=='o'){
        if(*b=='S'){
            if(*(b+n-1)=='S'&&*(b+1)=='S'){
                sp++;
            }else if(*(b+n-1)=='W'&&*(b+1)=='W'){
                sp++;
            }
        }else{
            if(*(b+n-1)=='S'&&*(b+1)=='W'){
                sp++;
            }else if(*(b+n-1)=='W'&&*(b+1)=='S'){
                sp++;
            }
        }
    }else{
        if(*b=='S'){
            if(*(b+n-1)=='S'&&*(b+1)=='W'){
                sp++;
            }else if(*(b+n-1)=='W'&&*(b+1)=='S'){
                sp++;
            }
        }else{
            if(*(b+n-1)=='S'&&*(b+1)=='S'){
                sp++;
            }else if(*(b+n-1)=='W'&&*(b+1)=='W'){
                sp++;
            }
        }
    }
    return sp;
}

int main(){
    int n;
    scanf("%d",&n);
    char s[n];
    scanf("%s",s);

    char t[n],u[n],v[n],w[n];
    t[0]='S';
    t[1]='S';
    int st=judge(s,t,n);
    u[0]='S';
    u[1]='W';
    int su=judge(s,u,n);
    v[0]='W';
    v[1]='S';
    int sv=judge(s,v,n);
    w[0]='W';
    w[1]='W';
    int sw=judge(s,w,n);

    if(st>1){
        for(int i=0;i<n;i++){
            printf("%c",t[i]);
        }
    }else if(su>1){
        for(int i=0;i<n;i++){
            printf("%c",u[i]);
        }
    }else if(sv>1){
        for(int i=0;i<n;i++){
            printf("%c",v[i]);
        }
    }else if(sw>1){
        for(int i=0;i<n;i++){
            printf("%c",w[i]);
        }
    }else{
        printf("-1\n");
    }
    return 0;
}

Measured memory_bytes: 2068
import           Data.Maybe
import qualified Data.ByteString.Char8         as C8

getInts :: IO [Int]
getInts = fmap (map (fst . fromJust . C8.readInt) . C8.words) C8.getLine

main :: IO ()
main = do
    [_, x] <- getInts
    xs     <- getInts
    print . foldl1 gcd . map (\y -> abs (y - x)) $ xs


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

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

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}





void oneCase () {
    int n;
    cin >> n;
    vector<string> lines(n);
    for (auto& l : lines) {
        cin >> l;
    }
    vector<int> minCounter(26, 1e9);

    for (int i = 0; i < n; ++i) {
        vector<int> cur(26);
        for (auto letter : lines[i]) {
            cur[int(letter) - int('a')] += 1;
        }
        for (int i = 0; i < 26; ++i) {
            minCounter[i] = min(minCounter[i], cur[i]);
        }
    }
    for (int i = 0; i < 26; ++i) {
        for (int j = 0; j < minCounter[i]; ++j) {
            cout << char('a' + i);
        }
    }
    cout << "\n";

}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

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

int main()
{
  map<int,int>m;
  int n,k;
  cin>>n;
int flag=1;
  for(int i=0;i<n;i++)
  {
      cin>>k;
      m[k]++;
      if(m[k]>1) flag=0;
  }
  if(flag) puts("YES");
  else puts("NO");
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long int ll;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct X_magic_ { X_magic_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } X_magic__;
constexpr ll INF = ((1LL << 61) + (1 << 29));

int main() {
	int X;
	cin >> X;
	map<int, int> f = {
		{ 600, 8 },
		{ 800, 7 },
		{ 1000, 6 },
		{ 1200, 5 },
		{ 1400, 4 },
		{ 1600, 3 },
		{ 1800, 2 },
		{ 2000, 1 }
	};
	for (auto kv : f) {
		if (X < kv.first) {
			std::cout << kv.second << std::endl;
			return 0;
		}
	}
}

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

int main() {
    using namespace std;
    unsigned long N, M;
    cin >> N >> M;
    vector<vector<unsigned long>> edge(N);
    for(unsigned long i = 0, A, B; i < M; ++i){
        cin >> A >> B;
        edge[--A].push_back(--B);
    }
    deque<unsigned long> ans, vis(N);
    auto dfs = [rec = [&edge, &ans, &vis](auto f, unsigned long now, unsigned long prev, unsigned long begin) -> bool{
        if(now != prev && now == begin)return true;
        if(vis[now])return false;
        vis[now] = 1;
        for(const auto& i : edge[now])if(i != prev)if(f(f, i, now, begin)){
            ans.push_back(now);
            return true;
        }
        return false;
    }](auto begin){return rec(rec, begin, begin, begin);};
    for(unsigned long i = 0; i < N; ++i){
        fill(vis.begin(), vis.end(), 0UL);
        if(dfs(i))break;
    }
    if(ans.empty())return 0 & puts("-1");
    reverse(ans.begin(), ans.end());
    vector<unsigned long> memo(N);
    unsigned long as{ans.size()};
    for(unsigned long i = 0; i < as; ++i)memo[ans[i]] = i;
    for(unsigned long i = 0; i < as; ){
        unsigned long mx{0};
        auto t = ans.front();
        ans.pop_front();
        for(const auto& j : edge[t])mx = max(mx, memo[j]);
        if(mx > 1){
            while(!ans.empty() && memo[ans.front()] < mx){
                memo[ans.front()] = 0;
                ans.pop_front();
            }
            i = 0;
        }
        if(mx == 1)++i;
        if(mx == 0)abort();
        ans.push_back(t);
        as = ans.size();
        for(unsigned long j = 0; j < as; ++j)memo[ans[j]] = j;
    }
    cout << as << endl;
    for(const auto& i : ans)cout << i + 1 << endl;
    return 0;
}

Measured memory_bytes: 384
makeShape :: Int -> a -> a -> [a]
makeShape n a b = a : f' (n - 1)
  where f' x = if x > 1 then b : f' (x - 1) else [a]

makeFrame :: Int -> Int -> [String]
makeFrame h w = makeShape h hl ml
  where
    hl = replicate w '#'
    ml = makeShape w '#' '.'

main = do
  contents <- getContents
  let
    dat = takeWhile (/= [0,0]) 
      $ map (map (read :: String -> Int)) 
      $ map words 
      $ lines contents
    ansList = map (\[h,w] -> makeFrame h w) dat
  mapM_ (putStrLn . unlines) ansList


Measured memory_bytes: 4380
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
n,m = iim()
mod = 1000_000_007

def prepare(n, MOD):
     # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return factorials, invs


fac,inv = prepare(max(n,m),mod)
if abs(n-m) == 1:
    print(fac[n]*fac[m]%mod)
elif abs(n-m) == 0:
    print(fac[n]*fac[m]*2%mod)
else:
    print(0)

Measured memory_bytes: 16848
#include <stdio.h>

#define Max 2000
#define Inf 100000000
#define NIL -1
#define WHITE 0
#define BLACK 1



int i, j, n, total = 0;
int matrix[Max][Max], d[Max], pi[Max], color[Max];


void prim(){

int u, v, mincost;

 for(u = 0 ; u <n ; u++){
   d[u] = Inf;
   pi[u] = NIL;
   color[u] =WHITE;
 }
 d[0] = 0;
 
 while(1){
   mincost = Inf;
   for(i = 0 ; i < n ; i++){
     if(color[i] != BLACK && d[i] < mincost){
       mincost = d[i];
       u = i;
     }
   }
   if( mincost == Inf)
     break;
   
   color[u] =BLACK;
   
   for(v = 0 ; v < n ; v++){
     if(matrix[u][v] == NIL)
       continue;
     else if(color[v] != BLACK && matrix[u][v] < d[v]){
       pi[v] = u;
       d[v] = matrix[u][v];      
     }
   }
 }
}


int main(){


  scanf("%d",&n);

  for( i = 0 ; i < n ; i++)
    for( j = 0 ; j < n ; j++)
      scanf("%d",&matrix[i][j]);
    
  prim();


  for( i = 0 ; i < n ; i++)
    total += d[i];
 
  printf("%d\n",total);

  return 0;
}
  

Measured memory_bytes: 1044
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

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

void solve(){
	auto s = rstring, t = rstring;
	auto a = rint, b = rint;
	auto u = rstring;

	if(s == u) writeln(a - 1, " ", b);
	else writeln(a, " ", b - 1);
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		solve();
	}
	static void solve() {
		Scanner sc = new Scanner(System.in); 
		int h = sc.nextInt();
		int n = sc.nextInt();
		int sum = 0;
		int array[] = new int [n];
		for(int i = 0; i<n; i++) {
			array[i] = sc.nextInt();
			sum+=array[i];
			}
		if(sum>=h) {
			System.out.println("Yes");
		}
		else
			System.out.println("No");
	}

}


Measured memory_bytes: 52104
#include <bits/stdc++.h>
#include <math.h>
#include <iostream>
#include <stdlib.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main(void){
    int n;
    cin >> n;
    int A[n-1], B[n-1];
    cin >> B[0];
    A[0] = B[0];
    long int answer = A[0];
    for(int i=1;i<n-1;i++){
        cin >> B[i];
        A[i] = min(B[i-1],B[i]);
        answer += A[i];
    }
    answer += B[n-2];
    cout << answer << endl;
    return 0;
}

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  int t[n];
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }
  int m;
  cin >> m;
  int p[m], x[m];
  for (int i = 0; i < m; i++) {
    cin >> p[i] >> x[i];
  }
  int ans;
  for (int i = 0; i < m; i++) {
    ans = 0;
    int tmp = t[p[i] - 1];
    t[p[i] - 1] = x[i];
    for (int j = 0; j < n; j++) {
      ans += t[j];
    }
    cout << ans << endl;
    t[p[i] - 1] = tmp;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int) n;i++)
#define rep1(i,m,n) for(int i=(int) m;i<(int) n;i++)
#define fix(n) cout << fixed << setprecision((int)n)

void absll(ll &x) {
    if(x>=0) return ;
    else x=-x; return;
}

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

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

const ll INF = 1LL << 60;

int N;

//DPテーブル
vector<ll> dp(100010);

int main() {
    int a;
    cin>>a;
    a=a+a*a+a*a*a;
    cout<<a<<endl;
}

Measured memory_bytes: 3904
def divide_all(a):
    success = True
    for i, n in enumerate(a):
        if n % 2 != 0:
            success = False
            break
        a[i] = n / 2
    if success is False:
        return (a, False)
    return (a, True)

n = int(input())
a = list(map(int, input().split()))
c = 0
while True:
    a, r = divide_all(a)
    if r is False:
        break
    c += 1


print(c)


Measured memory_bytes: 3060
import Control.Applicative( (<$>))
import Data.IntSet( fromList, toAscList, member, deleteFindMin)
import qualified Data.IntSet as IS

main = do
    let
	readLine = Prelude.map read . words <$> getLine

    [n_, k_] <- readLine
    as_ <- readLine
    let
	aset = fromList as_

	(minA, taleSet) = deleteFindMin aset

	parts = toAscList $ IS.map (`gcd` minA) taleSet

	candidate = dropWhile (k_>=) $ toAscList aset

	toMake = (subtract k_) <$> candidate

	check _	    []		    _	    = False
	check []    _		    _	    = False
	check prts targets@(t:ts) []	    = check prts ts prts
	check prts targets@(t:ts) (p:ps)
	  | t `rem` p == 0		= True
	  | otherwise			= check prts ts ps

    putStr $ if k_ `member` aset    || check parts toMake parts
		then "POSSIBLE"
		else "IMPOSSIBLE"

Measured memory_bytes: 52604
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

const int N = 3010;
typedef long long LL;

string s,t;
int dp[N][N];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>s>>t;
    int n = s.size(), m = t.size();
    s = " " + s;
    t = " " + t;
    

    for(int i = 1; i<=n; i++){
        for(int j = 1; j<=m; j++){
            if(s[i] == t[j]) dp[i][j] = dp[i-1][j-1] + 1;
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    
    // for(int i = 1; i<=n; i++){
    //     for(int j = 1; j<=m;j ++){
    //         cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
    //     }
    // }
    
    string ans = "";
    int i = n, j = m;
    while(dp[i][j]){
        if(s[i] == t[j]){
            ans += s[i];
            i--;
            j--;
        }else{
            if(dp[i][j] == dp[i][j-1]) j--;
            else i--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
    return 0;
}

Measured memory_bytes: 38316
#include <bits/stdc++.h>
using namespace std;
int main(){
   int n;
   cin >> n;
   vector<int> a(n);
   for(int i = 0;i<n;i++){
       cin >> a.at(i);
   }

   bool flag = true;
   int cnt = 0;
   int tmp = 0;
   while(flag){
       flag = false;
       for(int j = n-1;j >= 1;j--){
           if(a.at(j) < a.at(j-1)){
               swap(a.at(j-1),a.at(j));
               cnt++;
               flag = true;
           }
       }
   }

   for(int i = 0;i < n;i++){
       if(i > 0) cout << " ";
       cout << a.at(i);
   }
   cout << endl;

   cout << cnt << endl;

}


Measured memory_bytes: 3124
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(void)
{
    int x;
    int i, j;

    cin >> x;
    for(i = -1000; i <= 1000; i ++)
        for(j = -1000; j <= 1000; j ++)
            if((long long)i * i * i * i * i - (long long)j * j * j * j * j == x)
            {
                cout << i << ' ' << j << endl;
                return 0;
            }

    return 0;
}


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

int main() {
  string s;
  int sum = 0;
  cin >> s;
  rep(i,0,s.size()){
    sum += s[i]-'0';
    sum %= 9;
  }
  if(sum%9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3748
from collections import Counter,defaultdict,deque
import sys,bisect,math,itertools,string,queue
from heapq import heappop, heappush
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
res = float('inf')
for i in range(1,10**6+1):
    if n%i == 0:
        res = min(res, i + n/i)
print(int(res-2))


Measured memory_bytes: 41192
(H, W) = gets.split.map(&:to_i)
(h2, w2) = gets.split.map(&:to_i)

c = H * W
d = 0

H.times do |i|
  W.times do |j|
    d = d + 1 if i < h2 || j < w2
  end
end

puts c - d

Measured memory_bytes: 1788
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    double x1, y1, x2, y2, dis;
    
    cin >> x1 >> y1 >> x2 >> y2;
    
    dis = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
    
    cout << fixed << dis << endl;
    
    return 0;
}


Measured memory_bytes: 3268
/**
 *    author:  Atreus
**/
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int maxn = 1e5 + 10;
int a[maxn], dp[maxn];

int main(){
	ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	memset(dp, 63, sizeof dp);
	dp[1] = 0;
	for (int i = 2; i <= n; i++)
		for (int j = i - 1; j >= max(1, i - k); j--)
			dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
	cout << dp[n] << '\n';
}


Measured memory_bytes: 1024
process.stdin.resume();
process.stdin.setEncoding('ascii');

var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

process.stdin.on('data', function (data) {
    input_stdin += data;
});

process.on('SIGINT', function(){
    input_stdin_array = input_stdin.split("\n");
    main();
    process.exit();
});

process.stdin.on('end', function () {
    input_stdin_array = input_stdin.split("\n");
    main();    
});

function readLine() {
    return input_stdin_array[input_currentline++];
}

/////////////// ignore above this line ////////////////////


function main() {
	var a = readLine();
	var b = readLine();
	var c = readLine();
	
	var turno = "a";
	while (true){
		var nextTurno;
		if (turno == "a"){
			nextTurno = a.substring(0,1);
			a = a.substring(1);
		} else if (turno == "b"){
			nextTurno = b.substring(0,1);
			b = b.substring(1);
		} else {
			nextTurno = c.substring(0,1);
			c = c.substring(1);
		}
		if (nextTurno.localeCompare("a") != 0 && 
		    nextTurno.localeCompare("b") != 0 &&
			nextTurno.localeCompare("c") != 0){
			break;
		}
		turno = nextTurno;
	}
	console.log(turno.toUpperCase());
	
    process.exit();
}

Measured memory_bytes: 10680
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
#define PI 3.141592653589793238462643383279502
#define debug(n1) cout<<"debug... "<<n1<<"\n"
const ll INF=(1ll<<60)-1;//ll ans = 3e18 + 5;
////////////////////////////////////////////////////////
ll power(ll x, ll y, ll p)
{
    ll res = 1;   // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    if( res < 0 )
    res+=rem;
    return res;
}
////////////////////////////////////////////////////////
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll tc=1;
   // cin>>tc;
    while(tc--)
    {
        ll n;
        cin>>n;
        // vector<ll> dp(1000000,0);
        // dp[1]=0;
        // dp[2]=2;
        ll ans = power( 10 , n , rem ) - (2*power( 9 , n , rem ))%rem + power( 8 , n , rem );
        if( ans < 0 )
        ans+=rem;
        cout<<ans%rem;
    }
}

Measured memory_bytes: 3648
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    Node[] nodes = new Node[N];
    for (int i = 0; i < N; i++) nodes[i] = new Node();

    for (int i = 0; i < N - 1; i++) {
      int a = scanner.nextInt() - 1;
      int b = scanner.nextInt() - 1;
      nodes[a].adjacent.add(nodes[b]);
      nodes[b].adjacent.add(nodes[a]);
    }
    dfs(nodes[0], null);

    int M = 1_000_000_007;
    long res = N * modpow(2, M - 2, M) % M;
    for (Node node : nodes) {
      res += (node.adjacent.size() - 1) * modinv(modpow(2, N, M), M) % M;
      if (res >= M) res -= M;
      for (Node c : node.children) {
        res -= modinv(modpow(2, N - c.size, M), M);
        if (res < 0) res += M;
      }
      if (node.parent != null) {
        res -= modinv(modpow(2, node.size, M), M);
        if (res < 0) res += M;
      }
    }
    System.out.println(res);
  }

  private static long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
  }

  private static long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
      if (n % 2 == 1) res = (res * a) % mod;
      a = (a * a) % mod;
      n >>= 1;
    }
    return res % mod;
  }

  private static int dfs(Node node, Node parent) {
    node.parent = parent;
    node.size = 1;
    for (Node a : node.adjacent) {
      if (a != parent) {
        node.children.add(a);
        node.size += dfs(a, node);
      }
    }
    return node.size;
  }

  private static class Node {
    private Node parent;
    private int size;
    private List<Node> children = new ArrayList<>();
    private List<Node> adjacent = new ArrayList<>();
  }
}


Measured memory_bytes: 186616
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <deque>
#include <tuple>
#include <map> 
#include <set>
#include <stack>
#include <functional>
#define ll long long
using namespace std;

int main() {

	int idx = 0;
	for (int i = 0; i < 5; i++) {
		int num;
		cin >> num;
		if (num == 0) {
			idx = i + 1;
		}
	}
	cout << idx << endl;
}

Measured memory_bytes: 3600
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt, pi
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

# A:赤, B:緑, C:青
# A < B < Cにする
A, B, C = getNM()
K = getN()

cnt = K
while cnt > 0:
    if A >= B:
        B *= 2
        cnt -= 1
    else:
        C *= 2
        cnt -= 1
if A < B and B < C:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 78072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (int i = 0; i < B; i++) {
        ans *= A - i;
    }
    for (int i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
int main(){
 int n,x;
  cin>>n>>x;
  int p=0;
  vector<int>A(n);
  rep(i,n){
   cin>>A[i];
p+=A[i];}
  x-=p;
  sort(A.begin(),A.end());
  n+=x/A[0];
  cout<<n<<endl;
}




Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t;cin>>s>>t;
    cout<<((t.substr(0,s.size())==s)?"Yes":"No");
    return 0;
}

Measured memory_bytes: 3640
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		UINT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main()
{
	ll N = 0;
	ll tmp = 0;
	set< ll > d;

	cin >> N;

	Rep(i, N) {
		cin >> tmp;
		d.insert(tmp);
	}

	cout << d.size() << endl;

	return 0;
}





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

int main() {
	int ab[2], cd[2];
	int ans = 1e9;
	cin >> ab[0] >> ab[1] >> cd[0] >> cd[1];
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			ans = min(ab[i] + cd[j], ans);
		}
	}
	cout << ans << 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++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}



signed main(){
    int n;
    cin >> n;
    int dist[n];
    vector<int> G[n];
    REP(i,n) dist[i] = -1;
    REP(i,n){
        int v,k;
        cin >> v >> k;
        REP(j,k){
            int to;
            cin >> to;
            to --;
            G[i].push_back(to);
        }
    }

    queue<int> Q;
    dist[0] = 0;
    Q.push(0);
    while(Q.size()){
        int v = Q.front();
        Q.pop();
        itrfor(itr,G[v]){
            if(dist[*itr] ==  -1){
                Q.push(*itr);
                dist[*itr] = dist[v] + 1;
            }
        }
    }
    REP(i,n){
        cout << i + 1 << " " << dist[i] << endl;
    }

}


Measured memory_bytes: 3156
#include<iostream>
#include<cmath>
#include<stdio.h>

struct POINT{
	double x;
	double y;
	POINT& operator += ( const POINT& p )
	{
		x += p.x;
		y += p.y;
		return *this;
	}
	POINT& operator -= ( const POINT& p )
	{
		x -= p.x;
		y -= p.y;
		return *this;
	}
	POINT& operator *= ( double factor )
	{
		x *= factor;
		y *= factor;
		return *this;
	}
	POINT& operator /= ( double factor )
	{
		x /= factor;
		y /= factor;
		return *this;
	}
};

POINT operator + ( const POINT& a , const POINT& b )
{
	POINT p(a);
	p += b;
	return p;
}

POINT operator - ( const POINT& a , const POINT& b )
{
	POINT p(a);
	p -= b;
	return p;
}

POINT operator * ( const POINT& a , double factor )
{
	POINT p(a);
	p *= factor;
	return p;
}

POINT operator / ( const POINT& a , double factor )
{
	POINT p(a);
	p /= factor;
	return p;
}

typedef POINT VECTOR2; // 2次元ベクトル

std::istream& operator >> ( std::istream& s , POINT& p )
{
	char c;
	return s >> p.x >> c >> p.y;
}

double getDotProduct( const VECTOR2& a , const VECTOR2& b )
{
	return a.x * b.x + a.y * b.y;
}

double getSizeofVECTOR2( const VECTOR2& a )
{
	return sqrt( pow( a.x , 2 ) + pow( a.y , 2 ) );
}

double getTheta( const VECTOR2& a , const VECTOR2& b )
{
	double dotProduct = getDotProduct( a , b );
	double sizeofVECTORa = getSizeofVECTOR2( a );
	double sizeofVECTORb = getSizeofVECTOR2( b );

	return acos( dotProduct / ( sizeofVECTORa * sizeofVECTORb ) );
}

int main(void)
{
	POINT p1, p2, q, r;
	while(1){
		char c;
		std::cin >> p1 >> c >> p2 >> c >> q;
		if( std::cin.eof() ){
			break;
		}
		VECTOR2 p1q, p1p2;
		p1q = q - p1;
		p1p2 = p2 - p1;
		POINT crossPoint = p1 + p1p2 * getDotProduct( p1q , p1p2 ) / pow(getSizeofVECTOR2(p1p2),2);
		r = ( crossPoint - q ) + crossPoint;

		printf( "%f %f\n" , r.x , r.y );
	}

	return 0;
}

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

#define IOS cin.tie(0);ios::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vs      vector<string>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

const int INF = 1e9;
const int MOD = 1e9+7;

#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?' ':'\n'); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);}//最小公倍数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

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

const int NMAX = 200;
bool flag;

bool comp(int x,int y,int compare){
    return abs(compare-x)<abs(compare-y);
}

signed main(){
    IOS;
    flag=false;
    SCIN(s,t);
    rep(i,s.size()){
        if(s==t){flag=true;break;}
        s=s.back()+s.substr(0,s.size()-1);
    }
    Yes(flag);

    return 0;
}

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

long long gcd(long x, long y)
{    if (y == 0)
        return x;
    return gcd(y, x % y);}
long long lcm(long x, long y){ return x * y / gcd(x, y);}


int main()
{
    string N;
    int ans=0;
    cin>>N;

    ans=N[0]-'1';

    ans+=(N.length()-1)*9;

    int f=1;
    for(int i=1;i<N.length();i++){
        if(N[i]!='9'){
            f=0;
            break;
        }
    }
    if(f==1)ans+=1;

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define		CH		ch=(getchar())

inline		int		IN(){
	int x=0,f=1;char ch;
	for (CH;ch>'9'||ch<'0';CH) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';CH) (x*=10)+=ch-'0';
	return x*f;
}

int i,j,k,l,n,m,L,a[105];
char s[1000005];

int main(){
	scanf("%s",&s);
	L=strlen(s);
	for (i=0;i<L;i++) a[(int)(s[i]-'a')]=1;
	for (i=0;i<26;i++) if (a[i]==0){
		printf("%c",(char)((char)i+'a'));
		return 0;
	}
	puts("None");
	return 0;
}


Measured memory_bytes: 256
x = gets
y = gets
x = x.split
y = y.split
i = 1
tmp = 0
while i < x[1].to_i do
  if tmp < y[i].to_i - y[i-1].to_i
  	tmp = y[i].to_i - y[i-1].to_i
  end
  i += 1
end
if tmp < y[0].to_i + (x[0].to_i - y[-1].to_i)
  tmp = y[0].to_i + (x[0].to_i - y[-1].to_i)
end
puts x[0].to_i - tmp

Measured memory_bytes: 13836
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>
#include <cassert>
using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int n;
    cin >> n;
    multiset<int> a;
    rep(i,(1<<n)){
        int p;
        cin >> p;
        a.insert(-p);
    }
    vector<int>s;
    s.push_back(*(a.begin()));
    a.erase(s[0]);
    for(int i=0;i<n;i++){
        vector<int>t;
        for(auto x:s){
            t.push_back(x);
            auto p = a.upper_bound(x);
            if(p==a.end()){
                cout << "No" << endl;
                return 0;
            }else{
                int k = *p;
                t.push_back(k);
                a.erase(p);
            }
        }
        s = t;
    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int count = 0;
    for(int i = 1; i < a; ++i)
        for(int j = 1; j <= 31; ++j) if(i == j) count++; 
    if(a <= b) count++;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	vector<int>dp(n,INT_MAX);
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++)
	{
		dp[i]=min(dp[i-2]+abs(a[i-2]-a[i]),dp[i-1]+abs(a[i-1]-a[i]));
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include <cmath>
#include <vector>
#include <iostream>
using namespace std;
const double moondist = 380000;
const double kaguyadist = 1900;
const double moontime = 2500000;
const double kaguyatime = 7200;
const double moonradius = 1800;
const double pi = acos(-1.0);
double sqr(double x) {
    return x * x;
}
int main() {
    double l = moondist, r = moondist + kaguyadist;
    for(int i = 0; i < 100; ++i) {
        double m = (l + r) * 0.5;
        double tcos = (m * m + moondist * moondist - kaguyadist * kaguyadist) / (2 * m * moondist);
        double tsin = sqrt(1.0 - sqr(tcos));
        if(tsin < moonradius / moondist) r = m;
        else l = m;
    }
    double threshold = l;
    int M, T;
    cin >> M >> T; T *= 60;
    double theta = (M / 360.0) * (2 * pi);
    int sep = 1000000;
    double ans = 0.0;
    for(int i = 0; i <= 2 * sep; ++i) {
        double t = double(T) * i / (2 * sep);
        double mx = moondist * cos(theta + t / moontime * (2 * pi));
        double my = moondist * sin(theta + t / moontime * (2 * pi));
        double mz = 0.0;
        double vx = -kaguyadist * sin(t / kaguyatime * (2 * pi));
        double vy = 0.0;
        double vz = kaguyadist * cos(t / kaguyatime * (2 * pi));
        double kx = mx + vx;
        double ky = my + vy;
        double kz = mz + vz;
        double dist = sqrt(sqr(kx) + sqr(ky) + sqr(kz));
        if(dist > threshold) {
            if(i == 0 || i == 2 * sep) ans += 1;
            else if(i % 2 == 0) ans += 2;
            else ans += 4;
        }
    }
    ans /= 6 * sep;
    ans *= T;
    cout.precision(15);
    cout << fixed << ans / 60.0 << endl;
    return 0;
}


Measured memory_bytes: 3684
s = input()
ans = ''
for i in range(len(s)):
    if s[i] == '0':
        ans += '0'
    elif s[i] == '1':
        ans += '1'
    else:
        if len(ans) == 0:
            pass
        else:
            ans = ans[0:len(ans)-1]
print(ans)

Measured memory_bytes: 3060