akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll N,D,X;
    cin >> N >> D >> X;
    ll i;
    ll A;
    for(i=0;i<N;i++){
      cin >> A;
      X+=(D-1)/A+1;
    }
    cout << X;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
#-*- coding:utf-8 -*-

H_s,W_s = input().split()
h_s,w_s = input().split()

H = int(H_s)
W = int(W_s)
h = int(h_s)
w = int(w_s)

num_total    = H * W
num_black_h  = h * W
num_black_w  = H * w
num_black_hw = h * w
num_white = num_total - num_black_h - num_black_w + num_black_hw

print(num_white)

Measured memory_bytes: 3060
#include <stdio.h>

int cnt = 0;

void bubbleSort( int *A, int N )
{
    int flag = 1;
    int tmp;
    int i = 0;

    while ( flag != 0 ) {
        flag = 0;
        for ( int j = N - 1; j >= i + 1; j-- ) {
            if ( A[j] < A[j - 1] ) {
                tmp = A[j];
                A[j] = A[j - 1];
                A[j - 1] = tmp;
                flag = 1;
                cnt++;
            }
        }
        i++;
    }
}

int main(void)
{
    int A[100] = {0};
    int N;
    
    scanf("%d", &N);
    
    for ( int i = 0; i < N; i++ ) {
        scanf("%d", &A[i]);
    }
    
    bubbleSort( A, N );
    
    for ( int i = 0; i < N; i++ ) {
        printf("%d", A[i]);
        if ( i == N - 1 ) {
            printf("\n");
        } else {
            printf(" ");
        }
    }
    
    printf("%d\n", cnt);
    
    return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  vector<int> p(n);
  rep(i,n){
    cin>>p[i];
  }
  vector<int> q(n);
  rep(i,n){
    cin>>q[i];
  }
  vector<int> base(n);
  rep(i,n){
    base[i]=i+1;
  }
  int eqP=-1;
  int eqQ=-1;
  int c=1;
  do{
    if(eqP<0 && equal(all(base),all(p))){
      eqP=c;
    }
    if(eqQ<0 && equal(all(base),all(q))){
      eqQ=c;
    }
    next_permutation(all(base));
    c++;
  }while(eqP<0 || eqQ<0);
  cout << abs(eqP-eqQ) << endl;
  return 0;
}

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

int main() {
  long long N, A, B, ans, rem;
  cin >> N >> A >> B;
  
  ans = N / (A+B)*A;
  rem = N % (A+B);
  ans += min(rem, A);
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   if(n & 1){
      cout << "0\n";
      return 0;
   }
   int n1 = n;
   int va1 = 0;
   while(n1){
      va1 += n1/2;
      n1 = n1/2;
   }
   int va2 = 0;
   n1 = n;
   while(n1){
      n1 = n1/5;
      va2 += n1/2;
   }
   cout << min(va1,va2) << '\n';
   return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n;
        n = input.nextInt();
        boolean[] cards = new boolean[52];
        HashMap<String,Integer> mark = new HashMap<String,Integer>();
        mark.put("S",0);
        mark.put("H",1);
        mark.put("C",2);
        mark.put("D",3);
        HashMap<Integer,String> revmark = new HashMap<Integer,String>();
        revmark.put(0,"S");
        revmark.put(1,"H");
        revmark.put(2,"C");
        revmark.put(3,"D");
        for (int i = 0; i < n; i++){
            String mk = input.next();
            int num = input.nextInt();
            cards[mark.get(mk)*13 + num - 1] = true;
        }
        for (int i = 0; i < 52; i++){
            if (!cards[i]){
                int mk = i/13;
                int num = i%13 + 1;
                System.out.printf("%s %d\n",revmark.get(mk),num);
            }
        }
    }
}


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

int main(){
	int n;
	cin >> n;
	
	vector<tuple<string,int,int>>a;
	
	for(int i=1; i<n+1; i++){
		string s;
		int p;
		cin >> s >> p;
		p*=-1;
		a.emplace_back(s,p,i);
	}
	
	sort(a.begin(), a.end());
	
	for(int i=0; i<n; i++){
		cout << get<2>(a[i]) << endl;
	}
}

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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

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

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;


const int mod = 1000000007;

int main() {
	int s, w;
	cin >> s >> w;

	if(s <= w) {
		cout << "unsafe" << endl;
	} else {
		cout << "safe" << endl;
	}

}



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

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

	int arr[100000];
	int mx = 0, mn = 100000;
	for (int i = 0; i < N; ++i) {
		cin >> arr[i];
		mx = max(mx, arr[i]);
		mn = min(mn, arr[i]);
	}

	if (mn == mx) {
		if (mx == N - 1 || mx * 2 <= N) cout << "Yes";
		else cout << "No";
	}
	else if (mn + 1 == mx) {
		int x = 0, y = 0;
		for (int i = 0; i < N; ++i)
			arr[i] == mn ? ++x : ++y;

		if (x > mn) cout << "No";
		else if (mn - x + 1 <= y / 2) cout << "Yes";
		else cout << "No";
	}
	else cout << "No";

	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<bitset>

#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.bigin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vi>
#define vvi64 vector<vi64>

using namespace std;

int main(){
    int n, ans = 0;
    cin >> n;
    vi64 l(n);
    Srep(n) cin >> l[i];
    Vsort(l);
    Srep(n-2) Lrep(j,i+1,n-1) Lrep(k,j+1,n){
        if((l[i]!=l[j]) && (l[i]!=l[k]) && (l[j]!=l[k])){
            if(l[i] + l[j] > l[k]) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
n,m = [int(i) for i in input().split()]
ck = []
for i in range(n):
    ck.append(list(map(int,input().split())))

co1=co2=co3=-1

scores = []
maxi = 0
for i in range(2):
    co1 *= -1
    for j in range(2):
        co2 *= -1
        for k in range(2):
            co3*= -1
            scores = []
            score = 0
            for a,b,c in ck:
                scores.append(a*co1 + b*co2 + c*co3)
            scores.sort(reverse=True)
            for x in range(m):
                score += scores[x]
            maxi = max(maxi,score)

print(maxi)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, K, S;
    cin >> N >> K >> S;
    if (K == N) {
        REP (i, N) cout << S << " \n"[i+1==N];
        return 0;
    }
    const int INF = 1000000000;
    int dm = INF - 2 * (S == INF);
    if (S == 1) {
        REP (i, K) cout << S << " ";
        REP (i, N - K) cout << dm << " \n"[i+1==N-K];
        return 0;
    }
    REP (i, N) {
        if (i <= K) {
            if (i % 2 == 0) cout << 1 << " ";
            else cout << S - 1 << " ";
        } else {
            cout << dm << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 1280
import sys


n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

result = -1
min_diff_of_temprature = sys.maxsize
for i in range(n):
    diff_of_temprature = abs(a - (t - 0.006 * h[i]))
    if diff_of_temprature < min_diff_of_temprature:
        result = i
        min_diff_of_temprature = diff_of_temprature

print(result + 1)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	
	int N = 100000;
	
	bool a[100000];
	
	for(int i = 0; i < N; i++){
		a[i] = true;
	}
	
	a[0] = false;
	a[1] = false;
	
	for(int i = 2; i < N; i++){
		if(a[i]){
			for(int j = i * 2; j < N; j += i){
				a[j] = false;
			}
		}
	}
	
	int n;
	
	while(true){
		cin >> n;
		if(cin.eof()){
			break;
		}
		int count = 0;
		for(int i = 1; i <= n; i++){
			if(a[i] && a[n - i + 1]){
				count++;
			}
		}
		printf("%d\n", count);
	}
	
	return 0;
}

Measured memory_bytes: 1240
from fractions import gcd
K, S = map(int, input().split())
ans = 0
for z in range(0, min(S + 1, K + 1)):
    #print(z)
    if S - z <= 2 * K:
        x1 = min(K, S - z)
        y1 = S - z - x1

        y2 = min(K, S - z)
        x2 = S - z - y2

        ans += gcd(abs(x1 - x2), abs(y1 - y2)) + 1
        #print(ans)
print(ans)

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

int N;
     

int main() {

    cin >> N;
    int A[110];
    
    for (int i = 0; i < N; ++i) cin >> A[i];
    sort(A, A + N); 
    cout << A[N - 1] - A[0]  << endl; 
    
}

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

public class Main{

	private static List<Long> getStrings(Scanner sc, long num) {
		List<Long> stringList = new ArrayList<>();
		while(num>0) {
			long nextInt = sc.nextLong();
			stringList.add(nextInt);
			num--;
		}
		return stringList;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
		long m = sc.nextInt();
		List<Long> array = getStrings(sc, m);
		long sum = array.stream().mapToLong(t -> t.longValue()).sum();
		if (n>=sum) {
			System.out.println(n-sum);
		} else {
			System.out.println(-1);
		}
	}

}


Measured memory_bytes: 46680
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;

// nCr
ll po[POW_MAX + 2];
ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
ll mod_inv (ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}
ll comb(int n, int r) {
  return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}
// greatest common divisor
ll gcd(ll a, ll b) {
  while (a % b != 0) {
    ll tmp = a;
    a = b;
    b = tmp % b;
  }
  return b;
}

struct PairSecondLess {
  bool operator() (Pil a, Pil b) {
    return a.second < b.second;
  }
};

const int N_MAX = 1e5;

int N, M;
int B[N_MAX + 1];
ll A[N_MAX + 1], C[N_MAX + 1];
priority_queue<Pil, vector<Pil>, PairSecondLess> Q;

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

  rep(i, N) {
    ll a;
    scanf("%lld", &a);
    Q.push(Pil(1, a));
  }
  rep(i, M) {
    int b;
    ll c;
    scanf("%d %lld", &b, &c);
    Q.push(Pil(b, c));
  }

  ll sum = 0;
  int count = 0;
  while (count < N) {
    Pil pil = Q.top();
    Q.pop();
    if (count + pil.first > N) {
      ll x = (N - count) * pil.second;
      sum += x;
    } else {
      sum += pil.first * pil.second;
    }
    count += pil.first;
  }
  printf("%lld\n", sum);
}


Measured memory_bytes: 6128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.ARC071
{
    class TrBBnsformBBtion
    {
        class BinaryIndexedTree
        {
            int[] array;
            public BinaryIndexedTree(int length)
            {
                array = new int[length];
            }
            public int this[int from, int to]
            {
                get { return At(to) - At(from - 1); }
            }
            int this[int idx]
            {
                set
                {
                    for (var i = idx; i < array.Length; i += RightenZero(i))
                        array[i] += value;
                }
            }
            public void Set(int idx, int value)
            {
                this[idx] = value;
            }
            public int Length
            {
                get { return array.Length; }
            }
            int At(int idx)
            {
                int sum = 0;
                for (var i = idx; i >= 0; i -= RightenZero(i))
                    sum += array[i];
                return sum;
            }
            static int RightenZero(int idx)
            {
                return (~idx) & (idx + 1);
            }
        }
        static BinaryIndexedTree ReadString(string a)
        {
            var bit = new BinaryIndexedTree(a.Length);
            for (var i = 0; i < a.Length; ++i)
                bit.Set(i, (a[i] == 'A') ? 1 : 2);
            return bit;
        }
        static bool IsTransFormable(BinaryIndexedTree a, BinaryIndexedTree b, params int[] query)
        {
            return (a[query[0] - 1, query[1] - 1] % 3 == b[query[2] - 1, query[3] - 1] % 3);
        }
        public static void Main()
        {
            var s = ReadString(ReadLine().Trim());
            var t = ReadString(ReadLine().Trim());
            for (var n = int.Parse(ReadLine()); n > 0; --n)
            {
                var q = ReadLine().Trim().Split(' ').Select(i => int.Parse(i)).ToArray();
                if (IsTransFormable(s, t, q))
                {
                    WriteLine("YES");
                }
                else
                {
                    WriteLine("NO");
                }
            }

        }
    }
}

/*
"A"     => "BB"
"AA"    => "B"
"AAA"   => "BBB"

*/

Measured memory_bytes: 19116
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数


template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*///map < string, ll> s;

int main() {
	ll N,a;cin >> N;
	string S;cin >> S;
	map <string, ll> s;
	for (int i = 0;i < N;i++) {
		if (S[i] == 'R') s["R"]++;
		if (S[i] == 'G') s["G"]++;
		if (S[i] == 'B') s["B"]++;
	}
	ll sum = s["R"] * s["G"] * s["B"];
	if (N % 2 != 0)a = N / 2;
	else a = N / 2 - 1;
	for (int i = 1;i <= a;i++) {
		for (int j = 0;j<N-(i*2);j++){
			if (S[j] != S[j + i] && S[j + i*2] != S[j] && S[j + i] != S[j + i*2]) sum--;
		    if (sum == 0)break;
		}
	}
	//cout<< s["R"] <<endl<< s["G"] <<endl<< s["B"]<<endl;
	cout << sum << endl;
}

Measured memory_bytes: 3600
n, m = gets.split.map(&:to_i)
cd = m.times.map{gets.split.map(&:to_i)}
b = Array.new(n+1, false)
cd.each do |cc|
    cc[0].upto(cc[1]-1) do |i|
        b[i] = true
    end
end
p b.count{|bl| bl} * 2 + n + 1

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

const ll M = 998244353;

vector<ll> fac(3000010); 
vector<ll> ifac(3000010); 

ll mpow(ll x, ll n){ 
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ 
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

void init()
{
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<3000000; i++){
        fac[i+1] = fac[i]*(i+1) % M; 
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; 
    }
}


int main(int argc, char **argv)
{
	init();
	ll N; cin >> N;
	vector<ll> V(N); for (ll i = 0; i < N; ++i) cin >> V[i];

	vector<ll> sum(N+1, 0);
	for (ll i = 0; i < N; ++i)
		++sum[V[i]];

	ll conb_sum{0};
	for (ll i = 1; i <= N; ++i)
	{
		conb_sum += sum[i] * (sum[i] - 1) / 2;
	}

	for (ll i = 0; i < N; ++i)
	{
		ll target = V[i];
		std::cout << conb_sum - sum[target] + 1<< std::endl;
	}
}


Measured memory_bytes: 52608
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int

int main()
{
    ll n, ans = 0;
    ll a[100000], b[100000], c[100000];

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
    }
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);
    for (int i = 0; i < n; i++)
    {
        ll *apos = lower_bound(a, a + n, b[i]);
        ll *cpos = upper_bound(c, c + n, b[i]);
        ans += (int)(apos - a) * (n - (int)(cpos - c));
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <cstddef>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <set>
#define L64 long long
#define UL64 unsigned long long
#define MOD (1000000007LL)
using namespace std;
int main(void)
{
  int n;
  cin >> n;
  vector<int> a;
  for(int i = 0; i < n; i++){
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(), a.end());
  cout << a[n / 2] - a[n / 2 - 1] << endl;
}


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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353
#define Graph vector<vector<int>>

int main() {
    int N, D, X; cin >> N >> D >> X;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A.at(i);
    int ans = X, day;
    for (int i = 0; i < N; i++) {
        day = 1;
        while (day <= D) {
            ans ++;
            day += A.at(i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3536
n=int(input())
x=[list(map(int,input().split())) for i in range(n)]
ans=0

for i in range(n):
  for j in range(i+1,n):
    ans+=((x[i][0]-x[j][0])**2+(x[i][1]-x[j][1])**2)**0.5
print(ans/(n/2))


Measured memory_bytes: 9456
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int n,rem,flag=0;
    cin>>n;
    
    while(n>0)
    {
        rem=n%10;
        if(rem==7)
        {
            flag=1;
            break;
            
        }
        n=n/10;
    }
    if(flag==1)
    cout<<"Yes";
    else
    cout<<"No";
    
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

template<typename T>
void trace(T *a, int s, int n) {
    for (int i=s; i<n; i++) {
	cout<<a[i]<<" ";
    }
    cout<<endl;
}



typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;




ll n;

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

    cin>>n;

    ll ans=0;

    //count k s.t. n%k=1 => n=xk+1 => xk=n-1
    ll n1=n-1;
    for (ll i=1;i*i<=n1; i++) {
        if (n1%i==0) {
	    if (i>1) ans++;
	    if (n1/i!=i && n1/i>1) {
		ans++;
	    }
	}
    }

    auto test = [](ll i) {
	assert(i>1);
	ll x=n;
	while (x%i==0) {
	    x=x/i;
	}
	return (x%i)==1;
    };

    //test all factors>1
    for (ll i=1; i*i<=n; i++) {
	if (n%i==0) {
	    if (i>1 && test(i)) ans++;
	    if (n/i!=i && (n/i)>1 && test(n/i)) ans++;
	}
    }


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


Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
signed main()
{
	fastio;
	int n;
	cin>>n;
	int sum=(n/500)*1000;
	n-=(n/500)*500;
	sum+=n/5*5;
	cout<<sum;
	
}












Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
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(){
cout<<fixed<<setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);

int A,B;
  cin>>A>>B;
  int ans=A+B;
  if(ans>=10){
    cout<<"error"<<endl;
  }else{
    cout<<ans<<endl;
  }
}



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

bool comp(pair<int,int>& a,pair<int,int>& b)
{
	return a.second>b.second;
}
int main()
{
	int n,a[50005],b[50005],p,q,ans;
	vector<pair<int,int> >ca,cb;
	cin>>n;
	for(int i=0;i<n/2;i++)cin>>a[i]>>b[i];
	sort(a,a+n/2);
	sort(b,b+n/2);
	p=q=1;
	ca.push_back(make_pair(0,0));
	cb.push_back(make_pair(0,0));
	ca.push_back(make_pair(a[0],1));
	cb.push_back(make_pair(b[0],1));
	for(int i=1;i<n/2;i++)
	{
		if(ca[p].first!=a[i])
		{
			ca.push_back(make_pair(a[i],1));
			p++;
		}
		else
		{
			ca[p].second++;
		}
		if(cb[q].first!=b[i])
		{
			cb.push_back(make_pair(b[i],1));
			q++;
		}
		else
		{
			cb[q].second++;
		}
	}
	sort(ca.begin(),ca.end(),comp);
	sort(cb.begin(),cb.end(),comp);
	ans=n-ca[0].second-cb[0].second;
	if(ca[0].first==cb[0].first)ans=min(n-ca[1].second-cb[0].second,n-ca[0].second-cb[1].second);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1660
use proconio::input;
use proconio::marker::Usize1;

fn main() {
    input! {
        n: usize,
        a: [Usize1; n],
    };
    let mut ans = 0;
    for (i, &j) in a.iter().enumerate() {
        if i == a[j] && i < j {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define all(a) a.begin(),a.end()
#define rep(i,n) for(long long i=0;i<n;i++)
#define P pair<long,long>
#define F first
#define S second
#define INF 100000000000000000
#define mod 1000000007
signed main(void){
    int n;cin>>n;int x;
    vector<int>v(n+1);
    v[0]=(int)0;
    rep(i,n){
        cin>>x;v[i+1]=v[i]+x;
    }
    vector<vector<int>>dp(n,vector<int>(n,INF));//dp[i][j]はi~jのコストの最小値
    rep(i,n)dp[i][i]=0;
    for(int i=1;i<n;i++){
        for(int j=0;j+i<n;j++){
            //dp[j][j+i]に入力
            for(int k=j;k<j+i;k++){
                dp[j][j+i]=min(dp[j][j+i],dp[j][k]+dp[k+1][j+i]+v[k+1]-v[j]+v[j+i+1]-v[k+1]);
                
            }
        }
    }
    cout<<dp[0][n-1];
}

Measured memory_bytes: 1536
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   int mx = 0;
   int ans = 0;
   for(int i = 0; i < n; ++i){
      int x;
      cin >> x;
      mx = max(mx,x);
      ans += mx-x;
   }
   cout << ans;
   return 0;
} 


Measured memory_bytes: 3644
n=input()
if int(n[len(n)-1])==2 or int(n[len(n)-1])==4 or int(n[len(n)-1])==5 or int(n[len(n)-1])==7 or int(n[len(n)-1])==9:
  print("hon")
if int(n[len(n)-1])==0 or int(n[len(n)-1])==1 or int(n[len(n)-1])==6 or int(n[len(n)-1])==8 :
  print("pon")
elif int(n[len(n)-1])==3:
  print("bon")
  


Measured memory_bytes: 9204
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define ppi pair<int,pair<int,int> >
#define fr first
#define sc second
#define PI acos(-1)
#define mp make_pair

using namespace std;

#define sim template < class c

#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "




int main()
{
    int a,b;
     cin >> a >> b ;
     cout << max(a-b,max(a+b , a * b));

	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		char[] s = new Scanner(System.in).next().toCharArray();
		int[] count = new int[3];
		int n = s.length;
		for(int i=0;i<n;i++) {
			count[s[i]-'a']++;
		}
		Arrays.sort(count);
		System.out.println(count[2] - count[0] <= 1 ? "YES" : "NO");
	}

}

Measured memory_bytes: 25944
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof x)
#define copy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair < int, int > pa;

inline int read()
{
	int sc = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') sc = sc * 10 + ch - '0', ch = getchar();
	return sc * f;
}

const int MAXN = 505;
const int INF = INT_MAX;

int n, a[MAXN][MAXN], ans = INF, c, cnt;

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = read();
	for (int i = 1; i <= n; i ++)
		for (int j = 1; j <= n; a[i][j ++] = c == '#')
			for (c = getchar(); c != '#' && c != '.'; c = getchar());
	for (int i = 1; i <= n; i ++)
		for (int j = 1; j <= n; j ++)
			if (!a[j][i])
			{
				cnt ++;
				break;
			}
	for (int i = 1; i <= n; i ++)
	{
		int ret = 0, f = 0;
		for (int j = 1; j <= n; j ++)
			if (a[i][j])
			{
				f = 1;
				break;
			}
		if (!f) continue;
		for (int j = 1; j <= n; j ++)
			if (a[j][i])
			{
				f = 0;
				break;
			}
		if (f) ret ++;
		for (int j = 1; j <= n; j ++) ret += !a[i][j];
		ans = min(ans, ret + cnt);
	}
	if (ans == INF) ans = -1;
	return printf("%d\n", ans), 0;
}


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int N,M,Q;
vector<int> a,b,c,d;
int res = 0;
void dfs(vector<int> &A){
    if(A.size()==N){
        //得点check
        int tmp_res = 0;
        rep(i,Q){
            if(A.at(b.at(i))-A.at(a.at(i))==c.at(i))tmp_res+=d.at(i);
        }
        chmax(res,tmp_res);
        return;
    }

    for(int v = 1; v <= M; v++){
        if(A.size()!=0){
            int A_end = A.back();
            if(A_end>v)continue;
        }
        A.push_back(v);
        dfs(A);
        A.pop_back();
    }
}

int main(){
    cin>>N>>M>>Q;
    a.resize(Q);
    b.resize(Q);
    c.resize(Q);
    d.resize(Q);
    rep(i,Q){
        cin>>a.at(i)>>b.at(i)>>c.at(i)>>d.at(i);
        a.at(i)--; b.at(i)--;
    }
    vector<int> A;
    dfs(A);
    cout<<res<<endl;
}


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

bool f() {
  int N; cin >> N;
  vector<pair<int, int>> v;
  for (int i = 0; i < N; i++) {
    int a, b; cin >> a >> b;
    v.emplace_back(b, a);
  }
  sort(v.begin(), v.end());
  ll T = 0;
  for (int i = 0; i < N; i++) {
    T += v[i].second;
    if (T > v[i].first) return false;
  }
  return true;
}

int main() {
  if (f()) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<string, ll> mstrll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << x
#define print(x) cout << x << '\n'
#define debug(x) cerr << #x << ": " << x << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, c, n, m, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s, t, u;
vll dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
//vll dx = {-1, 0, 1, -1, 1, -1, 0, 1}, dy = {-1, -1, -1, 0, 0, 1, 1, 1};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n){
        cin >> s >> t >> u;
        ans = 0;
        rep(i, n){
            if(s[i] == t[i] && t[i] == u[i]){
                continue;
            }else if(s[i] == t[i] || t[i] == u[i] || s[i] == u[i]){
                ans += 1;
            }else{
                ans += 2;
            }
        }
        print(ans);
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		
		String s=sc.next();
		String[] Array = s.split("");
		int[]intArray=new int[Array.length];
		int count=0;
		
		for (int i=0;i<Array.length;i++) {
		intArray[i]=Integer.parseInt(Array[i]);
		}
		for(int i=0;i<intArray.length-1;i++) {
			if(intArray[i]==intArray[i+1]) {
				if(intArray[i+1]==0) {
					intArray[i+1]=1;
					count++;
				}else {
					intArray[i+1]=0;
					count++;
				}
			}
		}
		System.out.println(count);
		sc.close();
	}

}

Measured memory_bytes: 32276
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		long n = in.nextLong();
		long m = in.nextLong();
		
		Queue<Long> queue = new PriorityQueue<>(Collections.reverseOrder());
		for (int i = 0; i < n; i++)
		        queue.add(in.nextLong());
		for (int i = 0; i < m; i++) 
		        queue.add(queue.poll() / 2);
		
		long ans = 0;
		int size = queue.size();
		for(int i = 0 ; i < size;i++)
		        ans += queue.poll();
		System.out.println(ans);
		
	}
}


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

int main(){
	int n;
	cin>>n;
	int ans=0;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		ans+=(a-1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
 
 
void swap (int *x, int *y) {
  int temp;    
 
  temp = *x;
  *x = *y;
  *y = temp;
}
 
int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }
 
  if(b==0){
    return a;
  }
 
  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }
 
  return b;
}
 
/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}
 
 
int modpow(int a,int n,int mod){
  int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}
 
int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}
 
int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}
 
void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }
 
  return;
}
 
void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }
 
  return;
}
 

int main(void){
  char s[12];
  scanf("%s",s);
  int l=strlen(s);
  int min=1000;
  for(int i=0;i<l-2;i++){
    int x=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
    if(x<=753){
      chmin(&min,753-x);
    }else{
      chmin(&min,x-753);
    }
  }
  printf("%d\n",min);
  return 0;
}

Measured memory_bytes: 1728
#include<iostream>
using namespace std;
int main()
{
	long long x;
	cin>>x;
	long long now=100;
	for(int i=1;;i++)
	{
		now=now+now*0.01;
		if(now>=x) 
		{
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3192
n=int(input())
s=input()
cnt=0
for i in s:
    if i=="(": cnt+=1
    elif cnt>=1: cnt-=1
cnt2=0
for i in range(n-1,-1,-1):
    if s[i]==")": cnt2+=1
    elif cnt2>=1: cnt2-=1
print("("*cnt2+s+")"*cnt)

Measured memory_bytes: 9188
""""
5 8
5 3
2 3
2 4
5 2
5 1
1 4
4 3
1 3
"""

N, M = map(int, raw_input().split())

G = []
for _ in xrange(M):
    G.append(map(int, raw_input().split()))

h = [0]*(N+1)

dest = [[] for _ in xrange(N+1)]

for eg in G:
    h[eg[1]]+=1
    dest[eg[0]].append(eg[1])

que = []

for i in xrange(1, N+1):
    if h[i] == 0: que.append(i)

dp = [0]*(N+1)

while len(que)>0:
    now = que.pop(0)
    for edest in dest[now]:
        h[edest]-=1
        if h[edest]==0:
            que.append(edest)
            dp[edest] = max(dp[now] + 1, dp[edest])

print max(dp)


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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAXH { 10 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

int solve(int H, int W, int K, const vector<string>& xs)
{
    int ans = H*W;

    vector<vector<int>> ps(H + 1, vector<int>(W + 1, 0));

    for (int i = 1; i <= H; ++i)
        for (int j = 1; j <= W; ++j)
            ps[i][j] = ps[i - 1][j] + ps[i][j - 1] - ps[i - 1][j - 1] + xs[i - 1][j - 1] - '0';

#ifdef DEBUG
    for (int i = 1; i <= H; ++i)
        for (int j = 1; j <= W; ++j)
            cout << ps[i][j] << (j == W ? '\n' : ' ');
#endif

    auto sum = [&ps](int a, int b, int c, int d) {
        return ps[c][d] - ps[c][b - 1] - ps[a - 1][d] + ps[a - 1][b - 1];
    };

    auto search = [&ps, &sum](int r1, int r2, int c1, int c2, int K) {
        int a = c1, b = c2, res = -1;

        while (a <= b)
        {
            int m = a + (b - a)/2;

            if (sum(r1, c1, r2, m) <= K)
            {
                res = m;
                a = m + 1;
            } else
                b = m - 1;
        }

        return res;
    };

    for (int mask = 0; mask < (1 << (H - 1)); ++mask)
    {
        int res = 0;

        vector<int> cuts;

        cuts.push_back(0);

        for (int i = 0; i < H; ++i)
        {
            if (mask & (1 << i))
            {
                cuts.push_back(i + 1);
                ++res;
            }
        }

        cuts.push_back(H);

        int M = cuts.size();

#ifdef DEBUG
    cout << "--- mask = " << mask << ", res = " << res << ", cuts = ";
    for (auto c : cuts)
        cout << c << ' ';
    cout << endl;
#endif
        vector<int> ys(M + 1, 0);

        int col = 1;
        bool ok = true;

        while (col <= W)
        {
            int cut = W + 1;
 
            for (int i = 1; i < M; ++i)
            {
                auto r1 = cuts[i - 1] + 1, r2 = cuts[i];
                auto c = search(r1, r2, col, W, K);

                cut = min(cut, c);
#ifdef DEBUG
    cout << "   r1 = " << r1 << ", r2 = " << r2 << ", c1 = " << col << ", c2 = " << W << 
        ", c = " << c << ", cut = " << cut << endl;
#endif
            }
                 
            if (cut == -1)
            {
                ok = false;
                break;
            }

            if (cut < W)
                ++res;
#ifdef DEBUG
    cout << "   * res = " << res << ", cut = " << cut << endl;
#endif
            col = cut + 1;
        }

        if (ok)
            ans = min(ans, res);
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int H, W, K;
    cin >> H >> W >> K;

    vector<string> xs(H);

    for (int i = 0; i < H; ++i)
        cin >> xs[i];

    auto ans = solve(H, W, K, xs);

    cout << ans << '\n';

    return 0;
}


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

const int N = 100010;

int a[N];

int main(){
	int n, l;
	scanf("%d%d", &n, &l);
	for (int i = 1; i <= n; ++ i){
		scanf("%d", &a[i]);
	}
	for (int i = 1; i < n; ++ i){
		if (a[i] + a[i + 1] >= l){
			puts("Possible");
			for (int j = 1; j < i; ++ j){
				printf("%d\n", j);
			}
			for (int j = n - 1; j > i; -- j){
				printf("%d\n", j);
			}
			printf("%d\n", i);
			return 0;
		}
	}
	puts("Impossible");
	return 0;
}

Measured memory_bytes: 1152
N, K = map(int, input().split())
D = list(map(int, input().split()))

n = N

while True:
    i = n
    while i != 0:
        if i % 10 in D:
            break
        i = int(i / 10)
    if i == 0:
        break
    n += 1

print(n)


Measured memory_bytes: 3316
x, y = gets.split.map(&:to_i)

answer = 0

answer += 
  case x
  when 1
    3
  when 2
    2
  when 3
    1
  else
    0
  end

answer += 
  case y
  when 1
    3
  when 2
    2
  when 3
    1
  else
    0
  end

if x == 1 && y == 1
  answer += 4
end

puts answer * 100000


Measured memory_bytes: 1788
#include <stdio.h>

int main(){
    int n,a = 0;
    scanf("%d", &n);
    int d[n][2];
    for(int i = 0; i < n; i++){
        scanf("%d%d", &d[i][0],&d[i][1]);
    }
    for(int i = 0; i < n; i++){
        if(d[i][0] == d[i][1]){
            a++;
        }else{
            if(a < 3){
                a = 0;
            }
        }
    }
    if(a >= 3){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}

Measured memory_bytes: 1640
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int main(void){
    int cnt[7]={0};
    int n;
    cin>>n;
    double b;
    for(int i=0;i<n;i++){
        cin>>b;
        if(b<165.0)cnt[1]++;
        else if(b<170.0)cnt[2]++;
        else if(b<175.0)cnt[3]++;
        else if(b<180.0)cnt[4]++;
        else if(b<185.0)cnt[5]++;
        else if(b>=185.0)cnt[6]++;
    }
    for(int i=1;i<=6;i++){
        cout<<i<<":";
        for(int j=0;j<cnt[i];j++)cout<<"*";
        cout<<endl;
    }




	return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

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

    if(c <= a + b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {

  int a, b, c;
  cin >> a >> b >> c;
  bool can = false;

  if(a == 7 && b == 5 && c == 5) can = true;
  if(a == 5 && b == 7 && c == 5) can = true;
  if(a == 5 && b == 5 && c == 7) can = true;

  if(can) cout << "YES";
  else cout << "NO";


  
}



Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define SREP(s,i,m) for(unsigned int i = s; i < m; ++i)
#define REP(i,m) SREP(0,i,m)

using namespace std;
#ifdef _MSC_VER
using LONG = __int64;
#else
using LONG = long long int;
#endif


int main(void) {
  int gcount = 0;
  string S;
  string P;
  cin >> S;
  P.resize(S.size());
  int needG = (S.size() + 1) / 2;
  REP(i, S.size()) {
    if (S[i] == 'g') {
      gcount++;
    }
  }
  cout << (gcount - needG) << endl;
  return 0;
}

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


int main()
{
  int h,w,n;
  int maps[1001][1001];
  int cnts[1001][1001];
  for(;cin>>h>>w>>n,h;)
    {
      memset(cnts,0,sizeof(cnts));
      cnts[0][0]=n-1;
      for(int i=0;i<h;i++)
	for(int j=0;j<w;j++)
	  {
	    cin>>maps[i][j];
	    if(i>0)
	      {
		cnts[i][j]+=cnts[i-1][j]/2;
		if(maps[i-1][j]==0)
		  cnts[i][j]+=(cnts[i-1][j]%2);
	      }
	    if(j>0)
	      {
		cnts[i][j]+=cnts[i][j-1]/2;
		if(maps[i][j-1]==1)
		  cnts[i][j]+=(cnts[i][j-1]%2);
	      }
	  }
      for(int i=0;i<h;i++)
	for(int j=0;j<w;j++)
	  {
	    //   cout<<cnts[i][j]<<" ";
	    if(maps[i][j]==0 && (cnts[i][j]%2)!=0)
	      maps[i][j]=1;
	    else if(maps[i][j]==1 && (cnts[i][j]%2)!=0)
	      maps[i][j]=0;
	  }
      int i=0;
      int j=0;
      while(true)
	{
	  if(i>=h || j>=w)
	    {
	      cout<<i+1<<" "<<j+1<<endl;
	      break;
	    }
	  if(maps[i][j]==0)
	    i++;
	  else
	    j++;
	}
    }
}

Measured memory_bytes: 8992
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    string s;
    cin >> n >> s;
    int a = 0;
    rep(i, s.size())
    {
        if (s[i] == '#')
        {
            a++;
        }
    }
    int ans = a;
    for (int i = n - 1; i >= 0; i--)
    {
        if (s[i] == '#')
        {
            a--;
        }
        else
            a++;
        ans = min(a, ans);
        // cerr << s[i] << "," << ans << endl;
    }
    cout << ans << endl;
    return 0;
}


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

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

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> field(H);
    rep(i, H) cin >> field[i];

    vector<vector<int>> dist(H, vector<int>(W, -1));
    vector<vector<P>> prev(H, vector<P>(W));

    int sy, sx = 0;
    queue<P> que;
    que.push(P(sy, sx));
    dist[sy][sx] = 0;
    prev[0][0] = P(-1, -1);
    while (!que.empty())
    {
        int y, x;
        tie(y, x) = que.front();
        que.pop();

        int ny, nx;
        for (int i = 0; i < 4; i++)
        {
            ny = dy[i] + y;
            nx = dx[i] + x;

            if (ny < 0 || ny >= H || nx < 0 || nx >= W || field[ny][nx] == '#')
                continue;

            if (dist[ny][nx] == -1)
            {
                dist[ny][nx] = dist[y][x] + 1;
                que.push(P(ny, nx));
                prev[ny][nx] = P(y, x);
            }
        }
    }

    int y = H - 1;
    int x = W - 1;
    vector<P> short_root;
    while (y != -1 && x != -1)
    {
        P d = prev[y][x];
        short_root.push_back(d);
        tie(y, x) = prev[y][x];
    }

    // for (int y = 0; y < H; y++)
    // {
    //     for (int x = 0; x < W; x++)
    //     {
    //         cout << dist[y][x] << " ";
    //     }
    //     cout << endl;
    // }

    // for (P d : short_root)
    // {
    //     int y, x;
    //     tie(y, x) = d;
    //     cout << "(y, x): " << y << " " << x << endl;
    // }

    int ans = 0;
    for (int y = 0; y < H; y++)
    {
        for (int x = 0; x < W; x++)
        {
            if (field[y][x] != '#')
            {
                bool ok = true;
                for (P d : short_root)
                {
                    int ng_y, ng_x;
                    tie(ng_y, ng_x) = d;
                    if (ng_y == y && ng_x == x)
                    {
                        ok = false;
                        break;
                    }
                }
                if (ok)
                    ans++;
            }
        }
    }
    if (dist[H - 1][W - 1] == -1)
    {
        cout << -1 << endl;
    }
    else
    {

        cout << ans - 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256