akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Array.Sort(a);
            var max = a[n - 1];
            var center = max / 2d;
            var med = 0;

            if (n == 2)
                med = a[0];
            else
            {
                var min = double.MaxValue;
                for (var i = 0; i < n; i++)
                {
                    var abs = Math.Abs(a[i] - center);
                    if (min > abs)
                    {
                        min = abs;
                        med = a[i];
                    }
                }
            }

            Console.WriteLine($"{max} {med}");
        }
    }
}


Measured memory_bytes: 20832
import java.util.Scanner;

public class Main {

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

	    int N=gi();
	    String S= gs();
	    
	    char bc= S.charAt(0);
	    int n=1;
        for (int i=0; i<S.length(); i++) {
        	char c=S.charAt(i);
        	if (c!=bc) {
        		n++;
        		bc=c;
        	}
        }


        System.out.print(n);
        

	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
}

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

int main() {
    string  s;
    int     size;
    
    cin >> s;
    
    size = s.size();
    
    for ( int ii = 0; ii < size; ii++ ) {
        if ( s[ii] == 'B' ) {
            if ( ii == 0 ) {
                s.erase(ii, 1);
                ii--;
            } else {
                s.erase(ii - 1, 2);
                ii -= 2;
            }
            size = s.size();
        }
    }
    
    cout << s << endl;
    
    return 0;
    
}

Measured memory_bytes: 3580
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<cmath>
using namespace std;
int main(){
double n,d;
cin>>n>>d;
double x[11][11];
int count=0;
for(int i=0;i<n;i++){
  for(int j=0;j<d;j++){
    cin>>x[i][j];
  }
}

for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    double a=0;
    for(int k=0;k<d;k++){
      a+=abs(x[i][k]-x[j][k])*abs(x[i][k]-x[j][k]);
    }
    a=sqrt(a);
    if(fmod(a,1)==0)count++;
  }
}

cout<<count;

return 0;
}

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

int main() {
    double r;
    const double pi = 3.1415926535897932384626433;
    cin >> r;
    cout << setprecision(6) << fixed;
    cout << pi*r*r << ' ' << 2*r*pi << endl;
    return 0;
}


Measured memory_bytes: 3272
import sys

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

students = []
for _ in range(n):
    a, b = map(int, input().split())
    students.append((a, b))

checkpoints = []
for _ in range(m):
    c, d = map(int, input().split())
    checkpoints.append((c, d))

for i in range(n):
    min = sys.maxsize
    ans = -1
    for j in range(m):
        distance = abs(students[i][0] -
                       checkpoints[j][0]) + abs(students[i][1] -
                                                checkpoints[j][1])
        if min > distance:
            min = distance
            ans = j + 1
    print(ans)


Measured memory_bytes: 39280
#include<bits/stdc++.h>
using namespace std;
string ver;
map<int,int>mp;
map<int,bool>chk;

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int n,k,m,a,ans,i;
    cin>>n>>m;
    k=ans=0;
    while(m--)
    {
        cin>>a>>ver;
        if(chk.find(a)==chk.end())
        {
            if(ver=="AC")
            {
                k++;
                chk[a]=true;
                ans+=mp[a];
            }
            else mp[a]++;
        }
    }
    cout<<k<<" "<<ans<<endl;
    return 0;
}


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

const int INF = 0x3f3f3f3f;

class Edge{
public:
    int to, cost;
    Edge(int to, int cost): to(to), cost(cost){};
};

vector<int> dijkstra(vector<vector<Edge>>& G, int s){
    int N = G.size();
    vector<int> d(N, INF);
    
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
    d[s] = 0;
    q.push(make_pair(d[s], s));
    
    while(!q.empty()){
        pair<int, int> v = q.top(); q.pop();
        if(v.first != d[v.second])
            continue;
        
        for(Edge &e: G[v.second]){
            if(e.cost + d[v.second] < d[e.to]){
                d[e.to] = e.cost + d[v.second];
                q.push(make_pair(d[e.to], e.to));
            }
        }
    }
    return d;
}


int N, M, C;

void solve(){
    string src, dst;
    cin >> src >> dst;
    
    map<string, int> stoi;
    vector<string> cs(N), cd(N);
    vector<int> ds(N);
    for(int i=0; i<N; i++){
        cin >> cs[i] >> cd[i] >> ds[i];
        
        if(stoi.find(cs[i]) == stoi.end()){
            int x = stoi.size();
            stoi[cs[i]] = x;
        }
        if(stoi.find(cd[i]) == stoi.end()){
            int x = stoi.size();
            stoi[cd[i]] = x;
        }
    }
    
    vector<int> gass(M);
    for(int i=0; i<M; i++){
        string s; cin >> s;
        gass[i] = stoi[s];
    }
    gass.push_back(stoi[src]);
    gass.push_back(stoi[dst]);
    M = gass.size();
    
    vector<vector<Edge>> G(stoi.size());
    for(int i=0; i<N; i++){
        int si = stoi[cs[i]];
        int di = stoi[cd[i]];
        
        G[si].emplace_back(di, ds[i]);
        G[di].emplace_back(si, ds[i]);
    }
    
    vector<vector<int>> mat(M, vector<int>(M, INF));
    for(int i=0; i<M; i++)
        mat[i][i] = 0;
        
    for(int i=0; i<M; i++){
        int gs = gass[i];
        auto d = dijkstra(G, gs);
        for(int j=0; j<M; j++){
            int gd = gass[j];
            if(d[gd] <= C*10){
                mat[i][j] = d[gd];
                mat[j][i] = d[gd];
            }
        }
    }
    
    for(int k=0; k<M; k++)
        for(int i=0; i<M; i++)
            for(int j=0; j<M; j++)
                mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j]);

    cout << (mat[M-2][M-1] == INF? -1: mat[M-2][M-1]) << endl;
}

int main(){
    while(cin >> N >> M >> C, N|M|C)
        solve();
    
    return 0;
}

Measured memory_bytes: 4032
#include<stdio.h>
#include<string.h>
int main()
{
    char num[1005];
    int sum=0;
    while(1)
    {
        scanf("%s",num);
        sum=0;
        if (num[0]=='0') break;
        int i, sz=strlen(num);
        for(i=0;i<sz;i++)
 
        {
            sum+=num[i] - '0';
        }
 
    printf("%d\n",sum);
}
}


Measured memory_bytes: 2064
A,B,C = gets.split.map(&:to_i)

a = 10*A+B+C
b = 10*B+A+C
c = 10*C+A+B

r = Array.new
r[0] = a
r[1] = b
r[2] = c

max = -10000
for i in 0..2
 if r[i] > max
  max = r[i]
 end
end

puts(max)


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a+b>=c) out("Yes");
    else out("No");
}


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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	int cnt = 0;
	int step = 0;
	while (cnt < N) {
		step++;
		cnt += 2 * D + 1;
	}

	cout << step << "\n";

	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 a = sc.nextInt();
    int b = sc.nextInt();
    int answer=0;
    for(int i=1;i<=a;i++){
      if(i!=a){
        answer++;
      }else{
        if(a<=b){
          answer++;
        }
      }
    }
    System.out.print(answer);
  }
}


Measured memory_bytes: 21844
//Tax Rate Changed
#include<bits/stdc++.h>
using namespace std;

int main(){
  double x, y, s;
  while(true){
    cin>>x>>y>>s;
    if(x==0 && y==0 && s==0)break;
    int mx=0;
    for(double i=1; i<s; i+=1){
      for(double j=1; j<s; j+=1){
        if(i+j>s)break;
        int tmp;
        if((int)(i*(100.0+x)/100.0)+(int)(j*(100.0+x)/100.0) != (int)s)continue;
        tmp=(int)(i*(100.0+y)/100.0)+(int)(j*(100.0+y)/100.0);
        if(mx<tmp)mx=tmp;
      }
    }
    cout<<mx<<endl;
  }
  return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 1;
  for (int i = 1;i < n;i++){
    if (s[i-1] == s[i]){
      continue;
    }
    else{
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,count=0;
    long long int n,temp;
    cin >> n;
    int min=INT_MAX;
    //int arr[n+1];
    for(i=1;i<=n;i++)
    {
        cin >> temp;
        if(temp<min)
        {
            min=temp;
        }
        if(min==temp)
        {
            count++;
        }
    }
    cout << count;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define pb push_back
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])
		cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
/* Be your own light */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

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

    ll r;
    cin>>r;
    double d = 2* 3.1415926535897932*r;
    printf("%.9f", d);
}

Measured memory_bytes: 3736
package main

import "fmt"

var N, X int
var m []int

func main() {
	fmt.Scanf("%d %d", &N, &X)

	m := make([]int, N)

	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &m[i])
	}

	min := m[0]
	ans := N
	for i := 0; i < N; i++ {
		X -= m[i]
		if m[i] < min {
			min = m[i]
		}
	}

	ans += X / min

	fmt.Println(ans)
}


Measured memory_bytes: 512
from collections import deque

n=int(input())

tree=[[] for i in range(n)]
for i in range(n-1):
 a,b,c=map(int,input().split())
 tree[a-1].append([b-1,c])
 tree[b-1].append([a-1,c])

def BFS(s):
 dist=[-1 for i in range(n)]
 dist[s]=0

 que=deque()
 que.append(s)

 while que:
  x=que.popleft()
  for i,c in tree[x]:
   if dist[i]==-1:
    que.append(i)
    dist[i]=dist[x]+c

 return dist

q,k=map(int,input().split())
k_dist=BFS(k-1)

for i in range(q):
 x,y=map(int,input().split())
 print(k_dist[x-1]+k_dist[y-1])

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

int main() {
    int x[5];
    for (int i = 0; i < 5; i++) cin >> x[i];
    for (int i = 0; i < 5; i++) {
        if (x[i] == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,st,e;
    string s;
    cin>>s;
    int l=s.length();
    for(int i=0;i<l;i++)
    {
        if(s[i]=='A')
        {
            st=i+1;
            break;
        }
    }
    for(int i=0;i<l;i++)
    {
        if(s[i]=='Z')
        {
            e=i+1;
        }
    }
    m=e-st+1;
    cout<<m<<endl;
    return 0;
}


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
ll MOD = ll(1e8) + 9;

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    ll ans = 0;
    if (K <= A) {
        cout << K << endl;
        return;
    }

    K -= A;
    ans += A;
    if (K <= B) {
        cout << ans << endl;
        return;
    }

    K -= B;
    cout << ans - K << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}



Measured memory_bytes: 3612
N = int(input())
ans = 0

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return len(divisors)


for i in range(1,N+1,2):
    if make_divisors(i) == 8:
        ans += 1
print(ans)



Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

    public static void main(String[] args) {

        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        PrintWriter out = new PrintWriter(System.out);

        try {
    		String strData = br.readLine();
    		String strDat[] = strData.split(" ", -1);

    		int intR = Integer.parseInt(strDat[0]);
    		int intD = Integer.parseInt(strDat[1]);
    		int intX = Integer.parseInt(strDat[2]);

//    		System.out.println(intR );
//    		System.out.println(intD );
//    		System.out.println(intX );

    		int x =intX;

    		for (int y = 2000 ; y < 2010 ; y++) {
    			x = intR * x - intD;
        		System.out.println(x );
    		}




    		out.flush();


        } catch (IOException e) {

        }


    }


}

Measured memory_bytes: 21204
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vadim Semenov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABCSwap solver = new ABCSwap();
        solver.solve(1, in, out);
        out.close();
    }

    static final class ABCSwap {
        public void solve(int __, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            out.println(c + " " + a + " " + b);
        }

    }

    static class InputReader {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(readLine());
            }
            return tokenizer.nextToken();
        }

        public String readLine() {
            String line;
            try {
                line = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }

    }
}



Measured memory_bytes: 21328
#include <bits/stdc++.h>
using namespace std;
string s,t;
int ans[3001][3001];
int dp[3001][3001];
string subseq="";
void answer(int i, int j){
      if(i<=0 || j<=0) return;
      else if(ans[i][j]==1) {subseq+=s[i-1];answer(i-1,j-1);}
      else if(ans[i][j]==0) {answer(i,j-1);}
      else if(ans[i][j]==2) {answer(i-1,j);}
}        
int main() {
	// your code goes here
	cin>>s>>t;
	int n=s.length();
	int m=t.length();

    
	for(int i=1;i<=n;++i)
	{
	    for(int j=1;j<=m;++j)
	    {
	        if(s[i-1]==t[j-1]) {dp[i][j]=dp[i-1][j-1]+1;ans[i][j]=1;}
	        else if(dp[i][j-1]>dp[i-1][j])
	        {
	         dp[i][j]=dp[i][j-1];ans[i][j]=0;
	        }
	        else
	        {
	            dp[i][j]=dp[i-1][j];ans[i][j]=2;
	        }
	    }
	}


	answer(n,m);
	reverse(subseq.begin(),subseq.end());
	cout<<subseq;
	return 0;
}


Measured memory_bytes: 73908
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N, x = mi()
A = li()
adj = []
'''
for i in range(N-1):
    adj.append(A[i]+A[i+1])

ans = 0
for i, num in enumerate(adj):
    if num > x:
        ans += num - x
        if i < N-2:
            adj[i+1] = max(adj[i+1] - (num-x), A[i+2])
print(ans)
'''
ans = 0
for i in range(N-1):
    if A[i] + A[i+1] > x:
        wa = A[i] + A[i+1]
        ans += wa - x
        if A[i+1] < wa - x:
            A[i+1] = 0
        else:
            A[i+1] -= wa - x

print(ans)

Measured memory_bytes: 14656
import Control.Monad

main :: IO ()
main = do
  n <- readLn
  if n == 0
    then return ()
    else do
      ls <- replicateM n getLine
      k <- getLine
      let ls' = filter (\x -> [head x] == k) (concatMap words ls)
      putStrLn $ solve ls'
      main

solve :: [String] -> String
solve ls = format (take 5 (foldl getName [] (sort (countName ls))))
  where
    getName :: [String] -> (String,Int) -> [String]
    getName acc (name,i) = name:acc

    countName :: [String] -> [(String,Int)]
    countName [] = []
    countName (x:xs) = (x,(count x (x:xs))):(countName (filter (\y -> x /= y) xs))
      where
        count :: String -> [String] -> Int
        count _ [] = 0
        count a (b:bs)
          | a == b = 1 + (count a bs)
          | otherwise = count a bs

    sort :: [(String,Int)] -> [(String,Int)]
    sort [] = []
    sort ((a,b):r) = (sort lower) ++ [(a,b)] ++ (sort higher)
      where
        lower = filter (\(c,d) -> (d < b) || ((d == b) && (c > a))) r
        higher = filter (\(c,d) -> (d > b) || ((b == d) && (c <= a))) r
        
    format :: [String] -> String
    format [] = "NA"
    format [x] = x
    format (x:xs) = x ++ " " ++ (format xs)

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector< vector <int> > v2i;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
const int N = 1e5 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

int main()
{   
    
    std::vector<int> v(5);
    for (int i = 0; i < 5; ++i)
    {
    	cin>>v[i];
    }
    
  
    int k;
    cin>>k;

    if (v[4]-v[0]>k)
    {
    	cout<<":("<<endl;
    }
    else{
    	cout<<"Yay!"<<endl;
    }

    return 0;
}


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

int main(void){
    char a, b;
    cin >> a >> b;
    string as, bs;
    for(int i=0; i<b-'0'; i++) as += a;
    for(int i=0; i<a-'0'; i++) bs += b;
    cout << (as<bs ? as : bs) << '\n'; 
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define MAX 500005
 #include<iomanip>
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define x first
 #define y second
using namespace std;
int gcd(int a, int b);
  
int power(int x, unsigned int y, unsigned int m)
{
    if (y == 0)
        return 1;
    int p = power(x, y/2, m) % m;
    p = (p * p) % m;
  
    return (y%2 == 0)? p : (x * p) % m;
}
ll modInverse(int a, int m)
{
    int g = gcd(a, m);
   
    {
        // If a and m are relatively prime, then modulo inverse
        // is a^(m-2) mode m
      
             return power(a, m-2, m);
    }
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
//void spf(ll num)
//{
//    fore(i,0,num+1)arr[i]=i;
//    for(ll i=2;i<=num;i+=2)
//    {
//        arr[i]=2;
//    }
//    for(ll i=3;i<=num;i+=2)
//    {
//        if(arr[i]==i)
//        for(ll j=i;j<=num;j+=i)
//        {
//           if(arr[j]==j) arr[j]=i;
//        }
//    }
//}
ll pow2(ll x)
{ll e=0;
    while(x%2!=1)
    {
        x/=2,e++;
    }
    return e;
}
 int32_t main()
{
    Need_for_speed(activated);
//    satisfy
//    {}
    ll n,m;
    ll a[100005];
    cin>>n>>m;
    fore(i,0,n)cin>>a[i];
    ll k=pow2(a[0]);
    fore(i,0,n)
    {
        if(pow2(a[i])!=k)
        {
            return cout<<"0"<<endl, 0;
        }
        a[i]/=2;
    }
    ll lcm=1;
    fore(i,0,n)
    {
        lcm=lcm*(a[i]/(gcd(lcm,a[i])));
        if(lcm>m)return cout<<"0"<<endl,0;
    }
    ll ans=m/lcm;
    if(ans%2!=0)
    {
        ans/=2;ans++;
    }
    else ans/=2;
    cout<<ans<<endl;
    
    return 0;
    }


Measured memory_bytes: 1024
#include <stdio.h>

int gcm(int a, int b)
{
    int r;
    while (b > 0) {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int main()
{
    int a, b, g, l;
    while (scanf("%d%d", &a, &b) != EOF) {
        g = gcm(a, b);
        l = a / g * b;
        printf("%d %d\n", g, l);
    }
    return 0;
}


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

using namespace std;
using ll=long long;

#define rep(i,n) for (int i=0;i<(n);++i)
#define rep2(i,a,n) for (int i=(a);i<(n);++i)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int w,h,n;cin>>w>>h>>n;
  vector<vector<bool>> hoge(h,vector<bool>(w,true));
  int x,y,a;
  rep(i,n){
    cin>>x>>y>>a;
    //a=1$B$N$H$-$OD9J}7A$N(Bx$B:BI8$,(B<x$B$r$_$?$9NN0h(B
    if(a==1){
      rep(j,h){
        rep2(k,0,x){
          hoge[j][k]=false;
        }
      }
    //a=2$B$N$H$-$OD9J}7A$N(Bx$B:BI8$,(B>x$B$r$_$?$9NN0h(B
    }else if(a==2){
      rep(j,h){
        rep2(k,x,w){
          hoge[j][k]=false;
        }
      }
    //a=3$B$N$H$-$OD9J}7A$N(By$B:BI8$,(B<y$B$r$_$?$9NN0h(B
    }else if(a==3){
      rep2(j,0,y){
        rep(k,w){
          hoge[j][k]=false;
        }
      }
    //a=4$B$N$H$-$OD9J}7A$N(By$B:BI8$,(B>y$B$r$_$?$9NN0h(B
    }else if(a==4){
      rep2(j,y,h){
        rep(k,w){
          hoge[j][k]=false;
        }
      }
    }
  }
  int cnt=0;
  rep(i,h){
    rep(j,w){
      if(hoge[i][j]){
        cnt++;
      }
    }
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n, q;
    cin >> n >> q;
    vector<int> s(n);
    vector<pair<int, int> > s2(n);
    for(int i=0; i<n; ++i){
        cin >> s[i];
        s[i] = 1000000000 - s[i];
        s2[i] = make_pair(s[i], i);
    }
    sort(s.begin(), s.end());
    sort(s2.begin(), s2.end());

    vector<int> index(n);
    for(int i=0; i<n; ++i)
        index[s2[i].second] = i;

    set<int> leader;
    while(--q >= 0){
        string query;
        int x;
        cin >> query >> x;

        if(query == "ADD"){
            leader.insert(index[x-1]);
            continue;
        }
        if(query == "REMOVE"){
            leader.erase(index[x-1]);
            continue;
        }

        vector<int> v(leader.begin(), leader.end());
        for(unsigned i=0; i<v.size(); ++i)
            v[i] = lower_bound(s.begin(), s.end(), s[v[i]]) - s.begin();

        v.push_back(n);
        int rLeft = 0;
        int rRight = 1000000000 + 1;
        while(rLeft < rRight){
            int rMid = (rLeft + rRight) / 2;
            int cnt = v[0];
            for(unsigned i=1; i<v.size(); ++i)
                cnt += s.begin() + v[i] - upper_bound(s.begin() + v[i-1], s.begin() + v[i], s[v[i-1]] + rMid);
            if(cnt <= x)
                rRight = rMid;
            else
                rLeft = rMid + 1;
        }
        if(rLeft <= 1000000000)
            cout << rLeft << endl;
        else
            cout << "NA" << endl;
    }

    return 0;
}

Measured memory_bytes: 16828
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)


#define INF (1e9)
typedef long long unsigned int ll;


int main()
{

    int n;
    cin >> n;

    int A[n];

    REP(i,n){
        cin >> A[i];
    }


     
    int k = 0;

    bool f = false;
    int m = INF;
    sort(A, A + n);
    
    while (1)
    {
        f = false;
        int min =INF;
        REP(i, n)
        {
            if(A[i]!=0&&!f&&A[i]<min){
                min=A[i];
                k = i;
                f = true;
            }
        }
        for (int i = k + 1; i < n; i++)
        {
            A[i] =A[i]% min;
        }

        sort(A, A + n);
        
        int sum=0;
        REP(i,n){
            if(A[i]!=0){
                sum += 1;
                m = A[i];
            }
        }
        if(sum==1){
            break;
        }
    }

    cout << m;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

typedef long long ll;
typedef vector<long long> vi;
typedef pair<long long, long long> ii;
typedef vector<pair<long long, long long>> vii;
typedef stringstream ss;
ll mil() { return numeric_limits<long long>::min(); }
ll mal() { return numeric_limits<long long>::max(); }

#define R3(i, a, b) for (long long i = (a); i < (b); ++i)
#define R2(i, b) for (long long i = 0; i < (b); ++i)
#define R1(b) for (long long i = 0; i < (b); ++i)
#define RR(i, a, b) for (long long i = a; i > b; --i)
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)

// build: ctrl + f9

// run: shift + f10
// debug: shift + f9
// sanitize: shift + f11



ll recur(ll l, ll r, vii &ai, unordered_map<ll, ll> & cache) {
    ll i = (ai.size() - 1) - (r-l);

    if(i == ai.size()) {
        return 0;
    }  

    ll key = l*10000 + r*1;
    auto val = cache.find(key);
    if(val != cache.end()) {
        return val->second;
    }

    

    auto & e = ai[i];

    ll ret = max(abs(e.second - l)*e.first + recur(l+1, r, ai, cache), abs(e.second - r)*e.first + recur(l, r-1, ai, cache));    
    cache[key] = ret;
    
    return ret;
}

void solve() {
    
    int N;

    cin >> N;
    vii ai(N);

    ll val = 0;
    R1(N) cin >> val, ai[i] = MP(val, i);
    sort(ai.begin(), ai.end(), greater<ii>());
    unordered_map<ll, ll> cache;

    ll sum = recur(0, ai.size() - 1, ai, cache);
    
    cout << sum << endl;
}

int main(int argc, char **argv)
{
    /*freopen("../../input.txt", "r", stdin);
    freopen("../../output.txt", "w", stdout);

    ll ti;

    cin >> ti;

    R1(ti)*/
        solve();    
}

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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, ret = 100000;
    cin >> n;

    REP(i, n)
    {
        ret = ret * 1.05;
        ret = (ret % 1000 == 0 ? ret : ret - ret % 1000 + 1000);
    }

    cout << ret << endl;

    return 0;
}



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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    int a, b;
    cin >> h >> w >> a >> b;
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            cout << ((i <= b) ^ (j <= a));
        }
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>

using namespace std;
#define pi acos(-1)

int main(){
    double a, b, x;
    cin>>a>>b>>x;
    if(2 * x / a / a <= b){
        double p = 2 * (x / a) / b / b;
        printf("%.9lf", 90.0 - atan(p) / pi * 180.0);
    }
    else {
        double pp = 2 * x / a / a - b;
        double ppp = b - pp;
        printf("%.9lf", 90.0 - atan(a / ppp) / pi * 180.0);
    }

    return 0;
}

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

int main() {
	long long N, M, L = 0, R = 1000000000000;
	vector<long long> A;
	map<long long, long long> mp;
	cin >> N >> M;
	A.resize(N);
	for (int i = 0; i < N; i++) cin >> A[i], mp[A[i]]++;
	sort(A.begin(), A.end());
	while (R - L > 1) {
		long long MID = (L + R) / 2;
		long long COUNT = 0;
		for (int i = 0; i < N; i++) {
			COUNT += A.end() - lower_bound(A.begin(), A.end(), MID - A[i]);
		}
		if (COUNT >= M) L = MID;
		else R = MID;
	}
	long long MORE = 0, ANS = 0;
	vector<long long> SUM(N + 1);
	SUM[0] = 0;
	for (int i = 0; i < N; i++) SUM[i + 1] = SUM[i] + A[i];
	for (int i = 0; i < N; i++) {
		long long X = upper_bound(A.begin(), A.end(), L - A[i]) - A.begin();
		ANS += SUM[N] - SUM[X];
		ANS += A[i] * (N - X);
		MORE += N - X;
	}
	ANS += L * (M - MORE);
	cout << ANS << endl;
}

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

namespace AC {
#define ll long long
#define PLL pair<ll, ll>
#define PDD pair<double, double>
#define PDPLL pair<double, PLL>
#define PLPLL pair<ll, PLL>
#define pb push_back
#define fi first
#define se second
#define ls rt << 1
#define rs rt << 1 | 1

    const ll N = 1e5 + 66;

    ll BUGS = 1;

    inline ll read(){
        ll x = 0;    bool flag = 1;   char ch = getchar();
        while(ch < '0' || ch > '9') { if(ch == '-') flag = 0; ch = getchar(); }
        while(ch >= '0' && ch <= '9') { x = (x << 1) + (x << 3) + ch - '0'; ch = getchar(); }
        if(flag) return x;  return (~(x - 1));
    }

    inline void read(ll arr[], ll s, ll e) { for(ll i = s; i <= e; ++i) arr[i] = read(); }

    inline void write(ll x){
        if(x < 0) { x = ~(x - 1); putchar('-'); }
        if(x > 9) write(x / 10); putchar(x % 10 + '0');
    }

    inline void print(ll x) { write(x); puts(""); }

    inline void print(ll arr[], ll s, ll e) {
        for(ll i = s; i <= e - 1; ++i) write(arr[i]), putchar(' ');
        write(arr[e]); puts("");
    }

    inline ll max3(ll a, ll b, ll c) { return max(a, max(b, c)); }

    inline ll min3(ll a, ll b, ll c) { return min(a, min(b, c)); }

    inline void debugNum(ll num, string ss) { cout << "BUGS" << BUGS++ << " : " << ss << " : " << num << endl; }

    inline void debugArr(ll arr[], ll s, ll e, string ss) {
        cout << "BUGS" << BUGS++ << " : " << ss << " : " << endl;
        for(ll i = s; i <= e; ++i) cout << "i : " << i << " val : " << arr[i] << endl;
    }

    inline void IO() {
        //ios::sync_with_stdio(false), cout.tie(0), cin.tie(0);
        //cout << setiosflags(ios::fixed) << setprecision(1); //保留小数点后1位
        //cout << setprecision(1); //保留1位有效数字
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    }
}using namespace AC;

ll n, d;

int main() {
    //IO();
    while(~scanf("%lld", &n)) {
        d = read();
        ll ans = 0;
        for(ll i = 1; i <= n; ++i) {
            ll x = read(), y = read();
            if(x * x + y * y <= d * d) ans++;
        }
        print(ans);
    }
    return 0;
}



Measured memory_bytes: 3760
class kazoe:

    def __init__(self,b):
        b.sort()
        self.b = b

    def sum(self):
        c = [0] *4
        for i in range(len(self.b)):
            if(self.b[i] == "AC"):
                c[0] += 1
            else:
                if(self.b[i] == "TLE"):
                    c[1] += 1
                else:
                    if(self.b[i] == "WA"):
                        c[2] += 1
                    else:
                        c[3] += 1



        print('AC x',c[0])
        print('WA x',c[2])
        print('TLE x',c[1])
        print('RE x',c[3])


a = int(input())
b =[]
for i in range(a):
    b.append(input())

ans = kazoe(b)
ans.sum()

Measured memory_bytes: 16420
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int N;
	cin>>N;
	VI A(N);
	VI B(N);
	ll aco=0,bco=0,cnt=0;
	REP(i,N){cin>>A[i]; aco+=A[i];}
	REP(i,N){cin>>B[i]; bco+=B[i];}
	REP(i,N){
		//if(A[i]>B[i])cnt+=A[i]-B[i];
		if(A[i]<B[i]){
			cnt+=(B[i]-A[i]+1)/2;
			//if((B[i]-A[i])%2==1)cnt+=2;
		}
	}
	if(bco-aco>=cnt)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	ll n, k;
	cin >> n >> k;

	// (n+1)Ck + nC(k+1) + ... + (n+1)C(n+1)
	//=(n+1)C(n-k+1) + nC(n-k) + ... + (n+1)C(0)

	ll ans = 0;
	for(ll i = k; i <= n + 1; ++i)
	{
		ans = (ans + (long long)((n+1) * i) % MOD - (long long)(i * i) % MOD + 1) % MOD;
	}

	ans = (ans + MOD) % MOD;

	cout << ans << endl;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>

/* 選択ソート (0オリジン) */
int selectionSort(int A[], int N) {
  int i, j, t, sw = 0, mini;
  for(i=0; i<N-1; i++) {
    mini = i;
    for(j=i; j<N; j++) {
      if(A[j] < A[mini]) mini = j;
    }

  	t = A[i];
  	A[i] = A[mini];
  	A[mini] = t;

  	if(i != mini) sw++;
  }
  return sw;
}

int main(void) {
  int A[100], N, i, sw;
  scanf("%d", &N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);

  sw = selectionSort(A,N);

  for(i=0;i<N;i++) {
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n", sw);

  return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string S; cin >> S;
  int ans = 0;
  for (auto i : S) {
    if (i == '+') ++ans;
    else --ans;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int n;  
  
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    int x,y,b,p;
    scanf("%d %d %d %d",&x,&y,&b,&p);

    int v=x*b+y*p;

    if(b<5) b=5;
    if(p<2) p=2;
    int w=(int)((x*b+y*p)*0.8);

    printf("%d\n",min(v,w));
  }

  return 0;
}



Measured memory_bytes: 3236
#include<stdio.h>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g) {
  for ( int i = g; i < n; i++ ) {
    int v = A[i];
    int j = i - g;
    while ( j >= 0 && A[j] > v ) {
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }
    A[j + g] = v;
  }
}

void shellSort(int A[], int n) {
  for ( int h = 1; ; ) {
    if ( h > n ) break;
    G.push_back(h);
    h = 3*h + 1;
  }

  for ( int i = G.size()-1; i >= 0; i-- )
    insertionSort(A, n, G[i]);
}

int main() {
  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);
  cnt = 0;

  shellSort(A, n);

  printf("%d\n", G.size());
  for ( int i = G.size() - 1; i >= 0; i-- ) {
    printf("%d", G[i]);
    if ( i ) printf(" ");
  }
  printf("\n");
  printf("%d\n", cnt);
  for ( int i = 0; i < n; i++ ) printf("%d\n", A[i]);

  return 0;
}


Measured memory_bytes: 6556
#include <iostream>
#include <stdio.h>
using namespace std;
 
int main(){
	int a,b;
	char op;
	
	while (1) {
		
		cin >> a >> op >> b;
		if ( op == '?' ) {
			break;
		}
	
		if ( op == '+' ) {
			cout << a+b << endl;
		}else if ( op == '-' ) {
			cout << a-b << endl;
		}else if ( op == '*' ) {
			cout << a*b << endl;
		}else if ( op == '/' ) {
			cout << a/b << endl;
		}
	}
    return 0;
}

Measured memory_bytes: 1160
#include <map>
#include <vector>
#include <iostream>
using namespace std;
std::map<unsigned long long, unsigned> prime_factorize(unsigned long long x) {
	std::map<unsigned long long, unsigned> ret;
	for (unsigned i = 2; 1ULL * i * i <= x; i++) {
		while (x % i == 0) x /= i, ret[i]++;
	}
	if (x != 1) ret[x]++;
	return ret;
}
unsigned long long divisor_function(unsigned long long x, int r = 1) {
	std::map<unsigned long long, unsigned> res = prime_factorize(x);
	unsigned long long ret = 1;
	for (std::pair<unsigned long long, unsigned> w : res) {
		unsigned long long mulexp = 1, mul = 1, sum = 1;
		for (int i = 0; i < r; i++) mulexp *= w.first;
		for (int i = 0; i < w.second; i++) mul *= mulexp, sum += mul;
		ret *= sum;
	}
	return ret;
}
long long x;
int main() {
	while (cin >> x, x) {
		map<unsigned long long, unsigned> res = prime_factorize(x);
		long long ret = 1;
		for (pair<unsigned long long, unsigned> i : res) ret *= 2 * i.second + 1;
		cout << (ret + 1) / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
//BISMILLAH
#include<bits/stdc++.h>
using namespace std;
int main()
{


 int flag=0;
   char s[4];
   scanf("%s",s);
   for(int i=0;i<strlen(s);i++)
   {
       if(s[i]=='B')
       {
           flag=1;
           break;
       }
   }
   if(flag==1) cout<< "ARC"<<endl;
   else cout<< "ABC"<<endl;
   return 0;
}


Measured memory_bytes: 3688
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#include<cstdio>

using namespace std;

typedef double Real;

Real EPS = 1e-8;
const Real PI = acos(-1);

int sgn(Real a, Real b=0){return a<b-EPS?-1:a>b+EPS?1:0;}
Real sqr(Real a){return sqrt(max(a,(Real)0));}

struct Point{  
  Real add(Real a, Real b){
    if(abs(a+b) < EPS*(abs(a)+abs(b)))return 0;
    return a+b;
  }

  Real x, y;
  Point(){}
  Point(Real x,Real y) : x(x) , y(y){}

  Point operator + (Point p){return Point(add(x,p.x), add(y,p.y));}
  Point operator - (Point p){return Point(add(x,-p.x), add(y,-p.y));}
  Point operator * (Real d){return Point(x*d,y*d);}
  Point operator / (Real d){return Point(x/d,y/d);}
  bool operator == (Point p){return !sgn(dist(p));}
  //昇順
  bool operator < (Point p)const{return (p.x!=x)?x<p.x:y<p.y;}
  Real norm(){return sqr(x*x+y*y);}
  Real dist(Point a){return (*this-a).norm();}
  Real dot(Point a){return x*a.x+y*a.y;}
  Real cross(Point a){return x*a.y-y*a.x;}
};

struct Circle{
  Point p;
  Real r;
  Circle(){}
  Circle(Point p, Real r) : p(p) , r(r){}
  
  bool contain(Point a){
    return sgn((a-p).norm(),r)<=0;
  }
  
  Circle circumCircle(Point a,Point b){
    Point q=(a+b)/2;
    return Circle(q,(a-q).norm());
  }
  
  Circle circumscribedCircle(Point p, Point q, Point r){
    Point a=(q-p)*2,b=(r-p)*2;
    Point c(p.dot(p)-q.dot(q),p.dot(p)-r.dot(r));
    Circle res;
    res.p.x=a.y*c.y-b.y*c.x;
    res.p.y=b.x*c.x-a.x*c.y;
    res.p=res.p/a.cross(b);
    return Circle(res.p, p.dist(res.p));
  }

  Circle minEnclosingCircle(vector<Point>ps){
    if(ps.size()==0)return Circle(Point(0,0),0);
    if(ps.size()==1)return Circle(ps[0],0);

    Circle circle=circumCircle(ps[0],ps[1]);
    for(int i=2;i<ps.size();i++){
      if(!circle.contain(ps[i])){
	circle=circumCircle(ps[0],ps[i]);
	for(int j=1;j<i;j++){
	  if(!circle.contain(ps[j])){
	    circle=circumCircle(ps[j],ps[i]);
	    for(int k=0;k<j;k++){
	      if(!circle.contain(ps[k])){
		circle=circumscribedCircle(ps[i],ps[j],ps[k]);
	      }
	    }
	  }
	}
      }
    }
    return circle;
  }

};

int main(void){

  int n;
  cin >> n;
  vector<Point>ps(n);

  for(int i=0;i<n;i++)cin >> ps[i].x >> ps[i].y;
  Circle c;
  printf("%.9f",c.minEnclosingCircle(ps).r*2/2.0);
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
S = input()

if 'N' in S:
  if not 'S' in S:
    print('No')
    exit()
if 'S' in S:
  if not 'N' in S:
    print('No')
    exit()
if 'E' in S:
  if not 'W' in S:
    print('No')
    exit()
if 'W' in S:
  if not 'E' in S:
    print('No')
    exit()
print('Yes')





Measured memory_bytes: 9032
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

#define MAX(x,y) ((x>y)?x:y)


int main(){
	int i,j,k,n,kn,an,ans;
	char key[30],adv[105];
	
	scanf("%d",&n);
	scanf("%s",key);
	kn=strlen(key);
	ans=0;
	while(n--){
		scanf("%s",adv);
		an=strlen(adv);
		
		for(i=0;i<an;i++){
			if(key[0]!=adv[i])continue;
			for(k=1;i+(kn-1)*k<an;k++){
				for(j=0;j<kn;j++)if(key[j]!=adv[i+j*k])break;
				if(j==kn){
					ans++;
					goto nex;
				}
			}
		}
		nex:;
	}
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 600
// Ball
import java.util.Scanner;

public class Main {
	int[] in;

	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while (n-- > 0) {
			in = new int[10];
			for (int i = 0; i < 10; i++)
				in[i] = sc.nextInt();
			if (dfs(0, 0, 0))
				System.out.println("YES");
			else
				System.out.println("NO");
		}
		sc.close();
	}

	boolean dfs(int a, int b, int d) {
		if (d == 9 && (a < in[d] || b < in[d]))
			return true;
		boolean bool = false;
		if (a < in[d])
			bool |= dfs(in[d], b, d + 1);
		if (b < in[d])
			bool |= dfs(a, in[d], d + 1);
		return bool;
	}
}

Measured memory_bytes: 18140
INF = float('inf')


def main():
    n = int(input())
    p = [0 for _ in range(n+1)]

    for i in range(n):
        p1, p2 = map(int, input().split(' '))
        p[i-1], p[i] = p1, p2

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

    for l in range(2, n+1):
        for i in range(1, n-l+2):
            j = i + l - 1
            dp[i][j] = INF
            for k in range(i, j):
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + p[i-1] * p[k] * p[j])
    print(dp[1][n])


if __name__ == "__main__":
    main()



Measured memory_bytes: 5688
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()
ans = 0
left, right = 1, 0
el, er = A[0], A[0] 
while left + right < N:
    a = abs(A[left]-el)
    b = abs(A[left]-er)
    c = abs(A[-right-1]-el)
    d = abs(A[-right-1]-er)
    m = max(a, b, c, d)
    if m == a:
        ans += a
        el = A[left]
        left += 1
    elif m == b:
        ans += b
        er = A[left]
        left += 1
    elif m == c:
        ans += c
        el = A[-right-1]
        right += 1
    else:
        ans += d
        er = A[-right-1]
        right += 1

print(ans)

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

template <typename T>
ll lcm(T a, T b){
  return (ll)a * (ll)b / (ll)__gcd(a, b);
}

map<ll, ll> lc;
map<ll, ll> fact(ll n){
  map<ll, ll> res;
  for(ll i = 2LL; i*i <= n; i++){
    if(n % i == 0){
      res[i] = 1LL;
      if(!lc.count(i)) lc[i] = 1LL;
      n /= i;
      while(n % i == 0){
        res.at(i)++;
        n /= i;
      }
      chmax(lc.at(i), res.at(i));
    }
  }
  if(n != 1){
    res[n] = 1LL;
    if(!lc.count(n)) lc[n] = 1LL;
  }
  return res;
}

ll modbeki(ll x, ll n){
  ll res = 1LL;
  while(n > 0){
    if(n & 1){
      res *= x % MOD;
      res %= MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return res % MOD;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vll A(N);
  vector<map<ll, ll>> ff(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    ff.at(i) = fact(A.at(i));
  }

  ll xx = 1LL;
  for(auto ite = lc.begin(); ite != lc.end(); ite++){
    ll p = ite -> first;
    ll num = ite -> second;
    xx *= modbeki(p, num);
    xx %= MOD;
  }

  ll ans = 0LL;
  for(int i = 0; i < N; i++){
    ll inv = modbeki(A.at(i), MOD-2);
    ans += xx * inv % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3968