akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  while(true){
    int n = getInt();
    int a = getInt();
    int b = getInt();

    if(a+b+n == 0) break;

    if(min(a,b) == 1){
      puts("0");
      continue;
    }

    vector<bool> f(n+1);
    int ans = 0;
    f[0] = true;

    REP(i,n+1)
      if(f[i]){
        if(i+a <= n) f[i+a] = true;
        if(i+b <= n) f[i+b] = true;
      }else{
        ++ans;
      }

    print(ans);
  }
  return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

// ax+by=gcd(x,y)となるx,yを求める
// 返り値は gcd(a,b)
template <typename T>
T extgcd(T a, T b, T &x, T &y)
{
    T d = a;
    if (b != 0)
    {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }
    else
    {
        x = 1;
        y = 0;
    }
    return d;
}

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

    ll a, b;
    cin >> a >> b;
    ll x, y;
    extgcd(a, b, x, y);
    cout << x << " " << y << endl;
}



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

namespace AtCoder.ARC._103
{
    class c
    {
        static Dictionary<int, int> odd = new Dictionary<int, int>();
        static Dictionary<int, int> even = new Dictionary<int, int>();

        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim();
            var N = int.Parse(line);
            line = Console.ReadLine().Trim();
            var A = Array.ConvertAll(line.Split(' '), new Converter<string, int>(s => int.Parse(s)));
            for(var i = 0; i < N; ++i)
            {
                if(i % 2 == 0)
                {
                    if (odd.ContainsKey(A[i]))
                    {
                        odd[A[i]]++;
                    }
                    else
                    {
                        odd.Add(A[i], 1);
                    }
                }
                else
                {
                    if (even.ContainsKey(A[i]))
                    {
                        even[A[i]]++;
                    }
                    else
                    {
                        even.Add(A[i], 1);
                    }
                }
            }
            var oddList = searchPair(odd);
            var evenList = searchPair(even);
            if(oddList[0].Item1 != evenList[0].Item1)
            {
                Console.WriteLine(N - oddList[0].Item2 - evenList[0].Item2);
            }
            else
            {
                if(oddList.Count == 1 && evenList.Count == 1)
                {
                    Console.WriteLine(N / 2);
                }
                else if (oddList.Count == 1)
                {
                    Console.WriteLine(N / 2 - evenList[1].Item2);
                }
                else if(evenList.Count == 1)
                {
                    Console.WriteLine(N / 2 - oddList[1].Item2);
                }
                else
                {
                    var oddN1 = oddList[0].Item2;
                    var oddN2 = oddList[1].Item2;
                    var evenN1 = evenList[0].Item2;
                    var evenN2 = evenList[1].Item2;
                    Console.WriteLine(N - (oddN1 + evenN2 > oddN2 + evenN1 ? oddN1 + evenN2 : oddN2 + evenN1));
                }
            }
        }


        private static List<Tuple<int,int>> searchPair(Dictionary<int, int> list)
        {
            List<Tuple<int, int>> t = new List<Tuple<int, int>>();
            foreach(var k in list.Keys)
            {
                t.Add(new Tuple<int, int>(k, list[k]));
            }
            t.Sort((x,y) => x.Item2 == y.Item2 ? x.Item1 - y.Item1 : y.Item2 - x.Item2);
            return t;
        }
    }
}


Measured memory_bytes: 31580
#include<bits/stdc++.h>
#define int long long
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
#define loop(i,n) for(int i=0;i<n;i++)
#define double long double
#define mod 1000000007
#define F first
#define S second
#define pb push_back

using namespace std;

// set<pair<int,int> > s;

// void summer(int n,int k,int sum,bool taken[])
// {
// 	if(k<=0 && k>=k-n-1)
// 	{
// 		s.insert(make_pair(sum,abs(k)));
// 		// cout<<sum<<" ";
// 	}

// 	for(int i=0;i<=n;i++)
// 	{
// 		if(taken[i]==0)
// 		{
// 			taken[i]=1;
// 			summer(n,k-1,sum+i,taken);
// 			taken[i]=0;
// 		}
// 	}
// }

signed main()
{
	fast;
	int test=1;
	// cin>>test;
	for(int index=0;index<test;index++)
	{
		int n,k;
		cin>>n>>k;
		int ans=0;

		vector<int> pre(n+1);
		vector<int> suff(n+1);

		int temp=0;
		for(int i=0;i<=n;i++)
		{
			temp+=i;
			pre[i]=temp;
		}
		
		temp=0;
		// cout<<"iosfdj"<<endl;
		for(int i=n;i>=0;i--)
		{
			temp+=i;
			suff[n-i]=temp;
		}
		// for(int i=0;i<=n;i++)
		// {
		// 	cout<<suff[i]<<" ";
		// }
		
		for(int i=n+1;i>=k;i--)
		{	
			// cout<<suff[i]-pre[i]<<" ";
			ans+=(suff[i-1]-pre[i-1])+1;
			ans=ans%mod;
		}
		// cout<<endl;
		cout<<ans<<endl;

		// bool taken[n+1];
		// s.clear();
		// s.clear();
		// memset(taken,sizeof(taken),false);
		// summer(n,k,0,taken);
		// // for(int i=k;i<=n+1;i++)
		// // {
		// // 	s.clear();
		// // 	memset(taken,sizeof(taken),false);
		// // 	summer(n,k,0,taken);
		// // 	ans+=s.size();
		// // }
		// // summer(n,k,0,taken);
		// cout<<s.size();
		// cout<<endl;
		// // cout<<s.size()<<endl;
		

	}
}



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

using namespace std;

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

signed main(){

	lli n,m;
	cin>>n>>m;

	/*言語を話せる人たちをまとめる*/
	map<lli,vector<lli>> l;

	/*また、j番目の人が話せる言語もまとめる*/
	map<lli,vector<lli>> p;

	for(lli i=0;i<n;i++){
		lli k;
		cin>>k;
		REP(j,0,k){
			lli tmp;
			cin>>tmp;
			l[tmp].push_back(i);
			p[i].push_back(tmp);
		}
	}

	lli lflag[100100]={0};
	lli pflag[100100]={0};

	/*0番目の人が話せる言語にアクセスする*/
	pflag[0]=1;
	queue<lli> q;
	q.push(0);

	while(q.size()){
		lli top = q.front();
		q.pop();
		if(DEBUG)cout<<"topPerson="<<top<<endl;
		/*この人は何の言語を話せる?*/
		for(auto e:p[top]){
			if(DEBUG)cout<<"Lang="<<e<<endl;
			if(lflag[e]==0){
				lflag[e]=1;
				/*この言語を話せる人をqにつっこみまくる*/
				for(auto f:l[e]){
					if(DEBUG)cout<<"nextPerson="<<f<<endl;
					if(pflag[f]==0){
						if(DEBUG)cout<<"push!"<<f<<endl;
						pflag[f]=1;
						q.push(f);
					}
				}
			}
		}
	}

	lli cnt=0;
	for(lli i=0;i<100100;i++){
		if(pflag[i])cnt++;
	}
	if(DEBUG)cout<<"cnt="<<cnt<<endl;
	if(cnt==n)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;

	return 0;
}

Measured memory_bytes: 14324
n = int(input())
*A, = input().split()
B = A[:]
for i in range(n):
    for j in range(n-1, i, -1):
        if A[j][1] < A[j-1][1]:
            A[j], A[j-1] = A[j-1], A[j]
print(*A)
print("Stable")
 
for i in range(n):
    minj = i
    for j in range(i, n):
        if B[j][1] < B[minj][1]:
            minj = j
    B[i], B[minj] = B[minj], B[i]
print(*B)
if A == B:
    print("Stable")
else:
    print("Not stable")


Measured memory_bytes: 5608
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>

using namespace std;

const int INF=1000000;
int cost[101][101];
int mincost[101];
bool used[101];
int V;
int prim(){
	int a;
	for(a=0;a<=100;a++){
		used[a]=false;
		mincost[a]=INF;
	}
	mincost[0]=0;
	int res=0;
	while(1){
		int v=-1;
		int u;
		for(u=0;u<V;u++){
			if(!used[u] && (v==-1 || mincost[u]<mincost[v]))v=u;
		}
		if(v==-1)break;
		used[v]=true;
		res+=mincost[v];
		for(u=0;u<V;u++){
			mincost[u]=min(mincost[u],cost[v][u]);
		}
	}
	return res;
}

int main(void){
	int a,b;
	int n;
	int ans;
	while(1){
		for(a=0;a<=100;a++){
			for(b=0;b<=100;b++){
				cost[b][a]=INF;
			}
			cost[a][a]=0;
		}
		cin >> V;
		if(V==0)break;
		cin >> n;
		for(a=0;a<n;a++){
			int c,d,e;
			scanf("%d,%d,%d",&c,&d,&e);
			cost[c][d]=e/100-1;
			cost[d][c]=e/100-1;
		}
		ans=prim();
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

const int N = 100005;

int i, sm[N], n, q, l, r;

bool isPrime(int x) {
  if(x == 1) return 0;
  if(x == 2) return 1;
  if(x % 2 == 0) return 0;

  for(int i = 3; i * i <= x; i += 2)
    if(x % i == 0) return 0;

  return 1;
}


int isGood(int x) {
  if(!isPrime(x)) return 0;
  if(!isPrime((x + 1) / 2)) return 0;
  return 1;
}

int main() {
  for(i = 2; i < N; ++i) sm[i] = sm[i - 1] + isGood(i);

  for(scanf("%d", &q); q; --q) {
    scanf("%d %d", &l, &r);
    printf("%d\n", sm[r] - sm[l - 1]);
  }

  return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){

  int n;
  cin >> n;
  VLL v(n);
  rep(i,n) cin >> v[i];
  sort(all(v));
  priority_queue< double, vector<double>, greater<double>> que;
  rep(i,n) que.push(v[i]);
  while(que.size() != 1){
    double a = que.top();
    que.pop();
    double b = que.top();
    que.pop();
    que.push((a+b)/2.);
  }
  printf("%0.10lf\n",que.top());
  return   0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

cnt = 0
CNT = []
ANS = []

for i in range(1, N):
    if H[i]<=H[i-1]:
        CNT.append(1)
    else:
        CNT.append(0)

for i in range(N-1):
    if CNT[i]==0:
        ANS.append(cnt)
        cnt = 0
    elif CNT[i]==1:
        cnt += 1
ANS.append(cnt)

print(max(ANS))

Measured memory_bytes: 20424
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

using namespace std;
using pii=pair<int,int>;
using ll=long long;

int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
    
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0; i<n; i++) cin>>v[i];
    sort(v.begin(),v.end());
    double answer=(v[0]+v[1])/2.0;
    for(int i=2; i<n; i++) answer=(answer+v[i])/2.0;
    cout<<answer;

    return 0;
}


Measured memory_bytes: 256
fn main() {
    proconio::input! {
        s: proconio::marker::Chars,
    }

    let r = if s[0] == 'R' {
        if s[1] == 'R' {
            if s[2] == 'R' {
                3
            } else {
                2
            }
        } else {
            1
        }
    } else {
        if s[1] == 'R' {
            if s[2] == 'R' {
                2
            } else {
                1
            }
        } else {
            if s[2] == 'R' {
                1
            } else {
                0
            }
        }
    };
    println!("{}", r);
}


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

// マクロ //
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) x * x

// 型エイリアス //
using lint = long long;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;

// 関数 //
int gcd(int a, int b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

// End of Template //

int main() {

    string s;
    cin >> s;
    if (s == "SUN") {
        cou("7");
    }
    if (s == "MON") {
        cou("6");
    }
    if (s == "TUE") {
        cou("5");
    }
    if (s == "WED") {
        cou("4");
    }
    if (s == "THU") {
        cou("3");
    }
    if (s == "FRI") {
        cou("2");
    }
    if (s == "SAT") {
        cou("1");
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    string s;
    cin >> s;
    s[5] = s[13] = ' ';
    cout << s;

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] ch = sc.next().toCharArray();
		sc.close();

		int len = ch.length+1;
		int[] L = new int[len];
		int[] R = new int[len];
		for(int i = 1;i < len;i++) {
			if(ch[i-1]=='<') {
				L[i] = L[i-1] + 1;
			}
		}
		for(int i = len-2;i >= 0;i--) {
			if(ch[i]=='>') {
				R[i] = R[i+1] + 1;
			}
		}
		//System.out.println(Arrays.toString(L));
		//System.out.println(Arrays.toString(R));;
		long ans = 0;
		for(int i = 0;i < len;i++) {
			ans += Math.max(L[i], R[i]);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 32828
using System.IO;
using System.Linq;
using static System.Console;

namespace RootedTree
{
    public class Program
    {
        private const int max = 100005, nil = -1;
        private static int[] m_depth = new int[max];
        private static Node[] m_tree = new Node[max];
        
        public static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());

            for (var i = 0; i < n; i++)
            {
                m_tree[i] = new Node();
                m_tree[i].parent = m_tree[i].left = m_tree[i].right = nil;
            }
            for (var i = 0; i < n; i++)
            {
                // id, degree, children
                var input = ReadLine().Split(' ').Select(int.Parse).ToList();
                int tmp = -1;
                for (var j = 0; j < input[1]; j++)
                {
                    // childの数
                    if (j == 0) m_tree[input[0]].left = input[2 + j];
                    else m_tree[tmp].right = input[2 + j];
                    tmp = input[2 + j];
                    m_tree[input[2 + j]].parent = input[0];
                }


               
            }
            var r = nil;
            for (var i = 0; i < n; i++)
            {
                if (m_tree[i].parent == nil) r = i;
            }
            
            GetDepth(r, 0);

            var sw = new StreamWriter(OpenStandardOutput()) {AutoFlush = false};
            SetOut(sw);
            for (var i = 0; i < n; i++)
            {
               Print(i); 
            }

            Out.Flush();
        }

        private static void Print(int u)
        {
            Write("node " + u + ": ");
            Write("parent = " + m_tree[u].parent + ", ");
            Write("depth = " + m_depth[u] + ", ");
            
            if(m_tree[u].parent == nil) Write("root, ");
            else if (m_tree[u].left == nil) Write("leaf, ");
            else Write("internal node, ");
            
            Write("[");

            for (int i = 0, c = m_tree[u].left; c != nil; i++, c = m_tree[c].right)
            {
                if(i != 0) Write(", ");
                Write(c);
            }
            
            WriteLine("]");
        }
        private static void GetDepth(int u, int p)
        {
            m_depth[u] = p;
            if (m_tree[u].right != nil) GetDepth(m_tree[u].right, p);
            if (m_tree[u].left != nil) GetDepth(m_tree[u].left, p + 1);
        }

        public class Node
        {
            public int parent;
            public int left;
            public int right;
        }
    }
}


Measured memory_bytes: 39176
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <unordered_set>
//#define local
#ifdef local
#include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
#include <boost/multiprecision/cpp_int.hpp>
#endif

#define p std::pair
#define ll long long
#define ull unsigned long long
#define pi (acos(-1))
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
constexpr ll mod=1000000000+7;

int main()
{
int a,b,c,d;cin>>a>>b>>c>>d;
while (true){
	c-=b;if(c<=0){cout<<"Yes"<<endl;return 0;}
	a-=d;
	if(a<=0){cout<<"No"<<endl;return 0;}
}
	return 0;
}

ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}



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

int main() {
  long long N,A,B;
  cin >> N >>A >>B;
  
  if (A>B) cout << 0 << endl;
  else if (N==1) cout << (A==B ? 1 :0 ) << endl;
  else cout << (N-2)*(B-A)+1 << endl;
}

Measured memory_bytes: 256
s = list(input())
n = len(s)
t = list(input())
m = len(t)
dp = [[0] * (m+1) for _ in range(n+1)]

for i in range(n+1):
    dp[i][0] = i

for j in range(m+1):
    dp[0][j] = j

for i in range(n):
    for j in range(m):
        cost = 0 if s[i] == t[j] else 1
        dp[i+1][j+1] = min(dp[i][j+1] + 1, dp[i+1][j] + 1, dp[i][j] + cost)

print(dp[n][m])



Measured memory_bytes: 43064
def run
  gets
  aa = gets.chomp.split(/\s+/).map(&:to_i)
  tc, _ = aa.reduce([0, 0]){|h, a| if h[1] <= a then [h[0], a] else [h[0] + h[1] - a, h[1]] end}
  puts tc
end

run


Measured memory_bytes: 36064
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef pair<int,int> pint;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=2020000000;

int N;
int s[110];

int main() {
	cin>>N;
	Rep(i,N) cin>>s[i];
	int sum=0;
	Rep(i,N) sum+=s[i];
	bool f=true;
	if(sum%10==0){
		sort(s,s+N);
		Rep(i,N){
			if(s[i]%10!=0){
				cout<<sum-s[i]<<endl;
				f=false;
				break;
			}
		}
		if(f) cout<<0<<endl;
	}
	else{
		cout<<sum<<endl;
	}
	


	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> valueList = new ArrayList<>();
        for (int i=0; i<n; i++){
            valueList.add(sc.nextInt());
        }

        if (n == 2){
            System.out.println(Math.max(valueList.get(0), valueList.get(1)));
        }else {
            int[] leftGCM = new int[n];
            int[] rightGCM = new int[n];

            for (int i=0; i<n; i ++){
                if (i == 0){
                    leftGCM[0] = valueList.get(0);
                    rightGCM[n-1] = valueList.get(n-1);
                }else {
                    leftGCM[i] = getGCM(valueList.get(i), leftGCM[i-1]);
                    rightGCM[n-1-i] = getGCM(valueList.get(n-1-i), rightGCM[n-i]);
                }
            }

            int maxGCM = 1;
            for (int i=0; i<n; i++){
                if (i == 0){
                    int gcm = rightGCM[i+1];
                    if (gcm > maxGCM){
                        maxGCM = gcm;
                    }
                }else if (i == n-1){
                    int gcm = leftGCM[i-1];
                    if (gcm > maxGCM){
                        maxGCM = gcm;
                    }
                }else {
                    int gcm = getGCM(leftGCM[i-1], rightGCM[i+1]);
                    if (gcm > maxGCM){
                        maxGCM = gcm;
                    }
                }
            }

            System.out.println(maxGCM);

        }
    }

    private static int getGCM(int a, int b){
        int larger = Math.max(a, b);
        int gcm = Math.min(a, b);

        if (gcm == 0){
            return larger;
        }

        while (larger % gcm != 0){
            int smaller = gcm;
            gcm = larger % gcm;
            larger = smaller;
        }

        return gcm;
    }
}

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

int main() {
  int n;
  cin >> n;
  int count1 =0;
  for(int i=1;i<n+1;i++){
    if (i%2 != 0) count1++;
  }
  cout << setprecision(7) << (double)count1/n << endl;
}

Measured memory_bytes: 256
N = int(input())
n = int(N/2)

li = list(map(int,input().split()))
li_s = sorted(li)

A = li_s[n-1]
B = li_s[n]

for i in range(N):
    if li[i] <=A:
        print(B)
    else:
        print(A)


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

int n, A[2005], q, m[2005];

bool solve(int i, int m) {
    if (m == 0) {
        return true;
    }
    if (i >= n) {
        return false;
    }
    bool result = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return result;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> m[i];
    }
    for (int i = 0; i < q; i++) {
        if (solve(0, m[i])) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3124
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;

const int N=100005;
const int inf=1000000000; 

struct E{
	int to,next;
}mem[N<<1];
int n,x,y,rt,num,ans,all;
int d[N],head[N],sz[N],tag[N],vis[N],dp[N],sum[N];
char s[N];
vector<int> lev[N];

void add(int x,int y){
	num++;
	mem[num].to=y; mem[num].next=head[x];
	head[x]=num;
}

void dfs1(int k,int pre){
	int j,u;
	sz[k]=1;
	if (s[k]=='B') sum[k]=1;
	for (j=head[k];j;j=mem[j].next){
		u=mem[j].to;
		if (u==pre) continue;
		dfs1(u,k);
		sz[k]+=sz[u];
		sum[k]+=sum[u];
	}
	if (sz[k]==sum[k]) vis[k]=1;
	if (sz[k]!=sum[k]){
		for (j=head[k];j;j=mem[j].next){
			u=mem[j].to;
			if (u==pre) continue;
			if (!vis[u]){
				lev[k].push_back(u);
				lev[u].push_back(k);
				d[k]++; d[u]++;
			}
		}
	}
}

void dfs2(int k,int pre){
	int j,u,mx1,mx2; mx1=mx2=-inf;
	if (tag[k]) dp[k]=1;
	else dp[k]=-1;
	dp[k]++;
	for (j=0;j<lev[k].size();j++){
		u=lev[k][j];
		if (u==pre) continue;
		dfs2(u,k);
		mx2=max(mx2,dp[u]);
		if (mx2>mx1) swap(mx1,mx2);
	}
	if (mx1!=-inf&&mx2!=-inf) ans=max(ans,mx1+mx2+dp[k]);
	if (mx1!=-inf){
		ans=max(ans,mx1+dp[k]);
		dp[k]=mx1+dp[k];
	}
}

int main(){
	int i;
	scanf("%d",&n);
	for (i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	scanf("%s",s+1);
	for (i=1;i<=n;i++)
		if (s[i]=='W'){
			rt=i;
			break;
		}
	if (!rt){
		printf("0\n");
		return 0;
	}
	dfs1(rt,0);
	for (i=1;i<=n;i++) if (!vis[i]){
		tag[i]=0; all++;
		if ((s[i]=='W'&&d[i]%2==0)||(s[i]=='B'&&d[i]%2==1)) tag[i]=1;
	}
	all=(all-1)*2;
	for (i=1;i<=n;i++) all+=tag[i];
	dfs2(rt,0);
	printf("%d\n",all-ans);
	return 0;
} 

Measured memory_bytes: 17920
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
	
ll mod = 1e9 + 7;

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1){
            res = res * a;
			res %= mod;
		}
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}


int main(){
	ll n; cin >> n;
	if(n == 1)cout << 0;
	else{
		cout << (binpow(10, n) - (binpow(9, n) * 2 % mod) + binpow(8, n) + mod) % mod;
	}
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <iomanip>
#include <tuple>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;


int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int v[n];
	rep(i,0,n) cin >> v[i];
	int vpl[100005] = {};
	int vpr[100005] = {};

	rep(i,0,n){
		if(i%2==0){
			vpl[v[i]]++;
		}else{
			vpr[v[i]]++;
		}
	}
	int ml1=0,mr1=0,ml2=0,mr2=0;
	int ml1p,ml2p,mr1p,mr2p;
	rep(i,0,100005){
		if(ml1<=vpl[i]){
			ml2 = ml1;
			ml1 = vpl[i];
			ml2p = ml1p;
			ml1p = i;
		}else if(ml2<vpl[i]){
			ml2 = vpl[i];
			ml2p = i;
		}
		if(mr1<=vpr[i]){
			mr2 = mr1;
			mr1 = vpr[i];
			mr2p = mr1p;
			mr1p = i;
		}else if(ml2<vpr[i]){
			mr2 = vpr[i];
			mr2p = i;
		}
	}
	if(ml1p != mr1p){
		cout << n - ml1 - mr1 << endl;
	}else{
		if(ml1+mr2 > ml2+mr1){
			cout << n - ml1 - mr2 << endl;
		}else{
			cout << n - ml2 - mr1 << endl;
		}
	}

}




Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if((a>=1 && a<=9) && (b>=1 && b<=9))
	{
		cout<<a*b<<endl;
	}
	else
	{
		cout<<"-1"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    string s;
    cin >> s;

    for (auto cc : index(s)) {
        auto c = cc.value();
        if ((cc.index() + 1) % 2 == 0) {
            if (c == 'R') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (c == 'L') {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <cassert>
#include <fstream>

using namespace std;

int main() {
    
    
    string s;
    cin >> s;
    
    string s1, s2;
    s1 = s.substr(0, 2);
    s2 = s.substr(2);
    
    int i1 = stoi(s1);
    int i2 = stoi(s2);
    
    if (i1 > 12)
    {
        if (i2 > 12 || i2 == 0)
        {
            cout << "NA" << endl;
        }
        else
        {
            cout << "YYMM" << endl;
        }
    }
    else
    {
        if (i2 > 12)
        {
            if (i1 == 0)
            {
                cout << "NA" << endl;
            }
            else
            {
                cout << "MMYY" << endl;
            }
        }
        else
        {
            if (i1 == 0 && i2 == 0)
            {
                cout << "NA" << endl;
            }
            else if (i1 == 0)
            {
                cout << "YYMM" << endl;
            }
            else if (i2 == 0)
            {
                cout << "MMYY" << endl;
            }
            else
            {
                cout << "AMBIGUOUS" << endl;
            }
        }
    }
    
    
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int N= sc.nextInt();
        int game=N*(N-1)/2;
        int point[] =new int[N];
        for(int i=0;i<game;i++){
            int a=sc.nextInt();
            int b=sc.nextInt();
            int c=sc.nextInt();
            int d=sc.nextInt();
            if(c<d){
                point[b-1]+=3;
            }else if(c>d){
                point[a-1]+=3;
            }else if(c==d){
                point[a-1]+=1;
                point[b-1]+=1;
        }
        }
        int r[]=new int[N];
        for(int i=0;i<N;i++){
        r[i]=1;
        for(int j=0;j<N;j++){
        if(point[i]<point[j]){
        r[i]=r[i]+1;
        }
        }
        }
        for(int i=0; i<N;i++){
        System.out.println(r[i]);
        }
    	}
		}

Measured memory_bytes: 42168
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	for(cin>>n;n--;){
		string a,b;
		cin>>a;
		cin>>b;
		if(a.size()<b.size())swap(a,b);
		while(b.size()<a.size())b="0"+b;
		int f=0;
		for(int i=a.size()-1;i>=0;i--){
			a[i]+=(b[i]-'0'+f);
			if(a[i]>'9'){
				a[i]-=10;
				f=1;
			}else f=0;
		}
		if(f)a="1"+a;
		if(a.size()>80)
			cout<<"overflow"<<endl;
		else
			cout<<a<<endl;
		
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
#define gap ' '
#define L(i) ((i) - (&i))

const int MAXN = 1e9+1;
const int MAX = 1e6 + 1;
const int MOD = 1e9;
const int INF = 1e9 + 5; 

int main(){	
	int n; cin >> n;
	int x,l;
	vector<pair<int,int>> fi(n);
	for(int i = 0; i < n; ++i){
		cin >> x >> l;
		fi[i].first = x+l;
		fi[i].second = x-l;
	}
	sort(fi.begin(), fi.end());
	int ans = 1, k = fi[0].first;
	for(int i = 1; i < n; ++i){
		if(fi[i].second >= k)
			++ans,k=fi[i].first;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3972
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> X(N),Y(N);
    rep(i,0,N){
        cin >> X[i] >> Y[i];
    }
    map<P, int> mp;
    rep(i,0,N)rep(j,0,N){
        if(i==j)continue;
        P p = P(X[i] - X[j], Y[i] - Y[j]);
        mp[p]++;
    }
    int maxi = 0;
    for(auto pp:mp){
        maxi = max(maxi, pp.second);
    }
    cout << N - maxi<< endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <utility>
#include <cmath>

using namespace std;
int main (){
    int n,m;
    cin >> n >> m;
    int a[n];
    int b[n];
    int c[m];
    int d[m];
    int mdist[n];
    int tmdist;
    int student[n];
    for (int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        mdist[i]=INT32_MAX;
    }
    for (int i = 0; i < m; i++){
        cin >> c[i] >> d[i];
    }




    for (int i = 0; i < m; i++){
    for (int j = 0; j < n; j++){
        tmdist=abs(a[j]-c[i])+abs(b[j]-d[i]);
        if(tmdist<mdist[j]){
            mdist[j]=tmdist;
            student[j]=i;
        }
    }
    }

    for (int i = 0; i < n; i++)
    {
        cout << student[i]+1 << "\n";
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N; cin >> N;
		UL H, W; cin >> H >> W;
		UL ans = 0;
		rep(i, N) {
			UL h, w; cin >> h >> w;
			if (H <= h && W <= w) ans++;
		}
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 256
import numpy as np

n, m, q = map(int, input().split())

mat = np.zeros((n, n), dtype=int)

for _ in range(m):
    l, r = map(int, input().split())
    mat[l-1][r-1] += 1

ans = np.cumsum(np.cumsum(mat, axis=1)[::-1], axis=0)[::-1]

for _ in range(q):
    l, r = map(int, input().split())
    print(ans[l-1][r-1])


Measured memory_bytes: 18380
/*
 * 3028_Ball.c
 *
 *  Created on: 2019/05/19
 *      Author: nagashima
 */

#include <stdio.h>
#include <stdlib.h>

typedef struct ball{
	int color;
	int value;
}ball;

ball aux[1000*100];

void merge(ball a[], int l, int m, int r);
void mergesort(ball a[], int l, int r);

int main(){
	int N,M,C;
	int *l;
	ball *b;
	int res=0;
    int count=0;

	scanf("%d %d %d",&N,&M,&C);
	l=(int *)malloc(C*sizeof(int));
	b=(ball *)malloc(N*sizeof(ball));
	for(int i=0;i<C;i++)scanf("%d",&l[i]);
	for(int i=0;i<N;i++)scanf("%d %d",&b[i].color,&b[i].value);

    mergesort(b, 0, N-1);

    for(int i=N-1;i>-1;i--){
    	//printf("i:%2d color:%2d color_num:%2d value:%2d\n",i,b[i].color,l[b[i].color-1],b[i].value);
    	if(l[b[i].color-1]>0){
    		res+=b[i].value;
    		l[b[i].color-1]--;
    		count++;
    	}
    	if(count>=M)break;
    }



	printf("%d\n",res);

	free(l);
	free(b);
	return 0;
}

void merge(ball a[], int l, int m, int r){
	int i, j, k;
	for(i=m+1;i>l;i--)aux[i-1]=a[i-1];
	for(j=m;j<r;j++)aux[r+m-j]=a[j+1];
	for(k=l;k<=r;k++)
		if(aux[j].value<aux[i].value)
			a[k]=aux[j--];
		else
			a[k]=aux[i++];
}
void mergesort(ball a[], int l, int r){
	int m=(r+l)/2;
	if(r<=l)return;
	mergesort(a, l, m);
	mergesort(a, m+1, r);
	merge(a, l, m, r);
}



Measured memory_bytes: 3336
fun main(args : Array<String>) { 
  val (K, S) = readLine()!!.split(" ").map { x -> x.toInt() } 
  val r = (0..K).map { x ->
    (0..K).map { y ->
      val z = S - x - y
      if(0 <= z && z <= K) {
        //println("$x, $y, $z")
        1
      } else { 
        0
      }
    }
  }.flatMap { x ->
    x
  }.reduce { x,y ->
    x+y
  }
  println(r)
}


Measured memory_bytes: 163600
#include <iostream>
#include <vector>
using namespace std;
int N,Q;
int pars[100001];
bool input(){
	scanf("%d%d",&N,&Q);
	int par;
	if(N == 0 && Q ==0) return false;
	for(int i = 2;i <= N;++i){
		scanf("%d",&par);
		pars[i] = par;
	}
	pars[1] = 1;
}

int find(int x){
	if(x == pars[x]) return x;
	return find(pars[x]);
}

void M(int x){
	pars[x] = x;
}

int main(){
	while(input()){
		long long res = 0;
		char a;
		int b;
		for(int i = 0;i < Q;++i){
			scanf("\n%c%d",&a,&b);
			if(a == 'Q') res += find(b);
			else M(b); 
		}
		cout << res << endl;
	}
	return 0;
}


Measured memory_bytes: 3528
#include <iostream>

using namespace std;

int main(){

  int a,b,c,x;
  cin >> a >> b >> c >> x;

  int ans = 0;
  for(int i = 0; i <= a; i++){
	for(int j = 0; j <= b;j++){
	  for(int k = 0; k <= c;k++){
		if(500*i + 100*j + 50*k == x){
		  // cout << i << j << k<< endl;
		  ans++;
		}
	  }
	}
  }

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


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

int main() {
  int n;
  cin >> n;
  
  int page;
  
  if (n % 2 == 0) {
    page = n / 2;
  }
  else {
    page = n / 2 + 1;
  }
  cout << page << endl;
  return 0;
}

Measured memory_bytes: 256
N,W = map(int,input().split())
l0=[]
l1=[]
l2=[]
l3=[]
for i in range(N):
    w,v = map(int,input().split())
    if i == 0:
        w1 = w
    if w == w1:
        l0.append(v)
    elif w == w1+1:
        l1.append(v)
    elif w == w1+2:
        l2.append(v)
    elif w == w1+3:
        l3.append(v)

l0.sort()
l0.reverse()
l1.sort()
l1.reverse()
l2.sort()
l2.reverse()
l3.sort()
l3.reverse()
l0 = [0]+l0
l1 = [0]+l1
l2 = [0]+l2
l3 = [0]+l3
import numpy as np
l0 = np.cumsum(np.array(l0))
l1 = np.cumsum(np.array(l1))
l2 = np.cumsum(np.array(l2))
l3 = np.cumsum(np.array(l3))

ans = 0
for i in range(len(l0)):
    for j in range(len(l1)):
        for k in range(len(l2)):
            for l in range(len(l3)):
                if i*w1+j*(w1+1)+k*(w1+2)+l*(w1+3)<=W:
                    if ans < l0[i]+l1[j]+l2[k]+l3[l]:
                         ans = l0[i]+l1[j]+l2[k]+l3[l]

print(ans)

Measured memory_bytes: 21500
#include <bits/stdc++.h>
using namespace std;
const int mod = 1'000'000'007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &i : a) cin >> i;
  long long ans = 0, tot = 0;
  for (int i : a) {
    ans = (ans + tot * i) % mod;
    tot = (tot + i) % mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3992
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+50;
typedef long long ll;
int r[maxn];
int x,k,q,t,a;
int sgn=-1;
int pos=1,und,ds;
ll mx,mn,all;
void cal(ll &y)
{
    if(y<0)
        y=0;
    if(y>x)
        y=x;
}
void solve()
{
    while(r[pos]<=t&&pos<=k)
    {
        ll ds=(r[pos]-r[pos-1])*sgn;
        mx+=ds;
        mn+=ds;
        all+=ds;
        cal(mx);
        cal(mn);
        pos++;
        sgn*=-1;
        //cout << all << endl;
    }
    ll ans=a+all;
    if(ans>mx)
        ans=mx;
    if(ans<mn)
        ans=mn;
    ll temp=(t-r[pos-1])*sgn;
    ans+=temp;
    cal(ans);
    printf("%lld\n",ans);
}
int main()
{
    //ios::sync_with_stdio(false);
    scanf("%d%d",&x,&k);
    for(int i=1; i<=k; i++)
    {
        scanf("%d",&r[i]);
        //cin>>r[i];
    }
    pos=1;
    mx=x,mn=0,all=0;
    sgn=-1;
    r[0]=0;
    scanf("%d",&q);
    while(q--)
    {

        //cin>>t>>a;
        scanf("%d%d",&t,&a);
        solve();
    }
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 1536
import sys
import math
import bisect
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

k, x = na()
if 500 * k >= x:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def _kosa(a1, a2, b1, b2):
    x1,y1 = a1
    x2,y2 = a2
    x3,y3 = b1
    x4,y4 = b2

    tc = (x1-x2)*(y3-y1)+(y1-y2)*(x1-x3)
    td = (x1-x2)*(y4-y1)+(y1-y2)*(x1-x4)
    return tc*td < 0

def kosa(a1, a2, b1, b2):
    return _kosa(a1,a2,b1,b2) and _kosa(b1,b2,a1,a2)

def ky(p1, p2):
    return pow(pow(p1[0]-p2[0], 2) + pow(p1[1]-p2[1], 2), 0.5)

def distance3(p1, p2, p3):
    x1,y1 = p1
    x2,y2 = p2
    x3,y3 = p3

    ax = x2 - x1
    ay = y2 - y1
    bx = x3 - x1
    by = y3 - y1

    r = (ax*bx + ay*by) / (ax*ax + ay*ay)
    if r <= 0:
        return ky(p1, p3)
    if r >= 1:
        return ky(p2, p3)
    pt = (x1 + r*ax, y1 + r*ay, 0)
    return ky(pt, p3)


def main():
    rr = []

    def f(n):
        sx,sy,ex,ey = LI()
        sp = (sx,sy)
        ep = (ex,ey)
        a = [LI() for _ in range(n)]
        td = collections.defaultdict(lambda: inf)
        for x1,y1,x2,y2,h in a:
            ps = [(x1,y1), (x1,y2), (x2,y1), (x2,y2)]
            for p1,p2 in itertools.combinations(ps, 2):
                if kosa(sp,ep,p1,p2):
                    return 0
                for p in [sp,ep]:
                    dc = distance3(p1,p2,p)
                    if td[h] > dc:
                        td[h] = dc

            for p in ps:
                dc = distance3(sp,ep,p)
                if td[h] > dc:
                    td[h] = dc

        r = 1000
        for h,k in td.items():
            if k < h:
                if r > k:
                    r = k
                continue
            tr = 1.0 * (h**2 + k**2) / h / 2
            if r > tr:
                r = tr

        return '{:0.4f}'.format(r)

    while 1:
        n = I()
        if n == 0:
            break
        rr.append(f(n))
        # print('rr', rr[-1])

    return '\n'.join(map(str,rr))


print(main())



Measured memory_bytes: 9120
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, A; cin >> N >> A; ll X = A;
    vl as(N+1, 0);
    FOR(i,1, N+1){
        cin >> as[i]; X = max(X, as[i]);
    }
    
    vector<vvl> dp(N + 1, vvl(N + 1, vl(N * X + 1, 0)));
    dp[0][0][0]=1;
    FOR(i,1,N+1){
        REP(j, i+1){
            REP(k, j * X + 1){
                if(k < as[i] && i>=1)
                    dp[i][j][k] = dp[i-1][j][k];
                else if(k >= as[i] && i>=1 && j>=1)
                    dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-as[i]];
            }
        }
    }
    ll ret = 0;
    FOR(i, 1, N+1){
        ret += dp[N][i][i*A];
    }
    cout << ret << endstr;
    return 0;
}


Measured memory_bytes: 52224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

int gcd(int a, int b) {
  if (a < b) {
    swap(a, b);
  }
  if (a % b == 0) {
    return b;
  } else {
    return gcd(b, a-b);
  }
}

int gcd(int a, int b, int c) {
  int d = gcd(a, b);
  return gcd(d, c);
}
  
  
int main() {
  int k;
  cin >> k;
  int sum = 0;
  for (int a=1; a<=k; a++) {
    for (int b=1; b<=k; b++) {
      for (int c=1; c<=k; c++) {
	sum += gcd(a, b, c);
      }
    }
  }
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 3624
N, K = map(int, input().split())
p = list(map(int, input().split()))
if N == K:
    print((sum(p) + N) / 2)
else:
    s = sum(p[:K])
    ans = s
    for i in range(N - K):
        s += p[i + K] - p[i]
        ans = max(ans, s)
    print((ans + K) / 2)


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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    int a, b;
    cin.ignore();
    cin >> a >> b;
    cout << ((10 * a + b) % 4 == 0 ? "YES" : "NO") << endl;
}

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

int count(int n){
        if(n==0) return 0;
        return (n & 1) + count(n >> 1);
}

void search(){
        int N,ans;
        int x[15][14],y[15][14];
        int A[15];
        cin >> N;
        for(int i=0;i<N;i++){
                cin >> A[i];
                for(int j=0;j<A[i];j++){
                        cin >> x[i][j] >> y[i][j];
                }
        }
        ans = 0;
        for(int i=1;i<(1 << N);i++){
                bool ok = true;
                for(int j=0;j<N;j++){
                        if(!(i & (1 << j))) continue;
                        for(int k=0;k<A[j];k++){
                                if(((i >> (x[j][k]-1)) & 1) ^ y[j][k]) ok = false;
                        }
                }
                if(ok) ans = max(ans, count(i));
        }
        cout << ans << endl;
}

int main(){
        search();
        return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define MM	1000000
using namespace std;
int main(void)
{
	int i,j,n,p,k[101],t[101][100];
	int s,d,leng[101],r,flg[101],f,v,ii,jj,x;
	scanf("%d",&n);
	for(i=1;i<=n;i++)	{
		scanf("%d",&r);
		scanf("%d",&k[r]);
		for(j=0;j<k[r];j++)	{
			scanf("%d",&t[r][j]);
		}
	}
	scanf("%d",&p);
	for(i=0;i<p;i++)	{
		scanf("%d %d %d",&s,&d,&v);
		f=0;
		for(j=1;j<=n;j++)	{
			flg[j]=0;	leng[j]=MM;
		}
		leng[s]=1;
		for(j=1;j<v;j++)	{
			for(ii=1;ii<=n;ii++)	{
				if(leng[ii]==j)	{
					for(jj=0;jj<k[ii];jj++)	{
						x=t[ii][jj];
						if(leng[x]>j+1)	{
							leng[x]=j+1;
						}
						if(x==d)	{
							f=1;
							ii=n+1;
							j=v;
							break;
						}
					}
				}
			}
		}
		if(f==1)	{
			printf("%d\n",leng[d]);
		}
		else {
			printf("NA\n");
		}
	}
	return 0;
}


Measured memory_bytes: 1076
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  ll n,d; cin >> n >> d;
  vector<ll> x(n),y(n); rep(i,n) cin >> x[i] >> y[i];

  int ans = 0;
  rep(i,n){
    if(x[i]*x[i]+y[i]*y[i] <= d*d) ans++;
  }
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 6348
#include<stdio.h>
int main()
{
	int n,i;
  	long long s=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
  {
    if(i%3!=0&&i%5!=0)
      s=s+i;
  }
 printf("%lld",s);
  return 0;
}


Measured memory_bytes: 1732