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

int main(void){
	int n;
	while(cin >> n, n){
		vector<double> x(n), y(n);
		for (int i = 0; i < n; ++i){
			cin >> x[i] >> y[i];
		}
		int ans = 0;
		for (int i = 0; i < n; ++i){
			for(int j = i+1; j < n; ++j){
				double rx[2], ry[2], a, ax, ay, bx, by;
				ax = (x[j] - x[i]) / 2.0;
				ay = (y[j] - y[i]) / 2.0;
				a = sqrtl(ax*ax + ay*ay);
				by = ax * sqrtl(1.0-a*a) / a;
				bx = ay * sqrtl(1.0-a*a) / a;
				rx[0] = x[i] + ax + bx; rx[1] = x[i] + ax - bx;
				ry[0] = y[i] + ay - by; ry[1] = y[i] + ay + by;
				for(int k = 0; k < 2; ++k){
					int sum = 0;
					//cout << "[" << rx[k] << " " << ry[k] << "]" << endl;
					for(int l = 0; l < n; ++l){
						//cout << (x[l]-rx[k])*(x[l]-rx[k])+(y[l]-ry[k])*(y[l]-ry[k]) << endl;
						if((x[l]-rx[k])*(x[l]-rx[k])+(y[l]-ry[k])*(y[l]-ry[k]) <= 1.0001){
							sum++;
							//cout << x[l] << " " << y[l] << endl;
						}
					}
					ans = max(ans, sum);
				}
			}
		}
		cout << (ans?ans:1) << endl;
	}
	return 0;
}


Measured memory_bytes: 3372
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
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;}

int main(){
	int x;
	cin >> x;
	
	cout << (1999-x)/200+1 << endl;
	
	
	return 0;
}

Measured memory_bytes: 3636
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

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

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putLn :: Show a => a -> IO ()
putLn = print

putList :: Show a => [a] -> IO ()
putList [n] = put n
putList (n:ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n] = putStr n
putStrList (n:ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b
  | b = putStrLn "YES"
  | otherwise = putStrLn "NO"

yesNo b
  | b = putStrLn "Yes"
  | otherwise = putStrLn "No"

main = do
  [a, b] <- readInt
  if any (\x -> x `mod` 3 == 0) [a, b, a + b]
    then putStrLn "Possible"
    else putStrLn "Impossible"


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

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

    int judge = N+L-1;
    if(judge < 0){
        cout << (L+L+N-1)*N/2 - (L+N-1);
    }else if(L > 0){
        cout << (L+L+N-1)*N/2 - L;
    }else{
        cout << (L+L+N-1)*N/2;
    }
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i

res = ["AC", "WA", "TLE", "RE"]
hash = {
  "AC" => 0,
  "WA" => 0,
  "TLE" => 0,
  "RE" => 0,
}

n.times do
  s = gets.chomp
  hash[s] += 1
end

res.each do |s|
  puts "#{s} x #{hash[s]}"
end


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

int main() {
  int N, K, tmp, count;
  vector<int> vec(1000);
  
  cin >> N >> K;

  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (vec.at(i) > vec.at(j)) {
        tmp =  vec.at(i);
        vec.at(i) = vec.at(j);
        vec.at(j) = tmp;
      }
    }
  }
    
  count = 0;
  for (int k = 0; k < K; k++) {
    count += vec.at(k);
  }
  
  cout << count << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
using P = pair<int,int>;
#define MOD 1000000007
#define INF 1000000

/*
ボードを受け取って、
(1,1)(H,W)以外のマスを黒く塗ることができる。
(1,1)から(H,W)にたどり着けるような塗り方のうち、
よりたくさん塗れると嬉しい。

塗るのを全探索すると辛い・・・・

最短経路を求めて、それ以外のマスを塗ればいいじゃん
最短経路で使うマスの数を求めよう

答え＝H*W-N(#)-使うマスの数
*/

int H,W;
char S[55][55];

int dfs(P st)
{
  vector<vector<int>> dist(H+1,vector<int>(W+1,INF));
  dist[st.first][st.second]=0;
  queue<P> q;
  q.push(st);
  while (!q.empty())
  {
    int i,j;
    i = q.front().first;
    j = q.front().second;
    q.pop();
    //4方向のマスを埋めていく
    //top
    if (i-1>=1 && S[i-1][j]=='.' && dist[i-1][j]==INF)
    {
      dist[i-1][j]=dist[i][j]+1;
      q.push(P(i-1,j)); 
    }
    //down
    if (i+1<=H && S[i+1][j]=='.' && dist[i+1][j]==INF)
    {
      dist[i+1][j]=dist[i][j]+1;
      q.push(P(i+1,j)); 
    }
    //left
    if (j-1>=1 && S[i][j-1]=='.' && dist[i][j-1]==INF)
    {
      dist[i][j-1]=dist[i][j]+1;
      q.push(P(i,j-1)); 
    }
    //right
    if (j+1<=W && S[i][j+1]=='.' && dist[i][j+1]==INF)
    {
      dist[i][j+1]=dist[i][j]+1;
      q.push(P(i,j+1)); 
    }
  }
  return (dist[H][W]);
} 

int main()
{
  cin>>H>>W;
  int sharp_count=0;
  for (int i=1;i<=H;i++)
  {
    for (int j=1;j<=W;j++)
    {
      cin>>S[i][j];
      if (S[i][j]=='#') sharp_count++;
    }
  }
  P st(1,1);
  
  int ans = dfs(st);
  if (ans == INF) cout<<-1<<endl;
  else cout<<H*W-(ans+1)-sharp_count<<endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll A;
    double B;
    cin >> A >> B;
    ll b;
    b = round(100*B);
    cout << A*b/100 << endl;

}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<int>A(N); rep(i, 0, N) { cin >> A[i]; }
	int ans = 0;
	map<int, int>mp;
	rep(i, 0, N)mp[A[i]]++;
	sort(all(A), greater<int>());
	rep(i, 0, N) {
		if (mp[A[i]]) {
			mp[A[i]]--;
			rep(j, 0, 35) {
				int x = (1ll << j) - A[i];
				if (mp.count(x) and mp[x]) {
					mp[x]--;
					ans++;
				}
			}
		}
	}
	dump(mp.size());
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 14336
#CODEFESTIVAL2016qualC
N=int(input())
mod=10**9+7
T=list(map(int,input().split()))
A=list(map(int,input().split()))
ansT=[0]*N
ansA=[0]*N
ansT[0]=-1*T[0]
ansA[N-1]=-1*A[N-1]
for i in range(1,N):
    if T[i]>T[i-1]:
        ansT[i]=-1*T[i]
    else:
        ansT[i]=T[i]
    if A[N-1-i]>A[N-i]:
        ansA[N-1-i]=-1*A[N-1-i]
    else:
        ansA[N-1-i]=A[N-1-i]
ans=1
for i in range(N):
    if ansT[i]<0 and ansA[i]<0 and ansT[i]!=ansA[i]:
        ans=0
        break
    elif ansT[i]>0 and ansA[i]>0:
        ans=(ans*min(ansT[i],ansA[i]))%mod
    elif ansT[i]<0 and ansA[i]>0 and abs(ansT[i])>ansA[i]:
        ans=0
        break
    elif ansT[i]>0 and ansA[i]<0 and abs(ansA[i])>ansT[i]:
        ans=0
        break
print(ans)

Measured memory_bytes: 18752
#include<iostream>
#include<set>
using namespace std;
int main(){
  set<int> a;
  int n,s,q,t,c=0;;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s;
    a.insert(s);
  }
  cin >> q;
  for(int i=0;i<q;i++){
    cin >> t;
    if(a.find(t)!=a.end()){
      c++;
    }
  }
  cout << c << endl;
  return 0;
}

  

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
int main() {
    int h, a;
    cin >> h >> a;

    for(int i = 0; i <= h; i++) {
        int reslt = h - a * i;
        if(reslt <= 0) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

vector<int> G[1<<17];
int color[1<<17];
map<P,int> ma;
void dfs(int u,int v,int b){
    int cnt = 1;
    for(auto g:G[u]){
        if(g==v) continue;
        if(cnt==b) cnt++;
        color[ma[mp(g,u)]] = cnt;
        dfs(g,u,cnt);
        cnt++;
    }
}

int main(){
    int n;cin >> n;
    for (int i = 0; i < n-1; i++) {
        int a,b;cin >> a >> b;
        a--,b--;
        G[a].pb(b);
        G[b].pb(a);
        ma[mp(a,b)] = i;
        ma[mp(b,a)] = i;

    }
    int c = 1;
    for (int i = 0; i < n; i++) {
        c = max(c,(int)G[i].size());
    }
    dfs(0,0,0);
    cout << c << endl;
    for (int i = 0; i < n-1; i++) {
        cout << color[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 20096
#include<iostream>
#include<cstring>
using namespace std;
char a[16],b[16]={'C','O','D','E','F','E','S','T','I','V','A','L','2','0','1','6'};
int ans;
int main()
{
	cin>>a;
	for (int i=0;i<=15;i++)
	  if (a[i]!=b[i]) ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}
func scanFloat() float64 {
	sc.Scan()
	a, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		fmt.Println(err)
	}
	return a
}
func scanInt2() (int, int) {
	return scanInt(), scanInt()
}
func scanFloat2() (float64, float64) {
	return scanFloat(), scanFloat()
}
func main() {
	sc.Split(bufio.ScanWords)

	N, D := scanInt2()
	var ans int
	for i := 0; i < N; i++ {
		var xy float64
		X, Y := scanFloat2()
		xy = math.Sqrt(X*X + Y*Y)
		if xy <= float64(D) {
			ans++
		}
	}
	fmt.Println(ans)
}

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

int dp[3005][3005];

int main() {
  int n, t;
  cin >> n >> t;
  vector<P> p(n);
  rep(i, n) cin >> p[i].first >> p[i].second;
  sort(p.begin(), p.end());
  int ans = 0;
  rep(i, n) {
    rep(j, t) {
      chmax(dp[i + 1][j], dp[i][j]);
      int nj = j + p[i].first;
      if (nj < t) chmax(dp[i + 1][nj], dp[i][j] + p[i].second);
    }
    int now = dp[i][t - 1] + p[i].second;
    chmax(ans, now);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 38848
#ifndef ___GEOMETRY_LIBRARY
#define ___GEOMETRY_LIBRARY

#include <vector>
#include <algorithm>

template<class type>
class point2d {
public:
	type x, y;
	point2d() : x(type(0)), y(type(0)) {};
	point2d(type x_, type y_) : x(x_), y(y_) {};
	bool operator==(const point2d& p) { return x == p.x && y == p.y; }
	bool operator!=(const point2d& p) { return x != p.x || y != p.y; }
	point2d& operator+=(const point2d& p) { x += p.x; y += p.y; return *this; }
	point2d& operator-=(const point2d& p) { x -= p.x; y -= p.y; return *this; }
	point2d& operator*=(type val) { x *= val; y *= val; return *this; }
	point2d& operator/=(type val) { x /= val; y /= val; return *this; }
	point2d operator+(const point2d& p) const { return point2d(*this) += p; }
	point2d operator-(const point2d& p) const { return point2d(*this) -= p; }
	point2d operator*(type val) const { return point2d(*this) *= val; }
	point2d operator/(type val) const { return point2d(*this) /= val; }
	type norm() const { return x * x + y * y; }
	type abs() const { return type(std::sqrt(x * x + y * y)); }
	long double fabs() const { return std::sqrt((long double)(x * x + y * y)); }
	type dot(const point2d& p) const { return x * p.x + y * p.y; }
	type cross(const point2d& p) const { return x * p.y - y * p.x; }
	int ccw(const point2d& p1, const point2d& p2) const {
		// Centering at point p, p1 -> p2 is COUNTER-CLOCKWISE : (1)
		// Centering at point p, p1 -> p2 is CLOCKWISE : (-1)
		// Collinear with order p1 -> p -> p2 : (2)
		// Collinear with order p -> p1 -> p2 : (-2)
		// Collinear with order p -> p2 -> p1 : (0)
		point2d pr1 = p1 - point2d(*this);
		point2d pr2 = p2 - point2d(*this);
		if (pr1.cross(pr2) != 0) return pr1.cross(pr2) > 0 ? 1 : -1;
		if (pr1.dot(pr2) < 0) return 2;
		return pr1.norm() < pr2.norm() ? -2 : 0;
	}
};

template<class type>
class segment2d {
public:
	point2d<type> p1, p2;
	segment2d() : p1(point2d<type>()), p2(point2d<type>()) {};
	segment2d(const point2d<type>& p1_, const point2d<type>& p2_) : p1(p1_), p2(p2_) {};
	type norm() const { return (p1 - p2).norm(); }
	type abs() const { return (p1 - p2).abs(); }
	long double fabs() const { return (p1 - p2).fabs(); }
};

// DETERMINE IF "SEGMENT" S1 AND S2 INTERSECTS
template<class type>
bool intersect(const segment2d<type>& s1, const segment2d<type>& s2) {
	int f1 = s1.p1.ccw(s1.p2, s2.p1) * s1.p1.ccw(s1.p2, s2.p2);
	int f2 = s2.p1.ccw(s2.p2, s1.p1) * s2.p1.ccw(s2.p2, s1.p2);
	return (f1 <= 0 && f2 <= 0);
}

#endif // ___GEOMETRY_LIBRARY

#include <iostream>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int q;
	cin >> q;
	cout.precision(15);
	for (int i = 0; i < q; ++i) {
		segment2d<double> s1, s2;
		cin >> s1.p1.x >> s1.p1.y >> s1.p2.x >> s1.p2.y >> s2.p1.x >> s2.p1.y >> s2.p2.x >> s2.p2.y;
		cout << (intersect(s1, s2) ? "1\n" : "0\n");
	}
	return 0;
}


Measured memory_bytes: 3280
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a[10],b[10],d[10],e[10],c,i,cnt=0;
    for(i=1;i<=6;i++){
        scanf("%d",&b[i]);
        a[i] = b[i];}
    for(i=1;i<=6;i++){
        scanf("%d",&e[i]);
        d[i] = e[i];}
    for(i=1;i<=5;i++){
        if(a[i]>a[i+1]){
            c = a[i+1];
            a[i+1] = a[i];
            a[i] = c;}
        if(d[i]>d[i+1]){
            c = d[i+1];
            d[i+1] = d[i];
            d[i] = c;}}
    for(i=1;i<=6;i++){
        if(a[i] == d[i])
            cnt++;}
    if((cnt==6) && (a[1]==a[2]) && (a[2]==a[3]) && (a[3]==a[4]) && (a[4]==a[5])){
        printf("Yes\n");
        return 0;}
    for(i=0;i<4;i++){
        if(b[1] == e[1])
            break;
        c = b[1];
        b[1] = b[2];
        b[2] = b[6];
        b[6] = b[5];
        b[5] = c;}
    for(i=0;i<4;i++){
        if(b[1] == e[1])
            break;
        c = b[1];
        b[1] = b[3];
        b[3] = b[6];
        b[6] = b[4];
        b[4] = c;}
    for(i=0;i<4;i++){
        if(b[2] == e[2])
            break;
        c = b[2];
        b[2] = b[3];
        b[3] = b[5];
        b[5] = b[4];
        b[4] = c;}
    for(i=2;i<=6;i++){
        if(b[i] != e[i]){
            printf("No\n");
            return 0;}}
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define aio()                         \
    do {                              \
        std::ios::sync_with_stdio(0); \
        std::cin.tie(0);              \
    } while (0)
using namespace std;
typedef long long ll;
typedef long double ld;

bool can_build_triangle(ll a, ll b, ll c)
{
    return a + b > c && a + c > b && b + c > a;
}

int main()
{
    aio();

    int n;
    cin >> n;
    vector<ll> v(n);
    for (auto &i : v) {
        cin >> i;
    }
    sort(v.begin(), v.end());
    ll cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (v[j] == v[i]) {
                continue;
            }
            for (int k = j + 1; k < n; k++) {
                if (v[j] == v[k]) {
                    continue;
                }
                if (can_build_triangle(v[i], v[j], v[k])) {
                    cnt++;
                }
            }
        }
    }
    cout << cnt;
}


Measured memory_bytes: 3648
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

macro_rules! chmin {
    ($ base : expr , $ cmp : expr ) => {
        if $base > $cmp {
            $base = $cmp;
        }
    };
}
macro_rules! chmax {
    ($ base : expr , $ cmp : expr ) => {
        if $base < $cmp {
            $base = $cmp;
        }
    };
}
#[fastout]
fn main() {
    input! {//
        h:usize,w:usize,
        c:(Usize1,Usize1),
        d:(Usize1,Usize1),
        s:[Chars;h],
    }

    let mut dp = vec![vec![INF; w]; h];
    let mut q = VecDeque::new();
    q.push_back((c.0, c.1, 0));
    let dx = vec![-1, 0, 0, 1];
    let dy = vec![0, -1, 1, 0];
    while let Some(x) = q.pop_front() {
        let (nowh, noww, cnt) = x;
        // if dp[nowh][noww] <= cnt {
        //     continue;
        // }
        // dbg!(&x);
        dp[nowh][noww] = min(dp[nowh][noww], cnt);
        let mut flg = false;
        for o in 0..4 {
            let nxh = nowh as i64 + dx[o];
            let nxw = noww as i64 + dy[o];
            if (0..h as i64).contains(&nxh) && (0..w as i64).contains(&nxw) {
                let nxh = nxh as usize;
                let nxw = nxw as usize;
                if dp[nxh][nxw] > cnt && s[nxh][nxw] == '.' {
                    dp[nxh][nxw] = cnt;
                    q.push_front((nxh, nxw, cnt));
                    flg = true;
                }
            } else {
                continue;
            }
        }
        for hh in -2..=2 {
            for ww in -2..=2 {
                let nxh = nowh as i64 + hh;
                let nxw = noww as i64 + ww;
                if (0..h as i64).contains(&nxh) && (0..w as i64).contains(&nxw) {
                    let nxh = nxh as usize;
                    let nxw = nxw as usize;
                    if dp[nxh][nxw] > cnt + 1 && s[nxh][nxw] == '.' {
                        dp[nxh][nxw] = cnt + 1;
                        q.push_back((nxh, nxw, cnt + 1));
                    }
                }
            }
        }
        // }
    }
    // dbg!(&dp);
    if dp[d.0][d.1] == INF {
        println!("{}", -1);
    } else {
        println!("{}", dp[d.0][d.1]);
    }
}
const INF: i64 = 1 << 60;


Measured memory_bytes: 15128
#include "iostream"
#include "vector"
#include "list"
using namespace std;

void set_min(int &x, list<int> args) {
    for (auto i: args) {
        x = min(x, i);
    }
}

int main() {
    int n;
    cin >> n;
    vector <int> h(n+1);
    for (int i=1; i<=n; i++) {
        cin >> h[i];
    }
    vector <int> dp(n+1, INT_MAX);
    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    for (int i=3; i<=n; i++) {
        set_min(dp[i], {dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2])});
    }
    cout << dp[n] << endl;
}


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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	string a,b,c;
	cin>>a>>b>>c;
	cout<<char(toupper(a[0]))<<char(toupper(b[0]))<<char(toupper(c[0]))<<'\n';
}




Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int[] b = new int[n];
		Map<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			b[i] = a[i] - i;
			addCntMap(map, b[i]);
		}

		long ans = 0;
		for (int i = 0; i < n; i++) {
			int key = -i - a[i];
			Integer val = map.get(key);
			if (val != null) {
				ans += val;
			}
		}
		System.out.println(ans);
	}

	static void addCntMap(Map<Integer, Integer> map, Integer key) {
		if (map.containsKey(key)) {
			map.put(key, map.get(key) + 1);
		} else {
			map.put(key, 1);
		}
	}
}


Measured memory_bytes: 72372
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    vector<int> a(n);
    int c = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] > 0) c++;
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    //swap(a[1], a.back());
    //if (abs(a[0]) > abs(a[1])) swap(a[0], a[1]);

    //for (int i = 1; i < n; i++) {
    //    
    //}


    //if (a.front() > 0) {
    //    //最後だけ負の数のふりしてね
    //} else if (a.back() < 0) {
    //    //最後だけ正の数のふりしてね
    //} else {

    //}

    //vector<int> a0, a1;
    //for (int i = 0; i < n; i++) {
    //    int a;
    //    cin >> a;
    //    if (a > 0) a0.push_back(a); else a1.push_back(a);
    //}
    //sort(a0.begin(), a0.end());
    //reverse(a0.begin(), a0.end());
    //sort(a1.begin(), a1.end());

    vector<int> x(n), y(n);
    if (c <= 1) {
        for (int i = 1; i < n; i++) {
            x[i] = a[i - 1];
            y[i] = a[i];
            a[i] = a[i - 1] - a[i];
        }
    } else {
        int i1 = n;
        int k = 1, v = 0;
        for (int i = 0; i < n; i++) {
            if (i == n - 1 || a[i] <= 0) {
                i1 = i + 1;
                x[k] = a[i];
                y[k] = a[i - 1];
                v = x[k] - y[k];
                k++;
                for (int j = i - 2; j > 0; j--) {
                    x[k] = v;
                    y[k] = a[j];
                    v = x[k] - y[k];
                    k++;
                }
                x[k] = a[0];
                y[k] = v;
                v = x[k] - y[k];
                k++;
                break;
            }
        }
        for (int i = i1; i < n; i++) {
            x[k] = v;
            y[k] = a[i];
            v = x[k] - y[k];
            k++;
        }
    }
    int m = x[n - 1] - y[n - 1];
    cout << m << endl;
    for (int i = 1; i < n; i++) {
        cout << x[i] << ' ' << y[i] << '\n';
    }
    cout << flush;

    //1つ以外は好きな符号にできそう
    //1つだけ負（正）ならちょうどいい（多くてもそうか）
    //全部正（負）のときだけ都合が悪い 絶対値最小のものを捨てる 0が含まれているのは都合がいい
    //最初に符号違いを持ってくる必要がある
    //負の数が残っていたらどんどん引いていくだけでいい
    //まず最初のペアを作り正の数が残っていなければ簡単　残っていたら最初のペアを逆にする そこから引いていき最後の1個で正の数から引く
    //正の数が1個以下なら簡単 

    return 0;
}

Measured memory_bytes: 3072
nm = gets.chomp.split
n = nm[0].to_i
m = nm[1].to_i

a = gets.chomp.split
vote = 0
n.times do |i|
    a[i] = a[i].to_i
    vote += a[i]
end

a.sort!.reverse!

result = true
m.times do |i|
    if a[i] < vote / (4.0 * m)
        result = false
        break
    end
end

puts result ? "Yes" : "No"

Measured memory_bytes: 1788
#include<stdio.h>
#define M 60

int main(void){
  int i,j;
  int n,r;
  int p,c;
  int hnfd[M],swp[M];

  for(;;){
    scanf("%d%d",&n,&r);
    if(n==0 && r==0) break;

    for(i=0;i<n;i++) hnfd[i]=i+1;

    for(i=0;i<r;i++){
      scanf("%d%d",&p,&c);

      for(j=0;j<=n-p-c;j++) swp[j]=hnfd[j];

      for(j=0;j<c;j++) swp[n-1-j]=hnfd[n-p-j];

      for(j=1;j<p;j++) swp[n-c-j]=hnfd[n-j];

      for(j=0;j<n;j++) hnfd[j]=swp[j];
    }
    printf("%d\n",hnfd[n-1]);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define out(a) cout<<a<<" "
#define all(a) (a).begin(), (a).end()
#define upper_index(v, a) (int)distance(v.begin(), upper_bound((v).begin(), (v).end(), a))
#define lower_index(v, a) (int)distance(v.begin(), lower_bound((v).begin(), (v).end(), a))
typedef long long ll;
const long long INF = 1e17;

int main() {
  ll n,t;
  cin>>n>>t;
  vector<pair<ll,ll>> a(n);
  rep(i,n) cin>>a[i].first>>a[i].second;
  vector<vector<ll>> dp1(n+2,vector<ll>(t+1,0));
  vector<vector<ll>> dp2(n+2,vector<ll>(t+1,0));
  for(ll i=1;i<=n;++i)for(ll j=0;j<=t;++j){
    if (j-a[i-1].first>=0) {
      dp1[i][j]=max(dp1[i-1][j],dp1[i-1][j-a[i-1].first]+a[i-1].second);
    }else{
      dp1[i][j]=dp1[i-1][j];
    }
  }
  
  for(ll i=n;0<i;--i)for(ll j=0;j<=t;++j){
    if (j-a[i-1].first>=0) {
      dp2[i][j]=max(dp2[i+1][j],dp2[i+1][j-a[i-1].first]+a[i-1].second);
    }else{
      dp2[i][j]=dp2[i+1][j];
    }
  }
  ll ans=0;
  for(ll i=1;i<=n;i++)for(ll j=1;j<=t-1;j++){
    ll cnt=dp1[i-1][j]+dp2[i+1][t-1-j]+a[i-1].second;
    if (ans<cnt) ans=cnt;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
    ll n,W;
    cin>>n>>W;
    ll w[n],v[n];
    for(ll i=0;i<n;i++)
    cin>>w[i]>>v[i];
    
    ll dp[n+1][W+1];
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=W;j++)
        {
            if(i==0 || j==0)
            dp[i][j]=0;
            else if(w[i-1]<=j)
            dp[i][j]=max(v[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
            else
            dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][W]<<endl;
	return 0;
}

Measured memory_bytes: 79232
import math

def kock(n,p1x,p1y,p2x,p2y):
    if(n==0):
        return

    sx = (2*p1x+p2x)/3.0
    sy = (2*p1y+p2y)/3.0
    tx = (p1x+2*p2x)/3.0
    ty = (p1y+2*p2y)/3.0

    ux = (tx-sx)*math.cos(math.radians(60)) - (ty-sy)*math.sin(math.radians(60)) + sx
    uy = (tx-sx)*math.sin(math.radians(60)) + (ty-sy)*math.cos(math.radians(60)) + sy

    kock(n-1,p1x,p1y,sx,sy)
    print(sx,sy)
    kock(n-1,sx,sy,ux,uy)
    print(ux,uy)
    kock(n-1,ux,uy,tx,ty)
    print(tx,ty)
    kock(n-1,tx,ty,p2x,p2y)


n = int(input())
print(0,0)
kock(n,0,0,100,0)
print(100,0)


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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

const int MAXN = 2e5 + 5;
const int MOD = 998244353;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define FAIL0 {cout << "0\n"; return 0;}
#define FAIL1 {cout << "-1\n"; return 0;}
#define FAILNO {cout << "No\n"; return 0;}
#define OF {cout << "OVERFLOW!!!\n"; return 0;}

int N;
int A[100];
int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> N;
    int s = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        s += A[i];
    }

    int mn = s+1;
    int c = 0;
    for (int i = 0; i < N; i++) {
        c += A[i];
        mn = min(mn,abs(c-(s-c)));
    }

    cout << mn << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b) % 24 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <algorithm>

#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main(int argc, char *argv[]){

  int N;
  cin >> N;
  int a[N];
   long long  x  = 0, y = 0;
  for(int i = 0; i < N; i++){
    cin >> a[i];
    y += a[i];
  }
  x = a[0];
  y -= a[0];
   long long  mini = abs(x - y);
  for(int i = 1; i < N-1; i++){
    x += a[i];
    y -= a[i];
    //printf("x : %llu\n", x);
    //printf("y : %llu\n", y);
     long long tmp = abs(x-y);
    //printf("tmp : %llu\n", tmp);
    mini = (tmp < mini)? tmp:mini;
  }
  //printf("x : %d\n", x);
  printf("%llu\n", mini);

  return 0;
}


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

using namespace std;
long long int dp[100005][2];
long long int p = 1000000007;
long long int helper(int i,vector<int>adj[],int color,int par){
	//cout<<i<<" "<<color<<endl;
	if(dp[i][color] > -1){
		return dp[i][color];
	}
	long long int ans = 1;
	for(int j=0;j<adj[i].size();j++){
		if(par != adj[i][j]){
			if(color == 0){
				ans = (ans%p * helper(adj[i][j],adj,1-color,i)%p)%p;
			}
			if(color == 1){
				ans = (ans%p * (helper(adj[i][j],adj,color,i)%p + helper(adj[i][j],adj,1-color,i)%p)%p)%p;
			}
		//	cout<<i<<" "<<color<<" "<<ans<<endl;
		}
	}
	dp[i][color] = ans;
	return ans;
}
int main(){
		int n;cin>>n;
		vector<int>adj[n+1];
		for(int i=1;i<n;i++){
			int a,b;cin>>a>>b;
			adj[a].push_back(b);
			adj[b].push_back(a);
		}
		for(int i=0;i<100005;i++){
			for(int j=0;j<2;j++){
				dp[i][j] = -1;
			}
		}
	//	cout<<"######################################"<<endl;
		long long int ans = 0;
		ans = helper(1,adj,0,-1)%p;
	//	cout<<"#######################################"<<endl;
		ans = (ans%p + helper(1,adj,1,-1)%p)%p;
		cout<<ans<<endl;
}


Measured memory_bytes: 15616
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n,  k;
    string s;
    cin >> n >> k >> s;
    s[k-1] = s[k-1] + 0x20;
    cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
#define _all(arg) begin(arg),end(arg)

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0; }
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0; }

using namespace std;

bool check(vector<string> w, int begin) {
	bool res;
	int cur = begin;
	int buf = 0;
	int i = 0;
	vector<int> hoge = {5,7,5,7,7};
	for(i = 0; i < hoge.size() && cur < w.size(); cur++) {
		buf += w[cur].size();
		if(buf == hoge[i]) {
			buf = 0;
			i++;
		}
		if(buf > hoge[i]) {
			break;
		}
	}
	if(i == 5) {
		return true;
	}
	else {
		return false;
	}
}

int main(void){
	int n;
	while(cin>>n,n) {
		vector<string> W(n);
		rep(i,n) cin >> W[i];
		rep(i,n) {
			if(check(W, i-1)) {
				cout << i << endl;
				break;
			}
		}
	}
        
	return 0;
}

Measured memory_bytes: 3028
N = int(input())
X = [int(x) for x in input().split()]

def main():
    sorted_list = sorted(X)
    mid = N // 2
    left_median = sorted_list[mid - 1]
    right_median = sorted_list[mid]

    for num in X:
        ans = right_median if num <= left_median else left_median
        print(ans)

if __name__ == "__main__":
    main()

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

int main() {
    int a, b;
    cin >> a >> b;
    int c = a;
    int ans = 1;
    while(1) {
        if (c >= b) break;
        ans++;
        c += a-1;
    }
    if (b == 1) cout << 0 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    sort(a, a + n, greater<int>());

    int Alice = 0, Bob = 0;
    rep(i, n){
        if(i % 2 == 0){
            Alice += a[i];
        }else{
            Bob += a[i];
        }
    }

    p(Alice - Bob);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <cctype>
#include <cmath>
#include <cassert>
using namespace std;

enum FACE { TOP, BOTTOM, NORTH, SOUTH, WEST, EAST };

class dice {
private:
  int num[6];

  void roll(FACE a, FACE b, FACE c, FACE d) {
	const int tmp = num[a];
	num[a] = num[b];
	num[b] = num[c];
	num[c] = num[d];
	num[d] = tmp;
  }

public:
  dice() {
	num[TOP] = 1;
	num[BOTTOM] = 6;
	num[NORTH] = 4;
	num[SOUTH] = 3;
	num[WEST] = 2;
	num[EAST] = 5;
  }

  void set(int top, int front) {
	if(num[EAST] == top || num[WEST] == top) west();
	while(num[TOP] != top) north();
	while(num[NORTH] != front) cw();
  }

  int operator[](FACE f) const { return num[f]; }

  void north() { roll(TOP, SOUTH, BOTTOM, NORTH); }
  void south() { roll(TOP, NORTH, BOTTOM, SOUTH); }
  void east() { roll(TOP, WEST, BOTTOM, EAST); }
  void west() { roll(TOP, EAST, BOTTOM, WEST); }
  void ccw() { roll(SOUTH, WEST, NORTH, EAST); }
  void cw() { roll(SOUTH, EAST, NORTH, WEST); }

  void move(int d) {
	switch(d) {
	case 0:
	  east();
	  break;
	case 1:
	  south();
	  break;
	case 2:
	  west();
	  break;
	case 3:
	  north();
	  break;
	default:
	  assert(false);
	}
  }
};

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const FACE get_idx[] = {EAST, SOUTH, WEST, NORTH};
const int offset_x = 50;
const int offset_y = 50;
#define height first
#define top_face second
void cal(vector<vector<pair<int,int> > > &field,int x,int y,dice &die){
  
  for(int i = 6;i >= 4;i--){
	for(int dir = 0;dir < 4;dir++){
	  int nx = x+dx[dir],ny = y+dy[dir];
	  if(die[get_idx[dir]] == i && field[ny][nx].height < field[y][x].height){
		die.move(dir);
		cal(field,nx,ny,die);
		return;
	  }
	}
  }
  field[y][x].height++;
  field[y][x].top_face = die[TOP];
}
int main(){
  int n;
  while(cin >> n && n!=0){
	
	vector<vector<pair<int,int> > >field(100,vector<pair<int,int> > (100,pair<int,int>(0,0)));
	for(int i = 0;i < n;i++){
	  int t,f;
	  cin >> t >> f;
	  int x = offset_x,y = offset_y;
	  dice die = dice();
	  die.set(t,f);
	  assert(t == die[TOP] && f == die[NORTH]);
	  cal(field,x,y,die);
	}

	vector<int> cnt(7,0);
	for(int i = 0;i < 100;i++){
	  for(int j = 0;j < 100;j++){
		cnt[field[i][j].top_face]++;
	  }
	}

	for(int i =1;i < 7;i++){
	  cout << cnt[i] << (i == 6 ? "\n" : " ");
	}
  }
 
  
  return 0;
}

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

int main() {
    ll N;
    cin >> N;
    vector<ll>x(5);
    for (int i = 0; i < 5; ++i) {
        cin >> x[i];
    }
    sort(x.begin(), x.end());
    ll ans = (N + x[0] - 1) / x[0] + 4;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			int A = Integer.parseInt(br.readLine());
			int B = Integer.parseInt(br.readLine());
			int C = Integer.parseInt(br.readLine());
			int D = Integer.parseInt(br.readLine());
			int E = Integer.parseInt(br.readLine());

			int cost = 0;
			int current = A;
			if (current<=0) {
				cost += (-1)*current*C+D+B*E;
			} else {
				cost += (B-current)*E;
			}
			System.out.println(cost);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}



Measured memory_bytes: 24176
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    if(k <= a) cout << k << endl;
    else if(k <= a + b) cout << a << endl;
    else cout << a - (k - a - b) << endl;
} 



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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	FOR(i,0,n)cin >> a[i];
	sort(ALL(a));
	ll ans = 0;
	int b[n];
	FOR(i,0,n){
		if(i % 2 == 0){
			b[i] = a[i/2];
		}else{
			b[i] = a[n-(i+1)/2];
		}
	}
	FOR(i,0,n-1){
		ans += abs(b[i] - b[i+1]);
	}
	if(n >= 3)
		ans += b[n-3+((n%2==0)?1:0)] - a[0];

	FOR(i,0,n){
		if(i % 2 == 0){
			b[i] = a[n-i/2-1];
		}else{
			b[i] = a[i/2];
		}
	}
	ll sum = 0;
	FOR(i,0,n-1){
		sum += abs(b[i] - b[i+1]);
	}
	if(n >= 3)
		sum -= b[n-3+((n%2==0)?1:0)] - a[n-1];

	ans = max(ans, sum);
	ANS(ans);
	return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
using namespace std;
const int dx[] = {-2,-2,-2,2,2,2,-1,0,1,-1,0,1},dy[] = {0,1,-1,0,1,-1,2,2,2,-2,-2,-2};
#define INF 1e+8
#define EPS 1e-8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = (j); i < (k); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
class P{
	public:
	int x,y,next;
	P(int x,int y,int next):x(x),y(y),next(next){}
};
bool check(int stage[15][15],int x,int y,int next){
	const int ddx[]={-1,0,1,-1,0,1,-1,0,1,0},ddy[]={1,1,1,0,0,0,-1,-1,-1,0};
	rep(i,10){
		rep(j,10){
			if(stage[j][i] == next){
				rep(k,10){
					if(i+ddx[k] == x && j+ddy[k] == y)return true;
				}
				return false;
			}
		}
	}
}
int main(){
	int sx,sy;
	while(scanf("%d%d",&sx,&sy),(sx|sy)){
		int n;
		int stage[15][15];
		memset(stage,-1,sizeof(stage));
		scanf("%d",&n);
		rep(i,n){
			int x,y;
			scanf("%d%d",&x,&y);
			stage[y][x] = i;
		}
		bool f = false;
		queue<P> Q;
		Q.push(P(sx,sy,0));
		while( Q.size() ){
			P p = Q.front();Q.pop();
			if(p.next == n){f=true;break;}
			rep(i,12){
				if(p.x+dx[i] > 9 || p.x+dx[i] < 0 || p.y+dy[i] > 9 || p.y+dy[i] < 0 )continue;
				if( check(stage,p.x+dx[i],p.y+dy[i],p.next) ) Q.push(P(p.x+dx[i],p.y+dy[i],p.next+1));
			}
		}
		f ? puts("OK") : puts("NA");
	}
	return 0;
}

Measured memory_bytes: 1192
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	s := nextStr()
	ans := ""

	for i := 0; i < len(s); i++ {
		if s[i] == 'B' {
			if len(ans) > 0 {
				ans = ans[:len(ans)-1]
			}
		} else {
			ans += string(s[i])
		}
	}

	fmt.Println(ans)

}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define reset(x, y) memset(x, y, sizeof(x))
#define BUG(x) cerr << #x << " = " << (x) << endl
#define BUGP(x) cout << #x << " = " << (x)._1 << ", " << (x)._2 << endl
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
// Head

const int N = 212345;

int n, a[N];
bool vis[N];
LL k;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> k;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    vector<int> vec;
    int pos = 1;
    while (!vis[pos]) {
        vis[pos] = true;
        vec.pb(pos);
        pos = a[pos];
    }

    int st = -1;
    for (int i = 0; i < vec.size(); ++i) {
        if (vec[i] == pos) {
            st = i;
            break;
        }
    }

    int len = vec.size() - st;

    if (k < st) {
        cout << vec[k] << '\n';
    } else {
        k -= st;
        k %= len;
        cout << vec[st + k] << '\n';
    }

    return 0;
}

Measured memory_bytes: 5232
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a, b, c; cin >> a >> b >> c;
    int tmp = c / a; 
    int ans = tmp * b;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

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

	double a,b, h,m,sum=0;
	cin>>a>>b>>h>>m;
	double x=0,y=0;
	x=h*30;
	x+=0.5*m;
	y=6*m;
	double zz=cos(3.14159265358979 / 180 * abs(x-y));
	double c= pow(a,2)+pow(b,2)-(2*a*b*zz);
	cout<<fixed<<setprecision(10)<<pow(  pow(a,2)+pow(b,2)-(2*a*b*zz)  ,0.5)<<endl;

		return 0;
	}


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

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

  vector<int> b(n);
  rep(i, n - 1) cin >> b[i];

  int ans = b[0] + b[n-2];

  for (int i = 1; i < n - 1; i++) {
    ans += min(b[i - 1], b[i]);
  }

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


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <map>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <memory>

using namespace std;

#if 1
#define PRINT(x) { cout << #x << ": " << (x) << endl; }
#define PRINT_CONTAINER(x)  { cout << #x << ": ";                       \
        for (size_t ix = 0; ix < (x).size(); ++ix) cout << (x)[ix] << ", "; \
        cout << endl; }
#else
#define PRINT(x)
#define PRINT_CONTAINER(x)
#endif

typedef pair<int, int> p;

int n;

int main(int argc, char *argv[]) {
    char s[4][4];
    scanf("%s", s[0]);
    scanf("%s", s[1]);
    scanf("%s", s[2]);
    printf("%c%c%c\n", s[0][0], s[1][1], s[2][2]);
}


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

using namespace std;

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

const long long MOD = 1e9 + 7;
const int INF = 1e9;
const double EPS = 1e-9;

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    int digits = 0;
    int t = i;
    while (t > 0) digits++, t /= 10;
    if (digits % 2 == 1) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256