akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
#define MAX_B 1001001
#define NIL -1
const int MOD = 1e9+7;
const int INF = 1 << 29;
const ll INFTY=1000000000000000000LL;
int main(){
    //まず素数表を完成させる->エラストテネスのふるい
    bitset<MAX_B>is_prime(0);
    for(int i=2;i<MAX;i++)is_prime.set(i);
    for(int i=2;i<MAX;++i){
        if(is_prime[i]){
            for(int j=i*2;j<MAX;j+=i){
                is_prime.set(j,0);
            }
        }
    }
    //2017-like
    bool a[MAX];
    for(int i=1;i<MAX;i+=2){
        if(is_prime[i] && is_prime[(i+1)/2]){
            a[i]=1;
        }
    }
    //累積和
    int sum[MAX];
    sum[1]=0;
    for(int i=1;i<MAX-1;i++){
        sum[i+1]=sum[i]+a[i];
    }
    //あとは問題の処理
    int q,l,r;
    cin>>q;
    rep(i,q){
        cin>>l>>r;
        cout<<sum[r+1]-sum[l]<<endl;
    }
}

Measured memory_bytes: 1280
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const double EPS = 1e-12;
const double INF = 1e12;

int N,M;
int ar[11];
set<string>ch;

void re(string str,vector<bool>used,int cnt){
	if(cnt==0){
		ch.insert(str);
	}else{
		REP(i,SZ(used)){
			if(!used[i]){
				used[i]=true;
				re(str+toString(ar[i]),used,cnt-1);
				used[i]=false;
			}
		}
	}
}
int main(){
	
	while(cin>>N>>M){
		if(N==0&&M==0)break;
		ch.clear();
		REP(i,N)cin>>ar[i];
		vector<bool>used(N,false);
		re("",used,M);
		cout<<SZ(ch)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1476
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define si(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define in(x) cin >> x
using pii = pair<int,int>;
using psi = pair<string,int>;
using pis = pair<int,string>;
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;


int main() {
 int N,K;
  cin >> N >>K;
  if(N == 1 )  out(K);
  else {
   ll ans =K;
    for(itn i=0;i<N-1;i++) ans *= (K-1);
    out(ans);
  }

}
  


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string.h>
#include <cmath>
using namespace std;

double memo[51][51][2501];
int X, Y, Z, V[4], E[51], A[51];
bool exist[110];

double rec(int n, int now, int sum){
	if(now >= Y){
		return sum / (pow(X, n));
	}
	if(exist[now]){
		if(E[now] == 1){
			now += A[now];
			if(now >= Y){
				return sum / (pow(X, n));
			}
		}
		else if(E[now] == 2){
			sum += A[now];
		}
		else{
			sum = max(sum - A[now], 0);
		}
	}
	
	if(memo[n][now][sum] != -1.0)
		return memo[n][now][sum];
		
	double res = 0;
	for(int i = 0; i < X; ++i)
		res += rec(n + 1, now + V[i], sum);
		
	return memo[n][now][sum] = res;
}

int main() {
	int n, e, a;
	while(cin >> X >> Y >> Z && (X || Y || Z)){
		for(int i = 0; i <= 50; ++i)
			for(int j = 0; j <= 50; ++j)
				for(int k = 0; k <= 2500; ++k)
					memo[i][j][k] = -1.0;
		memset(exist, 0, sizeof(exist));
		for(int i = 0; i < X; ++i)
			cin >> V[i];
		for(int i = 0; i < Z; ++i){
		scanf("%d %d %d", &n, &e, &a);
			exist[n] = true;
			E[n] = e; A[n] = a;
		}
		cout << (int)rec(0, 0, 0) << endl;
	}
		return 0;
}

Measured memory_bytes: 52132
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = readInteger >>= printf "%.10f\n" . ( ** 3 ) . ( / 3 ) . ( fromIntegral :: Integer -> Double )

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

int main(){
    int a,b;
    cin>>a>>b;
    int a1=0,b1=0;
    for(int i=1;i<=b;i++){
        a1+=a*pow(10,(i-1));
    }
    for(int i=1;i<=a;i++){
        b1+=b*pow(10,(i-1));
    }
    if(a1>b1)cout<<a1<<endl;
    else cout<<b1<<endl;
    return 0;
}

Measured memory_bytes: 4128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>


int main()
{
	long long x, a, b;

	std::cin >> x >> a >> b;


	if (a - b >= 0) {
		std::cout << "delicious" << std::endl;
	}
	else if (b - a <= x) {
		std::cout << "safe" << std::endl;
	}
	else {
		std::cout << "dangerous" << std::endl;
	}
	
	return 0;
}

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

int main(){
    int k;
    ll sum = 0;
    cin >> k;
    for(int a = 1; a <= k; a++){
        for(int b = 1; b <= k; b++){
            for(int c = 1; c <= k; c++){
                sum += __gcd(__gcd(a,b),c);
            }
        }
    }
    cout << sum;
}


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

using namespace std;

int main(){
	string s;
	getline(cin, s);
	for(int i=0; i< s.size(); i++){
		if(s.substr(i, 5) == "apple") s.replace(i, 5, "peach");
		else if(s.substr(i, 5) == "peach") s.replace(i, 5, "apple");
	}
	cout << s << endl;
}

Measured memory_bytes: 1184
//#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(x...) cerr << __LINE__ << ": " << #x << " = "; DBG::_print(x)
#else
#define DEBUG(x...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

const int INF = 1000000000;

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int N, M, X;
   cin >> N >> M >> X;

   VI C(N);
   VVI A(N, VI(M));

   REP(i, N) {
      cin >> C[i];
      REP(j, M)
         cin >> A[i][j];
   }

   int best = INF;
   REP(mask, 1<<N) {
      int cost = 0;
      VI level(M);
      REP(i, N) {
         if (mask & (1<<i)) {
            cost += C[i];
            REP(j, M)
               level[j] += A[i][j];
         }
      }
      bool ok = true;
      REP(j, M)
         if (level[j] < X) {
            ok = false;
            break;
         }
      if (ok)
         best = min(best, cost);
   }

   cout << (best < INF ? best : -1) << '\n';

   return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> s(H);
    for (int i = 0; i < H; i++) {
        cin >> s[i];
    }

    int num = 0;
    vector< vector<int> > ans(H, vector<int>(W, 0));
    for (int i = 0; i < H; i++) {
        vector<int> v;
        for (int j = 0; j < W; j++) {
            if (s[i][j] =='#') {
                v.push_back(j);
            }
        }

        if (v.empty()) {
            if (i == 0 || ans[i - 1][0] == 0) continue;
            for (int j = 0; j < W; j++) {
                ans[i][j] = ans[i - 1][j];
            }
        } else {
            int j = 0;
            for (int idx = 0; idx < v.size(); idx++) {
                num++;
                while (j <= v[idx]) {
                    ans[i][j] = num;
                    j++;
                }
            }
            while (j < W) {
                ans[i][j] = num;
                j++;
            }
        }
    }

    for (int i = H - 2; i >= 0; i--) {
        if (ans[i][0] == 0) {
            for (int j = 0; j < W; j++) {
                ans[i][j] = ans[i + 1][j];
            }
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << ans[i][j] << " \n"[j + 1 == W];
        }
    }
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
struct point{double x;double y;};
int i,j,k,count1=0,count2=0;

int main(void){
    int n,a=0,b=0,A,B;
    char c;
    cin>>n>>A>>B;
    for(i=0;i<n;i++){
        cin>>c;
        if(c=='a'){
            a++;
            if(a<=(A+B)){
                cout<<"Yes"<<endl;
            }else{
                a--;
                cout<<"No"<<endl;
            }
        }
        if(c=='b'){
            a++;
            b++;
            if(b<=B&&(a<=(A+B))){
                cout<<"Yes"<<endl;
            }else{
                a--;
                b--;
                cout<<"No"<<endl;
            }
        }
        if(c=='c'){
            cout<<"No"<<endl;
        }
    }
}

Measured memory_bytes: 640
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

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

int main() {
	int x, y;
	cin >> x >> y;
	if (x == 2) {
		if (y == 2) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	if (x == 4 || x == 6 || x == 9 || x == 11) {
		if (y == 4 || y == 6 || y == 9 || y == 11) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) {
		if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

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

   if(b - a == c - b) puts("YES");
   else puts("NO");
}

Measured memory_bytes: 256
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    for i in range(N):
        input_raw = read_func().strip().split()
        [a] = [int(input_raw[0])]
        if a % 2 != 0:
            print "first"
            exit()
    print "second"


if __name__ == '__main__':
    main()


Measured memory_bytes: 6000
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
	int n;
	cin>>n;
	int c=0;
	rep(i,n){
		int a;
		cin>>a;
		if(a%2==1)c++;
	}
	if(c%2==1)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
}

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

long long n;

int main() {
  cin >> n;
  long long sum = 0;
  for (int i = 0; i < n - 1; ++i) {
    long long x, y;
    cin >> x >> y;
    if (x > y) swap(x, y);
    sum -= x * (n - y + 1);
  }
  for (int i = 0; i < n; ++i) sum += (long long)(i + 1) * (i + 2) / 2;

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3616
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
 
#include<bits/stdc++.h>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>*/
 
#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define rep(a, b, c) for(int a = b; a <= c; ++a)
#define per(a, b, c) for(int a = b; a >= c; --a)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
 
using namespace std;
//using namespace __gnu_pbds;
 
typedef unsigned long long ull;
typedef long long ll;
/*typedef tree<pair<int, int>, 
null_type, less<pair<int, int>>, 
rb_tree_tag, tree_order_statistics_node_update>
ordered_set;*/
//find_by_order() order_of_key()
 
const double eps = 1e-7;
const int mod = 1e9+7, MXN = 5e5+17;
const int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};
 
template<typename T>inline bool updmin(T &a, const T &b) {return a > b ? a = b,1 : 0;}
template<typename T>inline bool updmax(T &a, const T &b) {return a < b ? a = b,1 : 0;}
 
int h, w, a, b;
int f[MXN];
 
inline int Add(int a, int b) {
	a += b;
	if(a > mod) a -= mod;
	if(a < mod) a += mod;
	return a;
}
 
inline int Mul(int a, int b) {
	return (a*1ll*b)%mod;
}
 
inline int Pow(int a, int b) {
	int res = 1;
	while(b) {
		if(b&1) res = Mul(res,a);
		b >>= 1;
		a = Mul(a,a);
	}
	return res;
}
 
inline int Div(int a, int b) {
	return Mul(a,Pow(b,mod-2));
}
 
inline int Cnk(int n, int k) {
	return Div(f[n],Mul(f[k],f[n-k]));
}
 
int32_t main() { _
#ifdef DanQQQQQ
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	cin >> h >> w >> a >> b;
	f[0] = 1;
	rep(i,1,200050) f[i] = Mul(f[i-1],i);
	ull cur = Cnk(h+w-2,h-1), res = 0;
	rep(i,0,b-1) res = (res+Mul(Cnk(h-a+i-1,i),Cnk(w+a-i-2,a-1)))%mod;
	cout << (cur-res+mod)%mod << endl;
	return 0;
}

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

using namespace std;

int main(){
 string S; cin >> S; string T;
  for(int i = 0; i < S.size(); i +=2){
    T.push_back(S[i]);}
 for(int i = 0; i < T.size();i++){ cout << T[i];} return 0;}

Measured memory_bytes: 512
"""

https://atcoder.jp/contests/agc021/tasks/agc021_d

ある部分でcutしたとする。
前半と後半のLCSを求めたとすると、交差した後のLCSの長さも同じ
→左からindex iまでと右からindex jまでのLCSを求めればいい (i < j)
あとは、普通のLCSと同様のdpでいける

dp[i][j][k] = 左からi番目の文字までと、右からindex jの文字までのk回替えた際のLCS長さ
あとは2倍すれば大体行ける？
i+1 == jでは、2倍すればおk
i+1 < j では、真ん中の文字を使えるので、2倍して1足す

"""

import sys
S = input()
S = " "+S
K = int(input())
N = len(S)-1
if N == 1:
    print (1)
    sys.exit()
elif N == 2:
    if S[1] == S[2] or K > 0:
        print (2)
    else:
        print (1)
    sys.exit()

dp = [[[0] * (K+1) for i in range(N+2)]]
ans = 0

for i in range(1,N+1):

    dp.append( [[0] * (K+1) for i in range(N+2)] )

    for j in range(N,i,-1):

        for k in range(K+1):

            #同じ場合、どっちも進める
            if S[i] == S[j]:
                dp[i][j][k] = max( dp[i][j][k] , dp[i-1][j+1][k] + 1)
            else:
                dp[i][j][k] = max( dp[i][j][k] , dp[i-1][j][k] , dp[i][j+1][k] )
                if k != 0:
                    dp[i][j][k] = max(dp[i][j][k] , dp[i-1][j+1][k-1] + 1)

            if i+1 == j:
                ans = max(ans , dp[i][j][k] * 2)
            else:
                ans = max(ans , dp[i][j][k] * 2 + 1)

    dp[i-1] = []

print (ans)
                


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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,start,end) for(int i=(start);i<=(end);i++)
#define all(n) begin(n),end(n)

#define DEBUG

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

	if(d == 25) cout << "Christmas" << endl;
	if(d == 24) cout << "Christmas Eve" << endl;
	if(d == 23) cout << "Christmas Eve Eve" << endl;
	if(d == 22) cout << "Christmas Eve Eve Eve" << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace Project {
    class Program {
        static void Main(string[] args) {
            var cr = new CR();
            var K = cr.i;
            var S = cr.i;

            var ans = 0;
            for (int x = 0; x <= K; x++) {
                for (int y = x; y <= K; y++) {
                    for (int z = y; z <= K; z++) {
                        if (x + y + z == S) {
                            if (x == y && x == z)
                                ans++;
                            else if (x == y || x == z || y == z)
                                ans += 3;
                            else
                                ans += 6;
                        }
                    }
                }
            }
            Console.WriteLine(ans);
        }

        private class CR {
            System.IO.TextReader _r;
            Queue<string> _d;
            public CR() { _r = Console.In; _d = new Queue<string>(); }
            string Read() {
                while (_d.Count == 0)
                    foreach (var v in _r.ReadLine().Split(' '))
                        if (v != "")_d.Enqueue(v);
                return _d.Dequeue();
            }
            public int i { get { return int.Parse(Read()); } }
            public string s { get { return Read(); } }
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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 (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ld r;
    cin >> r;

    cout << r * r * PI <<" "<<2*r*PI<< endl;
}


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

int main(){
  int n;
  cin >> n;
  string s[n];
  for(int i=0;i<n;i++){
    cin >> s[i];
  }
  long long int m,a,r,c,h;
  m=0;
  a=0;
  r=0;
  c=0;
  h=0;
  for(int i=0;i<n;i++){
    if(s[i].at(0)=='M'){
      m++;
    }
    else if(s[i].at(0)=='A'){
      a++;
    }
    else if(s[i].at(0)=='R'){
      r++;
    }
    else if(s[i].at(0)=='C'){
      c++;
    }
    else if(s[i].at(0)=='H'){
      h++;
    }
  }
    long long int ans;
    ans=m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h;
    cout << ans << endl;
}


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

string S;
int suma,sumb;

int main()
{
	cin>>S;
	for(int i=0;i<S.size();i++)
	{
		if(S[i] == 'S') suma++;
		if((suma)&&(S[i]=='T'))
		{
			suma--;
			sumb+=2;
		}
	}
	cout<<S.size()-sumb<<endl;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll mod=1e9+7;
 
using namespace std;

int main(){
	int q=1;
	//cin>>q;
	while(q--){
		int n;
		cin>>n;

		map<int,int> m;
		for(int i=0;i<n;i++)
			m[i]=0;

		for(int i=1;i<n;i++){
			int x;cin>>x;
			m[x-1]++;
		}

		for(auto i:m)
			cout<<i.ss<<endl;
	}
   
}

Measured memory_bytes: 13008
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
using vc = vector<char>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  int n;
  cin >> n;
  if(n % 2 == 0){
    cout << n*(n-2)/2 << "\n";
    for(int i=1;i<=n;i++){
      for(int j=i+1;j<=n;j++){
        if(i + j == n+1) continue;
        cout << i << " " << j << "\n";
      }
    }
  }else{
    cout << (n-1)*(n-1)/2 << "\n";
    for(int i=1;i<=n;i++){
      for(int j=i+1;j<=n;j++){
        if(i + j == n) continue;
        cout << i << " " << j << "\n";
      }
    }
  }
}


Measured memory_bytes: 256
#include <cstdio>

int main() {
    int i, x, y, t;
    for (i = 0;; ++i) {
        scanf("%d %d", &x, &y);
        if (x == 0 && y == 0) break;

        if (x > y) {t = x; x = y; y = t;}
        printf("%d %d\n", x, y);
    }
    return 0;
}

Measured memory_bytes: 1028
#include <stdio.h>
#define INF 19900001

int N, M, R, map[200][200] = {}, must_visit[8], all[40320][8], cnt, temp[8];
bool use[8];

int inline min(int a, int b)
{
	return (a < b) ? a : b;
}

void dfs(int index)
{
	if (index == R)
	{
		for (int i = 0; i < R; i++) all[cnt][i] = temp[i];
		cnt++;
		return;
	}
	for (int i = 0; i < R; i++)
	{
		if (!use[i])
		{
			use[i] = true;
			temp[index] = must_visit[i];
			dfs(index + 1);
			use[i] = false;
		}
	}
}

int main()
{
	long long answer = -1;
	scanf("%d %d %d", &N, &M, &R);
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			if (i == j) continue;
			map[i][j] = INF;
		}
	}
	for (int i = 0; i < R; i++)
	{
		scanf("%d", &must_visit[i]);
		must_visit[i] -= 1;
	}
	dfs(0);
	for (int i = 0; i < M; i++)
	{
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		map[a - 1][b - 1] = min(map[a - 1][b - 1], c);
		map[b - 1][a - 1] = min(map[b - 1][a - 1], c);
	}
	for (int k = 0; k < N; k++)
	{
		for (int i = 0; i < N; i++)
		{
			if (map[i][k] == INF) continue;
			for (int j = 0; j < N; j++)
			{
				if (map[k][j] == INF) continue;
				map[i][j] = min(map[i][j], map[i][k] + map[k][j]);
			}
		}
	}
	for (int i = 0; i < cnt; i++)
	{
		long long sum = 0;
		for (int j = 0; j < R - 1; j++) sum += map[all[i][j]][all[i][j + 1]];
		if (answer == -1 || sum < answer) answer = sum;
	}
	printf("%lld\n", answer);
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>

int main(void){
    int n, y;
    std::cin >> n >> y;

    bool check = false;

    for(int i = 0; i <= 2000; i++){
        for(int j = 0; j <= 4000; j++){
            int z = n - i - j;
            if(y == 10000*i + 5000*j + 1000*z && 0 <= z && z <= 20000){
                std::cout << i << " " << j << " " << z << std::endl;
                return 0;
            }
        }
    }

    std::cout << -1  << " " << -1 << " "  << -1 << std::endl;
    return 0;
}

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

long long r, d, x;

int main(){

    scanf("%lld %lld %lld", &r, &d, &x);

    for(int i = 0; i < 10; i++){
        x = r * x - d;
        printf("%lld\n", x);
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <list>
#include <unordered_map>
#include <cmath>

using namespace std;
typedef long long ll;

int main(void)
{
    int n;
    cin >> n;
    vector<int> x(n);

    int min_x = 0;
    int max_x = 101;

    for (size_t i = 0; i < n; i++)
    {
        cin >> x[i];
        min_x = min(min_x, x[i]);
        max_x = max(max_x, x[i]);
    }

    int min_loss = 1000000000;
    for (int p = min_x; p <= max_x; p++)
    {
        int loss = 0;
        for (size_t i = 0; i < n; i++)
        {
            loss += (x[i] - p) * (x[i] - p);
        }
        //cout << p << "\t" << loss << endl;
        min_loss = min(min_loss, loss);
    }
    cout << min_loss << endl;
    return 0;
}

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



int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int x,y,a,b;
    cin>>x>>y>>a>>b;
    int t1 = a/y + (a%y ? 1 : 0);
    int t2 = x/b + (x%b ? 1 : 0);
    cout<<(t1 <= t2 ? "Yes" : "No")<<endl;
    return 0;
}

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

int main() {
    int n, a, ans;
    cin >> n;
    ans = 0;
    for ( int i = 0; i < n; i++ ) {
        cin >> a;
        
        while ( a % 2 == 0 ) {
            ans ++;
            a /= 2;
        }
    }
    
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

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

std::map<ll, ll> prime_factor( ll x )
{
  std::map<ll, ll> mp;

  for( ll i = 2; i*i <= x; ++i )
  {
    while( x % i == 0 )
      x /= i, ++mp[i];
  }

  if( x != 1 )
    ++mp[x];

  return mp;
}

ll A, B;
ll ans = 1;

int main()
{
  std::cin >> A >> B;

  ll g = gcd( A, B );

  auto mp = prime_factor( g );

  for( auto it = mp.begin(); it != mp.end(); ++it )
    ++ans;

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

int n, k;
vector<int> a;
vector<bool> memo(100005), flg(100005, false);

bool rec(int i){
    if(flg[i]) return memo[i];
    flg[i]=true;

    rep(j, n){
        if(i-a[j]>=0 && rec(i-a[j])==false) return memo[i]=true; 
    }
    return memo[i]=false;
    
}

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

    cin >> n >> k;
    a.resize(n);
    rep(i, n) cin >> a[i];

    if(rec(k)) cout << "First\n";
    else cout << "Second\n";
    
    return 0;
}


Measured memory_bytes: 5120
#include <stdio.h>
typedef long long ll;

ll gcd(ll a, ll b) {
  ll t;
  while(b) t = a % b, a = b, b = t;
  return a;
}

int main(void) {
  ll i, j, k, a, b, c, d, t, m;
  scanf("%lld", &t);
  for(i = 0; i < t; ++i) {
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    if(b > d || a < b) {
      printf("No\n");
      continue;
    }
    if(b <= c) {
      printf("Yes\n");
      continue;
    }
    a %= b;
    if(a > c) {
      printf("No\n");
      continue;
    }
    if(!(d % b)) {
      printf("Yes\n");
      continue;
    }
    m = gcd(d % b, b);
    if(a + (c - a) / m * m + m < b) printf("No\n");
    else printf("Yes\n");
  }
  return 0;
}

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

using ll = long long int;

ll n,a,b,c,d;

bool solve(ll i,ll l,ll r){
    
    if(l > r){
        cout << "error" << endl;
        return false;
    }
    //cout << i << " " << l << " " << r << endl;
    
    if( n-1 == i && l <= b && b <= r){
        //cout << i << " " << l << " " << r << endl;
        return true;
    }
    
    if(i == n-1){
        //cout << i << " " << l << " " << r << endl;
        return false;
    }
    
    if(abs(l-b) < abs(r-b)){
        return solve(i+1,l-d,r-c);
    }else{
        return solve(i+1,l+c,r+d);
    }
}

int main(void){
    
    cin >> n >> a >> b >> c >> d;
    
    if(solve(0,a,a)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    
}


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

void SharpSet(int w);

int main(){
  int H,W;
  cin >> H >> W;
  
  vector<string> A(H);
  for(int i = 0;i<H;i++){ 
    cin >> A.at(i);
  }
  
  SharpSet(W);
  for(int i = 0;i<H;i++){
  	cout << "#"<< A.at(i) <<"#" <<endl;
  }
  SharpSet(W);
  
}

void SharpSet(int w){
	for(int i=0;i<w+2;i++){
		cout <<"#";
	}
  	cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
bool prime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    int sum=0;
    for(int i=0;i<k;i++)sum+=a[i];
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3652
# -*- encoding: utf-8 -*-
class Node
  attr_accessor :key, :left, :right
  def initialize key
    @key = key
  end

  def inorder
    left.inorder if left
    print " ", key
    right.inorder if right
  end

  def preorder
    print " ", key
    left.preorder if left
    right.preorder if right
  end
end

def insert
  z = Node.new $key.to_i
  x = $root
  while x
    y = x  #???????¨????
    x = z.key < x.key ? x.left : x.right  #?????????????§????/?????????????§????
  end

  unless y  #y???nil?????´???
    $root  = z
  else
    z.key < y.key ? y.left = z : y.right = z  #z???y?????????????????????/z???y?????????????????????
  end
end

n = gets.to_i
n.times do
  command, $key = gets.split
  if command == "insert"
    insert
  else
    $root.inorder
    puts 
    $root.preorder
    puts
  end
end

Measured memory_bytes: 47932
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k;
	string s,s1;
	cin>>k>>s;
	if(s.size()<=k)
	cout<<s;
	else
	{
		s1=s.substr(0,k);
		s1+="...";
		cout<<s1;
	}
	return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <utility>
#include <algorithm>

using namespace std;

using uint=unsigned int;
using update_t=pair<int,uint>;//time value
const int MAXN=1e5+10;

struct Node{
    int lbound,rbound;
    update_t update;
    Node *left,*right;
};

int A[MAXN];
Node segtree[MAXN*2];
Node* next_pos=segtree;
int n,q;

Node* build(int left,int right){
    auto* cur=next_pos;
    next_pos++;
    cur->lbound=left;
    cur->rbound=right;
    cur->update=update_t(0,(1u<<31)-1);
    int mid=(left+right)/2;
    if (right-left==1) return cur;
    cur->left=build(left,mid);
    cur->right=build(mid,right);
    return cur;
}

void update(Node& self,int l,int r,update_t u){
    // puts("s");
    int mid=(self.lbound+self.rbound)/2;
    if (l==self.lbound&&r==self.rbound){
        self.update=u;
    }else if (l>=mid){
        update(*self.right,l,r,u);
    }else if (r<=mid){
        update(*self.left,l,r,u);
    }else{
        update(*self.left,l,mid,u);
        update(*self.right,mid,r,u);
    }
}

update_t query(Node& self,int i){
    // puts("q");
    if (self.rbound-self.lbound==1&&self.lbound==i) return self.update;
    int mid=(self.lbound+self.rbound)/2;
    if (i>=mid) return max(query(*self.right,i),self.update);
    else return max(query(*self.left,i),self.update);
}

int main(){
    scanf("%d%d",&n,&q);
    build(0,n);
    // puts("yes");

    for(int time=1;time<=q;time++){
        int t;
        scanf("%d",&t);
        if (t==0) {
            int s,t,x;
            scanf("%d%d%d",&s,&t,&x);
            update(segtree[0],s,t+1,update_t(time,x));
            // puts("updated");
        }else{
            int i;
            // puts("ok");
            scanf("%d",&i);
            
            auto v=query(segtree[0],i).second;
            
            printf("%u\n",v);
        }

    }

    return 0;
}


Measured memory_bytes: 8984
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
using namespace std;

int main(){
    
    
    int x,a,b;
    
    cin >> x >> a >> b;
     
    if(x > a){
    a = x - a;
    }
   else{a = a- x;}

    if(x > b){
    b = x - b;
    }else{b = b - x;}
    
    
    if(a < b){
    cout << "A" << endl;
    }
    else{cout << "B" << endl;}
    
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

    template <class T, class... Args>
    void impl(T&& v, Args&&... args)
    {
        cout << std::forward<T>(v) << ' ';
        impl(std::forward<Args>(args)...);
    }
    template <class T>
    void impl(T&& v)
    {
        cout << std::forward<T>(v);
    }

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class... Args>
    void operator()(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
        cout << '\n';
    }
    template <class... Args>
    void noreturn(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
            }
            cout << x;
            first = false;
        }
    }
};

void prog()
{
    input in;
    output out;

    int k, x;
    in >> k, x;
    out(500 * k >= x ? "Yes" : "No");
}

int main()
{
    prog();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

struct edge {int to; int cost;};
vector<edge> g[100100];
int dist[100100];
bool memo[100100];
const int INF = 1100100100;


void prim(int v) {
    priority_queue<P, vector<P>, greater<P> > q;
    fill(dist, dist+100100, INF);
    dist[v] = 0;
    q.push(P(0, v));
    while (!q.empty()) {
        P p = q.top(); q.pop();
        int cost = p.first;
        int node = p.second;
        memo[node] = 1;
        if (cost > dist[node]) continue;
        for (auto e: g[node]) {
            if (dist[e.to] > e.cost && !memo[e.to]) {
                dist[e.to] = e.cost;
                q.push(P(e.cost, e.to));
            }
        }
    }
}

int main() {
    int n;
    cin >> n;
    vector<P> x(n), y(n);
    rep(i,n) {
        cin >> x[i].first >> y[i].first;
        x[i].second = i;
        y[i].second = i;
    }
    
    sort(x.begin(), x.end());
    rep(i,n-1) {
        g[x[i].second].push_back({x[i+1].second, x[i+1].first - x[i].first});
        g[x[i+1].second].push_back({x[i].second, x[i+1].first - x[i].first});
    }

    sort(y.begin(), y.end());
    rep(i,n-1) {
        g[y[i].second].push_back({y[i+1].second, y[i+1].first - y[i].first});
        g[y[i+1].second].push_back({y[i].second, y[i+1].first - y[i].first});
    }

    prim(0);
    int all_cost = 0;
    rep(i,n) all_cost += dist[i];
    cout << all_cost << endl;

    return 0;
}


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

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    int ma=0,mb=0;
    for(int i=0;i<N;i++){
        cin>>A[i];
        if(ma<=A[i]){
            int a=ma;
            ma=A[i];
            mb=a;
        }
        else if(mb<A[i]) mb=A[i];
    }
    for(int i=0;i<N;i++){
        if(A[i]==ma)cout<<mb<<endl;
        else cout<<ma<<endl;
    }
}

Measured memory_bytes: 2432
package main

import (
	"fmt"
)

func main() {
	nums := ScanNums(5)
	minModulo := 10
	totalMin := 0
	for _, num := range nums {
		modulo := num % 10
		if modulo == 0 {
			totalMin += num
		} else {
			if modulo < minModulo {
				minModulo = modulo
			}
			totalMin += num + 10 - modulo
		}
	}
	
	fmt.Println(totalMin - (10 - minModulo))
}

func ScanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
    string b;
    cin>>a>>b;
	if(a.size()>b.size()){
	cout<<"GREATER";
}
	else if(a==b){
	cout<<"EQUAL";
}
	else if(b.size()>a.size()){
	cout<<"LESS";
}
else if(b.size()==a.size()){
	if(a>b)
	cout<<"GREATER";
	else
	cout<<"LESS";
}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    string S;
    cin >> S;
    if(S=="ABC")
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int i,a,b;
  string s,str;
  str="keyence";
  cin >> s;
  if (s.size()<7) {
    cout << "NO" << endl;
    return 0;
  }
  a=0;
  b=0;
  for(i=0;i<7;++i) {
    if (s[i] == str[i]) {
      a++;
    } else {
      break;
    }
  }
  for(i=1;i<=7;++i) {
    if (s[s.size()-i] == str[7-i]) {
      b++;
    } else {
      break;
    }
  }
  if (a+b >= 7) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import math
A, B, H, M = map(int, input().split(' '))
deg = abs(30 * H + 0.5 * M - 6 * M)
if deg > 180:
    deg = 360 - deg
deg = math.radians(deg)
print(math.sqrt((B - A * math.cos(deg)) ** 2 + (A * math.sin(deg)) ** 2))

Measured memory_bytes: 9548
N,M = map(int,input().split())
adj = [[0]*N for _ in range(N)]
intx = lambda x: int(x)-1
for i in range(M):
    a,b = map(intx,input().split())
    #print(a,b)
    adj[a][b] += 1
    adj[b][a] += 1
#print(adj)
for i in range(N): 
    print(sum(adj[i]))
    

Measured memory_bytes: 9184
#include <stdio.h>
i,j,N,p,P,t[36],c[36],T[36],C[36];
B(){
    for(i=0;i<N;i++)
    for(j=N-1;j>0;j--)
        if(t[j-1]>t[j]){
            t[j]^=t[j-1]^=t[j]^=t[j-1];
            c[j]^=c[j-1]^=c[j]^=c[j-1];
        }
}
S(){
    for(i=0;i<N;i++){
        for(j=p=i;j<N;j++)if(T[j]<T[p])p=j;
        P=T[p];T[p]=T[i];T[i]=P;
        P=C[p];C[p]=C[i];C[i]=P;
    }
}
int main(void){
    for(scanf("%d",&N);i<N;scanf(" %c%d",&c[i],&t[i]),T[i]=t[i],C[i]=c[i],i++);
    B();S();
    for(i=0;i<N;printf("%c%d%s",c[i],t[i],i==N-1?"\n":" "),i++);
    puts("Stable");
    for(i=0;i<N;printf("%c%d%s",C[i],T[i],i==N-1?"\n":" "),i++);
    for(i=p=0;i<N;i++){
        if(c[i]==C[i]){
            if(t[i]==T[i]){
                p++;
            }
        }
    }
    puts(p==N?"Stable":"Not stable");
}

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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

vector<lint> h;
int n;
int a, b, d;

bool f(lint m) {
	lint cnt = 0;
	rep(i, n) {
		lint H = h[i] - m * b;
		if (H <= 0) continue;
		cnt += (H + d - 1) / d;
	}

	return cnt <= m;
}

int main() {
	cin >> n >> a >> b;
	d = a - b;

	lint mazai = 0;
	rep(i, n) { h.pb(in()); chmax(mazai, h[i]); }

	lint l = 0, r = mazai / b + 1000;
	while (r - l > 1) {
		lint m = (l + r) / 2;
		if (f(m)) {
			r = m;
		} else {
			l = m;
		}
	}

	if (!f(l)) {
		l = r;
	}

	cout << l << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;
int main(){
    int N;
    cin >> N;
    int a[10000] = {};
    for (int i = 1; i < 100; i++)
    {
        for (int j = 1; j < 100; j++)
        {
            for (int k = 1; k < 100; k++)
            {
                if (i*i + j*j + k*k + i*j + j*k + k*i <= 10000)
                {
                    a[i*i + j*j + k*k + i*j + j*k + k*i - 1]++;
                }
            }
            
        }
        
    }
    for (int i = 0; i < N; i++)
    {
        cout << a[i] << endl;
    }
}


Measured memory_bytes: 3584