akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define endl '\n'

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

    int n; cin >> n;
    int a[n];
    for (int i=0; i<n; i++){
        cin >> a[i];
        if (a[i] % 2 == 0){
            if ( a[i] % 3 != 0 && a[i] % 5 != 0){
                cout << "DENIED\n";
                return 0;
            }
        }
    }
    cout << "APPROVED\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int R=1,C=1,H[1000010]={0};
int N[1000010]={-1000};
//ヒープに入れる
void hin(int a){
  int i=C++;
  for(N[R]=a;a<N[H[i/2]];i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//ヒープから最小値を取り出す
int hout(){
  int rt=H[1],nt=1,i=0,k=H[--C];
  while(nt-i){
    H[i=nt]=k;
    if(i*2  <C&&N[  k  ]>N[H[i*2  ]])H[i]=H[nt=i*2  ];
    if(i*2+1<C&&N[H[nt]]>N[H[i*2+1]])H[i]=H[nt=i*2+1];
  }
  return rt;
}
int CO[100010];
void dijk(int v,int e,int *a,int *to,int *co,int mi){
  int i,id[100010],ta[100010],nt[100010],f[100010]={0};
  for(i=0;i<v;i++)ta[i]=-1;
  for(i=0;i<v;i++)CO[i]=1000000000;
  for(i=CO[mi]=0;i<e;i++){
    nt[i]=ta[a[i]];
    ta[a[i]]=i;
  }
  while(--v){//printf("%d\n",mi);
    f[mi]=1;
    for(i=ta[mi];i+1;i=nt[i]){
      if(CO[to[i]]>CO[mi]+co[i])hin(CO[id[R]=to[i]]=CO[mi]+co[i]);
    }
    while(f[mi])mi=id[hout()];
  }
}
int main(){
  int n,m,fr[10000],to[10000],co[10000],a,b,c,d,i;
  scanf("%d %d",&n,&m);
  for(i=0;i<m*2;i+=2){
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    fr[i]=to[i+1]=a-1;
    to[i]=fr[i+1]=b-1;
    co[i]=c;
    co[i+1]=d;
  }
  scanf("%d,%d,%d,%d",&a,&b,&c,&d);
  dijk(n,m*2,fr,to,co,a-1);
  c-=d+CO[b-1];
  //for(i=0;i<n;i++)printf("%d ",CO[i]);printf("\n");
  dijk(n,m*2,fr,to,co,b-1);
  printf("%d\n",c-CO[a-1]);
  return 0;
}

Measured memory_bytes: 3080
n, T = map(int, input().split())
pair = []
for i in range(n):
  pair.append(list(map(int, input().split())))
a = []
for i in range(len(pair)):
  if pair[i][1] <= T:
    a.append(pair[i])
if len(a) == 0:
  print('TLE')
  exit()
else:
  a.sort()
  print(a[0][0])

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

int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << abs(a[2] - a[1]) + abs(a[1] - a[0]) << 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);
		
		while(true)
		{
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a==0&&b==0)
				break;
			if(a>b)
			{
				System.out.println(b+" "+a);
			}
			else
			{
				System.out.println(a+" "+b);
			}

		}
	}
}



Measured memory_bytes: 35252
""" AtCoder """

N, Q = map(int, input().split())
S = input()
lr = [list(map(int, input().split())) for _ in range(Q)]

tmp = 0
l = [0]

for i in range(1, N):
    if S[i - 1] + S[i] == "AC":
        tmp += 1
    l.append(tmp)

for i in range(Q):
    print(l[lr[i][1]-1] - l[lr[i][0]-1])


Measured memory_bytes: 30696
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(12);
  int n;
  cin>>n;
  int x[n],y[n];
  rep(i,n){
    cin>>x[i]>>y[i];
  }
  double ans=0;
  rep(i,n){
    repi(j,i+1,n){
      ans+=sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2) );
    }
  }
  int num=(n-1)*2;
  rep(i,n-2){
    num*=(i+1);
  }
  int num2=1;
  rep(i,n){
    num2*=(i+1);
  }
  //cout<<num<<" "<<ans<<endl;
  cout<<((double)num*ans)/num2<<endl;
  
  

  return 0;
}


Measured memory_bytes: 256
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from bisect import bisect_left # bisect_left(list, value)
#from fractions import gcd

sys.setrecursionlimit(10**7)
A, B, C = map(int, input().split())

s = set()
s.add(A)
s.add(B)
s.add(C)

if len(s) == 2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,w;
ll ans = 0,dp[2000004];
ll x,y;
int main(){
    ios::sync_with_stdio(false);
    cin >> n >> w;
    
    for(int i=1; i<=100000; i++)
        dp[i] = 100000000000000000;
    
    for(int i=1; i<=n; i++){
        cin >> x >> y;
        for(int i=100000 - y; i>=0; i--)
            dp[i + y] = min(dp[i + y] , dp[i] + x);
    }
    
    for(int i=1; i<=100000; i++)
        if(dp[i] <= w)ans = i;
        
        cout << ans;
    
    
    
    
    return 0;
}


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

using namespace std;
#define rep(i,n) for (int i = 0; i < (int)n; i++)

bool is_palindrome(string s){
    string t(s.rbegin(),s.rend());
    return s == t;
}

int main(){
    string s;
    cin>>s;
    int n=s.size();
    if(is_palindrome(s) && is_palindrome(s.substr(0,(n-1)/2)) && is_palindrome(s.substr((n+1)/2))){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3600
#include <stdio.h>
typedef long long LL;

int n;

LL s(int x)
{
	int b = n / x * x, c;
	c = b / x + 1;
	return (LL)b * (LL)c / 2;	 
}

int main()
{		
		
	scanf("%d", &n);
	printf("%lld\n", s(1) - s(3) - s(5) + s(15));
			
	return 0;
}

Measured memory_bytes: 1708
"""
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
def xor(x):
	for j in range(n):
		x = bin(x ^ a[j])
		x= int(x[2:])


"""
s = list(input())
k = len(s)//2
a =0
for i in range(k):
	if s[i] is not s[len(s)-i-1]:
		a+=1

print(a)

Measured memory_bytes: 2940
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int dy[8] = { 1, 1, 1, 0, 0, -1, -1, -1 };
const int lr[4] = { 0, 1, 0, -1 };
const int ud[4] = { 1, 0, -1, 0 };



//LOVE Ayane Sakura



using namespace std;

long long nCm(long long n, long long m) {
	long long ans = 1;
	for (long long i = 1; i <= m; i++) {
		ans = ans * n / i;
		n--;
	}
	return ans;
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<int>s(M), c(M);
	for (int i = 0; i < M; i++) {
		cin >> s[i] >> c[i];
	}
	if (N == 1) {
		for (int i = 0; i <= 9; i++) {
			int check = 0;
			string t = to_string(i);
			for (int j = 0; j < M; j++) {
				int n = stoi(t.substr(s[j] - 1, 1));
				if (n == c[j]) {
					check++;
				}
			}
			if (check == M) {
				cout << i << endl;
				return 0;
			}
		}
		cout << -1 << endl;
	}
	else if (N == 2) {
		for (int i = 10; i <= 99; i++) {
			int check = 0;
			string t = to_string(i);
			for (int j = 0; j < M; j++) {
				int n = stoi(t.substr(s[j] - 1, 1));
				if (n == c[j]) {
					check++;
				}
			}
			if (check == M) {
				cout << i << endl;
				return 0;
			}
		}
		cout << -1 << endl;
	}
	else {
		for (int i = 100; i <= 999; i++) {
			int check = 0;
			string t = to_string(i);
			for (int j = 0; j < M; j++) {
				int n = stoi(t.substr(s[j] - 1, 1));
				if (n == c[j]) {
					check++;
				}
			}
			if (check == M) {
				cout << i << endl;
				return 0;
			}
		}
		cout << -1 << endl;
	}
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var nk = Input.ar;
        if (nk[0] > nk[1])
        {
            WriteLine(0);return;
        }
        var comb = new Modulo.Combination(nk[1]+1);
        WriteLine(comb.Comb(nk[1], nk[0]));
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}
public class Modulo
{
    private static int Multiple(int num1, int num2)
        => (int)(BigMul(num1, num2) % Input.MOD);

    public static int Pow(int m, int n)
    {
        if (n == 0) return 1;
        if (n % 2 == 0) return Pow(Multiple(m, m), n / 2);
        else return Multiple(Pow(Multiple(m, m), n / 2), m);
    }

    public static int Div(int a, int b)
        => Multiple(a, Pow(b, Input.MOD - 2));

    public class Combination
    {
        private int[] _fac;
        public Combination(int num)//階乗をメモ化
        {
            _fac = new int[num + 1];
            _fac[0] = 1;
            for (var i = 1; i <= num; i++)
                _fac[i] = Multiple(_fac[i - 1], i);
        }
        public int Comb(int n, int r)
        {
            if (n < r) return 0;
            if (n == r) return 1;
            var calc = _fac[n];
            calc = Div(calc, _fac[r]);
            calc = Div(calc, _fac[n - r]);
            return calc;
        }
        public int fac(int num)
            => _fac[num];
    }

}




Measured memory_bytes: 19868
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
ct = list(Counter(A).items())
flg = 0
ct. sort(key=lambda x: x[0], reverse=True)
for i in ct:
    if i[1] >= 4 and flg == 0:
        flg = 2
        ans = i[0]**2
        break
    if i[1] >= 2 and flg == 0:
        flg = 1
        ans = i[0]
    elif i[1] >= 2 and flg == 1:
        flg = 2
        ans *= i[0]
        break

if flg != 2:
    print(0)
else:
    print(ans)

Measured memory_bytes: 21412
(defun xor (a b) ;xor
  (not (equal a b)))
(let* ((n (read-line))
       (lst (loop :repeat (read) :collect (if (= 1 (read))
                                              (list 1 nil nil)
                                              (list 2 (read) (read-char)))))
       (reverse nil)
       (from-stack nil)
       (to-stack nil))
  (loop :for (x y z) :in lst
        :do (if (= x 1)
                (setf reverse (not reverse))
                (if (xor reverse (= 1 y))
                    (push z from-stack)
                    (push z to-stack))))
  (princ (if reverse
             (reverse (concatenate 'string from-stack n (reverse to-stack)))
             (concatenate 'string from-stack n (reverse to-stack)))))


Measured memory_bytes: 72292
n=input()
x1=0
y1=0
t1=0
success=True
for i in range(int(n)):
    t,x,y = map(int,input().split())
    w = abs(x - x1) + abs(y - y1)
    if w > abs(t - t1):
        success=False
        break
    if w % 2 != abs(t -t1) % 2:
        success=False
        break
    x1 = x
    y1 = y
    t1 = t
 
print("Yes") if success else print("No")

Measured memory_bytes: 3064
<?php
$n=trim(fgets(STDIN));
$m=0;
$a=0;
$r=0;
$c=0;
$h=0;
while($n>0){
	$i=trim(fgets(STDIN))[0];
	if($i=='M'){
		++$m;
	}elseif($i=='A'){
		++$a;
	}elseif($i=='R'){
		++$r;
	}elseif($i=='C'){
		++$c;
	}elseif($i=='H'){
		++$h;
	}
	--$n;
}
$x=array($m,$a,$r,$c,$h);
$ans=0;
$i=0;
while($i<3){
	$j=$i+1;
	while($j<4){
		$k=$j+1;
		while($k<5){
			$ans+=$x[$i]*$x[$j]*$x[$k];
			++$k;
		}
		++$j;
	}
	++$i;
}
echo $ans;

Measured memory_bytes: 4728
#include<stdio.h>

#define MAX 1000000

int parent(int);
int left(int);
int right(int);
void buildMaxHeap(void);
void maxHeapify(int);

int Heap;
int A[MAX + 1];

int main(){
    
  int i;

  scanf("%d",&Heap);
  for(i=1;i <=Heap; i++) {
      scanf("%d",&A[i]);
}

for(i=Heap/2;i>=1;i--) {maxHeapify(i);
}

for(i=1;i<=Heap;i++){
  printf(" %d",A[i]);
}
    printf("\n");

  return 0;
}

int parent(int x){
  return x/2;
}

int left(int y){
  return 2*y;
}

int right(int z){
  return 2*z+1;
}

void maxHeapify(int i){
  int l,r,largest,temch;

  l=left(i);
  r=right(i);

  if(l<=Heap && A[l]>A[i]) largest = l;
  else largest = i;
  if(r<=Heap && A[r] > A[largest]) {
largest = r;
}

  if(largest != i){
    temch = A[i];
    A[i] = A[largest];
    A[largest] = temch;
    maxHeapify(largest);
  }
}

void buildMaxHeap(void){
int i;
  for(i=Heap/2;i>1;i--) {
maxHeapify(i);
}
}



Measured memory_bytes: 3660
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll od=0;
    while(n--)
    {
        ll a;
        cin>>a;
        if(a%2==1)
        {
            od++;
        }
    }
    if(od==0)
    {
        cout<<"second\n";
    }
    else
    {
        cout<<"first\n";
    }
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
dp = [[0,0,0] for _ in range(n+1)]
ans = 1
mod = 10**9+7
for i in range(n):
    for j in range(3):
        dp[i+1][j] = dp[i][j]
    for j in range(3):
        if A[i]==dp[i+1][j]:
            dp[i+1][j] += 1
            break
for i in range(n):
    ans *= dp[i].count(A[i])
    ans %= mod
print(ans)

Measured memory_bytes: 99468
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  rep(i, h){
    string line = s[i];
    cout << s[i] << endl;
    cout << s[i] << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n; cin >> n;
  string s; cin >> s;
  for(char c: s) {
    cout << (char)(((c-'A'+n)%26)+'A');
  }
  cout << endl;
  return 0;
}


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


int sol()
{  int n;
   cin>>n;
   int ar[n];
   for(int i=0;i<n;i++)cin>>ar[i];
   sort(ar,ar+n);
   int M=n-1;
   int i=n-1,c=0; long long ans=0;
   while(M>0)
     {   if(M==n-1)
            ans+=ar[i];
         else 
          {   
              ans+=ar[i];
              c++;
              i+=c%2;
          }
         M--; i--;
     }
    cout<<ans<<endl;     
    return 0;
}
int main()
{ sol();
}


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

int main(int argc, char const *argv[])
{
	string b;
	cin>>b;
	for (int i = 0; i < b.size(); ++i)
	{
		if (b.at(i)=='A')
		{
			cout<<"T";
		}
		else if (b.at(i)=='T')
		{
			cout<<"A";
		}
		else if (b.at(i)=='C')
		{
			cout<<"G";
		}
		else if (b.at(i)=='G')
		{
			cout<<"C";
		}
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <assert.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <fstream>

using namespace std;

int H,W,h,w;

int main()
{
	scanf("%d%d%d%d",&H,&W,&h,&w);
	if (H % h == 0 && W % w == 0)
	{
		puts("No");
		return 0;
	}
	puts("Yes");
	for (int i = 1;i <= H;i++,printf("\n"))
		for (int j = 1;j <= W;j++)
			printf("%d ",i % h == 0 && j % w == 0 ? -h * w * 1000 + 999 : 1000);
	return 0;
}

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


int main(int argc, char const *argv[])
{
    int a;
    int b;
    int c;
    cin>>a>>b>>c;
    
     if (a==b&&b==c&&c==a) {
        cout<<'1';
    }else
    if (a==b||b==c||a==c) {
        cout<<'2';
    }
    else
    {
        cout<<'3';
    }
       
    
    return 0;
}

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

int main() {
    string a, b;
    cin >> a >> b;

    auto c = stoi(a + b);
    auto s = sqrt(c);
    if (ceilf(s) == s && pow(s, 2) == c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
using namespace std;

const int inf = 1e18;

const int N = 100;

int32_t main(){

    FAST;

    int a,b,k;  cin >> a >> b >> k;

    unordered_map<int,int> f;

    int l1 = a , r1 = a + k - 1;
    int l2 = b - k + 1 , r2 = b;

    for(int x=l1;x<=r1;x++){
        if(x >= a and x<= b){
            f[x] = 1;
            cout << x << endl;
        }
    }

    for(int x=l2;x<=r2;x++){
        if(x >= a and x<= b){
            if(!f[x])
                cout << x << endl;
        }
    }




    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#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 FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)
#define YES(b) cout << ((b) ? "YES" : "NO") << endl
#define Yes(b) cout << ((b) ? "Yes" : "No") << endl
#define DOUBLE(d) cout << fixed << setprecision(15) << (d) << endl

const int MAX= 2e5+10;

int N;
int A[MAX];

int main() {
    cin >> N;
    REP (i, N-1) {
        int a;
        cin >> a;
        A[a-1]++;
    }
    REP (i, N) cout << A[i] << endl;
    
}

Measured memory_bytes: 4360
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <iomanip>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

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

int main() {
    int L; cin >> L;
    double l = L / double(3);
    cout << setprecision(20) << l * l * l << endl;
}


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

#define S second
#define F first
#define pb push_back

const int mod = 1e9 + 7;


int f[10101][2];
int g[10101][2];
int dp[5050][2];

int _2[5050];

int main(){
	int N, A, B;
	cin >> N >> A >> B;
	if(A > B)
		swap(A, B);
	
	_2[0] = 1;
	for(int i = 1; i <= 5000; i++)
		_2[i] = _2[i - 1] * 2 % mod;
	f[0][0] = 1;	
	for(int i = 1; i < A + B; i++)
	{
		for(int j = A; j <= ((i <= B) ? i : A); j++)
		{
			f[i][0] += f[i - j][1];
			if(f[i][0] >= mod)
				f[i][0] -= mod;
		}
		if(i <= B)
		{
			for(int j = 1; j <= B; j++)
			{
				f[i][1] += f[i-j][0];
				if(f[i][1] >= mod)
					f[i][1] -= mod;
			}
		}
	}
	g[0][1] = 1;	
	for(int i = 1; i < A + B; i++)
	{
		for(int j = A; j <= ((i <= B) ? i : A); j++)
		{
			g[i][0] += g[i - j][1];
			if(g[i][0] >= mod)
				g[i][0] -= mod;
		}
		if(i <= B)
		{
			for(int j = 1; j <= B; j++)
			{
				g[i][1] += g[i - j][0];
				if(g[i][1] >= mod)
					g[i][1] -= mod;
			}
		}
	}
	dp[0][0] = dp[0][1] = 1;
	for(int i = 1; i <= N; i++)
	{
		if(i < B)
		{
			dp[i][1] += g[i][1];
			if(dp[i][1] >= mod)
				dp[i][1] -= mod;
		}
		for(int j = 1; j < min(i + 1, B); j++)
		{
			dp[i][1] += 1ll * f[j][1] * dp[i - j][0] % mod;
			if(dp[i][1] >= mod)
				dp[i][1] -= mod;
		}
		for(int j = 1; j < min(i + 1, A); j++)
		{
			dp[i][0] += dp[i - j][1];
			if(dp[i][0] >= mod)
				dp[i][0] -= mod;
		}
	}
	int ans = 0;
	for(int i = 0; i <= N; i++)
	{
		if(i == 0)
		{
			for(int j = B; j < A + B; j++)
			if(i + j <= N)
			{
				ans += 1ll * dp[i][1] * (g[j][0] + g[j][1]) % mod * _2[N - i - j] % mod;
				if(ans >= mod)
					ans -= mod;
			}
		}
		for(int j = B; j < A + B; j++)
		if(i + j <= N)
		{
			ans += 1ll * dp[i][0] * (f[j][0] + f[j][1]) % mod * _2[N - i - j] % mod;
			if(ans >= mod)
				ans -= mod; 
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3784
N, K = map(int, input().split())
d_list = []
A_list = []
for i in range(K):
    d_list.append(int(input()))
    A_list += list(map(int, input().split()))

A_list = list(set(A_list))
ans = 0
for A in range(1, N + 1):
    if A not in A_list:
        ans += 1

print(ans)


Measured memory_bytes: 67724
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstring>
using namespace std;
#define U(v) cerr << #v << ": " << (v) << endl

int main() {
    int N;
    while (cin >> N) {
        vector<pair<int, int>> a(N);
        for (int i = 0; i < N; ++i) {
            cin >> a[i].first;
            a[i].second = i;
        }
        auto b = a;
        sort(a.begin(), a.end());
        auto p = a[a.size() / 2 - 1];
        auto q = a[a.size() / 2];
        for (int i = 0; i < N; ++i) {
            if (b[i].first <= p.first) {
                cout << q.first << endl;
            } else {
                cout << p.first << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v[i];
    int ans = 0;
    int act = 0;
    for(int i = 0; i < N; i++) {
        if(act >= v[i]) {
            act = v[i];
        } else {
            ans += v[i] - act;
            act = v[i];
        }
    }

    cout << ans << endl;
}


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

bool solve() {
    int N; cin >> N;
    multiset<int> ms;
    ms.insert(-1);
    rep(i, 0, 1 << N) {
        int s; cin >> s;
        ms.insert(s);
    }
    vector<int> used;
    auto mx = ms.rbegin();
    used.push_back(*mx);
    ms.erase(*mx);
    rep(loop, 0, N) {
        vector<int> add;
        sort(used.begin(), used.end());
        rep(i, 0, used.size()) {
            auto e = ms.lower_bound(used[i]);
            --e;
            if(*e == -1) return false;
            add.push_back(*e);
            ms.erase(e);
        }
        rep(i, 0, add.size()) used.push_back(add[i]);
    }
    return true;
}

int main() {
    cout << (solve() ? "Yes" : "No") << '\n';
    return 0;
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  for(int i=0;i<10;i++){
    if((i+1)*1000>=N){
      cout << (i+1)*1000 - N << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int bsr(int x) { return 31 - __builtin_clz(x); }
int bsr(ll x) { return 63 - __builtin_clzll(x); }
int bsf(int x) { return __builtin_ctz(x); }
int bsf(ll x) { return __builtin_ctzll(x); }

class compare {
public:
	bool operator()(tuple<ll, ll> a, tuple<ll, ll> b) {
		return (get<1>(a) > get<1>(b));
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	ll s=0;
	vl v(n),sum(n+1),val;
	rep(i,n){
		cin>>v[i];
		s+=v[i];
		sum[i+1]=s;
	}
	rep(i,n+1){
		rep(j,i){
			val.push_back(sum[i]-sum[j]);
		}
	}
	ll ans=0;
	vb b(val.size(),true);
	rep(i,41){
		int d=40-i;
		int cnt=0;
		ll tmp=(1ll<<d);
		rep(j,val.size()){
			if(b[j]&&((val[j]&tmp)==tmp)){
				cnt++;
			}
		}
		if(cnt>=k){
			rep(j,val.size()){
				if(b[j]&&((val[j]&tmp)==0)){
					b[j]=false;
				}
			}
			ans|=tmp;
		}
	}
	cout<<ans<<endl;
}

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

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

  int N, A;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A;
    if(A % 2 == 0){
      if(A % 3 == 0 || A % 5 == 0){
        continue;
      } else{
        cout << "DENIED" <<endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" <<endl;
}


Measured memory_bytes: 256
package main

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

type io struct {
	reader    *bufio.Reader
	tokens    []string
	nextToken int
}

func newIo() *io {
	return &io{
		reader: bufio.NewReader(os.Stdin),
	}
}

func (io *io) nextLine() string {
	var buffer []byte
	for {
		line, isPrefix, _ := io.reader.ReadLine()
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *io) nextString() string {
	for io.nextToken >= len(io.tokens) {
		line := io.nextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *io) nextInt() int {
	i, _ := strconv.Atoi(io.nextString())
	return i
}

func main() {
	io := newIo()
	n := io.nextInt()

	var one, two, four int
	for range make([]struct{}, n) {
		a := io.nextInt()

		if a%4 == 0 {
			four++
		} else if a%2 == 0 {
			two++
		} else {
			one++
		}
	}

	if one <= four || (two == 0 && one == four+1) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main() {
	static bool cmp[1000000] = { true };
	static int npr[1000000];
	for (int i = 2; i<1000000; i++) {
		if (!cmp[i]) {
			for (int j = 2; j*i<1000000; j++) {
				cmp[i*j] = true;
			}
		}
		npr[i] = npr[i - 1] + !cmp[i];
	}
	int n;
	while (cin >> n) {
		cout << npr[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 7972
<?php 
  fscanf(STDIN, "%d %d", $a, $b);
  
	$x = $a * $b;

	if($a < $b){
      $tmp = $a;
      $a = $b;
      $b = $tmp;
    }

	$r = $a % $b;
	while($r !== 0){
     	$a = $b;
      	$b = $r;
      	$r = $a % $b;
    }

   echo $x / $b;

  ?>

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

int main() {
    int w, h, x, y;
    cin >> w >> h >> x >> y;

    int flag = 0;
    if(x+x == w  && y+y == h ){
        flag = 1;
    }
    //double ans = (1.0*w) * (1.0*h) / 2.0;

    //cout << ans << " " << flag << endl;
	printf("%lf %d\n", double(w)*double(h) / 2,  flag);
}

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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

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

signed main() {
    int n, k;
    cin >> n >> k;
    
    int ans = 0;
    reps(b,k+1,n){
        ans += (n+1)/b * (b-k);
        ans += max(0LL, (n+1) % b - k);
    }
    
    if(k == 0) ans -= n;
    
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import math

def print_point(point):

	print(f"{point[0]:.8f} {point[1]:.8f}")

def koch(n,p1,p2):

	if n == 0:
		return 0

	# Calculate s,t,u from p1,p2
	s = [0,0]
	t = [0,0]
	u = [0,0]
	s[0] = (2 * p1[0] + 1 * p2[0]) / 3
	s[1] = (2 * p1[1] + 1 * p2[1]) / 3
	t[0] = (1 * p1[0] + 2 * p2[0]) / 3
	t[1] = (1 * p1[1] + 2 * p2[1]) / 3
	u[0] = (t[0] - s[0]) * math.cos(math.radians(60)) - (t[1] - s[1]) * math.sin(math.radians(60)) + s[0]
	u[1] = (t[0] - s[0]) * math.sin(math.radians(60)) + (t[1] - s[1]) * math.cos(math.radians(60)) + s[1]
	
	koch(n-1,p1,s)
	print_point(s)
	
	koch(n-1,s,u)
	print_point(u)

	koch(n-1,u,t)
	print_point(t)

	koch(n-1,t,p2)

def test():

	n = int(sys.stdin.readline())
	
	p1 = [0,0]
	p2 = [100,0]

	print_point(p1)
	koch(n,p1,p2)
	print_point(p2)

if __name__ == "__main__":
	test()




Measured memory_bytes: 5780
S = input()
T = input()

def count_diff(s, t):
    N = 0
    for i, j in zip(s, t):
        if i != j:
            N += 1
    return N


ns = len(S)
nt = len(T)

res = nt
for i in range(ns - nt + 1):
    sub = S[i:i+nt]
    a = count_diff(sub, T)
    if a < res:
        res = a

print(res)

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

/* BIT: 区間和の更新や計算を行う構造体
初期値は a_1 = a_2 = ... = a_n = 0
add(i,x): a_i += x とする
sum(i): a_1 + a_2 + ... + a_i を計算する
計算量は全て O(logn)
*/
template <typename T>
struct BIT {
  int n;          // 配列の要素数(数列の要素数+1)
  vector<T> bit;  // データの格納先
  BIT(int n_) : n(n_ + 1), bit(n, 0) {}

  void add(int i, T x) {
    for (int idx = i; idx < n; idx += (idx & -idx)) bit[idx] += x;
  }

  T sum(int i) {
    T s(0);
    for (int idx = i; idx > 0; idx -= (idx & -idx)) s += bit[idx];
    return s;
  }
};

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, q;
  cin >> n >> q;
  vector<int> a(n + 1), v(n + 1, -1), res(q);
  vector<tuple<int, int, int>> querys;
  BIT<int> seg(n + 5);
  rep(i, 1, n + 1) cin >> a[i];
  rep(i, 0, q) {
    int l, r;
    cin >> l >> r;
    querys.emplace_back(r, l, i);
  }
  int R = 1;
  sort(all(querys));
  for (auto &&[r, l, query_num] : querys) {
    for (R; R <= r; ++R) {
      if (v[a[R]] != -1) {
        seg.add(v[a[R]], -1);
      }
      v[a[R]] = R;
      seg.add(R, 1);
    }
    res[query_num] = seg.sum(r) - seg.sum(l - 1);
  }
  arep(i, res) cout << i << '\n';
  return 0;
}

Measured memory_bytes: 31200
#include <cstdio>
typedef long long LL;
const int N = 1e5 + 5; 
LL a[N], b[N];
int n;
int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i ++){
		scanf("%lld%lld", &a[i], &b[i]);
	}
	LL dx = 0;
	for(int i = n-1; i >= 0; i --){
		a[i] += dx;
		dx += (b[i] - a[i] % b[i]) % b[i];
	}
	printf("%lld\n", dx);
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,j;
    cin >> n;
    long long cost[n] = {},height[n],t1,t2;
    for(i = 0; i < n; i++)
        cin >> height[i];
    cost[0] = 0;
    cost[1] = abs(height[1] - height[0]);
    for(i = 2; i < n; i++)
    {
        t1 = cost[i - 2] + abs(height[i] - height[i - 2]);
        t2 = cost[i - 1] + abs(height[i] - height[i - 1]);
        cost[i] = min(t1,t2);
    }
    cout<<cost[n - 1]<<endl;
}

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

using Int = int;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> T th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int main(){
	Int m, d;
	cin >> m >> d;
	Int count = 0;
	ARC(i, 1, d + 1){
		Int x = i / 10;
		Int y = i % 10;
		if(x >= 2 && y >= 2 && x * y <= m) ++count;
	}
	cout << count << endl;
}


Measured memory_bytes: 256
n = int(input())
line = list(map(int, input().split()))
max = line[0]
min = line[0]
sum = line[0]
for i in range(1, n):
  if max < line[i]:
      max = line[i]
  elif min > line[i]:
      min = line[i]
  sum += line[i]
print(min, max, sum)




Measured memory_bytes: 6588
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define mod 1000000007;

int main(){
  ll n;
  cin >>n;
  int a;
  int b[n];
  if(n%2==0){
    rep(i,n){
      cin >> a;
      if(i%2==0)b[(n+i)/2]=a;
      else b[(n-i)/2]=a;
    }
  }else{
    rep(i,n){
      cin >> a;
      if(i%2==0)b[(n-i)/2]=a;
      else b[(n+i)/2]=a;
    }
  }
  rep(i,n-1){
    cout << b[i] << " " <<flush;
  }
  cout << b[n-1] << endl;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair

using namespace std;

int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   pair<ll,ll> arr[n];
   for(ll i=0;i<n;i++)
        cin>>arr[i].first>>arr[i].second;
   
   sort(arr,arr+n);
   
   ll fac = 1;
   for(ll i=n;i>1;i--)
        fac*=i;
   
   ld ans = 0;
   do
   {
       //cout<<"++\n";
       ld temp = 0;
       for(ll i=1;i<n;i++)
            temp+=sqrt((arr[i].first - arr[i-1].first)*(arr[i].first - arr[i-1].first) + (arr[i].second - arr[i-1].second)*(arr[i].second - arr[i-1].second));
       ans+=temp;        
   }
   while(next_permutation(arr,arr+n));
   
   cout<<fixed<<setprecision(8)<<ans/fac;
   
   return 0;
}  
   

Measured memory_bytes: 256
import sys
 
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = pow(10, 9)+7
zero = 0
plus = []
minus = []
for i in range(n):
  if a[i] == 0:
    zero += 1
  elif a[i] > 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
 
P, M = len(plus), len(minus)
plus.sort(reverse=True)
minus.sort()
ans = 1
if n == k:
  for i in range(n):
    ans *= a[i]
    ans %= mod
elif P+M < k:
  ans = 0
elif P == 0:
  if zero >= 1 and k%2 == 1:
    ans = 0
  else:
    if k%2:
      minus.reverse()
    for i in range(k):
      ans *= minus[i]
      ans %= mod
else:
  q = 0
  if k%2:
    ans *= plus[0]
    ans %= mod
    q = 1
  judge = []
  for i in range((len(plus)-q)//2):
    judge.append(plus[2*i+q]*plus[2*i+q+1])
  for i in range(len(minus)//2):
    judge.append(minus[2*i]*minus[2*i+1])
  judge.sort(reverse=True)
  for i in range(k//2):
    ans *= (judge[i]%mod)
    ans %= mod
 
print(ans)

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
long long INF = 1e18;
const int mod = 1e9 + 7;

using namespace std;

int main(){
    string s;
    cin >> s;
    int ans=s.size()/2;
    REP(i,s.size()) if(s[i] == 'p') --ans;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int k;
  cin >> k;
  vector<bool> rr(k, false);
  int now = 7;
  int n = 1;
  while (true) {
    if (now % k == 0) {
      break;
    }
    if (rr[now % k]) {
      n = -1;
      break;
    }
    rr[now % k] = true;
    ++n;
    now = (now * 10 + 7) % k;
  }
  cout << n << '\n';
  return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, c, s, t, a;
int ta[100010][31];
int ans, cnt;

signed main() {
	cin >> n >> c;
	for (int i = 0; i < n; i++) {
		cin >> s >> t >> a;
		ta[s][a]++;
		ta[t + 1][a]--;
	}
	for (int i = 1; i < 100010; i++) {
		for (int j = 1; j <= c; j++) {
			ta[i][j] += ta[i - 1][j];
		}
	}
	for (int i = 1; i < 100010; i++) {
		cnt = 0;
		for (int j = 1; j <= c; j++) {
			if (ta[i][j])cnt++;
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
}

Measured memory_bytes: 24576
#include<bits/stdc++.h>
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int count(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(long long K){
    Vi a={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};
    cout<<a[K-1]<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

ll n,k;
ll a[N];

bool possible(ll need)
{
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        if(a[i]<=need)
        {
            ;
        }
        else
        {
            if(a[i]%need==0)
            {
                ans+=(a[i]/need)-1;
            }
            else
            {
                ans+=a[i]/need;
            }
        }
    }
   // cout<<need<<' '<<ans<<endl;
    return ans<=k;
}

main()
{
    cin>>n>>k;
    for(ll i=0;i<n;i++)
        cin>>a[i];

    ll low=1,high=1e9;
    ll ans=-1;

    //cout<<possible(3.5)<<endl;

    while(low<=high)
    {
        ll mid=(high+low)/2;
        //cout<<mid<<endl;
        if(possible(mid))
        {
            ans=mid;
            high=mid-1;
        }
        else
            low=mid+1;
    }
    cout<<ans;
}



Measured memory_bytes: 5176
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        int ans = 0;
        for(int i=1; i<=N; i++){
            ans += i;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for (int i=0;i<(n);i++)
#define rep3(i,a,b) for (int i=a;i<(b);i++)
#define out(ans) cout << ans << endl;
#define outs(ans) cout << ans;
using ll = long long;

int main(){

    //imput n, a(n), b(n)
    int a,b,c,d,e,k;
    cin >>a >>b >>c >>d >>e >>k;

    //main process
    if((e-a)>k){
        out(":(")
    }
    else{
        out("Yay!")
    }

    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 m = scan.nextInt();
      int c[] = new int[n];

      double count=0;
      
      for(int i=0;i<n;i++){
        c[i] = scan.nextInt();
        count += c[i];
      }
      
      int judge=0;
      for(int i=0;i<n;i++){
        if(c[i]>=count/4/m){
          judge += 1;
        } 
      }
      
      if(judge>=m){
        System.out.println("Yes");
      }
      else{
        System.out.println("No");
      }
      
      }

  }


Measured memory_bytes: 23764
#include <stdio.h>

void gotonext(char map[100][101],int x,int y,int xmax,int ymax) {
	char current=map[y][x];
	if(current=='.')return;
	map[y][x]='.';
	if(y<ymax-1 && map[y+1][x]==current)gotonext(map,x,y+1,xmax,ymax);
	if(y>0 && map[y-1][x]==current)gotonext(map,x,y-1,xmax,ymax);
	if(x<xmax-1 && map[y][x+1]==current)gotonext(map,x+1,y,xmax,ymax);
	if(x>0 && map[y][x-1]==current)gotonext(map,x-1,y,xmax,ymax);
}

int main(void) {
	char map[100][101];
	int ymax,xmax;
	int x,y;
	int count;
	while(1) {
		scanf("%d %d",&ymax,&xmax);
		if(ymax==0 && xmax==0)break;
		for(y=0;y<ymax;y++)scanf("%s",map[y]);
		count=0;
		for(y=0;y<ymax;y++) {
			for(x=0;x<xmax;x++) {
				if(map[y][x]!='.') {
					gotonext(map,x,y,xmax,ymax);
					count++;
				}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 0