akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(void) {
	int n, m;
	long long x[1005], y[1005], z[1005];
	scanf("%d%d", &n, &m);
	for(int i=0; i<n; i++){
		scanf("%lld%lld%lld", &x[i], &y[i], & z[i]);
	}

		long long sum[1005],ans=0,max=0;
	//+++
	max=0;
	for(int i=0; i<n; i++){
		sum[i] = x[i] + y[i] + z[i];
	}
	sort(sum, sum+n);
	for(int i=n-1; i>=n-m; i--){
		max += sum[i];
	}
	if(max >= ans){
		ans = max;
	}
	//++-
	max=0;
	for(int i=0; i<n; i++){
		sum[i] = x[i] + y[i] - z[i];
	}
	sort(sum, sum+n);
	for(int i=n-1; i>=n-m; i--){
		max += sum[i];
	}
	if(max >= ans){
		ans = max;
	}
	//+-+
	max=0;
	for(int i=0; i<n; i++){
		sum[i] = x[i] - y[i] + z[i];
	}
	sort(sum, sum+n);
	for(int i=n-1; i>=n-m; i--){
		max += sum[i];
	}
	if(max >= ans){
		ans = max;
	}
	//+--
	max=0;
	for(int i=0; i<n; i++){
		sum[i] = x[i] - y[i] - z[i];
	}
	sort(sum, sum+n);
	for(int i=n-1; i>=n-m; i--){
		max += sum[i];
	}
	if(max >= ans){
		ans = max;
	}
	//-++
	max=0;
	for(int i=0; i<n; i++){
		sum[i] = (-1) * x[i] + y[i] + z[i];
	}
	sort(sum, sum+n);
	for(int i=n-1; i>=n-m; i--){
		max += sum[i];
	}
	if(max >= ans){
		ans = max;
	}
	//-+-
	max=0;
	for(int i=0; i<n; i++){
		sum[i] = (-1) * x[i] + y[i] - z[i];
	}
	sort(sum, sum+n);
	for(int i=n-1; i>=n-m; i--){
		max += sum[i];
	}
	if(max >= ans){
		ans = max;
	}
	//--+
	max=0;
	for(int i=0; i<n; i++){
		sum[i] = (-1) * x[i] - y[i] + z[i];
	}
	sort(sum, sum+n);
	for(int i=n-1; i>=n-m; i--){
		max += sum[i];
	}
	if(max >= ans){
		ans = max;
	}
	//---
	max=0;
		for(int i=0; i<n; i++){
		sum[i] = (-1) * x[i] - y[i] - z[i];
	}
	sort(sum, sum+n);
	for(int i=n-1; i>=n-m; i--){
		max += sum[i];
	}
	if(max >= ans){
		ans = max;
	}

	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
n, m, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

ans1 = 0
(0..x).each do |i|
  ans1 += 1 if a.include?(i)
end

ans2 = 0
(x..n).each do |i|
  ans2 += 1 if a.include?(i)
end

puts [ans1, ans2].min


Measured memory_bytes: 1788
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int n=sc.nextInt(),sum=0,f=0;
    int[] s=new int[n];
    for(int i=0;i<n;i++){
      s[i]=sc.nextInt();
      sum+=s[i];
    }
    if(sum%10!=0){
      System.out.println(sum);
    }else{
      Arrays.sort(s);
      for(int i=0;i<n;i++){
        if(s[i]%10!=0){
          System.out.println(sum-s[i]);
          f++;
          break;
        }
      }
      if(f==0){
        System.out.println(0);
      }
    }
  }
}


Measured memory_bytes: 21460
#include<stdio.h>
int main()
{
    int a,b,n;
    scanf("%d%d%d",&n,&a,&b);
    if(a%n==0 || b%n==0)
    {
        printf("OK");
        return 0;
    }
    if(a>b)
    {
        if(((b/n)+1)*n<=a)
        {
            printf("OK");
        }
        else
        printf("NG");
    }
    else
    {
        if(((a/n)+1)*n<=b)
        {
            printf("OK");
        }
        else
        printf("NG");
    }
}

Measured memory_bytes: 1732
package main

import "fmt"

func primeFactor(n int64) map[int64]int {
	ret := make(map[int64]int)
	for i := 2; int64(i)*int64(i) <= n; i++ {
		for n%int64(i) == 0 {
			ret[int64(i)]++
			n /= int64(i)
		}
	}
	if n != 1 {
		ret[n] = 1
	}
	return ret
}

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

	ans := 0
	for _, v := range primeFactor(n) {
		for i := 1; v >= i; i++ {
			v -= i
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1848
S = input()

F_NA = 0
F_Y = 1
F_M = 2
F_YM = 3

s = [0, 0]
s[0] = int(S[:2])
s[1] = int(S[2:])

flg = [0, 0]
for i in range(2):
    if s[i] >= 1 and s[i] <=12:
        flg[i] = F_YM
    elif s[i] == 0 or s[i] > 12:
        flg[i] = F_Y
    else:
        print("NA")
        exit()

if flg[0] == F_YM:
    if flg[1] == F_YM:
        print("AMBIGUOUS")
    else: #flg[1] == F_Y
        print("MMYY")
else: #flg[0] == F_Y
    if flg[1] == F_YM:
        print("YYMM")
    else: #flg[1] == F_Y
        print("NA")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int main(){
    int k;
    cin >> k;
    long long ans=0;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                long long A=a,B=b,C=c;
                int os=gcd(A,B);
                ans+=gcd(os,C);
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3596
#include <stdio.h>

int isprime(int n) {
 for(int i = 2; i * i <= n; i++) {
	 if(n % i == 0) return 0;
 }
 return 1;
}

int main(){
	int n,i,min,max;
	int number[10000+1] = {0};
	for(i = 2;i < 10000;i++){
		number[i] = isprime(i);
	}
	while(scanf("%d",&n)){
		if(n == 0)break;
		max = 0; min = 0;
		for(i = 2;i <= n;i++){
			if(number[i] && number[i-2]){
				min = i-2;
				max = i;
				//printf("%d %d\n",i-2,i);
			}
		}
		printf("%d %d\n",min,max);
	}
	return 0;
}

Measured memory_bytes: 1076
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn;
	cin >> nn;
	string ss;
	cin >> ss;
	for(int64 ii = 0;ii < ss.length();ii++)
	{
		ss[ii] += nn;
		if(ss[ii] > 'Z')
		{
			ss[ii] -= 26;
		}
	}
	cout << ss << endl;
	return 0;
}

Measured memory_bytes: 3568
total = input().rstrip().split(" ")
num_high = int(total[0])
ans = num_high
num_load = int(total[1])
height = input().rstrip().split(" ")
ans = [0 for i in range(num_high)]

for j in range(num_load):
    list = input().rstrip().split(" ")
    check_a = int(list[0])
    check_b = int(list[1])
    if int(height[check_a-1]) <= int(height[check_b-1]):
        ans[check_a-1] = 1
    if int(height[check_b-1]) <= int(height[check_a-1]):
        ans[check_b-1] = 1
print(ans.count(0))


Measured memory_bytes: 17656
//Edson version
#include <bits/stdc++.h>

using namespace std;

void solve(int X)
{
    bool ans = (X == 3) or (X == 5) or (X == 7);

    cout << (ans ? "YES" : "NO") << endl;
}

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

    int X;
    cin >> X;

    solve(X);

    return 0;
}

Measured memory_bytes: 3592
import sys


def handler():
    a, b, c = [int(i) for i in input().strip().split()]
    bar = int(input().strip())
    foo = 0
    while b <= a:
        b *= 2
        foo += 1
    while c <= b:
        c *= 2
        foo += 1
    if foo <= bar:
        sys.stdout.write('Yes\n')
    else:
        sys.stdout.write('No\n')


def main():
    while True:
        try:
            handler()
        except ValueError:
            continue
        except EOFError:
            break


if __name__ == '__main__':
    main()

Measured memory_bytes: 61784
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int A[] = new int[N];
        int num_popular_item = 0;
        int total_votes = 0;
        for (int i=0; i<N; i++) {
            A[i] = sc.nextInt();
            total_votes += A[i];
        }
        double r = 0.25 / M;
        for (int i=0; i<N; i++) {
            if (A[i] >= total_votes * r) {
                num_popular_item += 1;
            }
        }
        if (num_popular_item >= M) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n,m,tmp=0;
    bool flag = true;
    cin>>n>>m;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        cin>>v[i];
        tmp+=v[i];
    }
    sort(v.begin(), v.end(), greater<int>());
    for(int i=0;i<m;i++)
    {
        if(tmp>v[i]*4*m)flag=false;
    }

    if(flag==false)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


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

vector<int> path[10];
int cnt=0;
int n,m;

inline void dfs(vector<int> went,int now)
{
	if((int)went.size()==n)
	{
		cnt++;
		return;
	}
	for(int i=0;i<path[now].size();i++)
	{
		bool lgl=false;
		for(int j=0;j<went.size();j++)
			if(path[now][i]==went[j])lgl=true;
		if(!lgl)
		{
			went.push_back(path[now][i]);
			dfs(went,path[now][i]);
			went.pop_back();
		}
	}
}

int main()
{
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		path[a].push_back(b);
		path[b].push_back(a);
	}
//	for(int i=1;i<=n;i++)
//		for(int j=0;j<path[i].size();j++)cout<<path[i][j]<<' ';
	vector<int> linsh;linsh.push_back(1);
	dfs(linsh,1);
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int A,B;
int main(){
  cin>>A>>B;
  if(A<=5) prin(0);
  else if(A>=13) prin(B);
  else prin(B/2);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n;
  cin>>n;
  int pa,pb,pc,pd;
  cin>>pa>>pb>>pc>>pd;
  int ta,tb,tc,td;
  cin>>ta>>tb>>tc>>td;
  int mn = 10000;
  REP(i,n+1)REP(j,n+1)REP(k,n+1)REP(l,n+1) {
    if (ta*i+tb*j+tc*k+td*l < n) continue;
    mn = min(mn, pa*i+pb*j+pc*k+pd*l);
  }
  cout<<mn<<endl;
  return 0;
}



Measured memory_bytes: 3104
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<functional>
#include<queue>
using namespace std;
int n, m, q, a[100], d[209][209], minx = 1000000007;
int main() {
	cin >> n >> m >> q;
	for (int i = 0; i < q; i++)cin >> a[i]; sort(a, a + q);
	for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++)d[i][j] = 1000000007; d[i][i] = 0; }
	for (int i = 1; i <= m; i++) {
		int p1, p2, p3; cin >> p1 >> p2 >> p3; d[p1][p2] = p3; d[p2][p1] = p3;
	}
	for (int k = 1; k <= n; k++) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (d[i][j] > d[i][k] + d[k][j])d[i][j] = d[i][k] + d[k][j]; } } }
	do {
		int sum = 0;
		for (int i = 0; i < q - 1; i++)sum += d[a[i]][a[i + 1]];
		minx = min(minx, sum);
	} while (next_permutation(a, a + q));
	cout << minx << endl;
	return 0;
}

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


int main() {
  ll n,m; cin >> n >> m;
  vector<ll> a(n); rep(i,n)cin >> a[i];
  priority_queue<ll> pq;
  rep(i,n)pq.push(a[i]);
  rep(i,m){
    ll a = pq.top();
    a /= 2;
    pq.pop();
    pq.push(a);
  }
  ll sum = 0;
  while(!pq.empty()){
    sum += pq.top();
    pq.pop();
  }
    cout << sum << endl;
  
}


Measured memory_bytes: 2168
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
ll array[100005]={0};
int main(){
  ll n;
  cin>>n;
  for(int i=0;i<n;i++) cin>>array[i];
  ll ans1=0,ans2=0,sum1=0,sum2=0,pm1=1,pm2=-1;
  for(int i=0;i<n;i++){
    if(i%2==0){
      if(sum1+array[i]<1){
        ans1+=1-(sum1+array[i]);
        sum1=1;
      }
      else sum1+=array[i];
      if(sum2+array[i]>-1){
        ans2+=sum2+array[i]+1;
        sum2=-1;
      }
      else sum2+=array[i];
    }
    else{
      if(sum1+array[i]>-1){
        ans1+=sum1+array[i]+1;
        sum1=-1;
      }
      else sum1+=array[i];
      if(sum2+array[i]<1){
        ans2+=1-(sum2+array[i]);
        sum2=1;
      }
      else sum2+=array[i];
    }
  }
  cout<<min(ans1,ans2)<<endl;
}


Measured memory_bytes: 1024
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;


typedef long long LL;
const LL MOD = 1000000007;
static const size_t MAX_N = 2000001;

struct modll {
	long long x;
	modll() { }
	modll(int _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(int y) { return (x + y + MOD) % MOD; }
	modll operator+=(int y) { x = (x + y + MOD) % MOD; return *this; }
	modll operator-(int y) { return (x - y + MOD) % MOD; }
	modll operator-=(int y) { x = (x - y + MOD) % MOD; return *this; }
	modll operator*(int y) { return (x * y) % MOD; }
	modll operator*=(int y) { x = (x * y) % MOD; return *this; }
	modll operator/(int y) { return (x * modpow(y, MOD - 2)) % MOD; }
	modll operator/=(int y) { x = (x * modpow(y, MOD - 2)) % MOD; return *this; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

modll combination(LL n, LL r) {
	static modll fact[MAX_N + 1], inv[MAX_N + 1];
	if (!fact[0]) {
		fact[0] = 1;
		for (int i = 1; i <= MAX_N; ++i) {
			fact[i] = fact[i - 1] * i;
		}
		inv[MAX_N] = modll::modinv(fact[MAX_N]);
		for (int i = MAX_N; i >= 1; --i) {
			inv[i - 1] = inv[i] * i;
		}
	}
	if (r > n) {
		return 0;
	}
	return (fact[n] * inv[r]) * inv[n - r];
}


int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		LL n = -1, k;
		cin >> n >> k;
		if (n < 0) return 0;
		modll ans = 0;
		if (k == 1) {
			ans = combination(n, 2) * combination(n - 1, 2);
		} else {
			ans = 1;
			for (LL i = 0; i < min(n - 1, k); ++i) {
				ans += combination(n, i + 1) * combination(n - 1, i + 1);
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 31488
if __name__ == '__main__':
	n,m,l=map(int,raw_input().split())
	a=[map(int,raw_input().split()) for _ in [0]*n]
	b=zip(*[map(int,raw_input().split()) for _ in [0]*m])
	sums=[i[k]*j[k] for i in a for j in b for k in xrange(m)]
	c=[sum(sums[i:i+m]) for i in [j for j in xrange(len(sums)) if j%m==0]]
	c=[c[i:i+l] for i in xrange(len(c)) if i%l==0]
	for i in c:
		print " ".join(map(str, i))

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

using namespace std;

#define PI 3.1415926535897932

//typedef long long ll;


int lcm(int a,int b) { return a*b/__gcd(a,b); }
//ll lcm(ll a,ll b) { return a*b/__gcd(a,b); }

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 **/


int main(){
    int mod=1000000007;
    //int ans=-1000*1000;
    int a,b;
    scanf("%d %d",&a,&b);
    int ans=max(a+b,max(a-b,a*b));
    printf("%d\n",ans);
    

    return 0;
}


Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)
h.times do
  s = gets
  arr = Array.new(w, -1)
  w.times{ |i| arr[i] = 0 if s[i] == "c" }
  (1...w).each{ |i| arr[i] = arr[i-1] + 1 if arr[i-1] >= 0 && (arr[i] > arr[i-1] + 1 || arr[i] == -1) }
  puts arr.join(" ")
end

Measured memory_bytes: 8788
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	int n,d;
	cin>>n>>d;
	cout<<n/(d+d+1)+bool(n%(d+d+1))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    constexpr i64 inf = std::numeric_limits<i64>::max() / 2;
    int n;
    i64 d;
    std::cin >> n >> d;
    std::vector<i64> a(n), b, c;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        b.push_back(a[i] + i * d);
        c.push_back(a[i] - i * d);
    }

    for (int i = 1; i < n; i++) {
        b[n - 1 - i] = std::min(b[n - i - 1], b[n - i]);
        c[i] = std::min(c[i], c[i - 1]);
    }

    std::vector<int> r;
    i64 ret = 0;
    for (int i = 0; i < n; i++) {
        i64 cost = inf;
        if (i && c[i - 1] <= a[i] - i * d) {
            cost = std::min(cost, c[i - 1] + a[i] + i * d);
        }
        if (i + 1 < n && b[i + 1] <= a[i] + i * d) {
            cost = std::min(cost, b[i + 1] + a[i] - i * d);
        }

        if (cost < inf) ret += cost;
        else r.push_back(i);
    }

    for (int i = 1; i < r.size(); i++) {
        auto v = r[i - 1], w = r[i];
        ret += a[v] + a[w] + (w - v) * d;
    }
    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 6756
// 2011/12/12 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int a1, a2, a3, a4;
	cin >> a1 >> a2 >> a3 >> a4;
	int b1, b2, b3, b4;
	cin >> b1 >> b2 >> b3 >> b4;

	int S = a1+a2+a3+a4;
	int T = b1+b2+b3+b4;

	if(S>=T)
		cout << S << endl;
	else
		cout << T << endl;

	return 0;
}

Measured memory_bytes: 0
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N,M;
    cin >> N >> M;
    vector<vector<P>> res(N);
    vector<string> ans(M);
    REP(i,M) {
        int p,y; cin >> p >> y;
        res[p-1].push_back(P(y,i));
    }

    REP(i,N) {
        sort(res[i].begin(),res[i].end());
    }

    /*

    for(auto ret:res) {
        for(P p: ret) cout << "(" << p.first << "," << p.second << ") ";
        cout << endl;
    }

    */

    REP(i,N) {
        int cnt = 1;
        if(res[i].size() == 0) continue;
        for(auto x: res[i]) {
            string A = to_string(i+1);
            string B = to_string(cnt);
            REP(j,6-to_string(i+1).size()) A = '0' + A;
            REP(j,6-to_string(cnt).size()) B = '0' + B;
            ans[x.second] = A+B;
            cnt++;
        }
    }

    for(auto a:ans) cout << a << endl;
}

Measured memory_bytes: 12416
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 333;
int n, m;
int a[MAX][MAX];
const int st = MAX * 3 + 1;
const int ed = MAX * 3 + 2;
set<int> se;
int cnt[MAX];

int main(void) {
    scanf("%d%d", &n, &m);
    REP(i, n) {
        REP(j, m) {
            scanf("%d", a[i] + j);
            a[i][j]--;
        }
    }
    int ans = n;
    REP(i, m) {
        se.insert(i);
    }
    while (se.size()) {
        memset(cnt, 0, sizeof(cnt));
        REP(i, n) {
            REP(j, m) {
                if (se.count(a[i][j])) {
                    cnt[a[i][j]]++;
                    break;
                }
            }
        }
        int ma = 0, id = -1;
        REP(i, m) {
            if (chmax(ma, cnt[i])) {
                id = i;
            }
        }
        chmin(ans, ma);
        se.erase(id);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  int x,y;
  cin >> x >> y;
  cout << x+y/2<<endl;

  return 0;
}


Measured memory_bytes: 256
n, X = map(int,input().split())
x = list(map(int,input().split()))

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

gcd_value = abs(X-x[0])

for i in range(1,n):
    gcd_value = gcd(gcd_value,abs(X-x[i]))

print(gcd_value)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
  using namespace std;
  #define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  #define int long long int
  #define fi first
  #define se second
  #define pub push_back
  #define pi pair<int,int>
  #define all(v) (v).begin(), (v).end()
  #define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
  #define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
  #define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
  int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
  int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
  #define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
  #define clr(a,x) memset(a,x,sizeof(a))
  #define rr(v) for(auto &val:v)
  #define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
  #define ln length()
  #define sz size()
  #define mod 1000000007
  #define elif else if
  int32_t main(){
    int n; cin>>n;
    string s; cin>>s;
    int q; cin>>q;
    vector<set<int>> v(26);
    rep(i,0,n){
      v[s[i]-'a'].insert(i+1);
    }
    while(q--){
      int ch; cin>>ch;
      if(ch==1){
        int i; char c;
        cin>>i>>c;
       v[s[i-1]-'a'].erase(i);
       s[i-1]=c;
        v[c-'a'].insert(i);
      }
      else{
        int c=0;
        int l,r; cin>>l>>r;
        rep(i,0,26){
          auto it=v[i].lower_bound(l);
          if(it==v[i].end())continue;
          if(*it<=r)c++;
        }
        cout<<c<<"\n";
      }
    }
    return 0;
  }
  /*
  Edge cases? n=1? a[i]<=0?
  long vs int? 1LL? 64bits?
  Re-read problem. Is it as easy as it seems?
  KEEP CORRECTING AND SUBMITTING!
  */


Measured memory_bytes: 27252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  ll a, b, k;
  cin >> a >> b >> k;
  if (k <= a) a -= k;
  else {
    if (b >= k - a) b -= k - a;
    else b = 0;
    a = 0;
  }
  cout << a << " " << b << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
import scala.collection.mutable
object Main extends App {
  import scala.io.StdIn._
  val str = readLine.trim
  val m = readInt()
  val words = Array.fill(m){
    val Array(x, y) =readLine.trim.split(' ')
    (x, y)
  }
  val leftPos = Array.fill(m){-1}
  var forward = Automaton.make(words.map(_._1))
  for (i ← str.indices) {
    forward = forward.move(str(i))
    forward.popMatches.foreach(id ⇒
      leftPos(id) = i)
  }
  val rightPos = Array.fill(m){-1}
  var backward = Automaton.make(words.map(_._2.reverse))
  for (i ← str.indices.reverse) {
    backward = backward.move(str(i))
    backward.popMatches.foreach(id ⇒ rightPos(id) = i)
  }
  //println(words.indices.map(id ⇒ (leftPos(id), rightPos(id))).mkString(", "))
  println(
    words.indices.map{id ⇒
      if (leftPos(id) == -1 || rightPos(id) == -1 || leftPos(id) - words(id)._1.length >= rightPos(id) || leftPos(id) >= rightPos(id) + words(id)._2.length) 0
      else rightPos(id) - leftPos(id) + words(id)._1.length + words(id)._2.length - 1
    }.mkString("\n")
  )
}
sealed trait Automaton {
  protected var matches: List[Int]
  def popMatches: List[Int]
  def move(c: Char): Automaton
  val children: mutable.HashMap[Char, Automaton]
  protected def failure: Automaton
}
object Automaton {
  def make(words: Array[String]): Automaton = {
    val trieRoot = new Trie
    for (i ← words.indices) {
      var trie = trieRoot
      for (c ← words(i)) {
        trie = trie.children.getOrElseUpdate(c, new Trie)
      }
      trie.ids ::= i
    }
    val root = new Root
    val queue = mutable.Queue[(Automaton, Trie)]((root, trieRoot))
    while (queue.nonEmpty) {
      val (auto, trie) = queue.dequeue()
      for ((c, t) ← trie.children) {
        val child = new Child(auto.failure.move(c))
        child.matches = t.ids
        auto.children.update(c, child)
        queue.enqueue((child, t))
      }
    }
    root
  }
  class Trie {
    var ids: List[Int] = Nil
    val children: mutable.HashMap[Char, Trie] = mutable.HashMap()
  }
  class Root extends Automaton {
    override protected var matches: List[Int] = Nil
    override def popMatches: List[Int] = Nil
    override def move(c: Char): Automaton = children.getOrElse(c, this)
    override val children: mutable.HashMap[Char, Automaton] = mutable.HashMap()
    override protected def failure: Automaton = this
  }
  class Child(override val failure: Automaton) extends Automaton {
    var matches: List[Int] = Nil
    private var poped: Boolean = false
    override def popMatches: List[Int] = {
      if (poped) Nil
      else {
        poped = true
        val res = matches ::: failure.popMatches
        matches = Nil
        res
      }
    }
    override def move(c: Char): Automaton = children.getOrElseUpdate(c, failure.move(c))
    override val children: mutable.HashMap[Char, Automaton] = mutable.HashMap()
  }
}


Measured memory_bytes: 207096
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
ll a[101];
map<ll, ll>ma;
int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        ma[a[i]]++;
    }
    if (n <= 2){
        cout << 0 << endl;
        return 0;
    }
    sort(a + 1, a + 1 + n);
    n = unique(a + 1, a + 1 + n) - a - 1;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            for (int k = j + 1; k <= n; k++) {
                if (a[i] + a[j] > a[k]) {
                    ans += ma[a[i]] * ma[a[j]] * ma[a[k]];
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3164
N = gets.to_i
S = gets.chomp.split("")

min = N

for i in 0...N do
  leader = i
  if leader == 0 then
    turner_to_e = 0
    turner_to_w = S[1...N].count("E")
  elsif leader == N - 1
    leaders_west = leader - 1
    if S[leaders_west] == "W" then
      turner_to_e += 1
    end
    if S[leader] == "E" then
      turner_to_w -= 1
    end
  else
    leaders_west = leader - 1
    leaders_east = leader + 1
    
    if S[leaders_west] == "W" then
      turner_to_e += 1
    end
    if S[leader] == "E" then
      turner_to_w -= 1
    end
  end
  # p "leader:" + i.to_s
  # p turner_to_e.to_s + " " + turner_to_w.to_s
  min = [min, turner_to_e + turner_to_w].min
end

p min

Measured memory_bytes: 30468
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# import numpy as np
sys.setrecursionlimit(int(pow(10,6)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]



x,n=l()
p=l()
m=100000000
idx=0
for i in range(-100,201):
    if i not in p:
        if(abs(x-i)<m):
            m=abs(x-i)
            idx=i
print(idx)


Measured memory_bytes: 10644
from fractions import gcd

N = int(input())
As = list(map(int, input().split()))

A = max(As)
lst = [0]*(A+1)
rlt = [0]*(A+1)

for i in range(2, A+1):
  if lst[i] > 0:
    continue
  j = 1
  while i*j <= A:
    if lst[i*j] == 0:
      lst[i*j] = i
    j += 1
  if j == 1:
    break
    
for a in As:
  tmp = -1
  while a > 1:
    if tmp != lst[a]:
      rlt[lst[a]] += 1
      tmp = lst[a]
    a //= lst[a]

r = max(rlt) 

if r < 2:
  print('pairwise coprime')
elif r < N:
  print('setwise coprime')
else:
  print('not coprime')

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

reach = [False] * N
order = [0]
now_v = 0
cnt = 1
while 1:
    reach[now_v] = True
    next_v = A[now_v] - 1
    if reach[next_v]:
        goal = next_v
        break
    now_v = next_v
    order.append(now_v)
    cnt += 1
if cnt > K:
    print(order[K]+1)
    exit()

now_v = 0
cnt_tmp = 1

while 1:
    next_v = A[now_v] - 1
    if next_v == goal:
        break
    cnt_tmp += 1
    now_v = next_v
if cnt == cnt_tmp:
    cnt_tmp = 0

check = (K - cnt_tmp) % (cnt - cnt_tmp)
print(order[cnt_tmp+check]+1)


Measured memory_bytes: 32428
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

ll x;
ll upper(ll a,ll b){
  return (a + b - 1) / b;
}

int main(){
  cin >> x;
  cout << min(1 + upper(x - 6 , 11) * 2 , upper(x , 11) * 2) << endl;
  return 0;
}


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

public class AtCoder
{
  public static void Main()
  {
    var input = Console.ReadLine().Trim().Split().Select(e => int.Parse(e)).ToArray();
    var h = input[0];
    var w = input[1];

    var map = new char[w, h];

    for(var y=0; y < h; y++)
    {
      var line = Console.ReadLine();
      for(int x=0; x < w; x++)
      {
        map[x,y] = line[x];
      }
    }

    var dx = new []{ -1,0,1, -1,1, -1,0,1 };
    var dy = new []{ -1,-1,-1, 0,0 ,1,1,1 };

    for(var y=0; y < h; y++)
    {
      for(int x=0; x < w; x++)
      {
        if(map[x,y] == '#') continue;

        var count = 0;
        for(var i=0; i < 8; i++)
        {
          var tx = x + dx[i];
          var ty = y + dy[i];
          if(tx < 0 || w <= tx ) continue;
          if(ty < 0 || h <= ty ) continue;

          if(map[tx,ty] == '#') count++;
        }

        map[x,y] = count.ToString().First();
      }
    }

    for(var y=0; y < h; y++)
    {
      for(int x=0; x < w; x++)
      {
        Console.Write(map[x,y]);
      }
      Console.Write(Environment.NewLine);
    }
  }
}

Measured memory_bytes: 13396
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1];}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};
const main=()=>{
  let [n,d,x]=tnn(3)
  let c=tnn(n)
  let e=[...c];
  x+=n
  for(let i=2;i<=d;i++){
    for(let j=0;j<n;j++){
      if(i==c[j]+1){
        x++
        c[j]+=e[j]
      }
    }
  }
  to(x)
}
main()


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

int main()
{
  int X;
  cin >> X;
  for (int i = 1; i <= 360; i++)
  {
    if ((X * i) % 360 == 0)
    {
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 3612
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-18;
const double INF = 1e9;



int main(){
	long double x,y,xsum=0.0,ysum=0.0;
	char c;
	int cnt=0;
	vector<pair<long double,long double> >pi;
	while(cin>>x>>c>>y){
		pi.PB(MP(x,y));
		xsum+=x;ysum+=y;
		cnt++;
	}
	long double cx=xsum/cnt,cy=ysum/cnt;
	pi.PB(pi[0]);
	long double res=0.0;
	REP(i,SZ(pi)-1){
		long double a=sqrt(abs(cx-pi[i].first)*abs(cx-pi[i].first)+abs(cy-pi[i].second)*abs(cy-pi[i].second));
		long double b=sqrt(abs(cx-pi[i+1].first)*abs(cx-pi[i+1].first)+abs(cy-pi[i+1].second)*abs(cy-pi[i+1].second));
		long double c=sqrt(abs(pi[i].first-pi[i+1].first)*abs(pi[i].first-pi[i+1].first)+abs(pi[i].second-pi[i+1].second)*abs(pi[i].second-pi[i+1].second));
		long double z=(a+b+c)/2.0;
		res+=sqrt(z*(z-a)*(z-b)*(z-c));
		//cout<<fixed<<setprecision(7)<<sqrt(z*(z-a)*(z-b)*(z-c))<<endl;
		
	}
	cout<<fixed<<setprecision(7)<<res<<endl;
	return 0;
}

Measured memory_bytes: 1296
xs, *_ = ARGF.read.split("\n").map { |e| e.split }
s, *_ = xs.map { |e| e.to_i }

def f(n)
  if n % 2 == 0
    n / 2
  else
    3 * n + 1
  end
end

n = s
a = [s]
i = 2
while true
  x = f(n)
  # p [i, x]
  if a.include? x
    puts i
    exit
  end
  a << x
  n = x
  i += 1
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define P 1000000007
using namespace std;
typedef long long lnt;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, m, a[17];
lnt f[17][1<<16], tot;
lnt fac[1<<16], inv[1<<16];
void init() {
	fac[0] = inv[0] = inv[1] = 1;
	for (int i = 1; i < (1<<n); i++) fac[i] = fac[i-1]*i%P;
	for (int i = 2; i < (1<<n); i++) inv[i] = P-P/i*inv[P%i]%P;
	for (int i = 1; i < (1<<n); i++) inv[i] = inv[i-1]*inv[i]%P;
}
lnt coe(int s) {return __builtin_popcount(s)&1 ? -1LL : 1LL;}
lnt C(int n, int m) {return n < m ? 0 : fac[n]*inv[m]%P*inv[n-m]%P;}
int main() {
	read(n), read(m), init(), f[0][0] = 1;
	for (int i = 1; i <= m; i++) read(a[i]); sort(a+1, a+m+1, greater <int> ());
	for (int i = 0; i < m; i++) for (int s = 0; s < (1<<n); s++) if (f[i][s]) {
		(f[i+1][s] += f[i][s]) %= P;
		for (int j = 0; j < n; j++) if (!(s>>j&1))
			(f[i+1][s|(1<<j)] += C((1<<n)-s-a[i+1], (1<<j)-1)*f[i][s]%P*fac[1<<j]%P) %= P;
	}
	for (int s = 0; s < (1<<n); s++)
		(tot += coe(s)*f[m][s]*fac[(1<<n)-s-1]%P+P) %= P;
	return printf("%lld\n", tot*(1<<n)%P), 0;
}


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

typedef long long ll;

const ll mod = 1e9+7;
const int MAX = 100005;
const int N = 105;

ll dp[N][MAX];

int a[MAX];

ll sum(ll a ,ll b){
    return (a+b)%mod;
}

ll sub(ll a, ll b){
    return (a-b+mod)%mod;
}

int main(){
    int n, k;
    cin>>n>>k;
    for(int i = 1; i<=n; ++i){
        cin>>a[i];
    }

    int acum = 0;
    for(int i = 0; i<=N; ++i){
        dp[i][0] = 1;
    }

    for(int i = 1; i<=n; ++i){
        acum+=a[i];
        for(int j = 1; j<= acum && j<= k; ++j){
            dp[i][j] = sum(dp[i-1][j], dp[i][j-1]);
            if(j>a[i]){
                dp[i][j] = sub(dp[i][j], dp[i-1][j-a[i]-1]);
            }
        }
    }
    cout<<dp[n][k]<<"\n";
}


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

int main(){
  long long x, y;
  cin >> x >> y;

  long long count = 1;
  long long n = x;

  while(true){
    if(x*2 <= y){
      x *= 2;
      count++;
    } else {
      break;
    }
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define repd(i, n) for (ll i = (n)-1; i >= 0; --i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, ans;
    cin >> n >> m;
    if (n > 2 && m > 2)
        ans = n * m + 4 - 2 * (n + m);
    else
    {
        if (n == 2 || m == 2)
            ans = 0;
        else if (n == 1 && m == 1)
            ans = 1;
        else if (n == 1 || m == 1)
            ans = n * m - 2;
        else
            ans = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for (int i = 0; i < H; i++) {
        cin >> S.at(i);
    }
    
    bool can = true;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            bool flag = false;
            if (S.at(i).at(j) == '#') {
                for (int k = max(0, i - 1); k <= min(H - 1, i + 1); k++) {
                    if (k != i && S.at(k).at(j) == '#') {
                        flag = true;
                        break;
                    }
                }
                if (flag) continue;
                for (int l = max(0, j - 1); l <= min(W - 1, j + 1); l++) {
                    if (l != j && S.at(i).at(l) == '#') {
                        flag = true;
                        break;
                    }
                }
                if (flag) continue;
                can = false;
            }
            if (!can) break;
        }
        if (!can) break;
    }
    
    if (can) cout << "Yes" << endl; else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  string s;cin>>s;
  s = 'T'+s+'S';
  int n=(int)s.size();
  int pos=0;
  int ns=0, nt=0;
  int ans=n-2;
  while(pos<n){
    // out<<ns<<" "<<nt<<endl;
    if(s[pos]=='S'){
      if(ns*nt!=0){
        ans -= 2*min(ns, nt);
        ns=1+max(0, ns-nt);
        nt=0;
      }else{
        ns++;
      }
    }else{
      if(ns!=0)nt++;
    }
    pos++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 772
n=int(input())
t=[[0]*10 for _ in range(10)]
for i in range(1,n+1):
  t[int(str(i)[0])][i%10]+=1
a=0
for i in range(10):
  for j in range(10):
    a+=t[i][j]*t[j][i]
print(a)

Measured memory_bytes: 3060