akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<ll, ll>
const ll  MOD = 1000000007;

int main() {
	ll n;
	string s;
	cin >> n >> s;
	vector<ll> r, g, b;
	rep(i, n) {
		if (s.at(i) == 'R') r.push_back(i);
		else if (s.at(i) == 'G') g.push_back(i);
		else b.push_back(i);
	}
	if (r.empty() || g.empty() || b.empty()) {
		cout << 0;
		return 0;
	}
	ll ans = r.size() * g.size() * b.size();
	for (auto i : r) {
		for (auto j : g) {
			ll x = max(i, j);
			ll y = min(i, j);
			if (binary_search(all(b), y - (x - y))) ans--;
			if (binary_search(all(b), x + (x - y))) ans--;
			if ((x - y) % 2 == 0) {
				if (binary_search(all(b), y + (x - y) / 2)) ans--;
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3708
N = int(input())
A = list(map(int, input().split()))

for k in range(N):
    if k == N - 1:
        print(str(A[k]))
    else:    
        print(str(A[k]) + " ", end="")

for i in range(1, N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j + 1] = A[j]
        j -= 1
    A[j+1] = v
    for k in range(N):
        if k == N - 1:
            print(str(A[k]))
        else:    
            print(str(A[k]) + " ", end="")
            

Measured memory_bytes: 7960
# frozen_string_literal: true

n, k = gets.split.map(&:to_i)
scaffs = gets.split.map(&:to_i)

costs = Array.new(n, Float::INFINITY)
costs[0] = 0

(0...n - 1).each do |i|
  (i+1..[i + k, n - 1].min).each do |j|
    cost = costs[i] + (scaffs[i] - scaffs[j]).abs
    costs[j] = cost if costs[j] > cost
  end
end

puts costs.last


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

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

  vector<ll> A(N);
  rep(i, N) cin >> A.at(i);
  sort(A.begin(), A.end());

  ll l = -1e18 - 1;
  ll r = 1e18 + 1;
  while (r - l > 1) {
    ll mid = (l + r) / 2;
    ll sum = 0;
    rep(i, N) {
      if (A.at(i) > 0) sum += lower_bound(A.begin(), A.end(), (long double) mid / A.at(i)) - A.begin();
      if (A.at(i) < 0) sum += N - (upper_bound(A.begin(), A.end(), (long double) mid / A.at(i)) - A.begin());
      if (A.at(i) == 0) {
        if (mid > 0) sum += N;
      }
      if (A.at(i) * A.at(i) < mid) sum--;
    }
    if (sum / 2 < K) {
      l = mid;
    } else {
      r = mid;
    }
  }
  cout << l << endl;
  return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
  int time, n, start, finish;
  while (cin >> time, time) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> start >> finish;
      time -= finish - start;
    }
    if (time > 0)
      cout << time << endl;
    else
      cout << "OK" << endl;
  }
  return 0;
}

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

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

  vector<vector<int>> a(N, vector<int>(D));

  for(int i = 0; i < N; i++){
    for(int j = 0; j < D; j++){
      cin >> a.at(i).at(j);
    }
  }

  int ans = 0;

  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      int sum = 0;
      for(int k = 0; k < D; k++){
        sum += (a.at(i).at(k) - a.at(j).at(k)) * (a.at(i).at(k) - a.at(j).at(k));
      }

      int b = 1;

      while(b * b <= sum){
        if(b * b == sum){
          ans++;
        }
        b++;
      }
    }
  }

  cout << ans << endl;

  
}

Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	ll x, y; cin >> x >> y;
	if (abs(x - y) <= 1)cout << "Brown" << endl;
	else cout << "Alice" << endl;
}

Measured memory_bytes: 256
d['ZZ'],W,N,w,c,j,a;main(t){for(;scanf("%d%d",&W,&N),W;printf("Case %d:\n%d\n%d\n",t++,d[W],a))for(bzero(d,4004);N--;)for(j=W+scanf("%d,%d",&c,&w);j-->w;)d[j]=fmax(d[j],d[j-w]+c),a=d[j]-d[W]?a:j;}

Measured memory_bytes: 0
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
  	int N;
    cin >> N;
    int d[N];
    for(int i=0;i<N;i++) cin >> d[i];

    sort(d, d+N);

    cout << d[N/2]-d[N/2-1] <<endl;
    
  	return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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

	n = 2 * n;
	ll s = 0;

	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}

	sort(a.begin(), a.end());

	for (int i = 0; i < n; i++)
	{
		if (i % 2 == 0)
		{
			s += a.at(i);
		}
	}

	cout << s << endl;
}

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

//#define DEBUG

using namespace std;

template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}


void func_to_create(){    
    uint32_t N, M ;
    cin >> N >> M;
    std::vector<std::vector<int>> passage(N);
    std::vector<uint32_t> ans(N, 0);
    std::vector<bool> visit(N, false);
    visit[0] = true;
    uint32_t count_visit = 0;
    std::vector<uint32_t> current_seed;
    for(uint32_t i = 0 ; i < M ; i++){
        uint32_t A, B;
        cin >> A >> B;
        passage[A - 1].push_back(B);
        passage[B-1].push_back(A);
        if(A == 1){
            ans[B -1 ] = 1;
            current_seed.push_back(B);
            visit[B-1] = true;
        }else if (B  == 1){
            ans[A - 1] = 1;
            current_seed.push_back(A);
            visit[A -1] = true;
        }
    }
    while(true){
        // cout << "current seed ";
        // print_vect(current_seed);
        std::vector<uint32_t> next_seed;
        for(const auto &  seed : current_seed){
            for(const auto & city : passage[seed-1]){
                if(visit[city - 1] == false){
                    visit[city - 1] = true;
                    next_seed.push_back(city);
                    ans[city -1] = seed;
                }
            }
        }
        if(next_seed.size() == 0){
            break;
        }
        current_seed = next_seed;
    }

    for(uint32_t i = 0 ; i < visit.size() ; i++){
        count_visit += visit[i];
    }

    if(count_visit == N){
        cout << "Yes" << endl;
        for(uint32_t i = 1 ; i < N ; i++){
            cout << ans[i] << endl;
        }
    }else{
        cout << "No" << endl;
    }
    

}
int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    func_to_create();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}


Measured memory_bytes: 10600
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int>>
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long>>
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int t[SIZE],v[SIZE],a[SIZE],m;
template <class T>
void maa(T& x,T y){
  if(x<y)x=y;
}
template <class T>
void mii(T& x,T y){
  if(x>y)x=y;
}
int main(){
  DRI(N);
  REP(i,N){
    RI(t[i]);
    t[i]*=2;
  }
  REP(i,N){
    RI(v[i]);
    v[i]*=2;
  }
  REP(i,SIZE)a[i]=MOD;
  int it=0;
  a[0]=0;
  REP(i,N){
    mii(a[it],v[i]);
    REP(j,t[i]){
      it++;
      mii(a[it],v[i]);
    }
//    cout<<i<<","<<it<<endl;
  }
//  cout<<it<<endl;
  mii(a[it],0);
  REPP(i,1,it+1) {
//    if(i==140)cout<<a[i]<<","<<a[i-1]+1<<endl;
    mii(a[i],a[i-1]+1);
  }
  for(int i=it-1;i>=0;i--) {
//    if(i==140)cout<<a[i]<<","<<a[i+1]+1<<endl;
    mii(a[i],a[i+1]+1);
  }
  
//  REPP(i,0,it+1) cout<<i<<","<<a[i]<<endl;
  
  LL an=0;
  REP(i,it){
    an+=(a[i]+a[i+1]);
  }
  printf("%.12f\n",an*0.125);
  return 0;
}


Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n=0,i;
    string s;
    cin>>s;
    for(i=0;i<4;i++)
    {
        if(s[i]=='+')
            n++;
        else
            n--;
    }
    cout<<n<<endl;

    return 0;
}


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

namespace Codeforces
{
	internal class Template
	{
		private void Solve()
		{
			var list = new List<int>();
			for (var i = 0; i < 3; i++)
			{
				list.Add(cin.NextInt());
			}
			list.Sort();
			var count = 0;
			var visited = new HashSet<Tuple<int, int, int>>();
			visited.Add(Tuple.Create(list[0], list[1], list[2]));
			while (list.All(x => x%2 == 0))
			{
				count++;
				var newList = new List<int>();
				newList.Add(list[1]/2 + list[2]/2);
				newList.Add(list[0]/2 + list[2]/2);
				newList.Add(list[0]/2 + list[1]/2);
				newList.Sort();
				var key = Tuple.Create(newList[0], newList[1], newList[2]);
				if (visited.Contains(key))
				{
					Console.WriteLine(-1);
					return;
				}
				visited.Add(key);
				list = newList;
			}
			Console.WriteLine(count);
		}

		private static readonly Scanner cin = new Scanner();

		private static void Main()
		{
#if DEBUG
			var inputText = File.ReadAllText(@"..\..\input.txt");
			var testCases = inputText.Split(new[] { "input" }, StringSplitOptions.RemoveEmptyEntries);
			var consoleOut = Console.Out;
			for (var i = 0; i < testCases.Length; i++)
			{
				var parts = testCases[i].Split(new[] { "output" }, StringSplitOptions.RemoveEmptyEntries);
				Console.SetIn(new StringReader(parts[0].Trim()));
				var stringWriter = new StringWriter();
				Console.SetOut(stringWriter);
				var sw = Stopwatch.StartNew();
				new Template().Solve();
				sw.Stop();
				var output = stringWriter.ToString();

				Console.SetOut(consoleOut);
				var color = ConsoleColor.Green;
				var status = "Passed";
				if (parts[1].Trim() != output.Trim())
				{
					color = ConsoleColor.Red;
					status = "Failed";
				}
				Console.ForegroundColor = color;
				Console.WriteLine("Test {0} {1} in {2}ms", i + 1, status, sw.ElapsedMilliseconds);
			}
			Console.ReadLine();
			Console.ReadKey();
#else
			new Template().Solve();
			Console.ReadLine();
#endif
		}
	}

	internal class Scanner
	{
		private string[] s = new string[0];
		private int i;
		private readonly char[] cs = { ' ' };

		public string NextString()
		{
			if (i < s.Length) return s[i++];
			var line = Console.ReadLine() ?? string.Empty;
			s = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			i = 1;
			return s.First();
		}

		public double NextDouble()
		{
			return double.Parse(NextString());
		}

		public int NextInt()
		{
			return int.Parse(NextString());
		}

		public long NextLong()
		{
			return long.Parse(NextString());
		}
	}
}

Measured memory_bytes: 13524
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define int long long
using namespace std;

typedef pair<int, int> Pii;

void readline(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readline(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}

signed main(){

    int N;
    cin >> N;
    vector<int> A(N);
    readline(N, A);

    int l = 0, r = -1;
    int sumv = 0, xorv = 0;
    int ans = 0;

    for(l = 0; l < N; l++){
        if(r < l){
            r = l;
            sumv += A[l];
            xorv ^= A[l];
        }
        while(r < N - 1 && sumv + A[r + 1] == (xorv ^ A[r + 1])){
            sumv += A[r + 1];
            xorv ^= A[r + 1];
            r++;
        }
        ans += r - l + 1;
        sumv -= A[l];
        xorv ^= A[l];
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[3];
  a[0]=n/100;
  a[1]=(n-a[0]*100)/10;
  a[2]=n%10;
  for(int i=0;i<3;i++){
    if(a[i]==9)a[i]=1;
    else if(a[i]==1)a[i]=9;
    cout<<a[i];
  }
  cout<<endl;
}


Measured memory_bytes: 256
#include<iostream>  
 
using namespace std;  
   
char farm[100][100];  
int W, H;  
const int direction[4][2] = {  
  { -1, 0 },  
  { 1, 0 },  
  { 0, -1 },  
  { 0, 1 }
};  
   
void dfs(int x, int y, char tree)  
{  
  farm[x][y] = 'x';  
  for (int i = 0; i < 4; ++i)  
  {  
    int nx = x + direction[i][0];  
    int ny = y + direction[i][1];  
    if (nx >= 0 && nx < W && ny >= 0 && ny < H && farm[nx][ny] == tree)  
    {  
      dfs(nx, ny, tree);  
    }  
  }  
}  
   
int main()  
{  
   
  while (cin >> H >> W, W > 0)  
  {  
    int res = 0;  
    int x, y;  
    for (y = 0; y < H; ++y)  
    {  
      for (x = 0; x < W; ++x)  
      {  
        cin >> farm[x][y];  
      }  
    }  
   
    for (y = 0; y < H; ++y)  
    {  
      for (x = 0; x < W; ++x)  
      {  
        if (farm[x][y] != 'x')  
        {  
          dfs(x, y, farm[x][y]);  
          ++res;  
        }  
      }  
    }  
    cout << res << endl;  
  }  
  return 0;  
} 

Measured memory_bytes: 3464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, m;
	cin >> n >> m;
	print(n*(n-1)/2+m*(m-1)/2)
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<long long> oldpool,newpool;
long long a[1010],qzh[1010];
int n,k;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		qzh[i]=qzh[i-1]+a[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j++){
			oldpool.push_back(qzh[j]-qzh[i-1]);
		}
	}
	long long ret=0;
	newpool.clear();
	for(int bit=60;bit>=0;bit--){
		newpool.clear();
		for(int i=0;i<oldpool.size();i++){
			if((oldpool[i]>>bit)&1){
				newpool.push_back(oldpool[i]);
			}
		}
		if(newpool.size()>=k){
			oldpool=newpool;
			ret+=(1LL<<(bit));
		}
	}
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 6124
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a == b {
		fmt.Println("Draw")
	} else if ( a == 1 && b != 1 ) || ( b != 1 && a > b ) {
		fmt.Println("Alice")
	} else if ( b == 1 && a != 1 ) || ( a != 1 && b > a ) {
		fmt.Println("Bob")
	}
}


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

int main(){
    int n,t;
    cin >> n >> t;
    vector<pair<int,int>> a(n);
    for(int i=0;i<n;i++){
        cin >> a.at(i).first >>a.at(i).second;
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        if(a.at(i).second<=t){
            cout << a.at(i).first <<endl;
            return 0;
        }
    }
    cout << "TLE" << endl;
}

Measured memory_bytes: 256
class uf_tree():

    def __init__(self,n):
        self.n = n
        self.par = [i for i in range(n)]

    def indep(self):
        dep =0
        for i in range(self.n):
            if i == self.par[i]:
                dep += 1

        return dep

    def unite(self,child,mas):
        if self.root(child) == self.root(mas):
            return
        else:
            self.par[self.root(child)] = self.root(mas)

    def root(self,i):
        if self.par[i] == i:
            return i
        else:
            self.par[i] = self.root(self.par[i])
            return self.par[i]

    def same(self,x,y):
        if self.root(x) == self.root(y):
            return True
        else:
            return False
n,m = map(int,input().split())
arr = [[0 for i in range(n)] for j in range(n)]
e = set()
ans = 0
for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    e.add((a,b))

for el in e:
    tree = uf_tree(n)
    for key in e:
        if key != el:
            tree.unite(key[0],key[1])
    if tree.indep() > 1:
        ans += 1

print(ans)








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


int main() {
    int N;
    cin >> N;
    ll ninf = (ll)1e16 * (-1);
    vector<ll> A(N+1);
    for (int i = 1; i <= N; i++) cin >> A[i];
    
    vector<ll> oddsum(N+1, 0), evensum(N+1, 0), allsum(N+1, 0);
    for (int i = 1; i <= N; i++) {
        oddsum[i] = oddsum[i-1];
        evensum[i] = evensum[i-1];
        allsum[i] = allsum[i-1];
        allsum[i] += A[i];
        if (i%2 == 1) oddsum[i] += A[i];
        else evensum[i] += A[i];
    }
    
    if (N%2 == 0) {
        ll ans = ninf;
        for (int i = 0; i <= N; i += 2) {
            ans = max(ans, oddsum[i] + evensum[N] - evensum[i]);
        }
        cout << ans << endl;
        return 0;
    }
    
    if (N%2 == 1) {
        ll ans = oddsum[N]-A[1];
        ll mi = 0;
        for (int i = 1; i <= N; i+=2) {
            ll rg = evensum[i] - oddsum[i];
            ans = max(ans, oddsum[N]+rg-mi);
            if (i < N) mi = min(mi, evensum[i+1]-oddsum[i+1]);
        }
        cout << ans << endl;
        return 0;
    }
    
    return 0;
}

Measured memory_bytes: 9596
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

ll N, M;
ll a[1010], b[1010];
vector<ll> c[1010];
ll dp[1010][10000];

int main() {
  cin >> N >> M;
  rep(i, 0, M) {
    cin >> a[i] >> b[i];
    c[i].resize(b[i]);
    rep(j, 0, b[i]) { cin >> c[i][j]; }
  }

  rep(i, 0, 1010) {
    rep(j, 0, (1 << N)) { dp[i][j] = INF; }
  }
  dp[0][0] = 0;

  repe(i, 1, M) {
    ll mask = 0;
    for (auto e : c[i - 1]) {
      mask |= (1 << (e - 1));
    }
    for (ll bit = 0; bit < (1 << N); ++bit) {
      dp[i][bit] = dp[i - 1][bit];
    }
    for (ll bit = 0; bit < (1 << N); ++bit) {
      chmin(dp[i][mask | bit], dp[i - 1][bit] + a[i - 1]);
    }
  }

  ll all = (1 << N) - 1;

  if (dp[M][all] == INF) {
    cout << -1;
  } else {
    cout << dp[M][all];
  }
}


Measured memory_bytes: 40068
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
//const double EPS = 1e(-12);
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

int arr[1010];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);

    ll N;
    cin >> N;

    if (N % 11 == 0)
    {
        cout << (N / 11) * 2 << endl;
    }
    else if (N % 11 <= 6)
    {
        cout << (N / 11) * 2 + 1 << endl;
    }
    else
    {
        cout << (N / 11) * 2 + 2 << endl;
    }

    return 0;
}

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

using namespace std;

int W, H, x, y;
vector<string> map;

void Move(char c)
{
    if (c == 'U') {
        map[y][x] = '^';
        if (y - 1 >= 0 && map[y - 1][x] == '.') {
            swap(map[y][x], map[y - 1][x]);
            --y;
        }
    }
    else if (c == 'D') {
        map[y][x] = 'v';
        if (y + 1 < H && map[y + 1][x] == '.') {
            swap(map[y][x], map[y + 1][x]);
            ++y;
        }
    }
    else if (c == 'L') {
        map[y][x] = '<';
        if (x - 1 >= 0 && map[y][x - 1] == '.') {
            swap(map[y][x], map[y][x - 1]);
            --x;
        }
    }
    else if (c == 'R') {
        map[y][x] = '>';
        if (x + 1 < W && map[y][x + 1] == '.') {
            swap(map[y][x], map[y][x + 1]);
            ++x;
        }
    }
    else if (c == 'S') {
        int dx = 0, dy = 0;
        if (map[y][x] == '^')
            dy = -1;
        else if (map[y][x] == '>')
            dx = 1;
        else if (map[y][x] == 'v')
            dy = 1;
        else if (map[y][x] == '<')
            dx = -1;

        for (int i = 1; ; ++i) {
            if (x + i * dx < 0 || x + i * dx >= W ||
                y + i * dy < 0 || y + i * dy >= H)
                break;
            if (map[y + i * dy][x + i * dx] == '*') {
                map[y + i * dy][x + i * dx] = '.';
                break;
            }
            if (map[y + i * dy][x + i * dx] == '#')
                break;
        }
    }
}

int main()
{
    int T;

    cin >> T;
    while (T--) {
        cin >> H >> W;
        map.assign(H, "");

        for (int i = 0; i < H; ++i)
            cin >> map[i];
        for (int i = 0; i < H; ++i)
            for (int j = 0; j < W; ++j)
                if (map[i][j] == '^' || map[i][j] == '>' ||
                    map[i][j] == 'v' || map[i][j] == '<')
                    x = j, y = i;

        string order;
        int num;

        cin >> num;
        cin >> order;

        for (int i = 0; i < num; ++i)
            Move(order[i]);

        // Output
        for (int i = 0; i < H; ++i)
            cout << map[i] << "\n";
        if (T != 0)
            cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1212
{-# LANGUAGE OverloadedStrings #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import           Data.Char


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

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

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

distance :: Int -> Int -> Int -> Int
distance k from to =
        if from > to then to + k - from
        else to - from

main = do
    n <- readInt
    let i = (fromIntegral n :: Float) / 3
    print $ i * i * i





Measured memory_bytes: 508
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

LL func(LL a,LL b){
    if(a > b){
        LL tmp = a;
        a = b;
        b = tmp;
    }
    LL c = b/a;
    if(b%a == 0){
        return c*a*2-a;
    }else{
        return c*a*2 + func(a,b-a*c);
    }
}

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

    LL N,X;
    cin >> N;
    cin >> X;

    cout << N + func(X,N-X) << endl;
    
    return 0;
}

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

int main() {

int K;
cin >> K;
  
  vector<int> line;
  line =  {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
cout << line.at(K - 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  vector<int> MY(N+1);
  MY.at(0)=0;
  for(int i=1;i<N+1;i++){
    cin >> MY.at(i);
  }
  int count=0;
  for(int i=1;i<N+1;i++){
    if(i!=MY.at(i)){
      count++;
    }
  }
  if(count==0 || count==2){
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ; 
#define int long long
const int MAXN = 2e5 + 100 ; 

int n , cnt[30] , ans , fen[MAXN] , odd ; 
vector<int> pos[30] ; 
bool mark[MAXN] ; 
string s ;

void add(int i , int x)
{
	for( ; i<MAXN ; i+=(i&(-i)))
		fen[i] += x ; 
}
int get(int i)
{
	int res = 0 ; 
	for(; i>0 ; i-=(i&(-i)))
		res += fen[i] ; 
	return res ; 
}

int32_t main()
{
	cin >> s ; 
	n = s.size() ; 
	s = '#' + s ; 
	for(int i=1 ; i<=n ; i++)
	{
		int x = s[i] - 'a' ; 
		cnt[x] ++ ; 
		pos[x].push_back(i) ;  
		add(i , 1) ; 
	}
	for(int i=0 ; i<30 ; i++)
		odd += (cnt[i]%2) ; 
	if(odd > 1)
		return cout << "-1" , 0 ; 
	for(int i=1 ; i<=n ; i++)
	{
		if(mark[i] == 0)
		{
			int x = s[i] - 'a' ; 
			int match = pos[x].back() ; 
			pos[x].pop_back() ;  
			if(i == match)
			{
				ans += (get(n)-1)/2  ; 
				add(i , -1) ;  
				mark[i] = 1 ; 
			}
			else
			{
				ans += get(n) - get(match) ; 
				add(i , -1) ; 
				add(match , -1) ; 
				mark[i] = mark[match] = 1 ; 
			}
		}
	}
	
	cout << ans << endl ; 
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int x, t;
    cin >> x >> t;
    cout << max(x - t, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 


int main(){

	long long a,b,c;
	cin>>a>>b>>c;

	long long res=0;
	set<vector<long long> > s;
	while(a%2==0 && b%2==0 && c%2==0){
		vector<long long> v={a,b,c};
		sort(v.begin(),v.end());
		if(s.find(v)!=s.end()){
			cout<<-1<<endl;
			return 0;
		}else{
			s.insert(v);
		}

		res++;
		long long na=b/2+c/2,nb=a/2+c/2,nc=a/2+b/2;
		a=na,b=nb,nc=c;
	}

	cout<<res<<endl;

	return 0;
}

Measured memory_bytes: 764
#include <iostream>

using namespace std;

int main(void){

  int n;
  cin >> n;
  while(n--){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    double ans = 0;
    ans = a * c + b * d;
    if(c >= 5 && d >= 2){
      cout << ans * 0.8 << endl;
    }else if(c >= 5 && d < 2){
      d = 2;
      cout << min(ans, (a * c + b * d)* 0.8) << endl;
    }else if(c < 5 && d >= 2){
      c = 5;
      cout << min(ans, (a * c + b * d)* 0.8) << endl;
    }else cout << (int)ans << endl;

  }

  return 0;
}

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

int main(){

    int n; cin >> n;
    vector<vector<char> > s(n, vector<char> (n));
    vector<vector<char> > t(n, vector<char> (n));    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> s[i][j];
            t[i][j] = s[i][j];
        }
    }

    int ans = 0;
    for(int k = 0; k < n; k++){
        
        vector<char> temp(n);
        for(int j = 0; j < n; j++) temp[j] = t[0][j]; 
        //t
        for(int i = 0; i < n - 1; i++){
            for(int j = 0; j < n; j++){
                t[i][j] = t[i + 1][j];
            }
        }
        for(int j = 0; j < n; j++) t[n-1][j] = temp[j];
    
        /*for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                cout << t[i][j];
            }
            cout << endl;
        }*/

        bool flag = true;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(t[i][j] != t[j][i]){
                    flag = false;
                    break;
                }
            }
        }

        if(flag) ans += n;
    }

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

Measured memory_bytes: 512
n,m = map(int,input().split())
graph = [[]for i in range(n)]


for i in range(m):
    a,b = map(int,input().split())
    a -=1
    b-=1
    graph[a].append(b)
    graph[b].append(a)
def all_visited(l):
    a = 0
    for i in range(n):
        if l[i]:
            a+=1
    if a == n:
        return 1
    else: return 0
def dfs(now):

    ans = 0
    visited[now] = 1
  
    if all_visited(visited):
        
        return 1
    for next in graph[now]:
        if visited[next]:continue
        ans += dfs(next)
        visited[next] =0
    return ans
visited = [0]*n
print(dfs(0))

Measured memory_bytes: 3064
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back
// const ll mod = 1000000007;
const ll mod = 998244353;

void sayNo() {
	cout << "No" << endl;
}

void sayYes() {
	cout << "Yes" << endl;
}

vector< ll > divisor(ll n) {
	vector< ll > ret;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	// sort(begin(ret), end(ret));
	return (ret);
}


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

	// N = 2 * 10e5;
	// K = 10e12;

	vi A(N, 0);
	map<int, vi> idx;

	for (int i = 0; i < N; i++) {
		cin >> A[i];
		idx[A[i]].pb(i);
	}

	vi y(N);
	for (auto id : idx) {
		auto list = id.second;
		int s = list.size();
		list.pb(list[0] + N);
		for (int i = 0; i < s; i++) {
			y[list[i]] = list[i + 1] - list[i] + 1;
		}
	}

	// unordered_map<ll, ll> map;

	vvi G{ y };
	const ll inf = numeric_limits<long long>::max() / 3;
	// vector<vector<ll>> G(lgNK + 1, vector<ll>(N, 0));
	

	/*
	for (auto g : G[0]) {
		cout << g << " ";
	}
	cout << endl;
	// */

	ll lgNK = 60;
	// cout << lgNK << endl;
	for (ll k = 0; k < lgNK; k++) {
		vi &x = G.back();
		vi newY(N);

		// cout << k << endl;
		for (ll i = 0; i < N; i++) {
			newY[i] = min(inf, x[i] + x[(i + x[i]) % N]);
		}
		G.pb(newY);
	}

	ll pos = 0;
	// cout << "pos: 0" << endl;
	for (ll k = lgNK; k >= 0; k--) {
		ll newPos = pos + G[k][pos % N];
		if (newPos < N * K) {
			pos = newPos;
			// cout << " -> " << pos << " (+" << G[k][pos % N] << ")" << endl;
		}
		else {
			// cout << " ---------------------- " << endl;
		}
	}
	// cout << endl;


	vi s;
	set<ll> has;
	for (ll i = pos % N; i < N; i++) {
		if (has.count(A[i])) {
			while (1) {
				ll v = s.back();
				s.pop_back();
				has.erase(v);
				if (v == A[i])
					break;
			}
		}
		else {
			s.pb(A[i]);
			has.insert(A[i]);
		}
	}

	for (auto a : s) {
		cout << a << " ";
	}
	cout << endl;

	return 0;
}

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

int main() {
  int count=0;
  int N,M,X,Y;
  cin>>N>>M>>X>>Y;
  vector<int>Xi(N);
  vector<int>Yi(M);
  rep(i,N){
    cin>>Xi[i];
  }
  rep(i,M){
    cin>>Yi[i];
  }
  Xi.push_back(X);
  Yi.push_back(Y);
  sort(Xi.begin(),Xi.end());
  sort(Yi.begin(),Yi.end());
  if((Yi[0]-Xi[N])<1){
  cout<<"War";
  }
  else cout<<"No War";
}


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

 
int main()
{
 int n;
 cin>>n;
 string s;
 cin>>s;
 string a=s;
 sort(a.begin(),a.end());
 int cal1=0,cal2=0,cal3=0;
 for(int i=0;i<n;i++)
 {
     if(a[i]=='R'){cal1++;}
     if(a[i]=='W'){cal2++;}
     if(a[i]!=s[i]){cal3++;}
 }
 cout<<min(n-cal1,min(n-cal2,cal3/2));
 return 0;
}

Measured memory_bytes: 3924
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		long N = GetLong();
		long[] A = Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();

		long sumA = A.Sum();
		long part = (N * (N + 1)) / 2;
		if(sumA % part != 0)
		{
			Console.WriteLine("NO");
			return;
		}		
		long K = sumA / part;

		for(int i = 0; i < N; i++)
		{
			long d = A[(i + 1) % (int)N] - A[i];
			if(d > K || ((K - d) % N) != 0)
			{
				Console.WriteLine("NO");
				return;
			}
		}

		Console.WriteLine("YES");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 26848
#include <bits/stdc++.h>
//#include <boost/array.hpp>
//#include <boost/range/numeric.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/multiprecision/cpp_int.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
//using namespace boost::multiprecision;

constexpr long long INF = LLONG_MAX;
constexpr long long MOD = 1000000007;
constexpr long double PI = M_PI;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define CALL(x) x.cbegin(),x.cend()
#define RALL(x) x.rbegin(),x.rend()
#define CRALL(x) x.crbegin(),x.crend()

#define cout cout << fixed << setprecision(12)
#define dbglf cerr << '\n'

#define ACCM(arr) accumulate(ALL(arr),0LL)
#define Yes(ex) cout << ((ex) ? "Yes" : "No") << endl
#define YES(ex) cout << ((ex) ? "YES" : "NO") << endl

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void veccin(vector<T>& v) {
    for (auto && e : v) { cin >> e; }
}

template < typename T >
inline void dbg(T a) { cerr << a << ' '; }

ll n, m, k;
ll ans = 0, sum = 0, cnt = 0;
//ld d;
string s/*1, s2, s3*/;
char c/*1, c2, c3*/;
bool flag = false;

/*--------------------template--------------------*/

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

    cin >> n;

    cout << (ld)n *2.0*PI << endl;
}


Measured memory_bytes: 3780
#include<bits/stdc++.h>
    using namespace std;
     
    int mi[4]={-1,0,1,0};
    int mj[4]={0,-1,0,1};
     
    int main()
    {
      int H,W;scanf("%d %d",&H,&W);
      char S[H][W];string ans="Yes";  
      bool check[H][W];for(int i=0;i<H;i++)fill(check[i],check[i]+W,false);
      for(int i=0;i<H;i++)for(int j=0;j<W;j++)cin>>S[i][j];
      for(int i=0;i<H;i++)for(int j=0;j<W;j++)
      {
        if(check[i][j]||S[i][j]=='.')continue;
        queue<pair<int,int>> que;
        que.push({i,j});
        int count=1;
        while(!que.empty())
        {
          int I=que.front().first,J=que.front().second;que.pop();
          for(int k=0;k<4;k++)
          {
            int mI=I+mi[k],mJ=J+mj[k];
            if(mI<0||mI>H-1||mJ<0||mJ>W-1)continue;
            if(S[mI][mJ]=='.'||check[mI][mJ])continue;
            check[mI][mJ]=true;count++;
            que.push({mI,mJ});
          }
        }
        if(count==1)ans="No";
      }
      cout<<ans<<endl;
    }

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define MAX 2100000
#define INF 1001000000
using Graph=vector<vector<int>>;

pair<double,double> solve_matrix(vector<vector<double>> a,vector<double> b){
  double det=a.at(0).at(0)*a.at(1).at(1)-a.at(1).at(0)*a.at(0).at(1);
  double x=(a.at(1).at(1)*b.at(0)-a.at(0).at(1)*b.at(1))/det;
  double y=(-a.at(1).at(0)*b.at(0)+a.at(0).at(0)*b.at(1))/det;
  return make_pair(x,y);
}

pair<double,double> solve_center(double x1,double y1,double x2,double y2,double x3,double y3){
  vector<vector<double>> a(2,vector<double>(2));
  vector<double> b(2);
  a.at(0).at(0)=2.0*(x2-x1);
  a.at(0).at(1)=2.0*(y2-y1);
  a.at(1).at(0)=2.0*(x3-x1);
  a.at(1).at(1)=2.0*(y3-y1);
  b.at(0)=x2*x2+y2*y2-x1*x1-y1*y1;
  b.at(1)=x3*x3+y3*y3-x1*x1-y1*y1;
  return solve_matrix(a,b);
}

double distance(double x1,double y1,double x2,double y2){
  return sqrtl((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

int main(){
  int N;
  cin>>N;
  vector<int> x(N),y(N);
  for(int i=0;i<N;i++){
    cin>>x.at(i)>>y.at(i);
  }
  if(N==2){
    double ans=distance(x.at(0),y.at(0),x.at(1),y.at(1))/2.0;
    printf("%.7lf\n",ans);
    return 0;
  }
  double delta=1.0e-7;
  vector<double> X,Y;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      X.push_back((x.at(i)+x.at(j))/2.0);
      Y.push_back((y.at(i)+y.at(j))/2.0);
      for(int k=j+1;k<N;k++){
        if((x.at(k)-x.at(i))*(y.at(j)-y.at(i))==(x.at(j)-x.at(i))*(y.at(k)-y.at(i))){
          continue;
        }else{
          pair<double,double> p=solve_center(x.at(i),y.at(i),x.at(j),y.at(j),x.at(k),y.at(k));
          X.push_back(p.first);
          Y.push_back(p.second);
        }
      }
    }
  }
  int n=X.size();

  double small=0.0;
  double large=1000.0;
  while(small+delta<large){
    double z=(small+large)/2.0;
    bool flag=false;
    for(int i=0;i<n;i++){
      bool sub=true;
      for(int j=0;j<N;j++){
        if(distance(X.at(i),Y.at(i),x.at(j),y.at(j))>z){
          sub=false;
          break;
        }
      }
      flag=sub||flag;
    }
    if(flag){
      large=z;
    }else{
      small=z;
    }
  }

  printf("%.7lf\n",small);
}


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

int main() {
  int n;
  string tmp;
  cin >> n;
  vector<int> c(4, 0);
  rep(i, n) {
    cin >> tmp;
    if(tmp == "AC") c[0]++;
    if(tmp == "WA") c[1]++;
    if(tmp == "TLE") c[2]++;
    if(tmp == "RE") c[3]++;
  }
  cout << "AC x " << c[0] << endl;
  cout << "WA x " << c[1] << endl;
  cout << "TLE x " << c[2] << endl;
  cout << "RE x " << c[3] << endl;
  return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
using namespace std;


int main(){
  int a, b;
  cin >> a >> b;
  if( a > b ) cout << "a > b" << endl;
  else if( a < b ) cout << "a < b" << endl;
  else cout << "a == b" << endl;
  return 0;
}








// EOF

Measured memory_bytes: 3080
package main

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

const (
	maxBufSize = 1024 * 1024
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, 1)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	out = bufio.NewWriter(os.Stdout)
)

const yes = "Yes"
const no = "No"

func solve(n int64, m int64, as []int) bool {
	sum := int(0)
	for _, a := range as {
		sum += a
	}
	sort.Ints(as)
	return  as[n - m] * (4 * int(m)) >= sum
}

func main() {
	defer out.Flush()

	n := nextInt()
	m := nextInt()
	as := nextInts(int(n))
	if solve(n, m, as) {
		fmt.Fprintln(out, yes)
	} else {
		fmt.Fprintln(out, no)
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextStringAsBytes() []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := int(0); i < n; i++ {
		ret[i] = int(nextInt())
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


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

#define ll long long
#define eb emplace_back
#define fi first
#define se second

using namespace std;

const int nm = 200002;

struct rec {
	int k;
	ll l, r;
};

int n;
rec a[nm];
int nb, nc;
rec b[nm], c[nm];

bool cmp(rec &a, rec &b) {
	if (a.k != b.k) {
		return a.k < b.k;
	}
	return a.l - a.r > b.l - b.r;
}

bool cmp2(rec &a, rec &b) {
	if (a.k != b.k) {
		return a.k > b.k;
	}
	return a.r - a.l > b.r - b.l;
}

void solve() {
	scanf("%d", &n);
	ll res = 0;
	nb = nc = 0;
	for (int i = 1; i <= n; ++i) {
		scanf("%d%lld%lld", &a[i].k, &a[i].l, &a[i].r);
		if (a[i].l > a[i].r) {
			b[++nb] = a[i];
		} else if (a[i].l < a[i].r) {
			c[++nc] = a[i];
		} else {
			res += a[i].l;
		}
	}
	sort(b + 1, b + nb + 1, cmp);
	priority_queue<ll, vector<ll>, greater<ll>> cur;
	for (int i = 1; i <= nb; ++i) {
		if (cur.size() + 1 <= b[i].k) {
			res += b[i].l;
			cur.emplace(b[i].l - b[i].r);
		} else if (cur.size() == b[i].k && b[i].l - b[i].r > cur.top()) {
			res = res - cur.top() + b[i].l;
			cur.pop();
			cur.emplace(b[i].l - b[i].r);
		} else {
			res += b[i].r;
		}
	}
	sort(c + 1, c + nc + 1, cmp2);
	priority_queue<ll, vector<ll>, greater<ll>> cur2;
	for (int i = 1; i <= nc; ++i) {
		if (n - cur2.size() > c[i].k) {
			res += c[i].r;
			cur2.emplace(c[i].r - c[i].l);
		} else if (cur2.size() && n - cur2.size() == c[i].k && c[i].r - c[i].l > cur2.top()) {
			res = res - cur2.top() + c[i].r;
			cur2.pop();
			cur2.emplace(c[i].r - c[i].l);
		} else {
			res += c[i].l;
		}
	}
	printf("%lld\n", res);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int t;
	scanf("%d", &t);
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 14972
# -*- coding: utf-8 -*-

def main():
    while True:
        H, W = map(int, input().split())

        if H == 0 and W == 0:
            break

        print("#" * W)
        for i in range(H - 2):
            print("#" + "." * (W - 2) + "#")

        print("#" * W + "\n")

if __name__ == "__main__":
    main()



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


int main()
{
  ll a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;
    
  return 0;
}

Measured memory_bytes: 3636
import java.util.*;

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

        int num;
        num = cin.nextInt();

        String temp;
        HashMap<String, Integer> vote = new HashMap<>();
        for (int i = 0; i < num; i++) {
            temp = cin.next();
            if (vote.containsKey(temp)) {
                vote.put(temp, vote.get(temp) + 1);
            } else {
                vote.put(temp, 1);
            }
        }

        int max = Collections.max(vote.values());

        ArrayList<String> strings = new ArrayList<>();
        for (Map.Entry<String, Integer> entry : vote.entrySet()) {
            if (max == entry.getValue()) {
                strings.add(entry.getKey());
            }
        }

        Collections.sort(strings);

        for (String s: strings) {
            System.out.println(s);
        }
    }
}


Measured memory_bytes: 84908
#include <stdio.h>

int main()
{
  int a,b,c,d,i;

  scanf("%d %d %d",&a,&b,&c);
  
  for(i = a; i <= b; i++)
  {
    if( c % i == 0 )
    {
      d++;
    }
  }
   printf("%d\n",d);
return 0;
}

Measured memory_bytes: 596