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


const int Inf = 1e6;
const int MaxN = 400;
int dist[MaxN][MaxN];
int h, w;
vector<string> s;


void solve()
{
    int nv = h * w;
    for (int i = 0; i < nv; i++) {
        for (int j = 0; j < nv; j++) dist[i][j] = Inf;
    }

    int idx, idx2;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') continue;
            idx = i * w + j;
            dist[idx][idx] = 0;
            if (i - 1 >= 0 && s[i - 1][j] != '#') {
                idx2 = (i - 1) * w + j;
                dist[idx][idx2] = 1;
            }
            if (i + 1 < h && s[i + 1][j] != '#') {
                idx2 = (i + 1) * w + j;
                dist[idx][idx2] = 1;
            }
            if (j - 1 >= 0 && s[i][j - 1] != '#') {
                idx2 = i * w + j - 1;
                dist[idx][idx2] = 1;
            }
            if (j + 1 < w && s[i][j + 1] != '#') {
                idx2 = i * w + j + 1;
                dist[idx][idx2] = 1;
            }
        }
    }

    for (int k = 0; k < nv; k++) {
        for (int i = 0; i < nv; i++) {
            for (int j = 0; j < nv; j++) {
                int tmp = (dist[i][k] == Inf || dist[k][j] == Inf) ? Inf : (dist[i][k] + dist[k][j]);
                if (dist[i][j] > tmp) dist[i][j] = tmp;
            }
        }
    }

    int dmax = 0;
    for (int i = 0; i < nv; i++) {
        for (int j = 0; j < nv; j++) {
            if (dist[i][j] != Inf) dmax = max(dmax, dist[i][j]);
        }
    }
    cout << dmax << endl;
}


int main()
{
    string si;
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        cin >> si;
        s.push_back(si);
    }
    solve();
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
As = list(map(int, input().split()))
sm = sum(As[1:])
p = As[0]
t = abs(sm-p)
for a in As[1:-1]:
  p+=a
  sm-=a
  if t < abs(sm-p):
    break
  t = abs(sm-p)
print(t)

Measured memory_bytes: 26220
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

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

int base = 1, i, n, x[60], y[60];
double left, right;

int main(void) {
    while(scanf("%d", &n) == 1 && n != 0) {
        left = right = 0.0;
        REP(i, n) {
            scanf("%d%d", &x[i], &y[i]);
            if(i > 0) {
                left += x[i - 1] * y[i];
                right+= y[i - 1] * x[i];
            }
        }
        left += x[n-1] * y[0];
        right+= y[n-1] * x[0];
        printf("%d %.1lf\n", base++, 0.5*fabs(right - left));
    }
    return 0;
}

Measured memory_bytes: 1064
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
using ll = long long;
int main() {
	char str[4005];
	int n, i, j, sum[4005][3], tran[128], opp;
	ll res = 0;
	tran['R'] = 0;
	tran['G'] = 1;
	tran['B'] = 2;
	tran[0] = 'R';
	tran[1] = 'G';
	tran[2] = 'B';
	scanf("%d", &n);
	getchar();
	str[0] = getchar();
	for (j = 0; j < 3; j++) {
		sum[0][j] = 0;
	}
	sum[tran[str[0]]][0]++;
	for (i = 1; i < n; i++) {
		str[i] = getchar();
		for (j = 0; j < 3; j++) {
			sum[i][j] = sum[i - 1][j];
		}
		sum[i][tran[str[i]]]++;
	}
	for (i = 0; i < n - 3; i++) {
		for (j = i + 1; j < n - 1; j++) {
			if (str[i] == str[j])
				continue;
			opp = 3 - tran[str[i]] - tran[str[j]];
			if (j + (j - i) < n)
				if (str[j + (j - i)] == tran[opp])
					res--;
			res += sum[n - 1][opp] - sum[j][opp];
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3740
import sys
sys.setrecursionlimit(10 ** 6)


MOD = 10 ** 9 + 7


def prepare(n):
    global MOD
    modFacts = [0] * (n + 1)
    modFacts[0] = 1
    for i in range(n):
        modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD

    invs = [1] * (n + 1)
    invs[n] = pow(modFacts[n], MOD - 2, MOD)
    for i in range(n, 1, -1):
        invs[i - 1] = (invs[i] * i) % MOD

    return modFacts, invs


def dfs(v):
    global MOD
    childs = 0
    var = 1
    for e in edge[v]:
        if path[e] == 0:
            path[e] = 1
            nc, nvar = dfs(e)
            childs += nc
            V[v][e] = (nc, nvar)
            var *= nvar
            var %= MOD
            var *= invs[nc]
            var %= MOD
    var *= modFacts[childs]
    var %= MOD
    dp[v] = (childs, var)
    return childs + 1, var


def dfs2(v, pn, pVar):
    global MOD
    oNodes, oVar = dp[v]
    tNodes = pn + oNodes
    tVar = (oVar * pVar) % MOD
    tVar *= invs[oNodes] * modFacts[tNodes] * invs[pn]
    tVar %= MOD

    dp[v] = (tNodes, tVar)

    for e in V[v].keys():
        eNodes, eVar = V[v][e]
        nVar = (tVar * invs[tNodes] * modFacts[eNodes] * modFacts[tNodes - eNodes]) % MOD
        nVar *= pow(eVar, MOD - 2, MOD)
        nVar %= MOD
        dfs2(e, tNodes - eNodes + 1, nVar)


N = int(input())
edge = [[] for _ in range(N)]
for s in sys.stdin.readlines():
    a, b = map(int, s.split())
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)

modFacts, invs = prepare(N)

V = [{} for _ in range(N)]
path = [0] * N
dp = [None] * N
path[0] = 1
dfs(0)
dfs2(0, 0, 1)


for i in range(N):
    print(dp[i][1])


Measured memory_bytes: 176396
L, R = gets.split().map(&:to_i)

ans = 10000

(L..R).each do |i|
  (i+1..R).each do |j|
    ans = [ans, (i*j)%2019].min
    if (i*j) % 2019 == 0
      puts ans
      exit
    end
  end
end

puts ans

Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoders {
	class Program {
		static void Main(string[] args) {
			var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}

			var N = inputArray[0];
			var K = inputArray[1];

			var numArray = retreiveLongArray();
			//各さいころの期待値は(1+p)/2 よってpが最大となるKこのサイコロの選び方の場合の最大値をまず考える
			//Sum(expect)max =(Sum(p)max+K)/2

			var sumArray = new List<long>();

			for (int i = 0; i < N-K+1; i++) {

				//最初の処理はきちんと足す
				if (i == 0) {
					long sumFirst = 0;
					for (int n = 0; n < K; n++) {
						sumFirst += numArray[i + n];
					}
					sumArray.Add(sumFirst);
					continue;
				}

				//2番目以降は先頭を引いて末尾を足すだけでよい
				var sum = sumArray.Last() + numArray[i + K - 1] - numArray[i-1];
				sumArray.Add(sum);
			}

			var sumPmax = sumArray.Max();
			var ans = (sumPmax + K) / 2.0;

			//答えの出力
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray =  Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 36828
n=int(input())
A=list(map(int,input().split()))

total=0
for i in range(n-1):
    total+=abs(A[i]-A[i+1])
total+=abs(A[n-1]) +abs(A[0])

if( (A[0]-0)*(A[1]-A[0])<0 ):
    print(total-abs(A[0]) - abs(A[1] - A[0]) +abs(A[1]) )
else:
    print(total)


for i in range(1,n-1):
    if( (A[i-1] -A[i])*(A[i] - A[i+1]) <0 ):
        print(total - 2*min([abs(A[i-1]-A[i]),abs(A[i]-A[i+1])]))
    else:
        print(total)

if( (A[n-1] - 0)*(A[n-2]-A[n-1]) <0):
    print(total-abs(A[n-1]) - abs(A[n-1] - A[n-2]) + abs(A[n-2]))
else:
    print(total)

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

unsigned long long ans = 0;
int n, m;
bool connect[8][8];

void search(int position, bool done[]){
    done[position] = true;
    //cout << "position:" << position << ",";
    //for(int i=0;i<n;i++)cout << done[i] << ",";
    //cout << endl;
    int check = 0;
    for(int i=0;i<n;i++){
        if(done[i])check++;
    }
    if(check==n){
        ans++;
    }

    for(int i=0;i<n;i++){
        if(connect[position][i] && (!done[i]))search(i, done);
    }
    done[position] = false;
}

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

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)connect[i][j] = false;
    }

    int a[m], b[m];
    for(int i=0;i<m;i++){
        cin >> a[i] >> b[i];
        connect[a[i]-1][b[i]-1] = true;
        connect[b[i]-1][a[i]-1] = true;
    }

    bool done[n];
    for(int i=0;i<n;i++)done[i] = false;
    done[0] = true;
    int position = 0;
    search(position, done);

    cout << ans << endl;
}


Measured memory_bytes: 256
//header{{{
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
 
#include <boost/sort/spreadsort/spreadsort.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
//#include <boost/graph/graph_utility.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/trie_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
//using namespace boost::multiprecision;
//using namespace boost::math;
 
typedef boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS,
        boost::no_property, boost::property<boost::edge_weight_t, int> > Graph;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define bsort boost::sort::spreadsort::spreadsort
#define int int_fast64_t
using pii = pair<int,int>;
 
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
template <class Func>
 
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}
 
    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};
 
template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
 
template <typename T> using Set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename K, typename V> using Umap = gp_hash_table<K, V>;
using Trie = trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }
 
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
 
struct negrightshift {
    inline int operator() (const int &x, const unsigned offset) {
        return -(x >> offset);
    }
};
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	Umap<string,int> mp;
	int sum = 0;
	rep(i,n){
		string s;
		cin >> s;
		sort(all(s));
		++mp[s];
		sum += mp[s]-1;
	}
	cout << sum << '\n';
	return 0;
}


Measured memory_bytes: 21800
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a = Is()
k = I()
print(sum(a)-max(a) + max(a)*(2**k))

Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e18+18;
const ll MAX = 100005;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


int main(){
    ll N, K;
    cin>>N>>K;
    vector<ll> A(N);
    
    for(int i=0; i<N; i++){
        cin>>A[i];
    }
    sort(A.begin(), A.end());
    
    ll Min=-1*1000000000000000000-1;
    ll Max=1*1000000000000000000+1;

    while(Max-Min>1){
      	ll Mid=Max+Min;
        Mid/=2;
        ll Sum=0;
        for(int i=0; i<N; i++){
            if(A[i]>0){
                ll X=((Mid>=0)?Mid/A[i]:((Mid+1)/A[i]-1));
                auto itr=upper_bound(A.begin(), A.end(), X);
                Sum+=distance(A.begin(), itr);
                if(X>=A[i])Sum--;
            }
            else if(A[i]<0){
                ll X=((Mid>=0)?Mid/A[i]:(Mid+1)/A[i]+1);
                auto itr=lower_bound(A.begin(), A.end(), X);
                Sum+=distance(itr, A.end());
                if(X<=A[i])Sum--;
            }
            else if(Mid>=0){
                Sum+=N-1;
            }

        }
        Sum/=2;
        if(Sum<K){
            Min=Mid;
        }
        else{
            Max=Mid;
        }
    }
    cout<<Max<<endl;
}



Measured memory_bytes: 1920
import sys
input = sys.stdin.readline
N = int(input())

base_N = 0
if(N > 10):
	base_N  = int(str(N)[0])*(10**(len(str(N))-1))+int(str(N)[-1])

dig_N = len(str(N))

ans = 0
for x in range(1,10):
	for y in range(1,10):
		for dig_A in range(dig_N):
			for dig_B in range(dig_N):
				check = True
				ways_A, ways_B = 0, 0
				deduct = 0
				if(dig_A == 0 and x<=N):
					if(x==y): 
						ways_A = 1
					else: check = False
				elif(dig_A == 1 and x*10+y<=N):
					ways_A = 1
				elif((x+1)*10**dig_A <= N):
					ways_A = 10**(dig_A-1)
				elif(x*(10**dig_A) <= N):
					if(x*(10**dig_A)+y <= N):
						if(y > N%10): ways_A = (N - base_N)//10
						else : ways_A = (N - base_N)//10 + 1
					else : check = False
				else:
					ways_A = 0
					check = False

				if(dig_B == 0 and y<=N):
					if(x==y): ways_B = 1
					else: check = False
				elif(dig_B == 1 and y*10+x<=N):
					ways_B = 1
					if(dig_A!=dig_B) : ways_B
				elif((y+1)*10**dig_B <= N):
					ways_B = 10**(dig_B-1)
				elif(y*(10**dig_B) <= N):
					if(y*(10**dig_B)+x <= N):
						if(x > N%10): ways_B = (N - base_N)//10
						else: ways_B = (N - base_N)//10 + 1
					else : check = False
				else:
					ways_B = 0
					check = False
				tmp = ans
				ans += ways_B * ways_A - deduct

print(ans)

Measured memory_bytes: 40176
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(l[k-1])


Measured memory_bytes: 2940
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

N,M,L = map(int,readline().split())
ABC = [list(map(int,readline().split())) for _ in range(M)]
Q = int(readline())
ST = [list(map(int,readline().split())) for _ in range(Q)]
    
def warshall_floyd(d):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

INF = 10**11
d = [[INF]*N for i in range(N)] 
a =  [[INF]*N for i in range(N)] 
for x,y,z in ABC:
    if z <= L:
      d[x-1][y-1] = z
      d[y-1][x-1] = z
for i in range(N):
    d[i][i] = 0
    a[i][i] = 1
d = csr_matrix(d)
d = floyd_warshall(csgraph=d)

for i in range(N-1):
  for j in range(i+1,N):
    if d[i][j] <= L:
      a[i][j] = 1
      a[j][i] = 1
a = csr_matrix(a)
a = floyd_warshall(csgraph=a)

for s,t in ST:
  ans = a[s-1][t-1]
  if ans == INF:
      print(-1)
  else:
      print(int(ans)-1)

Measured memory_bytes: 46636
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (auto it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(int N) {
	std::vector<T> vec(N);
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
	return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
	const ll W = inputVal<ll>();
	const ll H = inputVal<ll>();
	const ll x = inputVal<ll>();
	const ll y = inputVal<ll>();

	const double halfarea = static_cast<double>(W * H) / 2.0;
	bool isCentre = (W == 2 * x) && (H == 2 * y);
	cout << halfarea << " " << (isCentre ? 1 : 0) << endl;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << std::fixed << std::setprecision(15);
	Main();

	double tmp;
	cin >> tmp;

	return 0;
}


Measured memory_bytes: 256
n = int(input())

for i in range(1, n+1, 1):
    if(n*2 % i == 0):
        j = n*2 // i
        if(i+1 == j): break
    if(i >= j):
        print("No")
        exit()

ans = [i*[0] for k in range(j)]

for k in range(i):
    ans[0][k] = k+1

for l in range(j-2):
    count = 1
    for k in range(i):
        if(l >= k):
            ans[l+1][k] = ans[k][l]
        else:
            ans[l+1][k] = ans[l][-1] + count
            count += 1

for k in range(i):
    ans[-1][k] = ans[k][-1]

print("Yes")
print(j)
for k in range(j):
    print("%d %d" %(i, ans[k][0]), end="")
    for l in range(1, i, 1):
        print(" %d" %(ans[k][l]), end="")
    print()

Measured memory_bytes: 9288
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> s(N);
  int sum = 0;
  rep(i, N)
  {
    cin >> s[i];
    sum += s[i];
  }

  if (sum % 10 != 0)
  {
    cout << sum << endl;
    return 0;
  }
  else
  {
    sort(s.begin(), s.end());
    for (int i = 0; i < N; i++)
    {
      if (s.at(i) % 10 != 0)
      {
        sum -= s.at(i);
        cout << sum << endl;
        return 0;
      }
    }
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const double PI = acos(-1.0);
int main() {
    int a, b, h, w;
    scanf("%d%d%d%d", &a, &b, &h, &w);
    double d = fabs(30 * h - 5.5 * w);
    printf("%.12f\n", sqrt(a * a + b * b - 2 * cos(d / 180 * PI) * a * b));
    return 0;
}

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

typedef long long ll;

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

	ll ans = 0;
	if(a==b){
		cout << a << endl;
		return 0;
	}

	if(a%2==1){
		ans ^= a;
		a++;
	}
	if(b%2==0){
		ans ^= b;
		b--;
	}
	
	if(a<b) if(((b+1-a)/2)%2==1) ans ^= 1;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
constexpr double pi = 3.141592653589793;
int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    const double theta = abs(60. * h - 11. * m) / 360. * pi;
    cout << fixed << setprecision(10);
    cout << sqrt(a * a + b * b - 2. * a * b * cos(min(theta, 2. * pi - theta))) << endl;
}

Measured memory_bytes: 4252
/*
 * Code be weshen zyk :'(
 */
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define F first
#define S second

using ll = long long;
using ii = pair<int, int>;
using db = long double;

#ifdef ONLINE_JUDGE
#define cerr if(0)cerr
#endif

template<class C> void amin(C &a4, C b4) {
	a4 = min(a4, b4);
}
template<class C> void amax(C &a4, C b4) {
	a4 = max(a4, b4);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
	os << "[";
	for (auto vv : V)
		os << vv << ",";
	return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) {
	return os << "(" << P.first << "," << P.second << ")";
}

const int N = 3e3 + 5;
double dp[N][N+N];
bool vis[N][N+N];
double p[N];
int n, m;
double solve(int x, int cnt) {
	if(x == 0)
		return (cnt > 0 ? 1 : 0);
	double &ret = dp[x][cnt+N];
	if(vis[x][cnt+N])
		return ret;
	vis[x][cnt+N] = 1;
	ret += solve(x-1,cnt+1) * p[x];
	ret += solve(x-1,cnt-1) * (1.0 - p[x]);
	return ret;
}
int main() {
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	cin >> n;

	for(int i = 1; i <= n; i++)
		cin >> p[i];

	cout << fixed << setprecision(9) << solve(n,0) << '\n';

	return 0;
}


Measured memory_bytes: 158080
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  long long sum=0;
  vector<int> a(n),cnt(100001,0);
  rep(i,n){
    cin >> a.at(i);
    cnt.at(a.at(i))++;
    sum+=a.at(i);
  }
  int q;
  cin >> q;
  vector<int> b(q),c(q);
  rep(i,q){
    cin >> b.at(i) >> c.at(i);
  }
  rep(i,q){
    if(cnt.at(b.at(i))>0){
      int cp=cnt.at(b.at(i));
      cnt.at(b.at(i))=0;
      cnt.at(c.at(i))+=cp;
      sum+=(c.at(i)-b.at(i))*cp;
    }
     cout << sum<<endl;
  }
}

Measured memory_bytes: 4836
import java.util.*;
public class Main {
	Scanner sc;
	long N;

	public Main() {
		sc = new Scanner(System.in);
	}
	
	private void calc() {
		N = sc.nextLong();
		
		System.out.println( N*(N-1)/2 );
		System.out.flush();
	}

	public static void main(String[] args) {
		new Main().calc();
	}

}

Measured memory_bytes: 23764
L,R = map(int, input().split())

ANS = 2020
if R - L <= 2019:
  for i in range(L,R+1):
    for j in range(i+1,R+1):
      #if ANS != min(ANS, (i * j) % 2019):
      #  print(i,j)
      ANS = min(ANS, (i * j) % 2019)
        
else:
  ANS = 0
print(ANS)

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong a, b;

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

    vector<llong> s(b, a);
    vector<llong> t(a, b);

    if (s < t) {
        for (auto v:s) cout << v;
    }
    else {
        for (auto v:t) cout << v;
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
package main

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

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

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var n int
	fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	x, _ := strconv.Atoi(sc.Text())
	minv := x
	ans := -(1 << 31)
	for i := 1; i < n; i++ {
		sc.Scan()
		x, _ = strconv.Atoi(sc.Text())
		ans = max(ans, x-minv)
		minv = min(minv, x)
	}
	fmt.Println(ans)
}



Measured memory_bytes: 4152
// D - Candidates of No Shortest Paths
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

// void vprn(vector<int> &v){ for(int i=0;i<v.size();i++) cout<<v[i]<<(i<v.size()-1?",\t":"\n"); }
// void vvprn(vector<vector<int>> &vv){ for(auto v:vv) vprn(v);cout<<"----\n"; }

#define INF (INT_MAX/2)

int in(){int x;scanf("%d",&x);return x;}

int main(){
	int N=in(), M=in();

	vi a(M), b(M), c(M);
	for(int e=0; e<M; e++){ a[e]=in()-1; b[e]=in()-1; c[e]=in(); }

	vvi dist(N,vi(N, INF));//dist[from][to] from->to: cost of shortest path
	for(int v=0; v<N; v++) dist[v][v] = 0;
	// vvprn(dist);//

	for(int e=0; e<M; e++){//set cost of edge
		dist[a[e]][b[e]] = min(dist[a[e]][b[e]], c[e]);
		dist[b[e]][a[e]] = min(dist[b[e]][a[e]], c[e]);
	}
	// vvprn(dist);//

	// Warshall Floyd (set cost of shortest path)
	for(int r=0; r<N; r++)//relay point
		for(int s=0; s<N; s++)//start point
			for(int t=0; t<N; t++)//terminal point
				dist[s][t] = min(dist[s][t], dist[s][r] + dist[r][t]);
	// vvprn(dist);//

	int ans = 0;
	for(int e=0; e<M; e++) if(dist[a[e]][b[e]] < c[e]) ans++;
	cout<< ans <<endl;
}

Measured memory_bytes: 384
def main():
    MOD = 10**9 + 7
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
   
    a_sum = sum(a)
    
    for i in range(n-1):
        a_sum -= a[i]
        ans += a[i] * a_sum
        ans %= MOD
    print(ans)
        
        
if __name__ == '__main__':
    main()

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

struct Pos{
	int x, y, z;
	Pos(int x, int y, int z) : x(x), y(y), z(z){}
};

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

int H, N;
vector<vector<Pos>> drops;

bool find(Pos p, const vector<Pos>& blocks) {
	for(auto q : blocks) {
		if (p.x == q.x && p.y == q.y && p.z == q.z) {
			return true;
		}
	}
	return false;
}

int fall(vector<Pos>& blocks) {
	int del = 0;

	for(int h = 0; h <= H + N * 2; ++h) {
		bool filled = true;
		for(int i = 0; i < 4; ++i) {
			int x = i & 1, y = i >> 1;
			Pos p(x, y, h);
			if (!find(p, blocks)) filled = false;
		}

		if (filled) {
			++del;
			vector<Pos> nblocks;
			for(auto p : blocks) {
				if (p.z == h) continue;
				if (p.z > h) --p.z;
				nblocks.push_back(p); 
			}
			blocks = nblocks;
			--h;
		}
	}
	return del;
}

int rec(int idx, const vector<Pos>& blocks) {
	if (idx == N) return 0;

	int ret = 0;
	for(int i = 0; i < 9; ++i) {
		auto d = drops[idx];
		bool valid = true;
		for(auto& p : d) {
			p.x += dx[i];
			p.y += dy[i];
			p.z += H + N * 2;
			if (p.x < 0 || p.x >= 2 || p.y < 0 || p.y >= 2) {
				valid = false;
			}
		}
		if (!valid) continue;

		while (true) {
			bool stop = false;
			for(auto p : d) {
				--p.z;
				if (p.z < 0 || find(p, blocks)) stop = true;
			}
			if (stop) break;
			for(auto& p : d) --p.z;
		}

		auto b = blocks;
		for(auto p : d) b.push_back(p);

		int del = fall(b);
		ret = max(ret, del + rec(idx + 1, b));
	}
	return ret;
}

bool solve() {
	cin >> H >> N;
	if (H == 0) return false;

	vector<Pos> blocks;
	for(int z = 0; z < H; ++z) {
		for(int x = 0; x < 2; ++x) {
			for(int y = 0; y < 2; ++y) {
				char c;
				cin >> c;
				if (c == '#') {
					blocks.emplace_back(x, y, z);
				}
			}
		}
	}

	drops.clear();
	drops.resize(N);
	for(auto& d : drops) {
		for(int z = 0; z < 2; ++z) {
			for(int x = 0; x < 2; ++x) {
				for(int y = 0; y < 2; ++y) {
					char c;
					cin >> c;
					if (c == '#') {
						d.emplace_back(x, y, z);
					}
				}
			}
		}
	}

	cout << rec(0, blocks) << endl;
	return true;
}

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



Measured memory_bytes: 3112
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
double Pi = 3.1415926535897932384626;
 
vector<ll> G1[500005];
vector<ll> G2[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
 
 
ll mod = 1000000007;
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

 
//ll fact[800005],rfact[800005];
/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[800000] = rui(fact[800000],mod - 2);
    for(ll i=800000; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,ans,a,b,c,e,g,h,w,i,j,k,q;
vector <ll> table[5000];
ll x[500005],y[500005];
char s[500005][15];
ll push_num;

int main(){
    cin >> n;
    for(i=0;i<n;i++){
        cin >> s[i];
        num = 0;
        for(j=0;j<10;j++){
            x[j] = (s[i][j] - 'a');
        }
        sort(x,x+10);
        num = 0;
        for(j=0;j<10;j++){
            num *= 26;
            num += x[j];
        }
        y[i] = num;
    }
    sort(y,y+n);
    ll stock = 0;
    for(i=0;i<n;i++){
        //p(y[i]);
    }
    for(i=0;i<n-1;i++){
        if(y[i] == y[i+1]){
            stock++;
        }else{
            ans += (stock * stock + stock) / 2;
            stock = 0;
        }
    }
    ans += (stock * stock + stock) / 2;
    p(ans);
    
    return 0;
}












Measured memory_bytes: 30208
#include <iostream>

int main() {
  long long N, K;
  std::cin >> N >> K;

  // N %= K;
  // int a = (N > K ? N - K : K - N);
  // if (N > a) {
  //   std::cout << a << '\n';
  // } else {
  //   std::cout << N << '\n';
  // }

  long long t = N % K;
  if (t < K - t) {
    std::cout << t << '\n';
  } else {
    std::cout << K - t << '\n';
  }

  return 0;
}


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

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

int main()
{
	string s;
	cin >> s;

	int add = 0;
	if (s[0] == 'o') add += 100;
	if (s[1] == 'o') add += 100;
	if (s[2] == 'o') add += 100;

	cout << 700 + add << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def read():
    H, W = map(int, input().strip().split())
    A = []
    for i in range(H):
        a = list(input().strip())
        A.append(a)
    return H, W, A


def solve(H, W, A):
    B = [["#" for j in range(W+2)] for i in range(H+2)]
    for i in range(H):
        for j in range(W):
            B[i+1][j+1] = A[i][j]
    for i in range(H+2):
        print("".join(B[i]))


if __name__ == '__main__':
    inputs = read()
    solve(*inputs)


Measured memory_bytes: 9224
#include <bits/stdc++.h>  
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- "
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x)               cout << x << "\n" ; 
#define MOD                100000007
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             (x).begin(),(x).end() 
/* 
  date | time : 3/22/2020 9:57:02 AM 
*/    
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
const int N = 2e5+7;
bool ok(string S){
	// cout << S << ' ' ; 
	int N = S.size();
	int i = 0 ; 
	while( i < N/2){
		if(S[i] != S[N-i-1])
			return false ;
		i++;  
	}
	return true ; 		 
}  
int tests(){ 
	string s ;
	cin >> s ;
	int Z = s.size() ; 
	if(ok(s) && ok(s.substr(0,Z/2)) && ok(s.substr(Z/2+1,Z/2)))
		return cout << "Yes\n",0;
	cout << "No\n" ; 
	return 0; 
} 
int main(){
    I__O ;          
    int cases = 1 ; 
    // cin >> cases ; 
    for(int i = 1 ; i <= cases ; i++ ){
      // cout << "Case #" << i << ": " ;  	
      tests(); 
    }
    return 0 ; 
}


Measured memory_bytes: 256
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_2-C: Stable Sort

#include <algorithm>
#include <iostream>

struct Card {
  char suit;
  unsigned int rank;
  Card() = default;
  Card(const Card&) = default;
  Card& operator=(const Card&) = default;
  bool operator!=(const Card& rhs) const { return rank != rhs.rank || suit != rhs.suit; }
  bool operator<(const Card& rhs) const { return rank < rhs.rank; }
};

std::ostream& operator<<(std::ostream& os, const Card& card)
{
  return os << card.suit << card.rank;
}

std::istream& operator>>(std::istream& is, Card& card)
{
  return is >> card.suit >> card.rank;
}

static void print_cards(const Card cards[], const unsigned int n)
{
  const char* sep = "";
  for (auto i = 0u; i < n; ++i) {
    std::cout << sep << cards[i];
    sep = " ";
  }
  std::cout << std::endl;
}

static void copy_cards(Card dst[], const Card src[], const unsigned int n)
{
  for (auto i = 0u; i < n; ++i) {
    dst[i] = src[i];
  }
}

static bool is_equal_cards(const Card cards1[], const Card cards2[], const unsigned int n)
{
  for (auto i = 0u; i < n; ++i) {
    if (cards1[i] != cards2[i]) {
      return false;
    }
  }
  return true;
}

static void bubble_sort(Card cards[], const unsigned int n)
{
  for (auto j = 0u; j < n-1; ++j) {
    for (auto i = n-1; i > j; --i) {
      if (cards[i] < cards[i-1]) {
        std::swap(cards[i], cards[i-1]);
      }
    }
  }
}

static void selection_sort(Card cards[], const unsigned int n)
{
  for (auto i = 0u; i < n-1; ++i) {
    auto min_j = i;
    for (auto j = i+1; j < n; ++j) {
      if (cards[j] < cards[min_j]) {
        min_j = j;
      }
    }
    if (i != min_j) {
      std::swap(cards[i], cards[min_j]);
    }
  }
}

int main()
{
  unsigned int n;
  std::cin >> n;
  Card cards1[n];
  Card cards2[n];
  for (auto i = 0u; i < n; ++i) {
    std::cin >> cards1[i];
  }
  copy_cards(cards2, cards1, n);
  bubble_sort(cards1, n);
  print_cards(cards1, n);
  std::cout << "Stable" << std::endl; // bubble sort is stable

  selection_sort(cards2, n);
  print_cards(cards2, n);

  if (is_equal_cards(cards1, cards2, n)) {
    std::cout << "Stable" << std::endl;
  } else {
    std::cout << "Not stable" << std::endl;
  }
}

// eof

Measured memory_bytes: 3108
using System;
 
namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			// 入力値をlongに変換して変数に代入
			long h = long.Parse(Console.ReadLine());
 
			long tmp = 1;
 
			// tmp > h になるまでtmpを2乗していく
			// 1, 2, 4, 8 ...
			while (true)
			{
				if (tmp > h) break;
				tmp *= 2;
			}

			// 2^n ≦ H < 2^(n + 1) とすると、
			// このときtmp = 2^(n + 1)になっているはず

			// 答えを出力
			Console.WriteLine(tmp - 1);
		}
 	}
}


Measured memory_bytes: 27528
N, Y = map(int, input().split())


for i in range(N+1):
  for j in range(N+1-i):
    k = N - i - j
    total = 10000 * i + 5000 * j + 1000 * k
    if Y == total:
      print(i, j, k)
      exit()
print(-1, -1, -1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  string s;
  while(cin>>n,n){
    cin>>s;
    int c=1;
    while(n--){
      string ss;
      r(i,s.size()){
        if(s[i]!=s[i+1]){
          char w[100];
          sprintf(w,"%d",c);
          r(df,strlen(w))ss+=w[df];
          ss+=s[i];
          c=1;
        }
        else c++;
      }
      s=ss;
    }
    cout<<s<<endl;
  }
}

Measured memory_bytes: 3392
#include <bits/stdc++.h>
using namespace std;
struct P
{
    //string r;
    int x,y,z;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x>a.x;
//        return z>a.z;
    }
};

vector<P> v[3333];
bitset<4001000> bit;
int a,c,i,b,k,d,n,m,e;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int l[110];
int o[3333];
int dx[10]={0,1,0,-1},dy[10]={1,0,-1,0},dz[10]={0,0,0,0,1,-1};

long long x,y,z,mod=1000000007;
P u[112];
int j[31][11111];

stack<int> s;
queue<int> q;
queue<int> q1;

deque<int> de;
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int,int > p;
//list<int> l;
string r[5];
//char r[333][333];

bool as(P a,P b)
{
    if((a.x/i)!=(b.x/i))
        return (a.x/i)<(b.x/i);
    return a.y<b.y;
}
//queue<P> q;


int main()
{
    scanf("%d",&a);
    bit.set(0);
    for(int t=1;t<=a;t++)
    {
        scanf("%d",&b);
        bit|=(bit<<b);
    }
    n=bit.count()/2+bit.count()%2;
    for(int t=4000000;;t--)
    {
        n-=bit.test(t);
        if(!n)
        {
            printf("%d",t);
            return 0;
        }
    }
}
//157 328


Measured memory_bytes: 1920
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

#define NUM_MAX 50

struct point2d {
    int x;
    int y;
};

struct rect {
    struct point2d bottom;
    struct point2d top;
};

int64_t get_area(struct rect r) {
#ifdef DEBUG
    printf("(%d, %d) (%d, %d)\n", r.bottom.x, r.bottom.y, r.top.x, r.top.y);
#endif
    return (int64_t)(r.top.x-r.bottom.x)*(int64_t)(r.top.y-r.bottom.y);
}

int count_points(struct rect r, struct point2d* ps, int size) {
    int i;
    int count = 0;
    for(i = 0; i < size; i++) {
        struct point2d p = ps[i];
        count += (r.bottom.x <= p.x && p.x <= r.top.x) && (r.bottom.y <= p.y && p.y <= r.top.y);
    }
    return count;
}

struct range {
    int start;
    int end;
};

#define LEN_MAX ((2e+9)+1)
#define AREA_MAX (4e+18)

int asc(const void *a1, const void *a2) {
    return *(int*)a1 - *(int*)a2;
}

int main(void) {
    int num, llimit;
    get_int2(&num, &llimit);
    struct point2d ps[NUM_MAX];

    int i, j;
    for(i = 0; i < num; i++) {
        get_int2(&ps[i].x, &ps[i].y);
    }

    int64_t min_area = AREA_MAX;
    int pos[NUM_MAX];
    int k;
    for(i = 0; i < num; i++) {
        struct point2d p1 = ps[i];
        for(j = i+1; j < num; j++) {
            int64_t res1 = LEN_MAX;
            int64_t res2 = LEN_MAX;
            int pidx = 0;
            struct point2d p2 = ps[j];
            struct range rx = (struct range){
                min(p1.x, p2.x),
                max(p1.x, p2.x),
            };
            for(k = 0; k < num; k++) {
                if(rx.start <= ps[k].x && ps[k].x <= rx.end) pos[pidx++] = ps[k].y;
            }
            qsort(pos, pidx, sizeof(int), asc);
            for(k = llimit-1; k < pidx; k++) {
                res1 = min(res1, pos[k]-pos[k-(llimit-1)]);
            }
            if(res1 != LEN_MAX) min_area = min(min_area, res1*(rx.end-rx.start));

            pidx = 0;
            struct range ry = (struct range){
                min(p1.y, p2.y),
                max(p1.y, p2.y),
            };
            for(k = 0; k < num; k++) {
                if(ry.start <= ps[k].y && ps[k].y <= ry.end) pos[pidx++] = ps[k].x;
            }
            qsort(pos, pidx, sizeof(int), asc);
            for(k = llimit-1; k < pidx; k++) {
                res2 = min(res2, pos[k]-pos[k-(llimit-1)]);
            }
            if(res2 != LEN_MAX) min_area = min(min_area, res2*(ry.end-ry.start));
        }
    }
    printf("%lld\n", min_area);
    return 0;
}

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

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    long long int N,A,B;
    long long int ans;
    cin >> N >> A >> B;
    if((B-A)%2 == 0){
        ans = (B-A)/2;
    }else{
        ans = min((A-1)+1+(B-A-1)/2,(N-B)+1+(B-A-1)/2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	int t;
	t=1;
	while(t--)
	{
		int n;
		cin>>n;
		ll arr[n];
		for(int i=0;i<n;i++)
		{
			cin>>arr[i];
		}
		ll cost=1000;
		ll s=0;
		for(int i=0;i<n-1;i++)
		{
			if(arr[i]<arr[i+1] && cost)
			{
				s=s+(cost/arr[i]);
				ll i1=cost/arr[i];
				cost=cost-(i1*arr[i]);
			}
			else if(s && arr[i]>=arr[i+1])
			{
				cost=cost+(s*arr[i]);
				s=0;
			}
		}
		if(s)
		{
			cost=cost+(s*arr[n-1]);
		}
		cout<<max((ll)1000,cost)<<endl;
	}
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int i,j,n,x[101],s=0,s2=0,a,s3=0,s4,b;
  scanf("%d", &n);
  for(i=0;i<n;i++)
  {
    scanf("%d", &x[i]);
    s=s+x[i];
  }
  s4=s;
  s=s/n;
  s4=(s4/n)+1;
  for(i=0;i<n;i++)
  {
    a=x[i]-s;
    b=x[i]-s4;
    s2=s2+pow(a,2);
    s3=s3+pow(b,2);
  }
  if(s2<s3)printf("%d\n", s2);
  else printf("%d\n", s3);
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  double sum=0;
  for(int i=0;i<N;i++){
  double a; string s;
    cin>>a>>s;
    if(s=="JPY")
       sum+=a;
       else
       sum+=a*380000.0;
  }cout<<setprecision(16)<<sum<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)

void chmax(ll& a, ll b) { a = max(a, b); }
void chmin(ll& a, ll b) { a = min(a, b); }


int main() {
    int n,a,b; cin >> n >> a >> b;
    int ans = 0;
    rep(i, n+1) {
        string now = to_string(i);
        int sum = 0;
        rep(j, now.size()) {
            sum += now[j] - '0';
        }
        if(sum >= a && sum <= b) ans += i;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k;
  cin >> n >> k;
  vector<double>a(n);
  for(int i=0;i<n;i++){
    cin >> a[i]; 
  }
  double s=0;
  double u=0;
  for(int j=0;j<k;j++){
    u+=a[j];
  }
  for(int i=0;i<n-k+1;i++){
    if(s<u){
      s=u;
    }
    u+=a[i+k]-a[i];
  }
  cout << fixed << setprecision(10);
  cout << (s+k)/2 << endl;
}

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

int N,M;
int connect[10][10];


int dfs(int v, int bit){
    bit |= (1<<(v-1));
    int count = 0;

    if(bit==(1<<N)-1) return 1;

    for(int i=1;i<=N;i++){
        if(connect[v][i]==1){
            if((bit>>(i-1))&1) continue;
            count += dfs(i, bit);
        }
    }

    return count;
}

int main(void){

    int a,b;

    cin>>N>>M;

    for(int i=0;i<M;i++){
        cin>>a>>b;
        connect[a][b]=1;
        connect[b][a]=1;
    }

    
    cout<<dfs(1,0)<<endl;



    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
 
min = min(A, B, C, D, E)
 
ans = 4 + int(N/min)
if N % min != 0:
    ans = ans + 1
print(ans)

Measured memory_bytes: 3064
n=int(input())
b=list(map(int,input().split()))
ans=0
w=max(b)
a=[0]*(w+1)
for i in b:
  x=i
  while x<=w:
    a[x]+=1
    x+=i
for i in b:
  if a[i]==1:
    ans+=1
print(ans)

Measured memory_bytes: 32032
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=(s);i<(t);++i)
#define per(i,s,t) for(int i=((t)-1);i>=s;--i)
#define repb(i,s,t) for(int i=(s);i<=(t);++i)
#define lepb(i,s,t) for(int i=(s);i>=(t);--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
#define mst(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define ft front()
#define bk back()
#define pft pop_front
#define pbk pop_back
#define discrete(x) sort(all(x));x.erase(unique(all(x)), x.end());

#define dd(x) DD(#x, (x))
#define de(x) DE(#x, (x))
template <class T> inline void DD(string s, const T &x) {cout << s << '=' << x << ' ';}
template <class T> inline void DE(string s, const T &x) {cout << s << '=' << x << '\n';}

typedef long long ll;
typedef double db;
typedef pair<ll,int> pii;
typedef pair<db,db> pdd;
typedef vector<vector<db> > mat;
typedef complex<double> cpd; //*counter rotate
typedef db(func)(db);
typedef int(isok)(db);

const int inf= 0x3f3f3f3f;
const ll infl= 4557430888798830399ll;
const db infd= 1. / 0.;
const db eps = 1e-10;
const db pi  = acos(-1.);
const ll mod = 998244353;

template<class T>inline int sgn(T x){return (x>eps)-(x<-eps);}
template<class T>inline db sq(T x){return x*x;}
template<class T>inline bool Max(T&x,T y){if(x<y){x=y;return true;}return false;}
template<class T>inline bool Min(T&x,T y){if(y<x){x=y;return true;}return false;}

#define ls n<<1,l,(l+r)/2
#define rs n<<1|1,(l+r)/2+1,r

const int maxn = 105;

int main()
{
 	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 	int n,a;vector<int> v;ll g;
 	cin>>n;
 	rep(i,0,n){cin>>a;v.pb(a);}
 	sort(all(v));
 	g=1;rep(i,0,n)(g*=__gcd(v[i],i))%=mod;
 	cout<<g<<endl;

}

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    ll n; cin >> n;
    vl a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    out(a[n-1] - a[0]);
}

Measured memory_bytes: 3656
dataset = []
while True:
    x = int(input())
    if not(x >= 1 and x <= 10000):
        break
    elif len(dataset) >= 10000:
        break
    elif x is not 0:
        dataset.append(x)
    else:
        break

for index, number in enumerate(dataset):
    print("Case {0}: {1}".format(index+1, str(number)))

Measured memory_bytes: 8064