akhauriyash/Code-Regression huggingface dataset:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a = I()
    s = input()
    if a >= 3200:
        print(s)
    else:
        print("red")
    return

#B
def B():
    n = I()
    a = LI()
    ans = 0
    for i in a:
        ans += 1/i
    print(1/ans)
    return

#C
def C():
    n = I()
    v = LI()
    q = []
    for i in v:
        heappush(q,i)
    while q:
        x = heappop(q)
        if not q:
            print(x)
            return
        y = heappop(q)
        heappush(q,(x+y)/2)
    return

#D
def D():
    def dfs(x,d,s):
        for y in v[x]:
            if d[y]:
                s += f[y]
                ans[y] = s
                d[y] = 0
                dfs(y,d,s)
                s -= f[y]
    n,q = LI()
    v = [[] for i in range(n)]
    for i in range(n-1):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    f = [0]*n
    for i in range(q):
        p,x = LI()
        p -= 1
        f[p] += x
    ans = [0]*n
    d = [1]*n
    d[0] = 0
    ans[0] = f[0]
    s = f[0]
    dfs(0,d,s)
    print(*ans)
    return

#E
def E():
    s = input()
    t = input()

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 291024
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

#define DIV 1000000007

using namespace std;

long long N;
long long A[300005];

long long modpow(long long ori, long long po){
	long long res = 1;
	while(po > 0){
		if(po&1){
			res *= ori;
			res %= DIV;
		}
		ori *= ori;
		ori %= DIV;
		po >>= 1;
	}
	return res;
}

int main(){
	cin >> N;
	rep(i, N) cin >> A[i];
	reverse(A, A + N);


	long long ans = 0;

	rep(i, 61) {
		//i bit目
		long long zerocount = 0;
		long long onecount = 0;
		rep(j, N) {
			long long num = A[j];

			if((num>>i)&1) {
				ans += zerocount * modpow(2, i);
				ans %= DIV;
			} else {
				ans += onecount * modpow(2, i);
				ans %= DIV;
			}

			if((num>>i)&1) {
				onecount++;
			} else {
				zerocount++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 5980
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array

main = do
  n <- (read::String -> Int) <$> getLine
  arr <- reverse . sort . map (read::String -> Int) . words <$> getLine
  let maximum = arr !! 0
      rest = sum . tail $ arr
  putStrLn $ if rest > maximum then "Yes" else "No"

Measured memory_bytes: 508
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#define dbg(x) cerr << #x << " = " << x <<endl
#define dbg2(x,y) cerr<< #x <<" = "<< x <<"  "<< #y <<" = "<< y <<endl
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
template<typename T>inline T _min(T A,T B){return A<B?A:B;}
template<typename T>inline T _max(T A,T B){return A>B?A:B;}
template<typename T>inline bool MIN(T&A,T B){return A>B?(A=B,1):0;}
template<typename T>inline bool MAX(T&A,T B){return A<B?(A=B,1):0;}
template<typename T>inline void _swap(T&A,T&B){A^=B^=A^=B;}
template<typename T>inline T read(T&x){
	x=0;int f=0;char c;while(!isdigit(c=getchar()))if(c=='-')f=1;
	while(isdigit(c))x=x*10+(c&15),c=getchar();return f?x=-x:x;
}
const int N=1e5+7;
struct thxorz{int nxt,to,w;}G[N*11];
int Head[N],tot;
int n;
inline void Addedge(int x,int y,int z){G[++tot].to=y,G[tot].nxt=Head[x],Head[x]=tot,G[tot].w=z;}
int dis[N];
priority_queue<pii,vector<pii>,greater<pii> > pq;
#define y G[j].to
inline void dij(){
	memset(dis,0x3f,sizeof dis);for(register int i=1;i<10;++i)MIN(dis[i%n],i),pq.push(make_pair(dis[i%n],i%n));
	while(!pq.empty()){
		int d=pq.top().first,x=pq.top().second;pq.pop();
		if(d^dis[x])continue;//dbg2(x,d);
		if(x==0)return;
		for(register int j=Head[x];j;j=G[j].nxt)if(MIN(dis[y],d+G[j].w))pq.push(make_pair(dis[y],y));
	}
}
#undef y
int main(){//freopen("test.in","r",stdin);//freopen("test.ans","w",stdout);
	read(n);
	for(register int i=1;i<n;++i)for(register int j=0;j<10;++j)Addedge(i,(10*i+j)%n,j);
	dij();
	return printf("%d\n",dis[0]),0;
}

Measured memory_bytes: 14964
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)

long long func(long long a, long long b) {
	if (b == 0) return a;
	return func(b, a % b);
}

int main() {
	long long a, b;
	cin >> a >> b;
	cout << a * b / func(a, b);


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long speed[3]={0LL,1LL,-1LL};
int n,mm,tt,i,j,cnt,a[100100],w[100100];
pair<long long, long long> b[100100];
long long m,t,cur,lft,rgh,r[100100];
long long hm(long long a, long long b) {
  return b/m+int(b%m>=a);
}
int main() {
  scanf("%d%d%d",&n,&mm,&tt);
  m=4LL*mm;
  t=4LL*tt;
  for (i=0; i<n; i++) {
    scanf("%d%d",&a[i],&w[i]);
    if (i>0 && a[i]<=a[i-1]) { for (;;); puts("0"); }
    cur=(a[i]*4LL+m+speed[w[i]]*((t-1)%m))%m;
    b[i]=make_pair(cur,(cur+m+speed[w[i]])%m);
  }
  if (t==0) { for (;;); puts("0"); }
  for (i=0; i<n; i++) if (w[i]!=w[0]) break;
  if (i>=n) {
    for (i=0; i<n; i++) printf("%lld\n",b[i].second/4LL);
    return 0;
  }
  if (w[0]==1) j=0; else j=i;
  lft=a[j]*4LL;
  rgh=lft+2*(t-1LL);
  for (i=0; i<n; i++) if (w[i]==2) cnt=(cnt+hm(a[i]*4LL,rgh)-hm(a[i]*4LL,lft))%n;
  cnt=(j+cnt)%n;
  rgh=(lft+t-1LL)%m;
  sort(b,b+n);
  for (i=0; i<n; i++) if (b[i].first==rgh) {
    for (j=i; j<n; j++, cnt++) {
      if (cnt>=n) cnt=0;
      r[cnt]=b[j].second/4LL;
    }
    for (j=0; j<i; j++, cnt++) {
      if (cnt>=n) cnt=0;
      r[cnt]=b[j].second/4LL;
    }
    break;
  }
  for (i=0; i<n; i++) printf("%lld\n",r[i]);
  return 0;
}



Measured memory_bytes: 4352
N = int(input())
onesPlace = N % 10
output = ''

if onesPlace == 3:
    output = 'bon'
elif onesPlace == 0 or onesPlace == 1 or onesPlace == 6 or onesPlace == 8:
    output = 'pon'
else:
    output = 'hon'

print(output)

Measured memory_bytes: 9156
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) begin(x),end(x)
#define F(i,n) for (int i = 0; i < n; ++i)
#define F1(i,n) for (int i = 1; i <= n; ++i)
#define dbg(x) cerr << #x << " = " << x << endl
#define dbgg(x) cerr << #x << " = " << x << ' '
#define T(x) x[pool]
#define mineq(x,y) { if ((x) > (y)) (x) = (y); }
#define maxeq(x,y) { if ((x) < (y)) (x) = (y); }
#define MEOW cout << "meowwwww" << '\n'; system("pause");
#define int long long
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

template<typename T>
ostream& operator <<(ostream &s, const vector<T> &c)
{
	s << "[ "; for (auto it : c) s << it << " "; s << "\b]\n";
	return s;
}

template<typename T>
ostream& operator <<(ostream &s, const pair<int, T> &c)
{
	s << "[ "; cout << c.fi << " , " << c.se << " ] ";
	return s;
}

const int maxa = 60, maxb = 25, maxn = 234567;
int n;
int pre[maxa][maxb];
string a[maxn];
int b[maxn], c[maxn], d[maxn];

void input()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	F1 (i, n) cin >> a[i];
}

int fu(int x)
{
	int ret = 0;
	bool f = false;
	for (auto i : a[x])
	{
		if (i == '.') f = true;
		else
		{
			ret *= 10;
			ret += i - '0';
			if (f) --b[x], --c[x];
		}
	}
	return ret;
}

void solve()
{
	int ans = 0;
	F1 (i, n)
	{
		d[i] = fu(i);
		while (d[i] % 2 == 0)
		{
			d[i] /= 2;
			b[i]++;
		}
		while (d[i] % 5 == 0)
		{
			d[i] /= 5;
			c[i]++;
		}
		for (int j = max(0ll, -b[i] + 10); j < maxa; ++j)
			for (int k = max(0ll, -c[i] + 10); k < maxb; ++k)
				ans += pre[j][k];
		pre[b[i] + 10][c[i] + 10]++;
		//dbgg(b[i]); dbg(c[i]);
	}
	cout << ans << '\n';
}

main()
{
	input();
	solve();
}


Measured memory_bytes: 15672
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		while(true) {
			int t=in.nextInt(),d=in.nextInt(),l=in.nextInt();
			if(t==0)break;
			int cnt=0,time=0;
			for(int i=0;i<t;i++) {
				if(time>=0)time--;
				if(time>=0)cnt++;
				int x=Integer.parseInt(in.next());
				if(x>=l)time=d;
				//System.out.printf("t=%d x=%d time=%d, cnt=%d\n", i,x,time,cnt);
			}
			System.out.println(cnt);
		}
		
	}

}



Measured memory_bytes: 145072
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""

int main(void)
{
    int N;cin>>N;
    map< std::vector<char>, ll> mp;
    map< std::vector<char>, ll>::iterator ite;
    ll sum = 0;
    for(int i=0; i<N;i++){
      std::vector<char> s;
      for(int j=0; j<10;j++){
        char cc; cin>>cc; s.push_back(cc);
      }
      sort(s.begin(), s.end());
      mp[s]++;
    }
    for(ite = mp.begin(); ite != mp.end() ; ++ite){
      if(ite->second > 1){
        sum += (ite->second)*(ite->second-1)/2;
      }
    }
    // for(ite = mp.begin(); ite != mp.end() ; ++ite){
    //   cout<<ite->second<<endl;
    // }

    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 11136
open System

let n, m, q =
    let l = Console.ReadLine().Split(' ') |> Array.map int
    l.[0], l.[1], l.[2]

let abcd =
    [ 1 .. q ]
    |> List.map (fun _ ->
        let l = Console.ReadLine().Split(' ') |> Array.map int
        l.[0], l.[1], l.[2], l.[3])

let total (arr: int List) =
    [ 0 .. q - 1 ]
    |> List.map (fun i ->
        let a, b, c, d = abcd.[i]
        (arr.[b - 1] - arr.[a - 1] = c, d))
    |> List.filter (fun (f, _) -> f)
    |> List.map (fun (_, d) -> d)
    |> List.sum

let ans =
    let rec dfs (l: int List) =
        if l.Length = n then
            total l
        else
            let len = l.Length

            let h =
                if len = 0 then 1 else l.[len - 1]
            [ h .. m ]
            |> List.map (fun i -> dfs (l @ [ i ]))
            |> List.max
    dfs []

ans |> printfn "%d"


Measured memory_bytes: 43132
#include <bits/stdc++.h>
#define f(a, n) for (int a=0; a<n; a++)
#define F(a, n) for (int a=1; a<=n; a++)
#define ll long long
using namespace std;

long long x, y;
int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(0);
	cin>>x>>x>>y;
	cout<<(abs(x-y)%2 == 0? "Alice" : "Borys")<<endl;
}


Measured memory_bytes: 256
N = int(input())
wardList = [input() for _ in range(N)]
ans = "Yes"
history = set()
lastCharacter = ''

for i in range(N):
    ward = wardList[i]
    if ward in history:
        ans = "No"
        break
    else:
        if i > 0:
            if lastCharacter != ward[0]:
                ans = "No"
                break
        history.add(ward)
        lastCharacter = ward[len(ward)-1]

print(ans)



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

using namespace std;

vector< int > g[100000];

int dfs(int idx, int par)
{
  int ret = 0;
  for(auto to : g[idx]) {
    if(to == par) continue;
    ret += dfs(to, idx);
  }
  if(ret >= 2) {
    cout << "First" << endl;
    exit(0);
  }
  return (ret ^ 1);
}


int main()
{
  int N;
  cin >> N;
  for(int i = 1; i < N; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  if(dfs(0, -1)) cout << "First" << endl;
  else cout << "Second" << endl;
}

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

using namespace std;
using ll = long long;


int main()
{
    int n;
    cin >> n;
    vector<int> prime;
    vector<char> c(10000000);
    

    for(int i = 2; i < 10000000; i++) {
        if(c[i])continue;
        prime.push_back(i);
        for(int j = i; j < 10000000; j += i) {
            c[j] = 1;
        }
    }


    cout << *lower_bound(prime.begin(), prime.end(), n) << endl;
}

Measured memory_bytes: 15984
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ii pair<int ,int >
#define pb push_back
#define vl vector <long long int >
#define vi vector <int >
#define mod 1000000007
#define eps 1e-9
#define fi first
#define se second
#define _ <<" "<<
#define forn(x,	n) for(int x = 0; x < n ;++ x) 
#define forn1(x,n) for(int x = 1; x <= n ;++ x)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}

int dp[(int)(1e5+1)][13];
int main(){
	IOS
 	
 	string s;
 	cin>>s;
 	unordered_map<int,int> mp;
 	for(int i=0;i<=12;i++)
 	{
 		mp[(i*10)%13] = i;
 	}
 	if(s[0]=='?')
 	{
 		for(int j=0;j<10;j++)
 			{
 				dp[0][j]=1;
 			}
 	}
 	else
 	{
 		dp[0][s[0]-'0']=1;
 	}

 	for(int i=1;i<s.size();i++)
 	{
 		char c = s[i];
 		if(c=='?')
	 		for(int j=0;j<13;j++)
 			{
 				for(int d=0;d<10;d++)
 				{
 					int req_rem = ((d>j?1:0)*13) + j -d;
 					int prev_rem = mp[req_rem];
 					//cout<<"req rem "<<req_rem<<"prev rem"<<prev_rem<<endl;

 					dp[i][j] = ((dp[i][j]%mod) + (dp[i-1][prev_rem]%mod))%mod;
 				} 
 			}
 		else
 		{
 			for(int j=0;j<13;j++)
 			{
 				int d = (int)(c-'0');
 				int req_rem = ((d>j?1:0)*13) + j -d;
 				int prev_rem = mp[req_rem];
 				dp[i][j] = ((dp[i][j]%mod) + (dp[i-1][prev_rem]%mod))%mod;
 			}
 		}
 	}

 	cout<<dp[s.size()-1][5]%mod;

	return 0;	
}

Measured memory_bytes: 5584
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	ans := 0
	for i := N; i > 0; i-- {
		ans += i
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 640
N = int(input())
dic = {}
for i in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
max_val = max(dic.values())
rst = [ key for key, val in dic.items() if val == max_val ]
[ print(i) for i in sorted(rst) ]


Measured memory_bytes: 145176
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"math/big"
	"os"
)

var scan *bufio.Scanner
var reader io.Reader
var writer io.Writer

func init() {
	scan = bufio.NewScanner(os.Stdin)
	reader = os.Stdin
	writer = os.Stdout
	scan.Split(bufio.ScanWords)
}

func main() {
	solve()
}

func solve() {
	var n int
	var res float64
	fmt.Scan(&n)
	o := n / 2
	if n%2 == 1 {
		o++
	}
	res = float64(o) / float64(n)
	fmt.Print(res)
}

func cin(a ...interface{}) {
	for i := 0; i < len(a); i++ {
		doScan(a[i])
	}
	return
}
func doScan(a interface{}) {
	switch a.(type) {
	case *[]int:
		s := *a.(*[]int)
		for i := 0; i < len(s); i++ {
			fmt.Fscan(reader, &s[i])
		}
	case *[]string:
		s := *a.(*[]string)
		for i := 0; i < len(s); i++ {
			fmt.Fscan(reader, &s[i])
		}
	default:
		fmt.Fscan(reader, a)
	}
	return
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func max(x int, y ...int) int {
	res := float64(x)
	for _, z := range y {
		res = math.Max(res, float64(z))
	}
	return int(res)
}

func min(x int, y ...int) int {
	res := float64(x)
	for _, z := range y {
		res = math.Min(res, float64(z))
	}
	return int(res)
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func sqrt(x int) int {
	return int(math.Sqrt(float64(x)))
}

func int2Int(x int) big.Int {
	var res big.Int
	res.SetInt64(int64(x))
	return res
}


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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	
	cout << (n-1+k-1-1)/(k-1) << endl;
	return 0;
}

Measured memory_bytes: 640
S=gets.chomp
arr = S.split("").map(&:to_i)
min = Float::INFINITY
(0..(arr.length - 3)).each do |i|
  number = 100 * arr[i] + 10 * arr[i + 1] + arr[i + 2]
  value = (number - 753).abs
  min = value if value < min
end
print("#{min}\n")

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
const long long M =1e6+10,MOD=1000000000;
typedef long long ll;
ll a[M],b[M];
ll tot=0;
map<ll,ll>mp;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++)
    {
      for(ll j=1;j<=n;j++)
      {
        for(ll k=1;k<=n;k++)
        {
            tot+=__gcd(i,__gcd(k,j));
        }
      }
    }
    cout<<tot<<"\n";
 
    return 0;
  }

Measured memory_bytes: 3564
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

Int Max(const Int a, const Int b) {
    if (a >= b) {
        return a;
    } else {
        return b;
    }
}

int main(void) {
    Int a, b;
    cin >> a >> b;
    cout << Max(0, a - 2 * b) << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };

const int MAX = 2100;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<vector<ll>> pas;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N, K;
    cin >> N >> K;
    COMinit();
    for (int i = 1; i <= K; ++i) {
        cout << COM(N - K + 1, i) * COM(K - 1, i - 1) % MOD << endl;
    }
    return 0;
}

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

int main() {
 int N;
 cin >> N;
 vector<int> p(N);
  for(int i = 0;i<N;i++){
    cin >> p[i];
  }
  vector<int> q(N);//保存用
   q = p;
  vector<int> r(N);//sort用
  r = p;
 sort(r.begin(),r.end());//rがpをソートしたものになった
  if(r !=q){
  bool flag1 = false;
  bool flag2 = false;
  for(int i = 0;i<N;i++){
    for(int j = i+1;j<N;j++){
      p[i] = q[j];
      p[j] = q[i];
      if(p == r){
        flag1 = true;
        flag2 = true;
        break;
      }
      if(p != r){
        p[i] = q[i];
        p[j] = q[j];
      }
    }
    if(flag2) break;
  }
      if(flag1) cout << "YES" << endl;
      else cout << "NO" << endl;
 }
  if(r == q){
    cout << "YES" << endl;
  }
  
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

vector<vector<int>> ch;
vector<string> s;

void dfs(int x, int d){
  rep(i,d){
    cout << '.';
  }
  cout << s[x] << endl;
  for(auto c:ch[x]){
    dfs(c, d+1);
  }
}

int main(){
  int n;
  cin >> n;
  ch = vector<vector<int>>(n);
  s = vector<string>(n);
  int k;
  rep(i,n){
    cin >> k;
    if(k>0){
      ch[k-1].push_back(i);
    }
    cin >> s[i];
  }
  dfs(0, 0);
  return 0;
}



Measured memory_bytes: 3352
#include <iostream>
#include <cstdlib>

using namespace std;

int main(){
    int i = 0;
    string n;
    int a[100];
    while(cin >> n){
        if(n=="+"){
            a[i-2] = a[i-1] + a[i-2];
            i--;
        }
        else if(n=="-"){
            a[i-2] = a[i-2] - a[i-1];
            i--;
        }
        else if(n=="*"){
            a[i-2] = a[i-2] * a[i-1];
            i--;
        }
        else{
            a[i] = atoi(n.c_str());
            i++;
        }
    }
    cout << a[0] << endl;
}


Measured memory_bytes: 3196
s=input()
l=len(s)
c=0
x=0
while x<l-1:
  if s[x]==s[x+1]:
    if x==l-2:
      c+=1
      x+=2
    else:
      c+=2
      x+=3
  else:
    if x==l-2:
      c+=2
      x+=2
    else:
      c+=1
      x+=1
if l==1:
  c=1
if x==l-1:
  c+=1
print(c)

Measured memory_bytes: 3500
x = int(input())
isLoop = True
for i in range(0, 121):
    a = i ** 5
    for j in range(0, i):
        b = j ** 5
    
        if a - b == x:
            print("{} {}".format(i,j))
            isLoop = False
            break
        elif a + b == x:
            print("{} {}".format(i,-j))
            break
    if isLoop == False:
        break

Measured memory_bytes: 9192
#pragma GCC optimize(2)
#define LOCAL0
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
typedef long long ll;
#define xx first 
#define yy second
#define INF 0x3f3f3f3f
void read(int &p)
{
    p=0;int flag=1;char c=getchar();
    while(!isdigit(c)) {if(c=='-') flag=-1;c=getchar();}
    while(isdigit(c)) {p=p*10+c-'0';c=getchar();}p*=flag;
}
//O(ElogV)
const int max_e=100000000;

double len(pair<double,double> p,pair<double,double> q){
    return sqrt((p.xx-q.xx)*(p.xx-q.xx)+(p.yy-q.yy)*(p.yy-q.yy));
}
struct edage
{
    int from;
    int to;
    double dis;
    bool operator < (const edage& x) const{
        return dis>x.dis;
    }
}e[max_e];

int par[10005];

int find(int x)
{
    return par[x]==x?x:par[x]=find(par[x]);
}

void unite(int x,int y)
{
    x=find(x),y=find(y);
    par[x]=y;
}
int V,m,E,cnt;
double sum,ans;

void kruskal()
{
    for(int i=1;i<=V;i++) par[i]=i;
    sort(e+1,e+1+E);
    for(int i=1;i<=E;i++)
    {
        if(find(e[i].from)==find(e[i].to)) continue;
        ans+=e[i].dis;
        unite(e[i].from,e[i].to);
        if(++cnt==V-1) return;
    }
}
pair<double,double> point[10005];
int main()
{
    #ifdef LOCAL
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    read(V),read(m);
    for(int i=1;i<=V;i++){
        scanf("%lf%lf",&point[i].xx,&point[i].yy);
    }
    int p,q;
    for(int i=1;i<=m;i++){
        read(p),read(q);
        e[++E].from=p;e[E].to=q;e[E].dis=len(point[p],point[q]);
        e[++E].from=q;e[E].to=p;e[E].dis=len(point[p],point[q]);
        sum+=len(point[p],point[q]);
    }
    kruskal();
    printf("%.3f",sum-ans);
    return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n;
    cin >> n;
    cout << 800 * n - n / 15 * 200 << endl;;
    return 0;
}



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

using namespace std;

int main(){
    int max = 0, cnt = 0;
    string S;
    cin >> S;
    for(int i = 0; i < S.length(); i++){
        if(S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C'){
            cnt++;
        }else{
            if(cnt > max){
                max = cnt;
                cnt = 0;
            }
        }
    }
    if(cnt > max){
        max = cnt;
    }
    cout << max << endl;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
W = [0 for i in range(N + 1)]

for i in range(1, N):
    if S[i] == 'C' and S[i - 1] == 'A':
        W[i + 1] = W[i] + 1
    else:
        W[i + 1] = W[i]

for i in range(Q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    ans = W[r + 1] - W[l]
    if l > 0 and S[l - 1] == 'A' and S[l] == 'C':
        ans -= 1
    print(ans)



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

vector<int> cc[30];
char a[510][32];
int n;
bool vis[26], can[26];

bool init()
{
    memset(vis, 0, sizeof(vis));
    memset(can, 0, sizeof(can));
    for(int i = 0; i < 26; ++ i) cc[i].clear();
    for(int i = 1; i < n; ++ i)
    {
        int j, len = min(strlen(a[i]), strlen(a[i-1]));
        for(j = 0; j < len; ++ j)
            if(a[i][j] != a[i-1][j]) break;
        if(strlen(a[i-1]) > strlen(a[i])  && j >= len) return false;
        if(j < len) cc[a[i][j] - 'a'].push_back(a[i-1][j] - 'a');
    }
    for(int i = 0; i < 26; ++ i)
    {
        sort(cc[i].begin(), cc[i].end());
        cc[i].erase(unique(cc[i].begin(), cc[i].end() ), cc[i].end());
    }
    return true;
}

bool dfs(int cur)
{
    vis[cur] = true;
    if(can[cur]) return false;
    can[cur] = true;
    for(int i = 0; i < (int)cc[cur].size(); ++ i)
        if(!dfs(cc[cur][i])) return false;
    can[cur] = false;
    return true;
}

int main()
{
    while(scanf("%d", &n) == 1 && n)
    {
        for(int i = 0; i < n; ++ i)
            scanf("%s", a[i]);
        if(!init())
        {
            puts("no");
            continue;
        }
        bool flag = 1;
        for(int i = 0; i < 26; i++)
        {
            if(!vis[i] && !dfs(i))
            {
                flag = 0;
                break;
            }
        }
        if(flag) puts("yes");
        else puts("no");
    }
    return 0;
}

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1};
constexpr int dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int n = input();
    vector< i64 > as(n + 1);
    range(i, 1, n + 1) cin >> as[i];

    int m = input();
    vector< i64 > bs(m), cs(m);
    cin >> bs >> cs;

    whole(sort, as);
    vector< i64 > rs = as;
    range(i, 1, n + 1) rs[i] += rs[i - 1];

    range(i, 0, m) {
        int idx = whole(lower_bound, as, bs[i] + 1) - as.begin() - 1;
        if (rs[idx] >= cs[i]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

signed main(int argc, char *argv[]) {
    solver();
}



Measured memory_bytes: 11884
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[][] = new int[2][n];
        for(int i=0; i<n; i++){
            a[0][i] = sc.nextInt();
        }
        for(int i=0; i<n; i++){
            a[1][i] = sc.nextInt();
        }

        //累積メモ配列
        int add_a[][] = new int[2][n];
        add_a[0][0] = a[0][0];
        add_a[1][0] = a[1][0];
        for(int i=1; i<n; i++){
            add_a[0][i] = add_a[0][i-1] + a[0][i];
        }
        for(int i=1; i<n; i++){
            add_a[1][i] = add_a[1][i-1] + a[1][i];
        }

        int max = a[0][0]+ add_a[1][n-1];
        for(int i=1; i<n; i++){
            max = Math.max(max,add_a[0][i] + add_a[1][n-1] - add_a[1][i-1]);
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 21972
arr_1 = gets.split.map(&:to_i) 
arr_2 = gets.split.map(&:to_i) 
arr_3 = gets.split.map(&:to_i) 

a1, a2, a3 = 0, 0, 0

while a1 <= arr_1[0]
	b1 = arr_1[0] - a1
	while a2 <= arr_1[1]
		b2 = arr_2[1] - a2
		if a1 + b2 == arr_2[0] && a2 + b1 == arr_1[1]
			while a3 <= arr_1[2]
				b3 = arr_3[2] - a3
				if a1 + b3 == arr_3[0] && a3 + b1 == arr_1[2] 
					if a2 + b3 == arr_3[1] && a3 + b2 == arr_2[2]
						print("Yes\n")
						exit
					end
				end
				a3 += 1
			end
		end
		a3 = 0
		a2 += 1
	end
	a2 = 0
	a1 += 1
end

print("No\n")

Measured memory_bytes: 1788
n = int(input())
ps = list(map(int, input().split()))

swap_count = 0
counter = 0
skip = False
for i in range(1, n+1):
  p = ps[counter]
  counter += 1
  if skip:
    skip = False
    continue
  if i == p:
    skip = True
    swap_count += 1
    
print(swap_count)

Measured memory_bytes: 13880
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    ls = [0] * 65
    for v in a:
        tt = bin(v)
        for i in range(len(tt)-2):
            ls[i] += int(tt[-i-1])
    t = 0
    for i in range(len(ls)):
        t += pow(2, i, mod) * (n - ls[i]) * ls[i]
        t %= mod
    print(t)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 89712
#include <iostream>

using namespace std;

int main(){
    while(true) {
        auto x = 0;
        auto y = 0;
        cin >> x >> y;
        if (x == 0 && y == 0) break;

        if (x > y) cout << y << " " << x << "\n";
        else cout << x << " " << y << "\n";
    }

    return 0;
}



Measured memory_bytes: 3012
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define REP(i,n) for (ll i = 0; i < n; i++)
#define REPR(i,n) for (ll i = n-1; i >= 0; i--)
#define FOR(i,m,n) for (ll i = m; i < n; i++)
#define FORE(x,xs) for (auto& x : xs)

const int MAX = 2e5+10;

int N, Q;
string s;
int S[MAX];
int t[MAX], d[MAX];

bool alive(int n, bool left) {
    REP (q, Q) if (S[n] == t[q]) {
        n += d[q];
        if (n < 0) return !left;
        if (n >= N) return left;
    }
    return true;
}

int main() {
    cin >> N >> Q >> s;
    REP (i, N) S[i] = s[i] - 'A';
    REP (q, Q) {
        char tt, dd;
        cin >> tt >> dd;
        t[q] = tt - 'A'; d[q] = (dd == 'L') ? -1 : 1;
    }

    int l = -1, // 左で死ぬ
        r = N; // 左で死なない
    while (r - l > 1) {
        int m = (r+l) / 2;
        if (alive(m, true)) r = m;
        else l = m;
    }
    int left = l;

    l = -1, // 右で死なない
    r = N; // 右で死ぬ
    while (r - l > 1) {
        int m = (r+l) / 2;
        if (alive(m, false)) l = m;
        else r = m;
    }
    cout << max(0, r - left - 1) << endl;
}

Measured memory_bytes: 2948
n = int(input())
a = list(map(int,input().split()))
ans = []
for i in range(min(a), max(a)+1):
    c = 0
    for j in range(len(a)):
        cc = (a[j] - i) ** 2
        c += cc
    ans.append(c)
print(min(ans))

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

int reverse(int n) {
    int res = 0;
    while (n > 0) {
        res = res * 10 + n % 10;
        n /= 10;
    }
    return res;
}

int calcFirstDigit(int n) {
    while (n >= 10) n /= 10;
    return n;
}

int add9(int n) {
    int res = 0;
    for (int i = 0; i < n; i++) res = res * 10 + 9;
    return res;
}

int calcEnd(int n) {
    if (n < 100) return n;

    int numDigits = 0;
    int t = n;
    while (t > 0) {
        numDigits++;
        t /= 10;
    }

    return n + add9(numDigits - 2) * 10;
}



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

    int res = 0;
    for (int i = 1; i <= N; i++) {
        int firstDigit = calcFirstDigit(i);
        int lastDigit = i % 10;
        if (lastDigit == 0) continue;

        if (firstDigit == lastDigit) res++;

        for (int j = 1; j <= 5; j++) {
            int start = lastDigit * (int)pow(10, j) + firstDigit;
            if (start > N) break;
            int end = calcEnd(start);

            for (int k = start; k <= end; k += 10) {
                if (k <= N) res++;
                else break;
            }
        }
    }

    cout << res << endl;
    return 0;
}

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

int main()
{
    long long N, C;
    scanf("%lld %lld", &N, &C);
    std::vector<long long> x(N), v(N);
    for(int i=0; i<N; i++) scanf(" %lld %lld", &x[i], &v[i]);

    std::vector<long long> left(N), right(N), left_back(N), right_back(N);
    left[0] = v[0] - x[0];
    right[0] = v[N-1] - (C - x[N-1]);
    left_back[0] = left[0] - x[0];
    right_back[0] = right[0] - (C - x[N-1]);
    for(int i=1; i<N; i++){
        left[i] = left[i-1] + v[i] - (x[i] - x[i-1]);
        right[i] = right[i-1] + v[N-1-i] - (x[N-i] - x[N-1-i]);
        left_back[i] = left[i] - x[i];
        right_back[i] = right[i] - (C - x[N-i-1]);
    }
    
    if(left[0] < 0) left[0] = 0;
    if(right[0] < 0) right[0] = 0;
    for(int i=1; i<N; i++){
        left[i] = std::max(left[i-1], left[i]);
        right[i] = std::max(right[i-1], right[i]);
        left_back[i] = std::max(left_back[i-1], left_back[i]);
        right_back[i] = std::max(right_back[i-1], right_back[i]);
    }

    long long max = 0;
    for(int i=0; i<N-1; i++){
        if(max < left[i] + right_back[N-i-2]) max = left[i] + right_back[N-i-2];
        if(max < right[i] + left_back[N-i-2]) max = right[i] + left_back[N-i-2];
    }
    if(max < left[N-1]) max = left[N-1];
    if(max < right[N-1]) max = right[N-1];
    
    printf("%lld\n", max);
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

const ll mod = 998244353;
ll dp[5000][5000][3];

int main(){
    ll a, b, c, d; cin >> a >> b >> c >> d;
    dp[a][b][0] = 1;
    loop(i,a,c+1) loop(j,b,d+1){
        dp[i][j+1][0] += dp[i][j][0]*i;
        dp[i][j+1][0] %= mod;
      
        dp[i][j+1][2] += dp[i][j][1] + dp[i][j][2]*i;
        dp[i][j+1][2] %= mod;

        dp[i+1][j][1] += (dp[i][j][0] + dp[i][j][1] + dp[i][j][2])*j;
        dp[i+1][j][1] %= mod;
    }

    cout << (dp[c][d][0] + dp[c][d][1] + dp[c][d][2]) % mod << endl;
}



Measured memory_bytes: 226536
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char a;
    int i = 0,flag = 1;
    while(cin>>a)
    {
        i++;
        if(i%2 && a=='L')
            flag = 0;
        if(i%2==0 && a=='R')
            flag = 0;
    }
    if(flag)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


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

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

#define roop(i, n) for(int i = 0;i < n;i++)

int main(void){

    int n;
    cin >> n;

    for(int i = 0;i < 3;i++){
        if(n%10 == 7){
            cout << "Yes" << endl;
            return 0;
        }

        n /= 10;
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3632
/*  -*- coding: utf-8 -*-
 *
 * 2972.cc: All your base are belong to us
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200;
const int CNT = 50;
const double DINF = 1e60;

/* typedef */

/* global variables */

int xs[MAX_N], ys[MAX_N];
double ds[MAX_N];

/* subroutines */

inline double fdsum(int n, int k, double x, double y) {
  for (int i = 0; i < n; i++) {
    double dx = x - xs[i], dy = y - ys[i];
    ds[i] = sqrt(dx * dx + dy * dy);
  }
  sort(ds, ds + n);

  double sum = 0.0;
  for (int i = 0, j = n - 1; i < k; i++, j--) sum += ds[j];
  return sum;
}

double checky(int n, int k, double x, double y0, double y1) {
  for (int cnt = 0; cnt < CNT; cnt++) {
    double y2 = (y0 * 2 + y1) / 3, y3 = (y0 + y1 * 2) / 3;
    if (fdsum(n, k, x, y2) > fdsum(n, k, x, y3)) y0 = y2;
    else y1 = y3;
  }
  return fdsum(n, k, x, (y0 + y1) / 2);
}

double check(int n, int k, double x0, double x1, double y0, double y1) {
  for (int cnt = 0; cnt < CNT; cnt++) {
    double x2 = (x0 * 2 + x1) / 3, x3 = (x0 + x1 * 2) / 3;
    if (checky(n, k, x2, y0, y1) > checky(n, k, x3, y0, y1)) x0 = x2;
    else x1 = x3;
  }
  return checky(n, k, (x0 + x1) / 2, y0, y1);
}

/* main */

int main() {
  int n, k;
  scanf("%d%d", &n, &k);

  double minx = DINF, maxx = -DINF, miny = DINF, maxy = -DINF;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", xs + i, ys + i);
    if (minx > xs[i]) minx = xs[i];
    if (maxx < xs[i]) maxx = xs[i];
    if (miny > ys[i]) miny = ys[i];
    if (maxy < ys[i]) maxy = ys[i];
  }

  double d = check(n, k, minx, maxx, miny, maxy);

  printf("%.5lf\n", d);
  return 0;
}



Measured memory_bytes: 3296
from math import gcd
from collections import Counter
import sys

N = int(input())
K = 10**9
L = 10**18
A = [0] * N
C = Counter()
ans = 0

for i in range(N):
	A[i] = round(K * float(input()))
	C[gcd(A[i],L)] += 1 
	
for k1,v1 in C.items():
	for k2 ,v2 in C.items():
		if k1 == k2:
			if k1*k2 % L == 0:
				ans += v1*(v1-1)/2
		elif k1 < k2:
			if k1*k2 % L == 0:
				ans += v1 * v2

print(int(ans))
			
	
	

Measured memory_bytes: 17056
#include <stdio.h>

#define PutChar(c) ; *p = (char)(c); ++p;

#define MAX_N (2000001)
#define MAX_Ai (10001)
#define STR_SIZE (10000010)

int getNum(void);
void putNum(int n);
void CountingSort(int A[], int B[], int k, int len);

int A[MAX_N];
int B[MAX_N];
char str[STR_SIZE];
char *p = str;

int main(void) {
	register int i;
	int n;

	fread(str, 1, STR_SIZE, stdin);
	
	n = getNum();
	for (i = 1; i <= n; ++i) {
		A[i] = getNum();
	}
	
	CountingSort(A, B, MAX_Ai, n);
	
	p = str;
	--n;
	for (i = 1; i <= n; ++i) {
		putNum(B[i]);
		PutChar(' ');
	}
	putNum(B[i]);
	PutChar('\0');
	
	puts(str);
	
	return 0;
}

int getNum(void) {
	int n = 0;
	while ((*p >= '0') && (*p <= '9')) {
		n = n * 10 + (int)(*p - '0');
		++p;
	}
	++p;
	return n;
}

void putNum(int n) {
	int d;
	if (n < 10) {
		PutChar('0' + n);
		return;
	}
	d = n / 10;
	if (d) putNum(d);
	PutChar('0' + (n - (d * 10)));
}

void CountingSort(int A[], int B[], int k, int len) {
	int C[MAX_Ai] = { 0 };
	int i, j;
	for (j = 1; j <= len; ++j) {
		++C[A[j]];
	}
	for (i = 1; i <= k; ++i) {
		C[i] += C[i - 1];
	}
	for (j = len; j > 0; --j) {
		B[C[A[j]]] = A[j];
		--C[A[j]];
	}
}

Measured memory_bytes: 25652
N,M=map(int, input().split()) 
a=[0]*M
for i in range(M):
  a[i]=int(input())
b=set(a)

dp=[0]*(N+1)
dp[0]=1
if 1 in b:
  dp[1]=0
else:
  dp[1]=1
  
for j in range(2,N+1):
  if j in b:
    dp[j]=0
  else:
    dp[j]=dp[j-2]+dp[j-1]

#print(dp)
print(dp[-1]%1000000007)

Measured memory_bytes: 460020
# https://atcoder.jp/contests/abc157/tasks/abc157_e
# セグメント木
# 各文字をビットに対応させる(セグ木を26本持っても良い)
import sys
read = sys.stdin.readline


def read_a_int():
    return int(read())


class SegmentTree:
    def __init__(self, ls: list, segfunc, identity_element):
        '''
        セグ木 (下書き)
        一次元のリストlsを受け取り初期化する。O(len(ls))
        区間のルールはsegfuncによって定義される
        identity elementは単位元。e.g., 最小値を求めたい→inf, 和→0, 積→1, gcd→0
        [単位元](https://ja.wikipedia.org/wiki/%E5%8D%98%E4%BD%8D%E5%85%83)
        '''
        self.ide = identity_element
        self.func = segfunc
        n = len(ls)
        self.num = 2 ** (n - 1).bit_length()  # n以上の最小の2のべき乗
        self.tree = [self.ide] * (2 * self.num - 1)  # −1はぴったりに作るためだけど気にしないでいい
        for i, l in enumerate(ls):  # 木の葉に代入
            self.tree[i + self.num - 1] = l
        for i in range(self.num - 2, -1, -1):  # 子を束ねて親を更新
            self.tree[i] = segfunc(self.tree[2 * i + 1], self.tree[2 * i + 2])

    def update(self, i, x):
        '''
        i番目の要素をxに変更する(木の中間ノードも更新する) O(logN)
        '''
        i += self.num - 1
        self.tree[i] = x
        while i:  # 木を更新
            i = (i - 1) // 2
            self.tree[i] = self.func(self.tree[i * 2 + 1],
                                     self.tree[i * 2 + 2])

    def query(self, l, r):
        '''
        区間[l,r)に対するクエリをO(logN)で処理する。例えばその区間の最小値、最大値、gcdなど
        '''
        if r <= l:
            return ValueError('invalid index (l,rがありえないよ)')
        l += self.num - 1
        r += self.num - 2  # ここで半開区間でなく[l,r]で以下を処理する
        res = self.ide
        while r - l > 1:  # 右から寄りながら結果を結合していくイメージ
            if l & 1 == 0:
                res = self.func(res, self.tree[l])
            if r & 1 == 1:
                res = self.func(res, self.tree[r])
                r -= 1
            l = l // 2  # 親の一つ右に移動
            r = (r - 1) // 2  # 親の一つ左に移動
        if l == r:
            res = self.func(res, self.tree[l])
        else:
            res = self.func(res, self.tree[l])
            res = self.func(res, self.tree[r])
        return res


def segfunc(x, y):
    # 処理したい内容
    return x | y


def moji_to_bit(a):
    return 1 << (ord(a) - ord('a'))


def bit_to_sum(n):
    return sum([(n >> i) & 1 for i in range(n.bit_length())])


N = read_a_int()
S = read()[:-1]
S_bit = [moji_to_bit(s) for s in S]

# build segment tree
st = SegmentTree(S_bit, segfunc, 0)

Q = read_a_int()
for q in range(Q):
    com, a, b = read().split()
    if int(com) == 1:
        i, c = int(a) - 1, b
        st.update(i, moji_to_bit(c))
    else:
        l, r = int(a) - 1, int(b)
        print(bit_to_sum(st.query(l, r)))


Measured memory_bytes: 48920
package main

import (
	"fmt"
)

func Dividing(a, b uint) {
	fmt.Printf("%d %d %f",a / b, a % b, float64(a) / float64(b))
}

func main(){
	var a, b uint
			fmt.Scan(&a)
			fmt.Scan(&b)
	Dividing(a, b)
}


Measured memory_bytes: 1180
N=int(input())
ans=0
for i in range(N):
  m,t=input().split()
  if t=='JPY':
    ans+=int(m)
  else:
    indi,low=m.split('.')
    ans+=int(indi)*380000.0+int(low)*(10**(-8))*380000.0
    
print(ans)

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

#define llint long long int

using namespace std;

int main(){
    string S;

    cin >> S;

    for(int i = 1; i < S.length(); i ++){
        if(S[0] != S[i]){
            cout << "Yes" << endl;

            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
/*******************************
Author:Morning_Glory
LANG:C++
Created Time:2019年09月28日 星期六 20时39分24秒
*******************************/
#include <cstdio>
#include <fstream>
#define ll long long
using namespace std;
//{{{cin
struct IO{
	template<typename T>
	IO & operator>>(T&res){
		res=0;
		bool flag=false;
		char ch;
		while((ch=getchar())>'9'||ch<'0')	flag|=ch=='-';
		while(ch>='0'&&ch<='9')	res=(res<<1)+(res<<3)+(ch^'0'),ch=getchar();
		if (flag)	res=~res+1;
		return *this;
	}
}cin;
//}}}
int n;
double ans;
int main()
{
	cin>>n;
	ans=n/2+(n&1);
	ans/=(double)n;
	printf("%.10lf\n",ans);
	return 0;
}

/*
               *********                       
              ************                     
              *************                    
             **  ***********                   
            ***  ****** *****                  
            *** *******   ****                 
           ***  ********** ****                
          ****  *********** ****               
        *****   ***********  *****             
       ******   *** ********   *****           
       *****   ***   ********   ******         
      ******   ***  ***********   ******       
     ******   **** **************  ******      
    *******  ********************* *******     
    *******  *********************** ******    
   *******  ****** ***************** *******   
   *******  ****** ****** *********   ******   
   *******    **  ******   ******     ******   
   *******        ******    *****     *****    
    ******        *****     *****     ****     
     *****        ****      *****     ***      
      *****      ****        ***      *        
        **       ****        ****              
*/


Measured memory_bytes: 128