akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

void print_frame(int h, int w);

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

  scanf("%d %d", &H, &W);
  while( H!=0 || W!=0 ){
    print_frame(H,W);
    printf("\n");
    scanf("%d %d", &H, &W);
  }
  return(0);
}

void print_frame(int h, int w){
  int i,j;
  for(i=0; i<h; i++){
    if(i==0 || i==(h-1))
      for(j=0; j<w; j++){
	printf("#");
      }
    else
      for(j=0; j<w; j++){
	(j==0 || j==(w-1)) ? printf("#") : printf(".");
      }
    printf("\n");
  }
}


Measured memory_bytes: 2096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
  static InputReader in;
  static PrintWriter out;
  
  static class Solution {
    void solve() throws IOException {
      double[][] P = new double[2][2];
      P[0][0] = in.nextDouble();
      P[0][1] = in.nextDouble();
      P[1][0] = in.nextDouble();
      P[1][1] = in.nextDouble();
      
      double distance = Math.sqrt(Math.pow(P[0][0] - P[1][0], 2) + Math.pow(P[0][1] - P[1][1], 2));
      out.printf("%.4f\n", distance);
//      End solve()
    }
//    End Solution
}


  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}


  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }

    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }

    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken());
    }

    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }

    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }

  }

}

Measured memory_bytes: 24688
n = [x for x in input()]
op_cnt = len(n) - 1
sum = int(0)

for index in range(2 ** op_cnt):
  op = [""] * op_cnt
  for index2 in range(op_cnt):
    if ((index >> index2) & 1):
      op[op_cnt - 1 - index2] = "+"
  
  formula = [None]*(len(n)+len(op))
  formula[::2] = n
  formula[1::2] = op
  
  sum += eval("".join(formula))

print(sum)

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
	int N;
	cin >> N;
	vector<vector<int>> A(N, vector<int>());
	for(int i = 1; i < N; i++){
      	int a;
      	cin >> a;
    	A[a-1].push_back(i);
    }
	for(int i = 0; i < N; i++){
    	cout << A[i].size() << endl;
    }
}

Measured memory_bytes: 13996
#include <iostream>
#include <queue>
#include <string>
#include <map>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <vector>
#include <stack>
#include <algorithm>
#include <string.h>
#include <set>
#include <cstdlib>
#include <iostream>
#include <bits/stdc++.h>
#define sz(x)       x.size()
#define pii         pair<int,int> 
#define ll          long long int 
#define sl(n)       scanf("%lld",&n)
#define s(n)        scanf("%d",&n)
#define f(i,n)      for(int i=0;i<n;++i)
#define fo(i,n)     for(int i=1;i<=n;++i)
#define fnm(n,m)    for(ll i=n;i<m+1;++i)
#define pb          push_back
#define pf          printf
#define F           first
#define S           second
#define srt(v)      sort(v.begin(),v.end());
#define srtc(v,cmp) sort(v.begin(),v.end(),cmp);
#define srta(v,n)   sort(v,v+n);
const ll            LL_INF=0x3f3f3f3f3f3f;
const ll            MOD=1073741824;



using namespace std;


int T;
int n,m,k;
int inp;
vector<pair<int,vector<int>>>v(15);
int arr[15]={0};
bool comp(const pair<int,vector<int>> &a, const pair<int,vector<int>> &b){
    return a.F<b.F;
}

int mn=1200005;

void gen(int pos,int sm){
    // pf("here\n");
    bool val=true;
    f(i,m){
        if(arr[i]<k){
            val=false;
            break;
        }
    }
    if(val)mn=min(mn,sm);
    if(pos>=n)return;
    gen(pos+1,sm);
    // pf("pos: %d, v[pos].F: %d\n",pos,v[pos].F);
    f(i,m)arr[i]+=v[pos].S[i];
    gen(pos+1,sm+v[pos].F);
    f(i,m)arr[i]-=v[pos].S[i];
}

void solve(){
    s(n);
    s(m);
    s(k);
    f(i,n){
        s(inp);
        v[i].F=inp;
        f(j,m){
            s(inp);
            v[i].S.pb(inp);
        }
    }
    // srtc(v,comp);
    // pf("v[0].F: %d\n\n",v[0].F);
    gen(0,0);
    if(mn!=1200005)pf("%d",mn);
    else pf("-1");
}


int main(){
    // pf("\t\t\t***************************************************************************\n\n");
    // pf("\t\t\t***************************************************************************\n\n");
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // s(T);
    T=1;
    f(i,T)solve();
    pf("\n");

    return 0;
} 

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i = 0; i < n; i++)
    cin >> d.at(i);
  sort(d.begin(), d.end());
  cout << d.at(n/2) - d.at(n/2-1) << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<map>
using namespace std;
typedef long long int LL;

int main(){
    int n;
    long long A;
    //long long sum[10004]={0};
    map<LL,LL>mp;
    mp[0]++;
    long long  m;
    cin>>n>>m;
    LL count=0;
    LL temp=0;
   
    
    for(int j=1; j<=n; j++)
    {
        cin>>A;
        temp=temp+A;
         temp=temp%m;
        count+=mp[temp];
        mp[temp]++;
    }
    
    cout<<count;
    return 0;
    
}


Measured memory_bytes: 4224
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long

using namespace std;

vector<bool> ok(10, true);

bool check(int n) {
    for (; n > 0; n /= 10) {
	int a = n % 10;
	if (!ok[a]) return false;
    }
    return true;
}

signed main() {
    int N, K;
    cin >> N >> K;

    for (int i = 0; i < K; i++) {
	int D;
	cin >> D;
	ok[D] = false;
    }

    while (!check(N)) N++;

    cout << N << endl;

    return 0;
}


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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  string s;cin>>s;
  int n = sz(s);

  int cnt = 0;
  rep(i, n){
    if (s[i]=='p') {
      cnt++;
    }
  }

  cout << n/2 - cnt << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


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

#define COUT(x) cout << #x << " = " << (x) << ", "
typedef long long ll;
const int MOD = 1000000007;

int N;
struct node{
  int num;
  int rank;
  int amt;
  struct node* ptr;
};
vector<node> G;

void init(){
  for(int i = 0; i < N; i++){
    G[i].num = i;
    G[i].ptr = NULL;
    G[i].rank = 1;
    G[i].amt = 1;
  }
}

int idx(int x){
  if(G[x].ptr == NULL){
    return x;
  }
  int tmp = idx(G[x].ptr->num);
  G[x].ptr = &G[tmp];
  return tmp;
}

int amount(int x){
  return G[idx(x)].amt;
}

void unite(int x, int y){
  if(idx(x) == idx(y)){
    return;
  }
  if(G[idx(x)].rank < G[idx(y)].rank){
    int a = amount(x);
    int b = amount(y);
    G[idx(x)].ptr = &G[idx(y)];
    G[idx(y)].amt = a + b;
  }else if(G[idx(x)].rank == G[idx(y)].rank){
    int a = amount(x);
    int b = amount(y);
    G[idx(x)].ptr = &G[idx(y)];
    G[idx(x)].amt = a + b;
    G[idx(y)].rank++;
  }else{
    int a = amount(x);
    int b = amount(y);
    G[idx(y)].ptr = &G[idx(x)];
    G[idx(x)].amt = a + b;
  }
  // cout << "unite" << x << " " << y << " " << idx(x) << " " << idx(y) << endl;
  return;
}

int main(){
  int M,K;
  cin >> N >> M >> K;
  G.resize(N);
  vector<int> F[N];
  init();
  for(int i = 0; i < M; i++){
    int a,b;
    cin >> a >> b;
    a--; b--;
    F[a].push_back(b);
    F[b].push_back(a);
    unite(a, b);
  }
  vector<int> B[N];
  for(int i = 0; i < K; i++){
    int c,d;
    cin >> c >> d;
    c--; d--;
    B[c].push_back(d);
    B[d].push_back(c);
  }
  for(int i = 0; i < N; i++){
    int tmp = amount(i);
    tmp -= F[i].size();
    for(auto x: B[i]){
      if(idx(x) == idx(i)){
	tmp--;
      }
    }
    tmp--;
    cout << tmp << " ";
  }
  cout << endl;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

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

	int ans=0;
	for(int i=0; i<n/2; i++){
		if(s[i]!=s[n-1-i]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
    // Your code here!
    int N, A[3][3], b[10];
    bool appear[3][3];
    for(int i = 0; i < 3; i++) {
 for(int j = 0; j < 3; j++) cin >> A[i][j];
 }
 cin >> N;
 for(int i = 0; i < N; i++) cin >> b[i];
     for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            appear[i][j] = false;
                for(int k = 0; k < N; k++) {
                    if(A[i][j] == b[k]) appear[i][j] = true;
                }
        }
    }
    string ANS = "No";
    for(int i = 0; i < 3; i++) {
        if(appear[i][0] and appear[i][1] and appear[i][2]) ANS = "Yes";
    }
    for(int i = 0; i < 3; i++) {
        if(appear[0][i] and appear[1][i] and appear[2][i]) ANS = "Yes";
    }
    if(appear[0][0] and appear[1][1] and appear[2][2]) ANS = "Yes";
    if(appear[0][2] and appear[1][1] and appear[2][0]) ANS = "Yes";
    cout << ANS << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long a[100000+10];
int main()
{
	long long n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	long long sum=0,num=0;
	for(int i=1;i<n;i++)
	{
		if(a[i]<=a[i-1])
		{
			sum++;
		}
		else
		{
			sum=0;
		}
		num=max(num,sum);
	}
	cout<<num<<endl;
}

Measured memory_bytes: 1024
N,A,B = map(int,input().split())
if A > B:
    print(0)
    exit()
if A == B:
    print(1)
    exit()
if N == 1:
    print(0)
    exit()
mx = B*(N-1) + A
mn = A*(N-1) + B
print(mx - mn + 1)


Measured memory_bytes: 3060
#include<cstdio>

#define ran 10111

int n;
int a[ran], b[ran];

int main() {
	scanf("%d", &n);
	for(int i=1;i<=n;i++) scanf("%d", &a[i]);
	for(int i=1;i<=n;i++) scanf("%d", &b[i]);
	
	long long todo = 0LL, offer = 0LL;
	for(int i=1;i<=n;i++) {
		if (a[i] > b[i]) todo += a[i]-b[i];
		else offer += (b[i]-a[i])/2;
	}
	puts(todo <= offer ? "Yes" : "No");
	
	return 0;
}

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

#define rep(i,n)  for(int i = 0; i < (int)(n); i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int x; std::cin >> x;
  if ( x == 0 ) std::cout << 1 << std::endl;
  else std::cout << 0 << std::endl;
  return 0;
}



Measured memory_bytes: 3648
import java.util.Scanner;

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

        int[] result, n, x;
        result = new int[300];
        n = new int[300];
        x = new int[300];
        int i, j, k;
        int cnt = 0;

        while(true){
            n[cnt] = sc.nextInt();
            x[cnt] = sc.nextInt();
            if(n[cnt] == 0 && x[cnt] == 0)
                break;
            result[cnt] = 0;
            for(i=1; i<n[cnt]-1; i++){
                for(j=i+1; j<n[cnt]; j++){
                    for(k=j+1; k<=n[cnt]; k++){
                        if(i + j + k == x[cnt])
                            result[cnt]++;
                    }
                }
            }
            cnt++;
        }
        for(i=0;i<cnt; i++){
                System.out.println(result[i]);
            }
        sc.close();
    }
}


Measured memory_bytes: 26960
#include<iostream>
#include<set>
using namespace std;
int N;
main()
{
	cin>>N;
	multiset<int>S;
	for(int i=0;i<N;i++)S.insert(-1);
	int ans=0;
	for(int i=0;i<N;i++)
	{
		int A;cin>>A;
		multiset<int>::iterator it=S.lower_bound(A);
		it--;
		if(*it==-1)ans++;
		S.erase(it);
		S.insert(A);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 6784
function main(input) {
    const args = input.split(' ');
    var A = parseInt(args[0], 10);
    var B = parseInt(args[1], 10);

    if(B%A === 0) {
        console.log(A+B);
    } else {
        console.log(B-A)
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 22080
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
xy = [LIST() for _ in range(N)]
ans = INF
xy.sort()
for l in range(N-K+1):  # 長方形に含まれる最も左の点
    for r in range(l+K, N+1):  # 長方形に含まれる最も右の点
        y = sorted(xy[l:r], key = lambda x: x[1])  # lからrの中でのyのとりうる値をソート
        for i in range(r-l-K+1):
            sq = (xy[r-1][0] - xy[l][0]) * (y[i+K-1][1] - y[i][1])  # 下からKこ選んだときの面積
            ans = min(ans, sq)
print(ans)


Measured memory_bytes: 5148
import Data.Function
import System.IO
import Control.Monad
import Control.Applicative
main = do
     fix $ \loop -> do
         eof <- isEOF
         unless eof $ do
           a:b:_ <- map read . words <$> getLine :: IO [Int]
           putStrLn $ show (gcd a b) ++ " " ++ show (lcm a b)
           loop

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

int main() {
string S ;
    cin >> S ;
  int count=7 ;
  if (S[0]=='o'){
  count ++ ;
  }
   if (S[1]=='o'){
  count ++ ;
  }
   if (S[2]=='o'){
  count ++ ;
  }
  count *=100 ;
  cout << count << endl;  
}


Measured memory_bytes: 256
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():

    N=int(input())
    H=list(map(int,input().split()))
    def main():
        if N == 1:
            return 'Yes'
        maxval=0
        for i in range(N):
            if maxval-2>=H[i]:
                return 'No'
            else:
                maxval=max(maxval,H[i])
        return 'Yes'
    print(main())


resolve()

Measured memory_bytes: 14252
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var aa = ToIntArray(input.ReadLine(), n);

        var min = int.MaxValue;
        var minp = 0;
        var sum = 0L;
        var minus = 0;

        for(int i=0; i<n; i++) {
            var x = Math.Abs(aa[i]);
            if (x < min) {
                min = x;
                minp = i;
            }
            sum += x;

            if (aa[i] < 0) minus++;
        }

        if(minus % 2 == 1) {
            sum -= (min*2);
        }

        return sum;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl =strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}

Measured memory_bytes: 29020
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    vector<vector<int>> a(n, vector<int>(3));
    rep(i, n) rep(j, 3)
    {
        cin >> a[i][j];
    }

    vector<vector<int>> dp(n, vector<int>(3));
    rep(i, n)
    {
        rep(j, 3)
        {
            if (i == 0) {
                dp[i][j] = a[i][j];
            } else {
                dp[i][j] = 0;
                rep(k, 3)
                {
                    if (k != j) {
                        dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);
                    }
                }
            }
        }
    }
    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

const int MAX_N = 110000;

int dp[MAX_N];

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

    rep(i, MAX_N) dp[i] = N;
    dp[0] = 0;

    for (int n = 0; n <= N; n++) {
        for (int pow6 = 1; pow6 + n <= N; pow6 *= 6) {
            chmin(dp[n + pow6], dp[n] + 1);
        }

        for (int pow9 = 1; pow9 + n <= N; pow9 *= 9) {
            chmin(dp[n + pow9], dp[n] + 1);
        }
    }

    cout << dp[N] << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

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

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


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

LL mod = 1000000007;

int main() {
	LL N, x;
	cin >> N >> x;
	vector<LL> a(100001);
	REP(i, N) {
		cin >> a[i];

	}
	LL sum = 0;
	FOR(i, 1, N) {
		if (a[i] + a[i - 1] > x) {
			if (a[i - 1] > x) {
				sum += a[i] + (a[i - 1] - x);
				a[i] = 0;
			}
			else {
				sum += a[i]-(x-a[i-1]);
				a[i] = x - a[i - 1];
			}
		}
	}
	cout << sum << endl;
}

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

#define pb push_back
#define ff first
#define ss second

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

int a, b, c;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> a >> b >> c;
	cout << a* b / 2;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    vector<int> h(n);
    rep(i, n)
    {
        cin >> h[i];
    }
    vector<int> dp(n);
    rep(i, n)
    {
        if (i == 0) {
            dp[i] = 0;
        } else {
            dp[i] = numeric_limits<int>::max();
            rep(j, k)
            {
                int l = i - 1 - j;
                if (l >= 0) {
                    dp[i] = min(dp[i], dp[l] + abs(h[l] - h[i]));
                }
            }
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>

#include <chrono>

#define INF 1e9
#define nmax 5000010
#define fst first
#define snd second
#define pb push_back
#define SZ(x) ((int)(x.size()))

#define MOD 1000000007

#define MOD1 998244353
#define MOD2 666013
#define P1 255
#define P2 2059

using namespace std;
using namespace std::chrono;

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

int n;

int main()
{
    scanf("%d", &n);

    double d = n / 3.0;

    printf("%.9f", d * d * d);

    // IMPORTANT!!!!!
    // Are you missing something????
    // check limits, int or ll

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int n, x;
  for ( ; ; ) {
    cin >> n >> x;
    if ((n == 0) && (x == 0)) break;
    int result = 0;
    for (int i = 1; i <= n - 2; ++i) {
      if (x < 3 * i + 3) break;
      for (int j = i + 1; i <= n - 1; ++j) {
        if (x < i + (2 * j + 1)) break;
        if (x <= i + j + n) ++result;
      }
    }
    cout << result << endl;
  }
  return 0;
} 



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

using namespace std;

int main(){
  int  X, N;
  cin >> X >> N;
  int p[N];
  for(int i=0;i<N;i++){
    cin >> p[i];
  }
  int c, d, e, f;
  for(int i=0;true;i++){
    c = X-i;
    d = X+i;
    e = 0;
    f = 0;
    for(int j=0;j<N;j++){
      if(c == p[j]){
        e = 1;
      }
      if(d == p[j]){
        f = 1;
      }
    }
    if(e != 1){
      cout << c;
      exit(0);
    }else if(f != 1){
      cout << d;
      exit(0);
    }
  }
  return 0;
}


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

int main() {
    string S;
    cin >> S;
    int N = S.size();
    int count[26] = {0};
    for (int i = 0; i < N; i++) {
        count[S[i] - 'a']++;
    }
    for (int i = 0; i < 26; i++) {
        if (count[i] == 0) {
            printf("%c\n", 'a' + i);
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 3740
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      
		int L = sc.nextInt();
		int R = sc.nextInt();
		int d = sc.nextInt();
      	int count = 0;
		
      	for(int i=L; L <= i && i <= R; i ++){
      		if(i%d == 0){
            	count ++;
            }
      	}
      	System.out.println(count);
    }
}

Measured memory_bytes: 35604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>

using namespace std;


int main()
{
	int N;
	vector<long long> Xs;
	vector<long long> Ys;
	vector<int> DXs;
	vector<int> DYs;

	cin >> N;	

	long long ymax = -2e9;
	long long xmax = -2e9;
	long long ymin = 2e9;
	long long xmin = 2e9;

	long long x, y;
	char c;
	for (int ni = 0; ni < N; ni++){
		cin >> x >> y >> c;
		x *= 2;
		y *= 2;
		Xs.push_back(x);
		Ys.push_back(y);
		if (c == 'U'){
			DXs.push_back(0);
			DYs.push_back(1);
		}else if(c == 'D'){
			DXs.push_back(0);
			DYs.push_back(-1);
		}else if(c == 'R'){
			DXs.push_back(1);
			DYs.push_back(0);
		}else if(c == 'L'){
			DXs.push_back(-1);
			DYs.push_back(0);
		}
		ymax = max(ymax, y);
		xmax = max(xmax, x);
		ymin = min(ymin, y);
		xmin = min(xmin, x);
	}

	long long A = (ymax - ymin) * (xmax - xmin);
	long long minA = A;

	int cnt = 0;
	long long w,h;
	h = (ymax - ymin);
	w = (xmax - xmin);

	while(cnt < 1e3){
		ymax = -2e9;
		xmax = -2e9;
		ymin = 2e9;
		xmin = 2e9;
		for(int ni = 0; ni < N; ni++){
			Xs[ni] += DXs[ni];
			Ys[ni] += DYs[ni];
			ymax = max(ymax, Ys[ni]);
			xmax = max(xmax, Xs[ni]);
			ymin = min(ymin, Ys[ni]);
			xmin = min(xmin, Xs[ni]);
		}
		A = (ymax - ymin) * (xmax - xmin);
		if (A < minA) {
			minA = A;
		}

		if ( (ymax - ymin) >= h && (xmax - xmin) >= w){
			break;
		}

		h = (ymax - ymin);
		w = (xmax - xmin);

	}

	printf("%f",(double)(minA/4.0));

	return 0;
}



Measured memory_bytes: 3284
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll fct[M],ar[M];

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

	ll n,k,i,v,ans = 0;

	cin >> n >> k;

	fct[0] = 1;
	for(i=1;i<=n;++i)
		fct[i] = (fct[i-1]*i)%md;

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

	sort(ar+1,ar+1+n);

	for(i=1;i<=n-k+1;++i)
	{
		v = (pwr(fct[k-1],md-2,md)*pwr(fct[n-i-k+1],md-2,md))%md;
		v = (v*fct[n-i])%md;
		v = (v*((md-ar[i])%md))%md;
		ans = (ans + v)%md;
	}

	for(i=1;i<=(n+1)/2;++i)
		swap(ar[i],ar[n-i+1]);

	for(i=1;i<=n-k+1;++i)
	{
		v = (pwr(fct[k-1],md-2,md)*pwr(fct[n-i-k+1],md-2,md))%md;
		v = (v*fct[n-i])%md;
		v = (v*((md+ar[i])%md))%md;
		ans = (ans + v)%md;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3072
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.nextLine().split("");
        int res1=0;
        int res2=0;
        for(int i=0;i<s.length;i++){
            if(i%2==0){
                if(s[i].equals("0"))res1++;
            }
            else{
                if(s[i].equals("1"))res1++;
            }
        }
        for(int i=0;i<s.length;i++){
            if(i%2==1){
                if(s[i].equals("0"))res2++;
            }
            else{
                if(s[i].equals("1"))res2++;
            }
        }
        System.out.println(Math.min(res1, res2));
    }
}

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

int main(void){
    double a, b;
    cin >> a >> b;

    if(ceil((a+1)/0.08) <= ceil(b/0.1) | ceil((a)/0.08) >= ceil((b+1)/0.1)){
      cout << -1 << endl;
    } else if (ceil((a)/0.08) >= ceil(b/0.1)){
        cout << ceil(a/0.08) << endl;
    } else {
        cout << ceil(b/0.1) << endl;
    }
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include"math.h"
using namespace std;
#define MOD 1000000007
class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int n, a, b, c;
int *l;
int ans = 100000000;
vector<int> A, B, C;

void check(int deep, int use) {
	if (use == 0) {
		A.push_back(l[deep]);
	}
	else if (use == 1) {
		B.push_back(l[deep]);
	}
	else if (use == 2) {
		C.push_back(l[deep]);
	}
	if (deep != 0) {
		for (int i = 0; i < 4; i++) {			
			check(deep - 1,i);
		}
	}
	else if(deep==0){
		if (!(A.size() == 0 || B.size() == 0 || C.size() == 0)) {
			int temp = 0;
			int mp = -30;
			for (int i = 0; i < A.size(); i++) {
				temp += A[i];
				mp += 10;
			}
			mp += abs(temp - a);
			temp = 0;
			for (int i = 0; i < B.size(); i++) {
				temp += B[i];
				mp += 10;
			}
			mp += abs(temp - b);
			temp = 0;
			for (int i = 0; i < C.size(); i++) {
				temp += C[i];
				mp += 10;
			}
			mp += abs(temp - c);
			if (ans > mp)ans = mp;
		}
	}
	if (use == 0) {
		A.pop_back();
		
	}
	else if (use == 1) {
		B.pop_back();
		
	}
	else if (use == 2) {
		C.pop_back();
		
	}

}

int main() {
	
	cin >> n >> a >> b >> c;
	l = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	for (int i = 0; i < 4; i++) {
		check(n - 1, i);
	}


	cout << ans;






	return 0;
}


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

int main() {
  int N,K,M;
  cin>>N>>K;
  vector<int> high(N);
  for(int i=0;i<N;i++){
    cin>>high.at(i);
  }
  
  vector<int> cost(N);
  cost.at(0)=0;
  cost.at(1)=abs(high.at(1)-high.at(0));
    for(int i=2;i<N;i++){
      M=732800000000000;
      for(int j=1;j<=min(i,K);j++){
        M=min(M,cost.at(i-j)+abs(high.at(i)-high.at(i-j)));
      }
      cost.at(i)=M;
    }
  
  cout<<cost.at(N-1);
    
}


Measured memory_bytes: 1024
#include <stdio.h>
#define FLAG -1
#define MAX 1000000


typedef struct{
  int head;
  int size;
  int data[MAX];
} queue;

void enq(queue *q, int en){
  if(q -> size < MAX){
    q -> data[(q -> head + q -> size) % MAX] = en;
    q -> size++;
  }
  return;
}

void deq(queue *q, int *de){
  if(q -> size > 0){
    *de = q -> data[q -> head];
    q -> head = (q -> head + 1) % MAX;
    q -> size--;
  }
  return;
}

int main(){
  int h, w;
  scanf("%d %d", &h, &w);
  char grd[h][w];
  queue q;
  q.head = 0;
  q.size = 0;
  for(int i = 0; i < MAX; i++){
    q.data[i] = 0;
  }
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      scanf(" %c", &grd[i][j]);
      if(grd[i][j] == '#'){
        enq(&q, i * w + j);
      }
    }
  }
  enq(&q, FLAG);
  int cnt = 0;
  while(q.size > 1){
    int d;
    deq(&q, &d);
    if(d == FLAG){
      cnt++;
      enq(&q, FLAG);
    }else{
      int x = d / w;
      int y = d % w;
      if((x != 0) && (grd[x - 1][y] == '.')){  //上
        grd[x - 1][y] = '#';
        enq(&q, d - w);
      }
      if((x != h - 1) && (grd[x + 1][y] == '.')){  //下
        grd[x + 1][y] = '#';
        enq(&q, d + w);
      }
      if((y != 0) && (grd[x][y - 1] == '.')){  //左
        grd[x][y - 1] = '#';
        enq(&q, d - 1);
      }
      if((y != w - 1) && (grd[x][y + 1] == '.')){  //右
        grd[x][y + 1] = '#';
        enq(&q, d + 1);
      }
    }
  }
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define H 1<<17
using namespace std;
int N,M,p[H],y[H],i;
vector<int> v[H];
int main(){
  scanf("%d%d",&N,&M);
  for(i=0;i<M;i++)scanf("%d%d",p+i,y+i),v[--p[i]].push_back(y[i]);
  for(i=0;i<N;i++)sort(v[i].begin(),v[i].end());
  for(i=0;i<M;i++)printf("%06d%06d\n",p[i]+1,lower_bound(v[p[i]].begin(),v[p[i]].end(),y[i])-v[p[i]].begin()+1);
  return 0;
}


Measured memory_bytes: 8704
from sys import stdin,setrecursionlimit
setrecursionlimit(10**7)
n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
point = 1
for i,j in enumerate(li):
    if li[j-1] == i+1:
        point += 1
point //= 2
print(point)

Measured memory_bytes: 13880
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    if (args.length > 0 && args(0) == "TEST") {
      println(test())
    } else {
      val input = io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim())
    }
  }

  def solve(input: String): String = {
    val s: Scanner = new Scanner(input)
    val n, a = s.nextInt
    if (n % 500 <= a) "Yes" else "No"
  }

  val tests = List(
    """2018
      |218""".stripMargin -> """Yes""",
    """2763
      |0""".stripMargin -> """No""",
    """37
      |514""".stripMargin -> "Yes"
  )

  def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }
    .zipWithIndex.map {
    case ((input, outputExpect), i) =>
      val output = solve(input).trim()
      val tnum = i + 1
      s"test$tnum:" + (
        if (output == outputExpect) "Passed"
        else s"Failed\nexpect:\n$outputExpect\noutput:\n$output")
  }
    .mkString("\n")
}

Measured memory_bytes: 27212
from itertools import accumulate
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    B = list(map(int, input().split()))
    A = [0] * N
    A[0] = B[0]
    A[N-1] = B[N-2]
    for i in range(1, N-1):
        A[i] = min(B[i-1], B[i])
    print(sum(A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
#define chmax(x,y) (x = max(x, y))
void solve(); int main() { solve(); return 0; }

void solve() {
  set<int> S;
  loop(i,0,3) {
    int a;
    cin >> a;
    S.insert(a);
  }
  cout << S.size() << endl;
}


Measured memory_bytes: 3596
a,b=map(int,input().split())
c=[[int(j) for j in input().split()] for i in range(b)]
d=[0 for i in range(a)]
for i in range(b):
    d[c[i][0]-1]+=1
    d[c[i][1]-1]+=1

for i in range(a):
  print(d[i])

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

int main(){
  int N;
  string S;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> S;
    if ( S == "Y") {
      cout << "Four" << endl;
      break;
    }
    if ( S != "Y" && i == N - 1)
      cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#pragma warning (disable : 4996)

int main() {

	int input;
	scanf("%d", &input);
	
	char kata[4];
	sprintf(kata, "%d", input);
	for (int i = 0; i < strlen(kata); i++) {
		if (kata[i] == '9') {
			printf("Yes\n");
			return 0;
		}
	}

	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX = 510000;
ll gcd(ll a, ll b){
    if (a % b == 0)
    {  return(b);}
    else{return(gcd(b, a % b));}
}
ll lcm(ll a, ll b)
{return a * b / gcd(a, b);}

int main(){
  ll N,X;
  cin>>N>>X;  
  vector<ll>x(N);
  rep(i,N){
  	ll a;cin>>a;
    x[i]=abs(a-X);
  }
  ll ans=x[0];
  rep(i,N-1ll){
  	ans=gcd(ans,x[i+1ll]);
  }
  cout<<ans;
}

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

int main() {
  ll n, wmax;
  cin >> n >> wmax;

  vector<ll> w(n + 1), v(n + 1);
  for (ll i = 0; i < n; i++) cin >> w[i + 1] >> v[i + 1];

  // dp[items until this index][total weight] = max value
  vector<vector<ll>> dp(n + 1, vector<ll>(wmax + 1, 0));
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < wmax; j++) {
      ll next_i = i + 1;
      ll next_j1 = j;
      ll next_j2 = j + w[next_i];

      dp[next_i][next_j1] = max(dp[next_i][next_j1], dp[i][j]);
      if (next_j2 <= wmax) {
        dp[next_i][next_j2] = max(dp[next_i][next_j2], dp[i][j] + v[next_i]);
      }
    }
  }

  cout << max_element(dp[n].begin(), dp[n].end())[0] << endl;
}


Measured memory_bytes: 80256
#include<stdio.h>

int temp[500000],cnt=0;

void MergeSort(int left,int right,int a[]);

void MergeSort(int left,int right,int a[]){
  int m,i,j,k;
  
  //printf("%d,%d,%d\n",left,right,a[0]);
  if(left>=right){
    return;
  }
  //ここまではok
  
  m=(left+right)/2;
  //左側を再起で呼び出し
  MergeSort(left,m,a);
  //右側を呼び出し
  MergeSort(m+1,right,a);
  
  //a[left]からa[m]を作業領域にコピー
  for(i=left;i<=m;i++){
    temp[i]=a[i];
    //printf("%d,",temp[i]);
  }

  //a[m+1]からa[right]を逆順にコピー　
  for(i=m+1,j=right;i<=right;i++,j--){
    temp[i]=a[j];
  }

  i=left;
  j=right;
  //小さい方から配列に戻す
  for(k=left;k<=right;k++){
    cnt++;
    if(temp[i]<temp[j]){
      a[k]=temp[i++];
    }else{
      a[k]=temp[j--];
    }
  }
	
}
int main(){
  int num,array[500000],i;

  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d",&array[i]);
  }
  MergeSort(0,num-1,array);
  //printf("%d,%d\n",num,array[0]);

  for(i=0;i<num-1;i++){
    printf("%d ",array[i]);
  }
  
  printf("%d\n%d\n",array[num-1],cnt);
  return 0;
}



Measured memory_bytes: 5632
import bisect
 
N=int(input())
L=list(map(int,input().split()))
 
count=0
L.sort()
for i in range(0,N):
  for j in range(i+1,N):
    index=bisect.bisect_left(L,L[i]+L[j])
    count+=max(0,index-j-1)
print(count)

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        String result = "Yes";

        int a = Integer.parseInt(str[0]);
        int b = Integer.parseInt(str[1]);
        int c = Integer.parseInt(str[2]);
        int d = Integer.parseInt(str[3]);

        while (a > 0 && c > 0) {
            c -= b;
            a -= d;
        }
        if (c > 0) {
            result = "No";
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 32848
//Source: https://ideone.com/vju6Uh

#include <cstdio>
#include <cmath>
int n;
double x[1005], y[1005], X, Y, d, e;
double dist(double a, double b) {
	return a*a + b*b;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf%lf", &x[i], &y[i]);
		X += x[i]; Y += y[i];
	}
	X /= n; Y /= n;
	double P = 0.01;
	for (int i = 0; i < 30000; i++) {
		int f = 0;
		d = dist(X - x[0], Y - y[0]);
		for (int j = 1; j < n; j++) {
			e = dist(X - x[j], Y - y[j]);
			if (d < e) { d = e; f = j; }
		}
		X += (x[f] - X)*P;
		Y += (y[f] - Y)*P;
		P *= 0.999;
	}
	printf("%.9lf", sqrt(d));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int k;
int col[9];
int dpos[20];
int dneg[20];

int store[9];
bool book[9];

inline bool check(int i,int j) {
    if(col[j] == 1 || dpos[i + j] == 1 || dneg[i - j + 10] == 1) {
        return false;
    }
    return true;
}

void dfs(int row) {
    if(row == 9) {
        for (int i = 1; i <= 8; i++) {
            for(int j = 1; j <= 8; j++) {
                cout << ((store[i] == j) ? "Q" : "." );
            }
            cout << endl;
        }
        return ;
    }
    if(book[row]) {
        dfs(row + 1);
    }
    else {
        for (int i = 1; i <= 8; i++) {
            if (check(row,i)) {
                col[i] = dpos[row + i] = dneg[row - i + 10] = 1;
                store[row] = i;
                dfs(row + 1);
                col[i] = dpos[row + i] = dneg[row - i + 10] = 0;
            }
        }
    }

}

int main() {
    cin >> k;
    while (k--) {
        int x,y; cin >> x >> y;
        x++, y++;
        book[x] = 1;
        store[x] = y;
        col[y] = 1;
        dpos[x + y] = 1;
        dneg[x - y + 10] = 1;
    }
    dfs(1);
    return 0;
}



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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

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

  const int N = 100000 + 5;
  
  int n, m;
  while (cin >> n >> m) {
    vector<pair<int, lli>> g[N];
    for (int i = 0; i < m; ++i) {
      int a, b, c;
      cin >> a >> b >> c;
      --a;
      --b;
      g[a].push_back({b, +c});
      g[b].push_back({a, -c});
    }

    map<int, lli> pos;
    set<int> vis;
    function<void(int)> rec = [&] (int curr) {
      vis.insert(curr);
      each (e, g[curr]) {
        int next = e.first;
        auto c = e.second;
        if (vis.count(next)) continue;
        pos[next] = pos[curr] + c;
        rec(next);
      }
      return ;
    };
    for (int i = 0; i < N; ++i) {
      if (vis.count(i)) continue;
      pos[i] = 0;
      rec(i);
    }

    // for (int i = 0; i < n; ++i) {
    //   cout << make_pair(i+1, pos[i]) << ",";
    // }
    // cout << endl;
    
    bool f = true;
    for (int i = 0; i < N; ++i) {
      each (e, g[i]) {
        int src = i;
        int dst = e.first;
        auto c = e.second;
        f = (f && pos[dst] == (pos[src] + c));
      }
    }
    cout << (f ? "Yes" : "No") << endl;
  }
  
  return 0;
}


Measured memory_bytes: 28800
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,string> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);


int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N,M; cin>>N>>M;
    ll ans=0;
    map<ll,ll,greater<ll> > m;
    rep(i,N){
        ll x; cin>>x;
        m[x]++;
    }
    rep(i,M){
        ll B,C; cin>>B>>C;
        m[C]+=B;
    }
    ll rem=N;
    for(auto x:m){
        ll L=min(rem,x.b);
        ans += L * x.a;
        rem-=L;
        if(rem==0) break;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 16068
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=3*(1e5)+10;
int a[N],dir[N],toleft[N],toright[N];
int n,m,totl,totr;
bool firstcheck(){
	for (int i=1;i<=n;++i)
		if ((i&1)!=(a[i]&1)) return false;
	return true;
}
bool doublecheck(){
	totl=totr=0;
	for (int i=1;i<=n;++i)
		if (a[i]<i) toleft[++totl]=a[i];
		else if (a[i]>i) toright[++totr]=a[i];
	for (int i=2;i<=totr;++i)
		if (toright[i-1]>toright[i]) return false;
	for (int i=2;i<=totl;++i)
		if (toleft[i-1]>toleft[i]) return false;
	int mx=0,mn=n+1,now=1;
	int l=1,r=1;
	while (now<=n){
		l=now; r=-1; mx=0; mn=n+1;
		bool op=a[now]==now;
		for (int i=0;l+i<=n;r=l+i,++i){
			if (!(i&1)){
				if (op==1&&a[l+i]!=l+i) break;
				else if (op==0&&a[l+i]==l+i) break;
			}
			else{
				if (op==1&&a[l+i]==l+i) break;
				else if (op==0&&a[l+i]!=l+i) break;
			}
			mx=max(a[l+i],mx); mn=min(a[l+i],mn);
		}
		if (r==-1||mn<l||mx>r) return false;
		now=r+1;
	}
	return true;
}

int main(){
#ifndef ONLINE_JUDGE
	//freopen("a.in","r",stdin);
#endif
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",a+i);
	if (!firstcheck()){printf("No\n"); return 0;}
	if (doublecheck()) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 3584