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

using namespace std;
#define pb push_back
#define mp make_pair
#define rep(i,a,n) for(int i=(int)a;i<n;i++)

int N, M, R;
int g[205][205];
vector<int> r, idx;

void floyd() {
    rep(k,1,N+1)
        rep(i,1,N+1)
            rep(j,1,N+1)
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
}

int solve() {
    int ans = INT_MAX;
    for (int i = 0; i < R; i++)
        idx.pb(i);
    do {
        int cur = 0;
        for (int i = 0; i < R - 1; i++) {
            cur += g[r[idx[i]]][r[idx[i + 1]]];
        }
        ans = min(ans, cur);
    } while(next_permutation(idx.begin(), idx.end()));
    return ans;
}

int main() {
    cin >> N >> M >> R;
    rep(i,0,R) {
        int t;
        cin >> t;
        r.pb(t);
    }
    memset(g, 0x3f3f3f3f, sizeof g);
    rep(i,0,N) g[i][i] = 0;
    rep(i,0,M) {
        int u, v, c;
        cin >> u >> v >> c;
        g[u][v] = g[v][u] = c;
    }
    
    floyd();
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 384
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
	var N = nextInt();
	if(N == 1){
		myout(0);
		return;
	}
	var s = next();
	var siro = new Array(N).fill(0);
	var kuro = new Array(N).fill(0);
	var output = 10000000;
	for(var i = 0; i < N; i++){
		if(s[i] == "#"){
			kuro[i]++;
		}else{
			siro[i]++;
		}
	}
	for(var i = 1; i < N; i++){
		siro[i] += siro[i - 1];
		kuro[i] += kuro[i - 1];
	}
	var siroMax = siro[N - 1];
	if(siroMax == N || siroMax == 0){
		myout(0);
		return;
	}
	if(s[0] == "#"){
		output = siroMax;
	}
	if(s[N - 1] == "."){
		output = Math.min(output,kuro[N - 1]);
	}
	for(var i = 1; i < N; i++){
		if(s[i - 1] == "." && s[i] == "#"){
			var elaseKuro = kuro[i - 1];
			var elaseSiro = siroMax - siro[i - 1];
			var tmpCount = elaseKuro + elaseSiro;
			//myerr({i,elaseSiro,elaseKuro});
			output = Math.min(output, tmpCount);
		}
	}
	
	
	myout(output);

}

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

int main()
{
	int n = 0;
	cin >> n;
	int S[13] = { 0 }, H[13] = { 0 }, C[13] = { 0 }, D[13] = { 0 }, rank = 0;
	string str;
	for (int i = 0; i < n; i++){
		cin >> str >> rank;
		if      (str == "S") S[rank - 1] = 1;
		else if (str == "H") H[rank - 1] = 1;
		else if (str == "C") C[rank - 1] = 1;
		else                 D[rank - 1] = 1;
	}
	for (int j = 0; j < 13; j++){
		if (S[j] == 0) cout << "S " << j + 1 << endl;
	}
	for (int j = 0; j < 13; j++){
		if (H[j] == 0) cout << "H " << j + 1 << endl;
	}
	for (int j = 0; j < 13; j++){
		if (C[j] == 0) cout << "C " << j + 1 << endl;
	}
	for (int j = 0; j < 13; j++){
		if (D[j] == 0) cout << "D " << j + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

#include "bits/stdc++.h"
using namespace std;

int main() {
	int A, B;
	cin >> A >> B;

	cout << int((double)(B - 1) / (A - 1) + 0.999) << endl;

	return 0;
}


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

#define PI 3.141592653589793238
#define INF 1050000000

using namespace std;



//cout << fixed << setprecision(15) << << endl;
//cout << << endl;

int main() {

	int N;

	cin >> N;

	char a = N % 10 + '0';
	char b = (N / 10) % 10 + '0';
	char c = N / 100 + '0';

	string ans = "ABC";

	ans += c;
	ans += b;
	ans += a;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
MODE = "stdio"

line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = "\
  3 4
  5 6
  3 3
  0 0
  ".split("\n")
  tmp.each{|s|
    line << s.strip
  }
end
r=Array.new
r = line.map{|s|s.split(" ")}

  
r.each{|s| s.map!(&:to_i)}.each do |h,w|
  break if h==0 && w==0
  (1..h).each do |n|
    puts ('#.'*(w/2+1))[1,w] if n.even?
    puts ('.#'*(w/2+1))[1,w] if n.odd?
  end
  puts ""
end

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

#define ONLINE_JUDGE
#define ll long long
#define PI 3.14159265359
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define pb(a) push_back(a)

//////////// Solution /////////////////////////////////

void solve() {
	ll n;
	cin >> n;
	ll sum = 0;
	for (ll i = 1; i*i <= n; ++i) {
		if (n%i==0) {
			ll j = n/i;
			if (i < j-1) {
				sum += j-1;
			}
		}
	}

	cout << sum << '\n';
}


/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 384
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    ll N,r=0,g=0,b=0,ans,i,j,k;
    string S;
    cin>>N>>S;
    for(i=0;i<N;i++){
        if(S[i]=='R')r++;
        if(S[i]=='G')g++;
        if(S[i]=='B')b++;
    }
    ans=r*g*b;

    for(i=0;i<N;i++){
        for(j=1;j<N;j++){
            if(i+2*j>=N)break;
            if(S[i]!=S[i+j]&&S[i+j]!=S[i+2*j]&&S[i+2*j]!=S[i])ans--;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>

using namespace std;

struct Dice{
	int P[6];
	void Roll(char a){
		
	int top;
	
	switch(a) {
		
		case 'E':
		top = P[0];
		P[0] = P[3];
		P[3] = P[5];
		P[5] = P[2];
		P[2] = top;
		break;
		
		case 'W':
		top = P[0];
		P[0] = P[2];
		P[2] = P[5];
		P[5] = P[3];
		P[3] = top;
		break;
		
		case 'R':
		top = P[1];
		P[1] = P[2];
		P[2] = P[4];
		P[4] = P[3];
		P[3] = top;
		break;
		
		default :
		top = P[0];
		P[0] = P[1];
		P[1] = P[5];
		P[5] = P[4];
		P[4] = top;
		break;	
	}	
}
	int Top() {
    return P[0];
  }
  	int Right(){
    return P[2];
  }
  	int Left(){
    return P[3];
  }
  	int Front(){
    return P[1];
  }
};

int main() {
	
	int n = 6;
	Dice S;
	
	while( cin >> S.P[0] ) {
		
		for(int i=1;i<n;i++)
		cin >> S.P[i];
		
		int n;
		cin >> n;
		
		int a, b;
		
		for(int i=0;i<n;i++){
		cin >> a >> b;
		if(S.Left()==a) S.Roll('E');
		
    	if(S.Right()==a) S.Roll('W');
    	
    	while(S.Top()!=a) S.Roll('N');
    	
    	while(S.Front()!=b) S.Roll('R');
    	
    	cout << S.Right() << "\n";	

	}
	}
	
	return 0;
}



Measured memory_bytes: 3076
#include<iostream>

using namespace std;

#define MAX 2000000

int H, A[MAX + 1];

void maxHeapify(int i) {
  int l = 2 * i;
  int r = 2 * i + 1;
  int largest;

  if (l <= H && A[i] < A[l]) 
    largest = l;
  else
    largest = i;
  if (r <= H && A[largest] < A[r]) 
    largest = r;

  if (largest != i) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

int main() {
  cin >> H;

  for (int i = 1; i <= H; i++) cin >> A[i];

  for (int i = H / 2; i >= 1; i--) maxHeapify(i);

  for (int i = 1; i <= H; i++) {
    cout << " " << A[i];
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 5040
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

const long long M = 1000000007;

long long power(long long x, long long n){
	long long res = 1;
	if(n > 0){
		res = power(x, n / 2);
		if(n % 2 == 0) res = (res * res) % M;
		else res = (((res * res) % M) * x ) % M;
	}
	return res;
}

long long cul(long long a){
	if(a <= 0) return 1;
	return ((a + 1) * a % M * power(2, M - 2) % M - (a - 1) + M) % M;
}

int main(){
	int h, w, k;
	while(cin >> h >> w >> k){
		if(w == 1) {
			cout << 1 << endl;
			continue;
		}

		vector<vector<long long>> dp(h + 1, vector<long long>(w, 0));
		dp[0][0] = 1;
		rep(i,h){
			rep(j,w){
				rep(s, 1 << (w - 1)){
					if(
							[&]() -> bool {
								rep(j,w - 2){
									bool x = (s >> j) bitand 1;
									bool y = (s >> (j + 1)) bitand 1;
									if(x and y) return true;
								}
								return false;
							}()
							) continue;


					if(j > 0 and ((s >> (j - 1)) bitand 1)){
						(dp[i + 1][j - 1] += dp[i][j]) %= M;
					}else if(j < w - 1 and ((s >> j) bitand 1)){
						(dp[i + 1][j + 1] += dp[i][j]) %= M;
					}else{
						(dp[i + 1][j    ] += dp[i][j]) %= M;
					}
				}
			}
		}
		cout << dp[h][k - 1] << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a[100];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, d, x;
    cin >> n >> d >> x;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        x += d / a[i] + (d % a[i] != 0);
    }
    cout << x;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF = 1000000100;

const int maxN=20;
vector<map<int,int>> X(maxN);

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        for(int j=0;j<a;j++){
            int x;
            cin >> x;
            x--;
            cin >> X[i][x];
        }
    }
    int maxcnt=0;
    for(int x=0;x<1<<n;x++){
        bool c=true;
        int cnt=0;
        for(int i=0;i<n;i++){
            if(x >> i & 1){
                for(auto itr=X[i].begin();itr!=X[i].end();itr++){
                    if(!((x >> itr->first)%2 == itr->second)){
                        c = false;
                        continue;
                    }
                }
            }
        }
        //cout << "x: " << x << " c: " << c << endl;
        if(c){
            for(int j=0;j<n;j++){
                if(x >> j &1) cnt++;
            }
        }
        maxcnt = max(maxcnt, cnt);
    }
    cout << maxcnt << endl;
     
}

Measured memory_bytes: 256
n = int(input())
a = sorted(list(int(input()) for _ in range(n)))
if n%2==0:
    ans = 2 * (sum(a[n//2:]) - sum(a[:n//2]))
    ans += a[n//2-1] - a[n//2]
    print(ans)
else:
    ans = 2 * (sum(a[n//2+1:]) - sum(a[:n//2]))
    print(ans - min(a[n//2+1] - a[n//2], a[n//2] - a[n//2-1]))

Measured memory_bytes: 14000
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define MOD 10000

int N, K;
int dp[110][3][3];
int P[110];

int main() {
  cin >> N >> K;
  for (int i=0; i<N; i++) P[i] = -1;
  for (int i=0; i<K; i++) {
    int a, b;
    cin >> a >> b;
    P[a-1] = b-1;
  }
  dp[0][0][0] = 1;
  for (int i=0; i<N; i++) {
    for (int j=0; j<3; j++) {
      for (int k=0; k<3; k++) {
        for (int n=0; n<3; n++) {
          if (i >= 2 && n == j && j == k) continue;
          if (P[i] != -1 && P[i] != n) continue;
          dp[i+1][n][j] = (dp[i+1][n][j] + dp[i][j][k]) % MOD;
        }
      }
    }
  }
  int ans = 0;
  for (int j=0; j<3; j++) {
    for (int k=0; k<3; k++) {
      ans += dp[N][j][k];
      ans %= MOD;
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3104
using System;
using System.IO;
using System.Linq;

class Program
{
    static void Solve()
    {
        var N = ReadInt();
        var S = new string[N];
        var P = new int[N];

        for (var i = 0; i < N; i++)
        {
            var input = Reads();
            S[i] = input[0];
            P[i] = int.Parse(input[1]);
        }

        var group = S.Zip(P, (s, p) => Tuple.Create(s, p)).Select((t, i) => Tuple.Create(t.Item1, t.Item2, i))
            .GroupBy(t => t.Item1)
            .OrderBy(g => g.Key);

        foreach (var city in group)
        {
            foreach (var restaurant in city.OrderByDescending(p => p.Item2))
            {
                Console.WriteLine(restaurant.Item3 + 1);
            }
        }
    }


    static void Main(string[] args)
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();

    }

    public static string Read() { return Console.ReadLine(); }
    public static int ReadInt() { return int.Parse(Read()); }
    public static long ReadLong() { return long.Parse(Read()); }
    public static double ReadDouble() { return double.Parse(Read()); }

    public static string[] Reads() { return Console.ReadLine().Split(' '); }
    public static int[] ReadInts() { return Reads().Select(_ => int.Parse(_)).ToArray(); }
    public static long[] ReadLongs() { return Reads().Select(_ => long.Parse(_)).ToArray(); }
    public static double[] ReadDoubles() { return Reads().Select(_ => double.Parse(_)).ToArray(); }
}

Measured memory_bytes: 13920
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int gcd(int a, int b){
  int max = std::max(a, b);
  int min = std::min(a, b);
  if (min==0) return max;
  return gcd(min, max%min);
}

int main(){
  int X;
  scanf("%d", &X);
  int g = gcd(X, 360);
  int ans = (X*360)/g/X;
  std::cout << ans << std::endl;
  return 0;
}
 

Measured memory_bytes: 3252
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
    public void Proc()
    {
        int n = int.Parse(Console.ReadLine());
        int[] A = new int[n];
        for(int i=0; i< n; i++) {
            A[i] = int.Parse(Console.ReadLine());
        }
        List<int> G = new List<int>();
        int item = 1;
        while(item <= n)
        {
            G.Add(item);
            item += (int)Math.Pow(3, G.Count);
        }
        G.Reverse();
        int m = G.Count;
        for(int i=0; i< m; i++)
        {
            this.InsertionSort(A, n, G[i]);
        }
        Console.WriteLine(m);
        System.Text.StringBuilder sb = new StringBuilder();
        foreach(int num in G)
        {
            if(sb.Length > 0)
            {
                sb.Append(" ");
            }
            sb.Append(num);
        }
        Console.WriteLine(sb.ToString());
        Console.WriteLine(this.Cnt);
        foreach(int num in A)
        {
            Console.WriteLine(num);
        }

    }

    private int Cnt = 0;

    private void InsertionSort(int[] A, int n, int g)
    {
        for(int i= g; i< n; i++)
        {
            int v = A[i];
            int j = i - g;
            while(j >= 0 && A[j] > v)
            {
                A[j + g] = A[j];
                j = j - g;
                this.Cnt++;
            }
            A[j + g] = v;
        }
    }

    static void Main(string[] args)

    {

        Program prg = new Program();
        prg.Proc();

    }
}

Measured memory_bytes: 16656
(a, b, c, d, e, f) = list(map(int, input().split()))
a *= 100
b *= 100

n = [[0, 0] for _ in range(f + 1)]
n[a][0] = a
for i in range(f + 1 - a):
    if n[i][0] != 0:
        n[i + a][0] = n[i][0] + a
if f >= b:
    n[b][0] = b
    for i in range(f + 1 - b):
        if n[i][0] != 0:
            n[i + b][0] = n[i][0] + b
for i in range(f + 1 - c):
    if n[i][0] == 0:
        continue
    tmpt = n[i][0] / 100
    if (c + n[i][1]) / tmpt <= e and n[i + c][1] / (i + c) < (n[i][1] + c) / (i + c):
            n[i + c][0] = n[i][0]
            n[i + c][1] = n[i][1] + c
for i in range(f + 1 - d):
    if n[i][0] == 0:
        continue
    tmpt = n[i][0] / 100
    if (d + n[i][1]) / tmpt <= e and n[i + d][1] / (i + d) < (n[i][1] + d) / (i + d):
            n[i + d][0] = n[i][0]
            n[i + d][1] = n[i][1] + d
maxp = [0, a, 0]
for i in range(len(n)):
    if(n[i][1] != 0 and maxp[0] < n[i][1] / i):
        maxp = [n[i][1] / i] + n[i]
print(str(maxp[1] + maxp[2]) + ' ' + str(maxp[2]))

Measured memory_bytes: 3316
def f(a,d,T):
    try:
        return T[d:].index(a)+d
    except ValueError:
        return len(T)

from random import randint
A=26

D=int(input())

C=[0]+list(map(int,input().split())) #減る満足度のベース
S=[0]*(D+1) #S[d][i] :(d+1)日目にコンテストiを開催した時の満足度

for i in range(1,D+1):
    S[i]=[0]+list(map(int,input().split()))

T=[0]
for i in range(D):
    T.append(int(input()))

L=[[0]*(A+1) for _ in range(D+1)]

for x in range(1,D+1):
    t=T[x]
    for j in range(1,A+1):
        if t!=j:
            L[x][j]=L[x-1][j]+1
        else:
            L[x][j]=0
            
X=0
for d in range(1,D+1):
    X+=S[d][T[d]]    
    for j in range(1,A+1):
        X-=C[j]*L[d][j]

M=int(input())
for _ in range(M):
    d,q=map(int,input().split())
    p=T[d]

    a=f(p,d+1,T)
    b=f(q,d+1,T)
    
    Y=0
    h=L[d-1][p]
    for i in range(d,a):
        h+=1
        Y+=h-L[i][p]
        L[i][p]=h
        
    m=0
    Z=0
    for j in range(d,b):
        Z-=m-L[j][q]
        L[j][q]=m
        m+=1

    T[d]=q
    X+=(S[d][q]-S[d][p])+Z*C[q]-Y*C[p]
    print(X)
    


Measured memory_bytes: 80288
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define MXN 100003

int n,ans,
	a[15]={0,1,6,9,36,81,216,729,1296,6561,7776,46656,59049},
	f[MXN];

int main(){

	scanf("%d",&n);
	for(int j=1;j<=n;j++)
		f[j]=1000000000;
	for(int i=12;i>=1;i--)
		for(int j=a[i];j<=n;j++)
			f[j]=std::min(f[j],f[j-a[i]]+1);

	printf("%d\n",f[n]);

	//system("pause");

	return 0;
}


Measured memory_bytes: 640
import math
N=int(input())
x=[0 for i in range(N)]
y=[0 for i in range(N)]
p=[]
for i in range(N):
    x[i],y[i]=map(int,input().split())
    p.append((x[i],y[i]))
def dist(p,q):
    a,b=p
    c,d=q
    return math.sqrt((a-c)**2+(b-d)**2)
def check(R):
    Q=[]
    for i in range(N):
        for j in range(i+1,N):
            d=dist(p[i],p[j])/2
            if R<d:
                return False
            h=math.sqrt(R*R-d*d)
            #print(d,h,R)
            nx,ny=(x[j]-x[i],y[j]-y[i])
            nr=math.sqrt(nx**2+ny**2)
            dx,dy=h*nx/nr,h*ny/nr
            mx,my=(x[i]+x[j])/2,(y[i]+y[j])/2
            #print(mx,my)
            #print(dx,dy)
            Q.append((mx+dy,my-dx))
            Q.append((mx-dy,my+dx))
    #print(Q,R)
    for pa in Q:
        flag=1
        for i in range(N):
            #print(pa,i,dist(pa,p[i]),R)
            if dist(pa,p[i])>R+9e-7:
                flag=0
                break
        if flag==1:
            return True
    return False

low=0
high=2000
for line in range(50):
    mid=(low+high)/2
    if check(mid):
        high=mid
    else:
        low=mid
print(mid)
    


Measured memory_bytes: 48108
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <math.h>

typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18+1;
const int N = 4e5+1;
const ll mod = 1e9+7;
const int bits = 19;


int main(){
    FASTIO;
    PRECISION;

    int n,m,x;
    cin>>n>>m>>x;
    vector<int>c(n);
    vector<vector<int>>arr(n,vector<int>(m));

    for(int i=0;i<n;i++){
        cin>>c[i];
        for(int j=0;j<m;j++){
            cin>>arr[i][j];
        }
    }
    int ans = 1e9;

    for(int mask=0;mask<(1<<n);mask++){
        vector<int>store(m);
        int cost = 0;
        for(int i=0;i<n;i++){
            if(mask&(1<<i)){
                cost+=c[i];
                for(int j=0;j<m;j++){
                    store[j]+=arr[i][j];
                }
            }
        }

        int done = true;
        for(int j=0;j<m;j++){
            if(store[j]<x){
                done = false;
                break;
            }
        }

        if(done){
            ans = min(ans,cost);
        }
    }

    if(ans==1e9){
        cout<<-1<<"\n";
    }else{
        cout<<ans<<"\n";
    }



}

Measured memory_bytes: 3664
#include <stdio.h>

int main() {
    int n, m, cn, cm, t;
    scanf("%d%d%d", &n, &m);
    cn = (n*(n-1))/2;
    cm = (m*(m-1))/2;
    t = (cn + cm);
    
    printf("%d\n", t);
    

    return 0;
}

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

int64_t mypow(int i, int64_t j){
  if(j == 0)
    return 1;
  int orgi = i;
  for(;;){
    if(j == 1)
      break;
    j--;
    i *= orgi;
  }
  return i;
}

int main(){
  int N;
  cin >> N;
  int64_t ans, a = 1, b = 1, c = 1;
  
  while(1){
    if(N < 9){
      a = a*mypow(10,N) % (mypow(10,9) + 7);
      b = 2*b*mypow(9,N) % (mypow(10,9) + 7);
      c = c*mypow(8,N) % (mypow(10,9) + 7);
      if(a - b + c < 0)
        a += mypow(10,9) + 7;
      ans = (a - b + c) % (mypow(10,9) + 7);
      break;
    }
    else{
      a = a*mypow(10,9) % (mypow(10,9) + 7);
      b = b*mypow(9,9) % (mypow(10,9) + 7);
      c = c*mypow(8,9) % (mypow(10,9) + 7);
      N -= 9;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3620
#include <stdio.h>

void swapper(int *m, int *n) {

    int buf;

    buf = *m;
    *m = *n;
    *n = buf;

}

int main(void) {

    int a, b, c;

    scanf("%d %d %d", &a, &b, &c);

    if (a > b) {
        swapper(&a, &b);
    }
    if (b > c) {
        swapper(&b, &c);
    }
    if (a > b) {
        swapper(&a, &b);
    }

    printf("%d %d %d\n", a, b, c);

    return 0;

}

Measured memory_bytes: 596
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
/*int main(){
	vector<int>v={32,64,321,86,123,645,3};
	for(auto i:v)cout<<i<<endl;
	cout<<endl;
	sort(v.begin(),v.end());
	for(auto i:v)cout<<i<<endl;
}
*/
int main(){
	int N;
	cin>>N;
	vector<int>a(N);
	for(int k=0;k<N;k++) cin>>a[k];
	sort(a.begin(),a.end(),greater<int>());
	
	int sum1=0,sum2=0;
	for(int k=0;k<N;k++){
		if(k%2==0)
			sum1+=a[k];
		else
			sum2+=a[k];
	}
	cout<<sum1-sum2<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <bitset>
#include <tuple>
#include <stack>
#include <utility>

using namespace std;
typedef long long ll;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> food(M, 0);
    for(int i=0; i<N; i++){
        int a, k;
        cin >> k;
        if(i == 0){
            for(int j=0; j<k; j++){
                cin >> a;
                food[a-1] = 1;
            }
        }
        else{
            vector<int> A(M);
            for(int j=0; j<k; j++){
                cin >> a;
                A[a-1] = 1;
            }
            for(int j=0; j<M; j++){
                food[j] *= A[j];
            }
        }
    }
    int ans = 0;
    for(int i=0; i<M; i++) ans += food[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N],col[N],dpos[2 * N - 1],dneg[2 * N - 1];

// 入力時に置かれたqueenを記録しておく配列,true = queenが置かれた
bool X[N][N];

void init(){
    for(int i = 0;i < N;++i){
        row[i] = col[i] = FREE;
    }
    for(int i = 0;i < 2 * N - 1;++i){
        dpos[i] = dneg[i] = FREE;
    }
    
    for(int i = 0;i < N;++i){
        for(int j = 0;j < N;++j){
            X[i][j] = false;
        }
    }
}

/**
 出力関数
*/
void printBoard(){
    for(int i = 0;i < N;++i){
        for(int j = 0;j < N;++j){
            if(X[i][j]){
                if(row[i] != j){
                    return;
                }
            }
        }
    }
    
    for(int i = 0;i < N;++i){
        for(int j = 0;j < N;++j){
            cout << ((row[i] == j) ?  "Q" : ".");
        }
        cout << endl;
    }
}

void recursive(int i){
    // 最後の行までクイーンを置くことができた
    if(i == N){
        printBoard();
        return;
    }
    
    for(int j = 0;j < N;++j){
        // (i,j)が他のクイーンに襲撃されている場合は飛ばす
        if(col[j]  == NOT_FREE || dpos[i + j] == NOT_FREE || dneg[i - j + N - 1] == NOT_FREE){
            continue;
        }
        // (i,j)にクイーンを配置する
        row[i] = j;
        col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
        // 次の行を試す
        recursive(i + 1);
        // 次の行がダメだった場合(i,j)に配置されたクイーンを取り除く
        row[i] = j;
        col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
    }
    // クイーンの配置に失敗した
}

int main(){
    init();
    
    int k;
    cin >> k;
    for(int i = 0;i < k;++i){
        int r,c;
        cin >> r >> c;
        X[r][c] = true;
    }
    
    recursive(0);
    
    return 0;
}



Measured memory_bytes: 3108
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.DP
{
    class EDPC_T
    {
        public const int mod = 1000000007;

        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();

            var dp = new long[n, n];
            var acc = new long[n];
            for (int i = 0; i < n; i++)
                dp[0, i] = 1;


            for (int i = 0; i < s.Length; i++)
            {
                acc[0] = dp[i, 0];
                for (int j = 1; j < n - i; j++)
                    acc[j] = (acc[j - 1] + dp[i, j]) % mod;

                if (s[i] == '<')
                {
                    for (int j = 0; j < n - i - 1; j++)
                        dp[i + 1, j] = acc[j];
                }
                else
                {
                    for (int j = 0; j < n - i - 1; j++)
                        dp[i + 1, j] = (acc[n - i - 1] - acc[j] + mod) % mod;
                }
            }

            long ans = 0;
            for (int i = 0; i < n; i++)
                ans += dp[n - 1, i];
            Console.WriteLine(ans % mod);
        }
    }
}


Measured memory_bytes: 81624
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static ConsoleApp.Util;
using static System.Math;

namespace ConsoleApp
{
    class Program
    {
       
        static void Main(string[] args)
        {
            var input = ReadLine();

            var ans = "";
            for (int i = 0; i < input.Count();i++)
            {
                ans += "x";
            }

            WriteLine(ans);
        }

        
    }


    static class Util{
        public static void ChMin(ref long a,long b){
            
            if(a > b){
                a = b;
            }
        }

        public static void ChMax(ref long a,long b){
            if(a < b){
                a = b;
            }
        }



		
    }
}



Measured memory_bytes: 11220
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	var i int
	if sc.Scan() {
		if num, err := strconv.Atoi(sc.Text()); err == nil {
			i = num
		}
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	l := float64(nextInt())
	length := (l / 3)
	fmt.Printf("%f\n", length*length*length)
}


Measured memory_bytes: 1772
x1,y1,x2,y2=map(int, input().split())
xm,ym=(x1+x2)/2,(y1+y2)/2
xa,ya=(x2-x1),(y2-y1)
xmn,ymn=xm-ya,ym+xa
print(int(xmn+xa/2),int(ymn+ya/2),int(xmn-xa/2),int(ymn-ya/2))

Measured memory_bytes: 3060
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
#define INF 2000000000
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
ll N, M, K,H,W, mi1,mi2,sum;
LL ans,a;
LL no;
bool b,bb[1000000000];
string s,t;

int main() {
	cin >> N>>K;
	LL A[2000];
	ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	H = 0;
	W = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			if (A[i] > A[j])H++;
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (A[i] > A[j])W++;
		}
	}
	ans = (H*K) % MOD;
	ans += W*((K*(K-1)/2)%MOD);

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



Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<map>
using namespace std;
#define mod 998244353
map<long long,int> tp;
char s[105];
vector<int> st[105];
int dp(vector<int> s);
int solve(vector<int> s)
{
	int sz=s.size(),as=0;
	if(sz==1)return 1+s[0];
	int s2=st[sz].size();
	for(int i=0;i<s2;i++)
	{
		int v=st[sz][i];
		vector<int> vl;
		for(int j=1;j<=v;j++)
		{
			int mx=1;
			for(int k=j-1;k<sz;k+=v)mx&=s[k];
			vl.push_back(mx);
		}
		as=(as+dp(vl))%mod;
	}
	return as;
}
int dp(vector<int> s)
{
	int sz=s.size();
	if(!sz)return 1;
	if(sz==1)return 1+s[0];
	long long vl=-1;
	if(sz<=50)
	{
		vl=0;
		for(int i=0;i<sz;i++)vl=vl*2+s[i];
		vl=vl*64+sz;
	}
	else vl=sz+(1ll<<60);
	if(tp[vl])return tp[vl];
	int as=0;
	for(int i=0;i<sz;i++)
	{
		vector<int> s1,s2;
		for(int j=0;j<=i;j++)s1.push_back(s[j]);
		for(int j=i+1;j<sz;j++)s2.push_back(s[j]);
		as=(as+1ll*solve(s1)*dp(s2))%mod;
	}
	if(vl!=-1)tp[vl]=as;
	return as;
}
int main()
{
	for(int i=1;i<=100;i++)for(int j=i*2;j<=100;j+=i)st[j].push_back(i);
	scanf("%s",s+1);vector<int> st1;
	for(int i=1;s[i];i++)st1.push_back(s[i]-'0');
	printf("%d\n",dp(st1));
}//

Measured memory_bytes: 3328
#include <cstdio>
#include <algorithm>
const int maxn = 1e5 + 5;
using namespace std;
struct E{
	int to, nxt;
}e[maxn];
int head[maxn], tot = 0;
void addedge(int u, int v){
	e[++tot].to = v, e[tot].nxt = head[u];
	head[u] = tot;
}
int a[maxn], dep[maxn], n, k, ans = 0;
void dfs(int cur, int fa){
	for (int i = head[cur]; i; i = e[i].nxt){
		int v = e[i].to;
		dfs(v, cur);
		dep[cur] = max(dep[cur], dep[v] + 1);
	}
	if (fa != 1 && dep[cur] == k - 1 && cur != 1) dep[cur] = -1, ++ans;
}
int main(){
	scanf("%d%d%d", &n, &k, a + 1);
	if (a[1] != 1) a[1] = 1, ++ans;
	for (int i = 2; i <= n; i++){
		scanf("%d", a + i);
		addedge(a[i], i);
	}
	dfs(1, 0);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 6784
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        x: i64,
    }
    println!("{}", x / 500 * 1000 + (x % 500) / 5 * 5);
}


Measured memory_bytes: 4352
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

from collections import defaultdict

N = ni()
W = nsn(N)
d = defaultdict(int)

flag = True
for i in range(N):
    if i and W[i - 1][-1] != W[i][0]:
        flag = False
    if d[W[i]] >= 1:
        flag = False
    d[W[i]] += 1

print("Yes" if flag else "No")

Measured memory_bytes: 3316
#include <iostream>
using namespace std;
int main() {
	int x, i, a[9];
	for (i = 0;i < 9;i++) {
		cin >> a[i];
	}
	for (x = 0;x < 101;x++) {
		if (a[0] == x + (a[0] - x) && a[1] == x + (a[1] - x) && a[2] == x + (a[2] - x) && a[3] == (a[0]-x)+(a[3]-(a[0]-x))&&a[4]==(a[1]-x)+(a[3]-(a[0]-x))&&a[5]==(a[2]-x)+(a[3]-(a[0]-x))&&a[6]==(a[0]-x)+(a[6]-(a[0]-x))&&a[7]==(a[1]-x)+(a[6]-(a[0]-x))&&a[8]==(a[2]-x)+(a[6]-(a[0]-x))) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
//ARC096 C
#include <cstdio>
#include <algorithm>
using namespace std;
int a,b,c,x,y,m,ans=0;
int main(){
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	if(c*2<=a+b){
		ans+=2*(m=min(x,y))*c;
		x-=m,y-=m;
	}
	ans+=x*min(2*c,a);
	ans+=y*min(2*c,b);
	printf("%d\n",ans);
}

Measured memory_bytes: 128
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    X,K,D = map(int,input().split())
    x = abs(X)
    if K * D < x:
        ans = x - K * D
    else:
        shou = x // D
        nokori = K - shou
        
        if nokori % 2 == 0:
            ans = x % D
            
        else:
            ans = abs((x % D) - D)
            
    print(ans)


    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9188
function Main(input) {
  input = input.split("\n");
  var X = parseInt(input[0].split(" ")[0]);
  var Y = parseInt(input[0].split(" ")[1]);
  ans= X + Y/2;
  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

const int N = 400 + 5;
const long long inf = 1e18;

int n;
int a[N];
bool vis[N][N];
long long prefix[N];
long long memo[N][N];

long long getSize(int l, int r){
	if(r <= l) return 0LL;
	return l == 0? prefix[r] : prefix[r] - prefix[l-1];
}

long long DP(int l, int r){
	if(r <= l) return 0LL;
	if(l + 1 == r) return a[l] + a[r];
	if(vis[l][r]) return memo[l][r];
	long long ans = inf;
	for(int k = l; k < r; k++){
		long long cand = DP(l, k) + getSize(l, r) + DP(k + 1, r);
		if(ans > cand){
			ans = cand;
		}
	}
	vis[l][r] = true;
	return memo[l][r] = ans;
}

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		prefix[i] = a[i];
		if(i > 0) prefix[i] += prefix[i - 1];
	}
	printf("%lld\n", DP(0, n - 1));
	return 0;
}


Measured memory_bytes: 5220
N, K = map(int,input().split())
MOD = 10**9+7
ls = [0]*(K+1) #個数
for i in range(1, K+1)[::-1]:
  ls[i] =  pow(K // i, N, MOD)
  if K // i != 1:
    a = K // i
    for j in range(2, a+1):
      ls[i] -= ls[i*j]  
    
ans = 0
for i in range(1, K+1):
  ans += i * ls[i]
  ans %= MOD  
print(ans) 

Measured memory_bytes: 74360
N, L = map(int, input().split())

s = ((L+1-1) + (L+N-1))*N // 2

if L+1-1 > 0:
    print(s - (L+1-1))
else:
    if L+N-1 >= 0:
        print(s)
    else:
        print(s - (L+N-1))


Measured memory_bytes: 2940
#include <stdio.h>
#include <math.h>

long long multiDimBurger(int n, long long x);

int main(){
	int N;
	long long X;
	scanf("%d", &N);
	scanf("%lld", &X);

	long long count = multiDimBurger(N,X);

	printf("%lld", count);

}

long long multiDimBurger(int n, long long x){
    if (n == 0){
        return 1;
    }
    else if (n > 0){
    	long long t = (long long)pow(2, n+1) - 3;
		if (x == 1){
			return 0;
		}else if (1 < x && x <= 1 + t){
			return multiDimBurger(n-1, x-1);
		}else if (x == 2 + t){
			return multiDimBurger(n-1, x-2) + 1;
		}else if (2 + t < x && x <= 2 + 2 * t){
			return multiDimBurger(n-1, x-2) + 1 + multiDimBurger(n-1, x-2-t);
		}else{
			return 2 * multiDimBurger(n-1, x-2) + 1;
		}
    }
}

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

int n,i,num[200005],f[200005][2];


inline char Getchar()
{
	static char buff[1000000],*p,*end=p;
	if(p==end)
		end=buff+fread(p=buff,1,1000000,stdin);
	if(p==end)
		return -1;
	return *(p++);
}
char rc;
template<typename name> void read(name &x)
{
	static int flag;
	rc=Getchar();flag=1;x=0;
	while(!isdigit(rc))
		flag=(rc=='-'?-1:1),rc=Getchar();
	while(isdigit(rc))
		x=x*10+rc-'0',rc=Getchar();
	x*=flag;
}

int main()
{
	read(n);
	rc=Getchar();
	while(rc!='.'&&rc!='#')
		rc=Getchar();
	for(i=1;i<=n;i++)
	{
		num[i]=rc=='#'?1:0,rc=Getchar();
		if(i==1)
		{
			f[i][num[i]]=0;f[i][num[i]^1]=1;
		}
		else
			f[i][num[i]]=num[i]==0?f[i-1][0]:min(f[i-1][0],f[i-1][1]),f[i][num[i]^1]=(num[i]==1?f[i-1][0]:min(f[i-1][0],f[i-1][1]))+1;
	}
	cout<<min(f[n][0],f[n][1]);
	return 0;
}

Measured memory_bytes: 2816
import java.util.Scanner;
import java.util.ArrayList;

class Main{
      public static void main(String args[]){
	Scanner sc = new Scanner(System.in);
	long a = 1;
	double p = 0;
	int n = sc.nextInt();
	boolean zero = false;
	long m;
	ArrayList<Long> l = new ArrayList<Long>();
	for(int i=0;i<n;i++){
	    m = sc.nextLong();
	    if(m==0){
		zero = true;
	    }
	    if(zero){
		continue;
	    }
	    if(!zero){
		p+=Math.log10(m);
		l.add(m);
	    }
	}
	long x = 1;
	for(int i=0;i<18;i++){
	    x*=10;
	}
	if(!zero&&p<=18){
	    for(int i=0;i<l.size();i++){
		a*=l.get(i);
	    }
	    if(a>x){
		System.out.println("-1");
	    }else{
		System.out.println(a);
	    }
	}else if(zero){
	    System.out.println("0");
	}else{
	    System.out.println("-1");
	}
      }
}


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

const long long int MOD = 1000000007;
const long long int INI = -1;
long long int n, m, a[101010];

int main(){
  cin >> n >> m;
  rep(i, n + 1) a[i] = INI;
  a[0] = 1;
  a[1] = 1;
  
  rep(i, m){
    int tmp; cin >> tmp;
    a[tmp] = 0;
  }
  
  for(int i = 2; i <= n; i++){
    if(a[i] == 0){
      continue;
    }
    a[i]  = a[i - 1] + a[i - 2];
    a[i] %= MOD;
    //cerr <<i <<" "<< a[i] <<" "<< a[i - 1] <<" "<<a[i - 2]<< endl;
  }
  cout << a[n] << endl;
  
  return 0;
}


Measured memory_bytes: 1024
def main():
    N = int( input())
    L = list( map( int, input().split()))
    L.sort()
    ans = 0
    if N <= 2:
        print(0)
        return
    for i in range(N-2):
        for j in range(i+1,N-1):
            for k in range(j+1,N):
                if L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
                    continue
                if L[i] + L[j] > L[k]:
                    ans += 1
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  ll cnt=0;
  rep(i,n-1){
    if(a[i]==a[i+1]){
      cnt++;
    }
  }
  cout << n-(cnt+1)/2*2 << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define INF INT64_MAX
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[8] = { 1,-1,0,0,1,1,-1,-1 }, ddy[8] = { 0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 222222

ll xx[9] = {0, 1,-1,0,0,1,1,-1,-1 }, yy[9] = {0,0,0,1,-1,1,-1,1,-1 };
ll an[11];
int main(void) {
  map<pll, ll> mp;
  ll h, w, a, b;
  vll x, y;
  cin >> h >> w >> n;
  FOR(i, 0, n) {
	cin >> a >> b;
	x.pb(a);
	y.pb(b);
  }

  FOR(i,0,n) {
	FOR(j, 0, 9) {
	  a = x[i] + xx[j]; b = y[i] + yy[j];
	  ok = true;
	  FOR(k, 0, 9) {
		if (a + xx[k] <= 0 || a + xx[k] > h || b + yy[k] <= 0 || b + yy[k] >w) {
		  ok = false;
		  break;
		}
	  }
	  if (ok) mp[pll(a,b)]++;
	}
  }

  for (auto it : mp) {
	an[it.second]++;
  }

  ans = (h - 2)*(w - 2);
  FOR(i, 1, 10) {
	ans -= an[i];
  }
  
  cout << ans << endl;
  FOR(i, 1, 10) {
	cout << an[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 58092
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int *)b - *(int *)a;
}
int main(void)
{
    int n;
    scanf("%d",&n);
    long a[n];
    int i;
    for(i=0;i<n;i++){
        scanf("%ld",&a[i]);
    }
    qsort(a, n, sizeof(long), compare_int);
    int j=1;
    long ans[n];
    ans[0]=a[0];
    for(i=1;i<n;i++){
        ans[i]=a[j];
        if(i%2==0){
            j++;
        }
    }
    long sum=0;
    for(i=0;i<n-1;i++){
        sum+=ans[i];
    }
    printf("%ld\n",sum);
    return 0;
}


Measured memory_bytes: 5336
import java.util.*;

public class Main {    
    
  public static void main(String[] args) {
      
    Scanner sc = new Scanner(System.in);    
               
    long N = sc.nextLong();
    long M = sc.nextLong();    
    
    if(Math.abs(M-N) >= 2){
        System.out.println(0);
        return;
    }
    
    long MOD = 1000_000_007;            
    long ans = 1;

    for(int i = 1;i <= N;i++){
        ans = (ans*i)%MOD;
    }
    
    for(int i = 1;i <= M;i++){
        ans = (ans*i)%MOD;
    }
       
    if(N == M){
        ans = (2*ans)%MOD;
    }
    
    System.out.println(ans);
      
  }          
}

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

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)


#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
 
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
 
typedef long double dbl;
bool codejam = 0;

const int MOD = 1000*1000*1000 + 7;
const int NMAX = 1000*1000 + 11;

int arr[NMAX];
int n,m,p,q,k,a,b,c,ans;
string s,str;
char ch;
vector<int> v;

void solve()
{
    cin>>a>>b>>n;

    if(b > n){
        cout<<(a*n)/b;;
    }else{
        cout<<(a*(b-1))/b;
    }
    return;
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif

#define GETTYPE(i) 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

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

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h,w;
  while(cin >> h >> w){
    TSTART();

    bool ab[h][w];
    REP(i,h){
      string s;
      cin >> s;
      REP(j,w){
	ab[i][j] = s[j] == '#';
      }
    }

    REP(i,h){
      REP(j,w){
	if(ab[i][j]){
	  cout << "#";
	  continue;
	}
	int cnt = 0;
	REP(k,8){
	  int indx = i + dx[k];
	  int indy = j + dy[k];
	  if(indx >= 0 && indy >= 0 && indx < h && indy < w ){
	    if(ab[indx][indy])cnt++;
	  }
	}
	cout << cnt;
      }
      cout << endl;
    }
    
    TSTOP();
  }
  return 0;
}


Measured memory_bytes: 256