akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.first+a.second > b.first+b.second; }

map< int64_t, int > prime_factor(int64_t n) {
    map< int64_t, int > ret;
    for(int64_t i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}
vector<int> cnt(1000001);
signed main() {
SS(ll,n);
SV(ll,a,n);
ll f=a[0];
rep(i,n){
    f=__gcd(f,a[i]);
}
ll sum=0;
set<ll>div_appear;
rep(i,n){
for (auto p : prime_factor(a[i]))
        {
            cnt[p.first]++;
        }
}
if(*max_element(all(cnt)) <= 1){
 p("pairwise coprime");
}else if(f==1){
 p("setwise coprime");
}else{
 p("not coprime");
}
}

Measured memory_bytes: 15052
#include <stdio.h>
 
int rot[24][7] = {
    { 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
    { 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
    { 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
    { 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
    { 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
    { 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 } };
int assign[7];
 
int main()
{
    int i, j;
    int a[7], b[7], dice[7];
 
    for (i = 1; i <= 6; i++) scanf("%d", assign+i);
    for (i = 1; i <= 6; i++) scanf("%d", a+i);
    for (j = 0; j < 24; j++) {
        for (i = 1; i <= 6; i++) dice[i] = rot[j][i];
        for (i = 1; i <= 6; i++) b[i] = assign[dice[i]];
        for (i = 1; ; i++) {
            if (i > 6) { puts("Yes"); return 0; }
            if (a[i] != b[i]) break;
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 2148
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()
getcontext().prec = 400
#N=int(input())
A,B=list(map(int,input().split()))
print(A*B)


Measured memory_bytes: 10100
package main

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

func main() {
	N, M := ReadInt(), ReadInt()
	adjL = make([][]int, N)
	for i := 0; i < M; i++ {
		A, B := ReadInt()-1, ReadInt()-1
		adjL[A] = append(adjL[A], B)
		adjL[B] = append(adjL[B], A)
	}

	seen = make([]bool, N)
	max := 0
	for i := 0; i < N; i++ {
		m := dfs(i)
		if m > max {
			max = m
		}
	}
	fmt.Println(max)
}

var adjL [][]int
var seen []bool

func dfs(visit int) int {
	if seen[visit] {
		return 0
	}
	seen[visit] = true
	s := 0
	for _, u := range adjL[visit] {
		s += dfs(u)
	}
	return 1 + s
}

type UnionFind []int

func MakeUnionFind(size int) UnionFind {
	parent := make([]int, size)
	for i := 0; i < size; i++ {
		parent[i] = i
	}
	return parent
}
func (uf UnionFind) Unite(x, y int) {
	if x, y = uf.Root(x), uf.Root(y); x != y {
		uf[x] = y
	}
}
func (uf UnionFind) Connected(x, y int) bool { return uf.Root(x) == uf.Root(y) }
func (uf UnionFind) Root(x int) int {
	if uf[x] == x {
		return x
	}
	uf[x] = uf.Root(uf[x])
	return uf[x]
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 43744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int in[100005];
ll res;
bool c;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>in[i];
	}
	c=false;
	for(int i=0;i<n;i++){
		if(c){
			res++;
			in[i]--;
		}
		res+=in[i]/2;
		in[i]%=2;
		if(in[i] && in[i+1]!=0) c=true;
		else c=false;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define sz 100005
#define rep(i,n) for(int i=0;i<n;i++)
#define faster_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;

int xx[sz],yy[sz];

int main()
{
    faster_io;
    int n,x,cnt=1,bounce=0;
    cin>>n>>x;
    int a[n+5];
    rep(i,n){
        cin>>a[i];
    }

    rep(i,n){
        bounce+=a[i];
        if(bounce>x) break;
        cnt++;
    }

    cout<<cnt<<endl;


    return 0;
}





Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int t = scan.nextInt();
		int a = scan.nextInt();
		int[] h = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = scan.nextInt();
		}
		double x = 0.006;
		double sa = 1<<30;
		int num = 0;
		for (int i = 0; i < n; i++) {
			double y = t- (h[i] * x);
			double z = Math.abs(a-y);
			if (sa > z) {
				num = i;
				sa = z;
			}
		}
		System.out.println(num+1);
	}
}


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

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


long int gcd(long int a, long int b){
  long int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


int main(void){
  char s[10];
  scanf("%s",s);
  if(s[2]==s[3]&&s[4]==s[5]){
    printf("Yes\n");
    return 0;
  }else{
    printf("No\n");
    return 0;
  }
}

Measured memory_bytes: 1592
p = 1000000007

N, K = map(int, input().split())
A = list(map(int, input().split()))

fac = [0] * (N + 1)
fac[0] = 1
for i in range(N):
    fac[i + 1] = fac[i] * (i + 1) % p


def mcomb(n, k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0
    return fac[n] * pow(fac[n - k], p - 2, p) * pow(fac[k], p - 2, p) % p


A.sort(reverse=True)
result = 0
for i in range(N - K + 1):
    result += A[i] * mcomb(N - (i + 1), K - 1)
    result %= p

A.reverse()
t = 0
for i in range(N - K + 1):
    t += A[i] * mcomb(N - (i + 1), K - 1)
    t %= p

result -= t
result %= p
# result += p
# result %= p
print(result)


Measured memory_bytes: 14416
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
using namespace std;
 
int main(){
    int n;
    cin>>n;
    int count=0;
   
    for(int j=0;j<4;j++){
    	if(n%10==7){
    		count++;
		}
		n = n/10;
}
	if(count>0){
		cout<<"Yes";
	}		
    else{
    	cout << "No";
	}	

    
    
    
	
	   return 0;
}

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

int main() {
  int N, L;
  cin >> N >> L;
  string a[N];
  for(int i = 0; i<N;i++) cin >> a[i];
  sort(a, a+N);
  for(int i = 0; i<N;i++){
  cout << a[i];
  }
  
            
}



Measured memory_bytes: 3624
import java.util.Scanner;

public final class Main{
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        for(int i=0; i<n; i++){
            x[i] = stdIn.nextInt();
            y[i] = stdIn.nextInt();
        }

        int a = fact(n-2) * 2;
        int b = 2 * fact(n-2);
        int c = fact(n-1) * 2 - (a + b);

        double lSum = 0;
        for(int i=0; i<n-1; i++){
            for(int j=i+1; j<n; j++){
                lSum += Math.sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
            }
        }

        if(n == 2){
            System.out.println((a) *lSum / fact(n));
        }else{
            System.out.println((a + b + c) * lSum / fact(n));
        }
    }

    private static int fact(int n){
        int ans = 1;
        for(int i=n; i>=1; i--){
            ans *= i;
        }
        return ans;
    }
}


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

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

int main()
{
	int n;
	cin >> n;
	map<string, int> m;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		m[s]++;
	}
	vector<string> ls = {"AC", "WA", "TLE", "RE"};
	for (auto& i : ls)
	{
		cout << i<< " x " << m[i] << endl;
	}
}

Measured memory_bytes: 3600
a = int(input())
b = int(input())
c = int(input())
d = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if d == 500 * i + 100 * j + 50 * k:
                ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>  
#include <cstdio>  
#include <cstring>  
#include <algorithm>  
#include <cmath>  
#include <string>  
#include <map>  
#include <stack>  
#include <vector>  
#include <set>  
#include <queue>  
#include <string>
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <map>
#include <cctype>
#include <vector>
#include <cstdlib>
using namespace std;

long long sum;
long long a;
long long b;
long long ans;
int main()
{
	cin >> a >> b;
	if (a  >= b/2)
	{
		cout << b/2 << '\n';
	}
	else
	{
		b -= a * 2;
		ans += a;
		cout << ans + b / 4<<'\n';
	}
	
	return 0;
	
}

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

int main() {
  //入力
  int N;
  cin >> N;

  vector<int> L(N);
  for (int i = 0;i < N; i++) {
    cin >> L[i];
  }
  //処理
  int longest = 0;
  int l_num = 0;
  int l_sum = 0;
  for (int i = 0; i < N; i++) {
    if (L[i] > longest) {
      longest = L[i];
      l_num = i;
    }
    l_sum += L[i];
  }
  //出力
  if (longest < (l_sum - longest)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		char WHITE = '.';
		char BLACK = '#';

		char[][] map = new char[100][100];

		for (int i = 0; i < 100; i++) {
			for (int j = 0; j < 100; j++) {
				if(i < 50) {
					map[i][j] = WHITE;
				} else {
					map[i][j] = BLACK;
				}
			}
		}

		int count = 0;
		for (int i = 0; i < a - 1; i++) {
			int column = 99 - ((i / 50) * 2);
			int row = i % 50 * 2;
			map[column][row] = WHITE;
		}

		for (int i = 0; i < b - 1; i++) {
			int column = (i / 50) * 2;
			int row = i % 50 * 2;
			map[column][row] = BLACK;
		}


		System.out.println("100 100");
		for (int i = 0; i < 100; i++) {
			for (int j = 0; j < 100; j++) {
				System.out.print(map[i][j]);
			}
			System.out.println("");
		}


	}

}


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

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# GCD
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x

# LCM
def lcm(x,y):
  return x*y/gcd(x,y)

def main():
  a,b,c,d=LI()
  ans=b-a+1
  ans-=b//c+(-a//c)+1
  ans-=b//d+(-a//d)+1
  ans+=b//int(lcm(c,d))+(-a//int(lcm(c,d)))+1
  return ans

# main()
print(main())


Measured memory_bytes: 5464
#include <bits/stdc++.h>
using namespace std;
 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define left  (2*idx)+1
#define right (2*idx)+2
#define pb push_back
#define ll long long
#define all(x) x.begin(),x.end()
 

const ll MOD = (ll)(1e9 + 7); 
const ll N = 0;

int main()
{
	FIO;
	int a, b;
	cin >> a >> b;
	if (a <= 9 & b <= 9) {
		cout << a*b << "\n";
	} else {
		cout << -1 << "\n";
	}
	return 0;	
}	

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

flag = False
min_c = 1000

for i in range(N):
    c, t = map(int, input().split())
    if min_c >= c and T >= t:
        min_c = c
        flag = True

if flag:
    print(min_c)
else:
    print("TLE")


Measured memory_bytes: 2940
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation
#include<complex>
#include<math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
	int N;
	cin >> N;
	if (N % 10 == 7) {
		cout << "Yes" << endl;
		return 0;
	}
	if ((N % 100 - N % 10) / 10 == 7) {
		cout << "Yes" << endl;
		return 0;
	}
	if ((N - N % 100) / 100 == 7) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<map>
#include<iomanip>
#include<limits>
#include<queue>
#include<set>


using namespace std;

int main(){

    int n,k,ans;
    cin >> n >> k;

    map<int,int>m;
    while(n--){
    	int t;
    	cin >> t;
    	m[t]++;
    }

    ans = 0;

    if(m.size() > k){
    	vector<int>v;
    	for(auto c:m){
    	  v.push_back(c.second);
    	}
    	sort(v.begin(),v.end());
    	for(int i = 0;i < m.size() - k;i++){
    		ans += v[i];
    	}
    }

    cout << ans <<endl;

	return 0;

}


Measured memory_bytes: 10748
#include<stdio.h>
int main()
{
	int n,a,b,c,d;
	scanf("%d",&n);
	a=n/100;
	d=n%100;
	b=d/10;
	c=d%10;
	if(a<=b&&b>=c&&a==c||a>=b&&b<=c&&a==c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


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

int main(){
	char str[256];
	int x, y, z;
	char* token;
		
	fgets(str,256,stdin);
	token = strtok( str, " " );
	x = atoi(token);
	//printf( "%s\n", token);
	
	token = strtok( NULL, " " );
	y = atoi(token);
	//printf( "%s\n", token);
	
	token = strtok( NULL, " ");
	z = atoi(token);
	//printf( "%s\n", token);
	
	printf("%d %d %d\n",z, x, y);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {
  int s, a[1000000], flag = 1, ans;

  if(scanf("%d", &s) == 1);
  a[0] = s;

  for(int i = 1; i < 1000000 && flag == 1; i++) {
    if(a[i-1] % 2 == 0) {
      a[i] = a[i-1] / 2;
    } else {
      a[i] = a[i-1] * 3 + 1;
    }
    for(int j = 0; j < i && flag == 1; j++) {
      for(int k = j + 1; k <= i; k++) {
        if(a[j] == a[k]) {
          ans = k + 1;
          flag = 0;
          break;
        }
      }
    }
  }

  printf("%d", ans);

  return 0;
}


Measured memory_bytes: 128
-- {-# LANGUAGE BangPatterns #-}
-- {-# LANGUAGE ScopedTypeVariables #-}
-- {-# LANGUAGE FlexibleContexts #-}
-- {-# LANGUAGE ViewPatterns #-}
-- {-# LANGUAGE OverloadedStrings #-}

import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector.Algorithms.Merge as VAM
import qualified Data.Heap as HP
import qualified Data.ByteString.Char8 as BC
import qualified Data.Map as MP
import qualified Data.Set as ST
import qualified Data.Sequence as SQ
import Data.Array
import Data.Array.Unboxed
import Data.Array.ST
import Data.Array.IO
import Data.Maybe
import Data.Ratio
import Data.Char
import Data.Bits
import Data.List
import Data.Tuple
import Data.Functor
import Data.IORef
import Data.STRef
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Debug.Trace

--------------------------------------------------------------------------
main = do
   xs <- map digitToInt <$> str :: IO [Int]
   putStrLn $ 
        if elem 7 xs
            then "Yes"
            else "No"

--------------------------------------------------------------------------
    
-- Input Util
int :: IO Int
int = readLn 

double :: IO Double
double = readLn 

str :: IO String
str = getLine

strBC :: IO BC.ByteString
strBC = BC.getLine

sLineToIntL :: IO [Int]
sLineToIntL = getLine >>= return . map read . words

sLineToDoubleL :: IO [Double]
sLineToDoubleL = getLine >>= return . map read . words

sLineToIntV :: Int -> IO (VU.Vector Int)
sLineToIntV n = BC.getLine >>= return . VU.unfoldrN n (BC.readInt . BC.dropWhile isSpace)

sLineToDoubleV :: Int -> IO (VU.Vector Double)
sLineToDoubleV n = BC.getLine >>= return . VU.fromList . map (read . BC.unpack) . BC.words

mLinesToIntL :: Int -> IO [Int]
mLinesToIntL n = replicateM n readLn

mLinesToDoubleL :: Int -> IO [Double]
mLinesToDoubleL n = replicateM n readLn

mLinesToIntV :: Int -> IO (VU.Vector Int)
mLinesToIntV n = VU.replicateM n readLn

mLinesToDoubleV :: Int -> IO (VU.Vector Double)
mLinesToDoubleV n = VU.replicateM n (BC.getLine >>= return . read . BC.unpack)

mLinesToTupleL :: Int -> IO [(Int, Int)]
mLinesToTupleL n = replicateM n (getLine >>= return . (\[a,b] -> (a,b)) . map read . words)

mLinesToTupleV :: Int -> IO (VU.Vector (Int, Int))
mLinesToTupleV n = VU.replicateM n $ do
    bs <- strBC
    let
        Just (a, bs') = BC.readInt $ BC.dropWhile isSpace bs
        Just (b, _) = BC.readInt $ BC.dropWhile isSpace bs'
    return (a,b)
    
mLinesToTripleV :: Int -> IO (VU.Vector (Int, Int, Int))
mLinesToTripleV n = VU.replicateM n $ do
    bs <- strBC
    let
        Just (a, bs') = BC.readInt $ BC.dropWhile isSpace bs
        Just (b, bs'') = BC.readInt $ BC.dropWhile isSpace bs'
        Just (c, _) = BC.readInt $ BC.dropWhile isSpace bs''
    return (a,b,c)

-- others
strToChr :: String -> Char
strToChr [x] = x

chrToStr :: Char -> String
chrToStr x = [x]

m1 :: Int -> Int
m1 x = subtract 1 x

toDouble :: Int -> Double
toDouble x = fromIntegral x

toInt :: Double -> Int
toInt x = floor x

Measured memory_bytes: 3728
import sys
 
from collections import deque
 
def LI():
	return [ int(s) for s in input().split() ]
 
N,K =LI()
tree = {}
for i in range(N):
  tree[i] = []
 
MOD = (10**9)+7
color = K
 
for _ in range(N-1):
    a,b = LI()
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
    
 
## bfs ###
search_candidate = deque([0])
visited = [False]*N
hierarchy = [-1]*N
hierarchy[0] = 1
for t in tree[0]:
    if t != 0:
        hierarchy[t] = 2

while search_candidate:
    search = search_candidate.popleft()
    if hierarchy[search] == 1:
        cnt = K - 1
    else:
        cnt = K - 2
    visited[search] = True
    
    for child in tree[search]:
        if visited[child]:
            continue 
 
        if cnt <= 0:
            print(0)
            sys.exit()
 
        color = (color*cnt) % MOD
        cnt -= 1
        search_candidate.appendleft(child)
      
print(color)

Measured memory_bytes: 33128
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int N; cin >> N; 
	long long X[200010], Y[200010]; 
	for(int i = 0; i < N; i++) cin >> X[i] >> Y[i]; 
	long long mxX = -1e15; 
	long long mxY = -1e15; 
	long long mnX = 1e15; 
	long long mnY = 1e15; 
	for(int i = 0; i < N; i++){
		long long x = X[i] + Y[i]; 
		long long y = X[i] - Y[i]; 
		mxX = max(mxX, x); 
		mxY = max(mxY, y);
	 	mnX = min(mnX, x); 
		mnY = min(mnY, y);
	}
	cout << max(mxX - mnX, mxY - mnY) << "\n"; 
}

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

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'x') cnt++;
    }

    if (cnt <= 7) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while (true) {
            if (n == 0)
                break;
            int a = sc.nextInt();
            int b = sc.nextInt();
            ArrayList<Integer> out = new ArrayList<Integer>();
            if (a <= b) {
                for (int i = a; i <= b; i++) {
                    out.add(i);
                }
            } else {
                if (a <= 5) {
                    for (int i = a; i >= b; i--) {
                        out.add(i);
                    }
                } else {
                    for (int i = a; i <= 9; i++) {
                        out.add(i);
                    }
                    if (b >= 6) {
                        for (int i = 5; i > 0; i--) {

                            out.add(i);
                        }
                        for (int i = 0; i <= b; i++) {
                            out.add(i);
                        }
                    } else {
                        for (int i = 5; i >= b; i--) {
                            out.add(i);
                        }

                    }
                }
            }
            boolean init = true;
            for (int i = 0; i < out.size(); i++) {
                if (init) {
                    init = false;
                } else {
                    System.out.print(" ");
                }
                System.out.print(out.get(i));
            }
            System.out.println();
            n--;
        }
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

typedef long double ld;
const ld PI = acos(-1.0);
bool eq(ld a, ld b) { return abs(a - b) < EPS; }
typedef complex<ld> Point;

struct Circle
{
	Point p; ld r;
	Circle() {};
	Circle(Point a, ld b) :p(a), r(b) {};
};

ld dist_cc(const Circle& a, const Circle& b)
{
	ld d = abs(a.p - b.p);
	return max(0.l, d - a.r - b.r);
}

ld dist_cp(const Circle& c, const Point& p)
{
	ld d = abs(c.p - p);
	return max(0.l, d - c.r);
}


typedef ld Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

void dijkstra(Graph &g, int s, Array &d)
{
	d.assign(g.size(), 1e20);
	d[s] = 0;
	typedef pair<Weight, int> P;
	priority_queue<P, vector<P>, greater<P>> que;
	que.push(P(0, s));
	while (!que.empty())
	{
		Weight dist = que.top().first;
		int v = que.top().second;
		que.pop();
		if (d[v] < dist) continue;
		REP(i, g[v].size())
		{
			Edge e = g[v][i];
			if (d[e.to] > d[v] + e.cost)
			{
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}


int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	ld sx, sy, gx, gy;
	cin >> sx >> sy >> gx >> gy;
	Point src(sx, sy), dst(gx, gy);
	int n; cin >> n;
	vector<Circle> v;
	v.emplace_back(src, 0);
	v.emplace_back(dst, 0);
	REP(i, n)
	{
		ld x, y, r;
		cin >> x >> y >> r;
		v.emplace_back(Point(x, y), r);
	}
	Graph g(n + 2);
	REP(i, n + 2)REP(j, i)
	{
		ld d = dist_cc(v[i], v[j]);
		add_edge(g, i, j, d);
		add_edge(g, j, i, d);
	}
	Array dist;
	dijkstra(g, 0, dist);
	cout << dist[1] << endl;
	return 0;
}

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

int n;
int k;


int main(){
  int num;
  cin>>n;
  int adj[n][n];
  int rin;
  int i=0,j=0;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      adj[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    cin>>num>>k;
    num--;
    for(j=0;j<k;j++){
      cin>>rin;
      rin--;
      adj[num][rin]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j)cout<<" ";
      cout<<adj[i][j];
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3108
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int n;

signed main(){
    io();

    in(n);
    vi vec(n);
    in(vec);
    double res=0.0;
    rep(i,n){
        res+=vec[i];
    }
    res/=(double)n;
    //show(res);
    double mn=INF;int f=0;
    rep(i,n){
        if(mn > fabs(vec[i]-res)){
            mn=fabs(vec[i]-res);
            f=i;
        }
    }
    out(f);

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, m;
    cin >> n >> m;
    bool e[n + 1][n + 1] = {};
    for (int i = 0, a, b; i < m; i++) {
        cin >> a >> b;
        e[a][b] = true;
        e[b][a] = true;
    }
    int t[n - 1];
    for (int i = 0; i <= n - 2; i++) t[i] = i + 2;
    int ans = 0;
    do {
        bool flag = true;
        int cur = 1, i = 0;
        while (i < n - 1 && flag) {
            if (e[cur][t[i]]) {
                cur = t[i];
            } else {
                flag = false;
                break;
            }
            i++;
        }
        if (flag) ans++;
    } while (next_permutation(t, t+n-1));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
typedef long long int lli;
const lli mod = 1e9+7;
using namespace std;

int main()
{

    lli n;cin>>n;
    lli a[n];
    for(int i=0; i<n; i++)
        cin>>a[i];
    map<lli,int> mp;
    for(int i=0; i<n; i++)
        mp[a[i]]++;

    lli count=0;
    for(auto i:mp)
    {
        lli x=i.second-1;
        count+=(x*(x+1))/2;
    }


    for(int i=0; i<n; i++)
    {
        lli y=mp[a[i]];
        cout<<count-(y-1)<<"\n";

    }

    return 0;
}


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

int main(){
  int N, M;
  vector<string> str;
  vector<int> cnt;
  string tmp;
  int words=1;
  
  cin >> N;
  cin >> tmp;
  str.push_back(tmp);
  cnt.push_back(1);
  for(int i = 1; i < N; i++){
    cin >> tmp;

    bool found = false;
    for(int j = 0; j < words; j++){
      if(str.at(j) == tmp){
        cnt.at(j)++;
        found = true;
        break;
      }
    }
    if(!found){
      str.push_back(tmp);
      cnt.push_back(1);
      words++;
    }
  }
  cin >> M;
  for(int i = 0; i < M; i++){
    cin >> tmp;

    bool found = false;
    for(int j = 0; j < words; j++){
      if(str.at(j) == tmp){
        cnt.at(j)--;
        found = true;
        break;
      }
    }
    if(!found){
      str.push_back(tmp);
      cnt.push_back(-1);
      words++;
    }
  }
  
  int result = 0;
  for(int i = 0; i < cnt.size(); i++){
    result = max(result, cnt.at(i));
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int d[111],f[111],G[111][111],t=1,n;
int dfs(int now){
  d[now]=t++;
  for(int i=1;i<=n;i++)
    if(G[now][i]&&d[i]==0)dfs(i);
  f[now]=t++;
}

int main(){
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    int v2,v1,k;
    scanf("%d%d",&v1,&k);
    for(int j=0;j<k;j++){
      scanf("%d",&v2);
      G[v1][v2]=1;
    }
  }
  for(int i=1;i<=n;i++)if(d[i]==0)dfs(i);
  for(int i=1;i<=n;i++)printf("%d %d %d\n",i,d[i],f[i]);
  
  return 0;
}



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

int main() {
    //n length of string
    //s string
    int n, t = 0;
    std::string s;

    std::cin >> n >> s;
    for(int i = 0; i < n-2; i++) {
        if(s[i] == 'A') {
            if(s[i+1] == 'B') {
                if(s[i+2] == 'C') {
                    t++;
                }
            }
        }
    }
    std::cout << t;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int r, g, b;
	cin >> r >> g >> b;

	int x = 100 * r + 10 * g + b;
	if(x % 4 == 0){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
typedef long long int ll;
#define rep(i,n) for(int i = 0;i < n; i++)
#define c(ans) cout << (ans) << '\n'
using namespace std;
int  m,k, a, b, c;string s, t;
vector<int> n = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
int main() {
	cin >> k;
	c(n[k - 1]);
}


Measured memory_bytes: 256
N = int(input())
dicta = {}
for i in range(N):
    s = input()
    if s not in dicta:
        dicta[s] = 1
    else:
        dicta[s]+=1
maxv = max(dicta.values())
ans = []
for k,v in dicta.items():
    if v == maxv:
        ans.append(k)
ans.sort()
for i in ans:
    print(i)

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

int main(int argc, const char * argv[]) {



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

    /////////////////////
    // Write code below /
    /////////////////////
    
    string S,T,U;
    int A,B;

    cin>>S>>T>>A>>B>>U;

    if(S == U){
        cout<<A - 1<<" "<<B<<endl;
    }
    else
    {
        cout<<A<<" "<<B - 1<<endl;
    }
    

    return 0;
}

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

using namespace std;

int main()
{
    int n;
    priority_queue<double, vector<double>, greater<double> > ingredients;

    cin >> n;

    for(int i = 0; i < n; ++i)
    {
        double vi;

        cin >> vi;

        ingredients.push(vi);
    }

    for(int i = 0; i < n - 1; ++i)
    {
        double x = ingredients.top(); ingredients.pop();
        double y = ingredients.top(); ingredients.pop();

        ingredients.push((x + y) / 2.0);
    }

    cout << ingredients.top() << endl;

    return 0;
}

Measured memory_bytes: 256
a,b,m = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
ans = min(a_list) + min(b_list)
for i in range(m):
  x,y,c = map(int, input().split())
  if ans > a_list[x-1] + b_list[y-1] - c:
    ans = a_list[x-1] + b_list[y-1] - c
print(ans)

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



int main() {
    int n;

    cin >> n;

    for(int i=1; i<=50000; i++){
        int val = 0;
        val = i*1.08;
        if(n == val){
        cout << i;
        return 0;
        }

    }

    cout << ":(";
}

Measured memory_bytes: 3640
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll A, B, C;
    cin >> A >> B >> C;
    if (A <= C)
    {
        if (C <= B)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}
template<class T>vector<T> make_vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vec(size_t a, Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));}
main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);
  
  ll n;
  cin>>n;
  vector<double> a(n);
  cin>>a;
  double ave=0.0;
  rep(i,n)ave+=a[i];
  ave/=(double)n;
  ll ansidx=-1,ansval=INF;
  rep(i,n){
    if(abs(ansval-ave)>abs(a[i]-ave)){
      ansval=a[i];
      ansidx=i;
    }
  }
  cout<<(ansidx)<<endl;


}


Measured memory_bytes: 256
//Harjot Singh Student NIT JALANDHAR	

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);



struct act
{

	int a,b,c;

};
int main()
{
    fastio
    int n=0;
    cin>>n;
     act arr[n];

     for(int i=0;i<n;i++)
     {
     	cin>>arr[i].a>>arr[i].b>>arr[i].c;
     }


    int dp[n][3];
    dp[0][0]=arr[0].a;
    dp[0][1]=arr[0].b;
    dp[0][2]=arr[0].c;

    for(int i=1;i<n;i++)
    {
    	dp[i][0]=arr[i].a+max(dp[i-1][1],dp[i-1][2]);
    	dp[i][1]=arr[i].b+max(dp[i-1][0],dp[i-1][2]);
    	dp[i][2]=arr[i].c+max(dp[i-1][0],dp[i-1][1]);

    }

    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
   

	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include<iostream>
#include <string>

int main(){
  std::string a;
  std::string s;
  int ad;
  std::cin >> a;
  if(a == "SUN"){
    s = "日曜日";
    ad = 7;
  }
  else if(a=="MON"){
    s = "月曜日";
    ad = 6;
  }
  else if(a=="TUE"){
    s = "火曜日";
    ad = 5;
  }
  else if(a=="WED"){
    s = "水曜日";
    ad = 4;
  }
  else if(a=="THU"){
    s = "木曜日";
    ad = 3;
  }
  else if(a=="FRI"){
    s = "金曜日";
    ad = 2;
  }
  else if(a=="SAT"){
    s = "土曜日";
    ad = 1;
  }
  std::string s1("今日は");
  std::string s2("です。よって、次の日曜日は");
  std::string s3("日後です。");
  std::string s5 = std::to_string(ad);
  std::string s4 = s1 + s + s2 + s5 + s3;
  std::cout <<  ad << std::endl;
}

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

typedef long long ll;
const int N = 100005;
const ll MOD = 1e9+7;

ll fact[N];
ll infact[N];

ll powermod(ll a,ll b){
	ll ret = 1;
	while(b){
		if(b&1){
			ret *= a;
			ret %= MOD;
		}
		b/=2;
		a *= a;
		a %= MOD;
	}
	return ret;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
	
	
	
	int n;
	cin>>n;
	fact[0] = 1;
	infact[0] = powermod(1,MOD-2);
	for(int i=1;i<=n;i++){
		fact[i] = fact[i-1]*i;
		fact[i] %= MOD;
		infact[i] = powermod(fact[i],MOD-2);
	}
	
	ll ans = 0;
	
	for(int i=1;i<=n;i++){
		int t = 3*i;
		if(t > n)break;
		//cout<<i<<" "<<t<<" "<<n-t<<" "<<i-1<<" "<<fact[n-t]<<endl;
		ll tmp = fact[n-t+(i-1)]*infact[i-1];
		tmp %= MOD;
		tmp *= infact[(n-t)];
		tmp %= MOD;
		ans += tmp;
		ans %= MOD;
	}
	
	cout<<ans;
	
	return 0;
}



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

#define int long long
//#define ll int long long
#define REP(i,n) for(int i=0;i<n;i++)
//#define ALL(vec) (vec).begin(),(vec).end()
//#print_double(d) printf("%.9f\n", d)
/*
int par[100002];
int rnk[100002];
void init(int n){REP(i,n){par[i]=i;rnk[i]=0;}}
int find(int x){if(par[x]==x){return x;}else{return par[x]=find(par[x]);}}
void unite(int x,int y){x=find(x);y=find(y);if(x==y)return;if(rnk[x]<rnk[y]){par[x]=y;}else{par[y]=x;if(rnk[x]==rnk[y])rnk[x]++;}}
bool same(int x,int y){return find(x)==find(y);}
*/

const int INF = numeric_limits<int>::max();
struct edge {int to,cost;};
typedef pair<int,int> P;
vector<int> dijkstra(int s,vector<vector<edge>>&G){
    vector<int> d(G.size(),INF);
    priority_queue<P,vector<P>,greater<P>> que;
    d[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
        P p=que.top();que.pop();
        int v=p.second;
        if(d[v]<p.first)continue;
        for(edge e : G[v]){
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
    return d;
}


signed main(){
    int n,m,s,t;
    cin>>n>>m>>s>>t;
    s--;t--;
    vector<vector<edge>> G(n),H(n);
    REP(i,m){
        int u,v,a,b;
        cin>>u>>v>>a>>b;
        u--;v--;
        G[u].push_back({v,a});
        G[v].push_back({u,a});
        H[u].push_back({v,b});
        H[v].push_back({u,b});
    }
    auto D=dijkstra(s,G);
    auto E=dijkstra(t,H);
    vector<int> ans(n+1,INF);
    for(int i=n;i--;)ans[i]=min(D[i]+E[i],ans[i+1]);
    int ken=1e15;
    REP(i,n){
        cout<<(ken-ans[i])<<endl;
    }
}


Measured memory_bytes: 19012
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cmath>
using namespace std;

long long s, w;

int main() {
    cin.tie(0); ios::sync_with_stdio(0);
    cin >> s >> w;
    if (w >= s) {
        cout << "unsafe";
    }
    else {
        cout << "safe";
    }
    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

#define chmax(x,y) x = max(x,y)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

ll dp[200005][4];

int main()
{
    cout << fixed << setprecision(15);
    
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    int k = 1+n%2;
    REP(i,n+1)REP(j,k+1) dp[i][j] = -LINF;
    dp[0][0] = 0;
    REP(i,n) {
        REP(j,k+1) {
        chmax(dp[i+1][j+1], dp[i][j]);
        ll now = dp[i][j];
        if ((i+j)%2 == 0) now += a[i];
        chmax(dp[i+1][j], now);
        }
    }
    ll ans = dp[n][k];
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 10388
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF = 2e9
#define LINF = 1e18
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << "=" << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO")
#define Yes(n) cout << ((n) ? "Yes" : "No")
#define PI 3.141592653589793

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

    bool f = 1;

    for(int i = 1; i <= 9; ++i){
        if(n%i == 0 && n/i <= 9){
             cout << "Yes" << endl;
             return 0;
        }
    }

    cout << "No" << endl;

}

Measured memory_bytes: 3524
a,b,c,r,K;gcd(n,m){return m?gcd(m,n%m):n;}main(){scanf("%d",&K);for(a=1;a<=K;++a){for(b=1;b<=K;++b){for(c=1;c<=K;++c)r+=gcd(a,gcd(b,c));}}printf("%d\n",r);}

Measured memory_bytes: 1688
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
/*ll divr[maxn];
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}
 
*/















int ct[100005][2];
int main()
{
     int n;
     cin>>n;
     int a[n];rep(i,n)cin>>a[i];
     map<int,int> m[2];
     for(int i=0;i<n;i++)
     m[i&1][a[i]]++;
     vector<pair<int,int>> v[2];
     for(int u=0;u<2;u++)
     {
          for(auto &p:m[u])v[u].emplace_back(p.second,p.first);
          if(v[u].size()==1)v[u].emplace_back(0,-1);
          sort(v[u].rbegin(),v[u].rend());

     }
     int ans=0;
     for(int i=0;i<2;i++)
     {
          for(int j=0;j<2;j++)
          {
               if(v[0][i].second!=v[1][j].second)
               {
                    ans=max(v[0][i].first+v[1][j].first,ans);
               }
          }
     }
     cout<<n-ans;

     
}
























 

Measured memory_bytes: 6520
#include<algorithm>
#include<stdio.h>
#include<math.h>

using namespace std;

int main(void){
	long long Q, H, S, D;
	long long N;
	long long ans = 0;
	scanf("%lld%lld%lld%lld", &Q, &H, &S, &D);
	scanf("%lld", &N);

	if (N >= 2){
		ans = min({ Q * 8, H * 4, S * 2, D }) * (N / 2);
		N %= 2;
	}
	ans += min({ Q * 4, H * 2, S}) * N;

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

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

int k;

void dfs(string num, int last, int len, int lm){
	if(len == lm){
		k--;
		if(!k){
			cout << num << endl;
			exit(0);
		}
		//cout << num << endl;
		return;
	}
	for(int i=last-1; i<last+2; i++){
		if(i >=0 && i<10){
			dfs(num + (char)(i+'0'), i, len+1, lm);
		}
	}
}

int main(void){
	cin >> k;
	int lm = 1;
	while(k>0){
		for(int i=1; i<10; i++){
        	dfs({(char)(i+'0')},i, 1, lm);
        }
		lm++;
	}
}

Measured memory_bytes: 256
//#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
//#include<cmath>
#define PI 3.14159265358979

using namespace std;

int main(){

	double r;
	cin>>r;
	//cout<<PI*r*r<<" "<<2*PI*r<<endl;
	printf("%lf %lf\n", r*r*PI, 2 * r*PI);
	return 0;
}

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

map<int,int> mp;
int a[100005],b[100005];
long long int c[100005];
int n,m;
vector<int> sima[100005];
int num;
long long int dfs(int now){
        if(mp[a[now]]+mp[b[now]]==0){
            mp[a[now]]=num;
            mp[b[now]]=num;
            sima[num].push_back(a[now]);
            sima[num].push_back(b[now]);
            num++;
            return c[now]+1LL;
        }
        else if(mp[a[now]]==0 || mp[b[now]]==0){
            if(mp[a[now]]==0 && mp[b[now]]>0){
                mp[a[now]]=mp[b[now]];
                sima[mp[b[now]]].push_back(a[now]);
                long long int tmp=sima[mp[b[now]]].size();
                return c[now]+tmp-1;
            }
            else{
                mp[b[now]]=mp[a[now]];
                sima[mp[a[now]]].push_back(b[now]);
                long long int tmp=sima[mp[a[now]]].size();
                return c[now]+tmp-1;
            }
        }
        else if(mp[a[now]]==mp[b[now]])return c[now];
        else{
            long long int tmp=sima[max(mp[a[now]],mp[b[now]])].size();
            long long int tmp2=sima[min(mp[a[now]],mp[b[now]])].size();
            for(int u:sima[max(mp[a[now]],mp[b[now]])]){
                mp[u]=min(mp[a[now]],mp[b[now]]);
                sima[min(mp[a[now]],mp[b[now]])].push_back(u);                
            }
            return c[now]+tmp*tmp2;       
        }
        }

int main(){
    cin >> n >> m;
    for(int i=1;i<m+1;i++)cin >> a[i] >> b[i];
    num=1;
    for(int i=m;i>0;i--)c[i-1]=dfs(i);
    for(int i=1;i<m+1;i++)cout << c[0]-c[i] << endl;
}

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

#define INF 1234567890
#define ll long long

int D, T, S;

int main()
{
	scanf("%d %d %d", &D, &T, &S);
	if (D <= T*S) printf("Yes");
	else printf("No");
	return 0;
}

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

int main(){
	double a,V;
	int L;
	cin>>L;
	a=L/3.00000000000000000;
	V=(L/3.00000000000000000000000000000000)*(L/3.00000000000000000000000000000000)*(L/3.00000000000000000000000000000000);
	cout << fixed << setprecision(15) << V << endl;
}



Measured memory_bytes: 256