akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld double
long double PI =3.14159265;
using ll = long long;

const ll modo=1e9+7;
const ll ms=2e5+5;
const int inf=1e9+9;

int ar[100][100]={0};


int main()
{
    idfc;

    int n;
    cin>>n;

    string s;
    int i;
    ll x;
    int a,b;
    int c;
    int f;
    int p;
    int k,j;
    ll ans=0;
    for(i=1;i<=n;i++)
    {
        cin>>s;
        x=0;
        c=9;
        f=0;
        for(char e:s)
        {
            p=e-48;
            if(f)c--;
            if(e=='.'){f=1;continue;}
            x*=10;
            x+=p;
        }
        while(c--)x*=10;
        a=0;
        b=0;


        while((x%2)==0)
        {
            x/=2;a++;
        }
        while((x%5)==0)
        {
            x/=5;b++;
        }

        for(j=0;j<=50;j++)
        {
            for(k=0;k<=50;k++)
            {
                if((j+a)>=18&&(k+b)>=18)
                {
                    ans+=ar[j][k];
                }
            }
        }
        ar[a][b]++;
    }
    cout<<ans;

    return 0;
}

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

int memo[4] = {10000, 5000, 1000, 500};
int ans = 0;
int p;

int main() {
  int i;
  cin >> p;
  for(i = 0; i < 4; ++i) {
    while(memo[i] <= p) {
      ans += memo[i];
      p -= memo[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3092
#include <iostream>


class Control
{
public:
    bool Run();

private:
    bool Read();

    void Sort();

    void Write();

    bool isValid(int target);

private:

    class SelectionSort
    {
    public:
        int size;
        int* data;

        int cnt;

        SelectionSort();

        void Sort();
    };

    SelectionSort selection_sort;

};

bool Control::Run()
{
    if (!Read())
        return false;

    Sort();

    Write();

    return true;
}

bool Control::Read()
{
    std::cin >> selection_sort.size;

    if (!isValid(selection_sort.size))
        return false;

    selection_sort.data = new int[selection_sort.size];

    for (int i = 0; i < selection_sort.size; i++) {

        std::cin >> selection_sort.data[i];
    }

    return true;
}

void Control::Sort()
{
    selection_sort.Sort();
}

void Control::Write()
{
    for (int i = 0; i < selection_sort.size; i++) {

        i == selection_sort.size - 1 ? std::cout << selection_sort.data[i] << std::endl : std::cout << selection_sort.data[i] << " ";

    }

    std::cout << selection_sort.cnt << std::endl;

    delete[] selection_sort.data;
    selection_sort.data = NULL;
}

bool Control::isValid(int target)
{
    const int MIN = 1;
    const int MAX = 100;

    if (MIN > target || MAX < target)
        return false;

    return true;
}

Control::SelectionSort::SelectionSort()
    : data(NULL)
    , size(0)
    , cnt(0)
{

}

void Control::SelectionSort::Sort()
{
    for (int i = 0; i < Control::SelectionSort::size; i++) {

        int min = i;
        bool flag = false;

        for (int j = i; j < Control::SelectionSort::size; j++) {

            if (Control::SelectionSort::data[j] < Control::SelectionSort::data[min]) {

                min = j;
                flag = true;
            }
        }

        if (flag) {
            int t = Control::SelectionSort::data[i];
            Control::SelectionSort::data[i] = Control::SelectionSort::data[min];
            Control::SelectionSort::data[min] = t;
            cnt++;
        }
    }
}

int main()
{
    if (!Control().Run())
        return 1;

    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{	
	int n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	for(int i=0;i<n;i++)
	{
		if(i+1==k)
		{	
			char t=tolower(s[i]);
			cout<<t;
		}
		else
		cout<<s[i];
	}


}			

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
//コピペするとこ
int binarysearch(vector<int> vec, int key){
    int left, right, mid ;
    left = 0 ;
    right = vec.size() ;
    while(left<right){
        mid = (left+right)/2 ;
        if(vec.at(mid)==key){
            return 1 ; //書き換え
        }
        else if(key<vec.at(mid)){
            right = mid ;
        }
        else{
            left = mid+1 ;
        }
    }
    return -1 ; //書き換え
}


//-------------------------------------------------


int main()
{
    int n ;
    cin >> n ;
    vector<int> vec(n) ;
    REP(i,n){
        cin >> vec.at(i) ;
    }
    int m ;
    cin >> m ;
    vector<int> vec1(m) ;
    REP(i,m){
        cin >> vec1.at(i) ;
    }
    
    int cnt = 0 ;
    
    REP(i,m){
        if(binarysearch(vec, vec1.at(i))==1){
            cnt++ ;
        }
    }
    
    cout << cnt <<endl ;
    
    return 0 ;
}


Measured memory_bytes: 3856
#include <cstdio>
#include <cstring>

using namespace std;


struct node
{
    char ch[110];
}c[110];
int main()
{
    int n, l;
    while(scanf("%d%d",&n, &l) != EOF)
    {
        for(int i = 0;i < n;i++)
        {
            scanf("%s",c[i].ch);
        }
        node e;
        for(int i = 0;i < n-1;i++)
        {
            for(int j = i+1;j < n;j++)
            {
                if(strcmp(c[i].ch,c[j].ch) > 0)
                {
                    e = c[i];
                    c[i] = c[j];
                    c[j] = e;
                }
            }
        }
        for(int i = 0;i < n;i++)
        {
            printf("%s",c[i].ch);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;

signed main(){
	int N;
	cin >> N;
	vector<int> t(N+1), x(N+1), y(N+1);
	for(int i = 1; i<= N; ++i){
		cin >> t[i] >> x[i] >> y[i];
	}
	for(int i = 1; i <= N; ++i) {
		int dt = t[i] - t[i-1], dx = abs(x[i] - x[i-1]), dy = abs(y[i] - y[i-1]);
		if(dt < dx + dy ||
				dt % 2 != (dx + dy) % 2) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  int i,sum=0;
  for(i=0;i<n;i++)
  {
    cin>>a[i];
    sum+=a[i];
  }
  sum=sum/n;
  int sum1=sum+1,p=0,p1=0;
  for(i=0;i<n;i++)
  {
    p+=pow(sum-a[i],2);
    p1+=pow(sum1-a[i],2);
  }
  int ans=min(p,p1);
  cout<<ans;
  return 0;
}
  

Measured memory_bytes: 3624
import numpy as np
N = int(input())
A = np.array(input().split(), dtype=int)
A.sort()

B = np.cumsum(A)

ans = 0
for i in range(N - 1):
    if B[i] * 2 >= A[i + 1]:
        ans += 1
    else:
        ans = 0

ans += 1
print(ans)


Measured memory_bytes: 32220
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

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

    vector<long long>A(N);
    for (long long i = 0; i < N; i++) cin >> A.at(i);

    sort(A.begin(), A.end(), greater<long long>());

    priority_queue<long long, vector<long long>> Q;
    Q.push(A.at(0));

    long long ans = 0;
    for (long long i = 1; i < N; i++) {
        ans += Q.top();
        Q.pop();
        Q.push(A.at(i)); Q.push(A.at(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 6908
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
ll int MOD=998244353;
#define N 3000000
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    ll int k;
    cin>>k;
    ll int kk=k;
    int n=50;
    ll int a[50]={};
    rep(i,50){
        a[i]=kk/50;
        k-=kk/50;
    }
    rep(i,50){
        if(k>0){
            a[i]++;
            k--;
        }
    }
    cout<<50<<endl;
    rep(i,50){
        a[i]=(ll)51*a[i]-kk+(ll)49;
        cout<<a[i]<<" ";
    }
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

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

for i in range(0,N-1):
    if( A[i] < A[i+1] ):
        cash += cash // A[i] * (A[i+1] - A[i])

print(cash)

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


void inp_str(int instr[]){
char *ptr;
int z,i,count;
char str[100]={'\0'};
char *ln;

fgets(str, 100, stdin); // 入力："123456\n"
ln = strchr(str, '\n'); /* 改行文字を検索 */
if (ln != NULL) { /* 改行が読み取られていたかどうか */
   *ln = '\0';    /* 改行文字を終端文字に置き換える */
}
else {            /* 入力ストリーム上に文字が残ってる場合 */
   while (1) {    /* 改行文字が読み取られるまで空読みする */
       z = getchar();
      if (z == '\n' || z == EOF) break;
   }
}
	count=0;
    ptr = strtok(str, " ");
    i = atoi(ptr);
    instr[count]=i;
    count=count+1;
    // 2回目以降
    while(ptr != NULL) {
        // strtok関数により変更されたNULLのポインタが先頭
        ptr = strtok(NULL, " ");
        // ptrがNULLの場合エラーが発生するので対処
        if(ptr != NULL) {
		    i = atoi(ptr);
    instr[count]=i;
    		count=count+1;
        }
    }
}

int main(void) {

//int input[120];
//char input1[120];
//int j,count;
int a,b,c,d,e,k;

int num[5];

//inp_str(input);
//N=input[0];

	//printf("%d\n",N);

scanf("%d",&num[0]);
scanf("%d",&num[1]);
scanf("%d",&num[2]);
scanf("%d",&num[3]);
scanf("%d",&num[4]);
scanf("%d",&k);

/*printf("%d\n",a);
printf("%d\n",b);
printf("%d\n",c);
printf("%d\n",d);
printf("%d\n",e);
printf("%d\n",k);*/

int B;
int C;
int ans;
int flag=0;


for(B=0;B<5;B++){
for(C=0;C<5;C++){

ans=num[B]-num[C];

if(ans>k) {
	flag=1;
}

}
}

if(flag==1) {
	printf(":(\n");
}else{
printf("Yay!\n");
}                        
    return 0;
}


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

const int maxn = 2e5 + 10;

long long ans;

struct node {
  long long f, g;
  int id;

  bool operator < (const node &rhs) const {
    return f * rhs.g == g * rhs.f ? id < rhs.id : f * rhs.g < g * rhs.f;
  }

  void read(int _id) {
    int x;
    id = _id;
    scanf("%d", &x);
    (x ? f : g) = 1;
  }

  void merge(node rhs) {
    ans += f * rhs.g;
    f += rhs.f;
    g += rhs.g;
  }
}a[maxn];

namespace dsu {
  int n, fa[maxn];

  void init(int _n) {
    n = _n;
    for(int i = 1; i <= n; i++) {
      fa[i] = i;
    }
  }

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

int n, fa[maxn];
set<node> st;

int main(void) {
  scanf("%d", &n);
  for(int i = 2, x; i <= n; i++) {
    scanf("%d", &fa[i]);
  }
  for(int i = 1; i <= n; i++) {
    a[i].read(i);
    if(i > 1) {
      st.insert(a[i]);
    }
  }
  dsu::init(n);
  while(!st.empty()) {
    node x = *st.begin();
    int y = dsu::find(fa[x.id]);
    st.erase(x);
    if(y > 1) {
      st.erase(a[y]);
    }
    a[y].merge(x);
    dsu::fa[x.id] = y;
    if(y > 1) {
      st.insert(a[y]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 20992
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int person[][][] = new int[4][3][10];
		
		try (Scanner sc = new Scanner(System.in);) {
			
			int n = sc.nextInt();
			
			for(int i = 0; i < n; i++) {
				int b = sc.nextInt();
				int f = sc.nextInt();
				int r = sc.nextInt();
				int v = sc.nextInt();
				
				person[b -1][f - 1][r - 1] += v;
			}
			
			StringBuilder sb = new StringBuilder();
			
			for(int i = 0; i < 4; i++) {
				for(int j = 0; j < 3; j++) {
					for(int k = 0; k < 10; k++) {
						sb.append(" ");
						sb.append(person[i][j][k]);
					}
					if(!(i == 3 && j == 2)) {
						sb.append("\n");
					}
				}
				if(i < 3) {
					sb.append("####################");
					sb.append("\n");
				}
			}
			
			System.out.println(sb.toString());
		}
	}
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  bool check = true;
  for(int i=0; i<N-1; i++){
    if(vec.at(i) == vec.at(i+1)){
      cout << "NO" << endl;
      check = false;
      break;
    }
  }
  if(check){
    cout << "YES" << endl;
  }
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;

int main() {
  long long x;
  int ans=0;
  double rate = 1.010;
  long long money =100;
  cin>>x;
  
  while(x>money){
    ans++;
    money=money*rate;
  }
  
  cout<<ans;
  return 0;
}

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

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

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

int main() {
  int a,b;
  cin >> a >> b;
  cout<<lcm(a,b)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  a+=b;
  int t=1;
  int sum=0;
  for(int i=0;i<a.size();i++){
    sum+=(a[a.size()-1-i]-'0')*t;
    t*=10;
  }
  for(int i=1;i*i<=sum;i++){
    if(i*i==sum){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}


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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    string a,b; cin>>a>>b;
    string s=a+b;
    ll n=stoll(s);
    bool ok=false;
    for(int i=1;i<=100000;i++){
        if(n==i*i) ok=true;
    }
    cout<<(ok?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 3520
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE FlexibleContexts #-}

import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.Text (Text)
import qualified Data.List as L

import qualified Data.Vector.Unboxed as V
import Data.Vector.Unboxed (Vector)
import qualified Data.Vector.Unboxed.Mutable as VMut

import Control.Monad  ( replicateM )

import System.IO.Unsafe
import Data.Bits (shiftR)

-- adapted from "vector-algorithms" package:

{-# INLINE binarySearchPBounds #-}
binarySearchPBounds p vec = loop
 where
 loop !l !u
   | u <= l    = return l
   | otherwise = VMut.unsafeRead vec k >>= \e -> if p e then loop l k else loop (k+1) u
  where k = (u + l) `shiftR` 1

{-# INLINE binarySearchL #-}
binarySearchL vec e = binarySearchPBounds (>= e) vec 0 (VMut.length vec)

{-# INLINE binarySearchR #-}
binarySearchR vec e = binarySearchPBounds (> e) vec 0 (VMut.length vec)



forceEither :: Either a b -> b
forceEither (Right r) = r 

parseLine :: Text -> [Int]
parseLine txt =
  map (fst . forceEither . T.decimal) $ T.splitOn (T.pack " ") txt

bisectLeft :: Int -> Vector Int -> Int
bisectLeft n xs = unsafePerformIO $ do
  xs' <- V.unsafeThaw xs
  binarySearchL xs' n

bisectRight :: Int -> Vector Int -> Int
bisectRight n xs = unsafePerformIO $ do 
  xs' <- V.unsafeThaw xs
  binarySearchR xs' n

getInput :: IO [Text]  
getInput = do
  res@[n, as, bs, cs] <- replicateM 4 T.getLine
  return res

sortedVec :: t -> Text -> Vector Int
sortedVec n txt = 
  V.fromList $ L.sort $ parseLine txt


parseProblemInput
  :: [Text] -> (Int, Vector Int, [Int], Vector Int)
parseProblemInput [nStr, asStr, bsStr, csStr] = 
  let [n] = parseLine nStr
      as =  sortedVec n asStr
      bs =  parseLine  bsStr
      cs = sortedVec n csStr
  in (n, as, bs, cs)

solve :: (Int, Vector Int, [Int], Vector Int) -> Int
solve (n, as, bs, cs) = 
  sum $ map (\ b -> bisectLeft b as * (n - bisectRight b cs)) bs


main = do
  ls <- getInput 
  print $ solve $ parseProblemInput ls

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

int main () {
	
	int h=0, w=0, i=0, j=0;
	string s="";

	cin >> h >> w;

	bool mat[h][w];
	int visited[h][w];

	queue <pair<int, int> > q;

	memset (visited, 0, sizeof(visited));

	for (i=0; i<h; i++) {

		cin >> s;

		for (j=0; j<w; j++) {

			if (s[j]=='#') {
				mat[i][j] = 0; 
				visited[i][j] = 1;
				q.push(make_pair(i, j));
			}
			else mat[i][j] = 1;
		}
	}

	int mx [4] = {0, -1, 0, 1};
	int my [4] = {-1, 0, 1, 0};

	while (!q.empty()) {

		i = q.front().first;
		j = q.front().second;
		q.pop();

		for (int idx = 0; idx<4; idx++) {

			if (i+mx[idx] < h &&  i+mx[idx] >= 0 && j+my[idx] < w && j+my[idx] >= 0) {

				if (mat[i+mx[idx]][j+my[idx]] == 1 && visited[i+mx[idx]][j+my[idx]] == 0) {
					mat[i+mx[idx]][j+my[idx]] = 0;
					visited[i+mx[idx]][j+my[idx]] = visited[i][j]+1;
					q.push(make_pair(i+mx[idx], j+my[idx]));
				}

			}

		}

	}

	int res = -1;
	for (i=0; i<h; i++)
		for (j=0; j<w; j++)
			res = max(res, visited[i][j]);
	

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

Measured memory_bytes: 13328
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        {
            int n = int.Parse(Console.ReadLine());
            var a = Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
            var x = 0.0;
            var sum = a.Sum();
            for (int i = 0; i < n; i++)
            {
                x += a[i];
                if (x >= sum / 2)
                {
                    Console.WriteLine(Math.Min(2 * x - sum, sum - 2 * x + 2 * a[i]));
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 33408
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<int>> p(N);
  for(int i=0;i<M;i++){
    int a,b; cin >> a >> b; --a; --b;
    p[a].push_back(b);
    p[b].push_back(a);
  }

  vector<int> ans(N,-1);
  deque<int> q;
  q.push_back(0);
  while(!q.empty()){
    int qi=q.back();
    q.pop_back();
    for(int qn:p[qi]){
      if(ans[qn]==-1){
        ans[qn]=qi;
        q.push_front(qn);
      }
    }
  }

  cout << "Yes" << endl;

  for(int i=1;i<N;i++) cout << ans[i]+1 << endl;

  return 0;
}


Measured memory_bytes: 10084
def primes(n):
  is_prime=[True]*(n+1)
  is_prime[0]=False
  is_prime[1]=False
  for i in range(2,int(n**0.5)+1):
    if not is_prime[i]:
      continue
    for j in range(i*2,n+1,i):
      is_prime[j]=False
  return [i for i in range(n+1) if is_prime[i]]

l=primes(100010)
x=int(input())
for i in range(len(l)):
  if l[i]>=x:
    print(l[i])
    break

Measured memory_bytes: 4072
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			StringBuilder b = new StringBuilder(scanner.next());

			for (int i = 0; i < n; i++) {
				StringBuilder builder = new StringBuilder();
				b.append(" ");
				int count = 1;
				for (int j = 1; j < b.length(); j++) {
					if (b.charAt(j) == b.charAt(j - 1))
						count++;
					else {
						builder.append(count);
						builder.append(b.charAt(j - 1));
						count = 1;
					}
				}
				b = builder;
			}
			System.out.println(b);
		}
	}
}

Measured memory_bytes: 25876
#include <cstdio>
using namespace std;

int main()
{
	double hei;
	double max_, min_;
	bool flag = false;
	
	while (scanf("%lf", &hei) != EOF){
		if (flag == false){
			max_ = hei;
			min_ = hei;
			flag = true;
		}
		if (hei > max_){
			max_ = hei;
		}
		else if (hei < min_){
			min_ = hei;
		}
	}
	
	printf("%.1lf\n", max_ - min_);
	
	return (0);
}

Measured memory_bytes: 1080
#include<iostream>
using namespace std;
int main(void){
	int a,b,c;
	string S;
	cin>>S;
	a=b=c=0;
	for (int i=0;i<S.size();++i)
		if (S[i]=='a') ++a;
		else if (S[i]=='b') ++b;
		else ++c;
	if ((a-1)*2>(b+c)||(b-1)*2>(a+c)||(c-1)*2>(a+b)) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 512
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    for i in 0..5 {
        let x:usize = read();
        if x == 0 {
            println!("{}", i+1);
            break;
        }
    }
}


Measured memory_bytes: 2080
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        sc.close();

        if (StringPalindrome(S)) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
    public static boolean StringPalindrome(String S) {
        // 1.Sは回文
        // 2.Sの1～(S.length()-1)/2文字目までが回文
        // 3.Sの(S.length()+3)/2～S.length()文字目までが回文
        StringBuffer sb = new StringBuffer(S);
        StringBuffer sb1 = new StringBuffer(S.substring(0, (S.length()-1)/2));
        if (sb.toString().compareTo(sb.reverse().toString()) == 0) {
            if (sb1.toString().compareTo(sb1.reverse().toString()) == 0) {
                return true;
            }
        }
        return false;
    }
}


Measured memory_bytes: 23764
#include <stdio.h>
#include <algorithm>

using namespace std;

int solve(int A, int B, int C, int X, int Y) {
    int val;

    val = min(A + B, 2 * C) * min(X, Y);
    if (X > Y) {
        val += (X - Y) * min(A, 2 * C);
    }
    else {
        val += (Y - X) * min(B, 2 * C);
    }

    return val;
}

int main(void) {
    int A, B, C, X, Y;

    scanf("%d %d %d %d %d", &A, &B, &C, &X, &Y);

    printf("%d", solve(A, B, C, X, Y));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    ll N;
    cin >> N;
    ll ans = 0;
    
    reps(i,1,N+1){
        ll a = N/(ll)i;
        a = (a+1)*a/2;
        ans += i*a;
        
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#include <string>
#define INF 100000
using namespace std;
char x[100001][2];
int N,M;
int cycle;
int tots;

typedef pair<int, int> P;

int main(){

    cin >> N >> M;
    vector<P> data;
    int a,b;
    for(int i=0;i<M;i++){
        cin >> a >> b;
        data.push_back(P(a,b));
    }
    sort(data.begin(),data.end(),greater<P>());
    
    int ans = 0;
    int now = INF;
    for(int i=0;i<M;i++){
        if(data[i].first <= now && data[i].second <= now ){
            now = data[i].first;
            ans++;
            
        }
    }
    // for(int i=0;i<data.size();i++)
    //     cout << data[i].first << " " << data[i].second<< endl;
    cout << ans << endl;
}

Measured memory_bytes: 1400
#include <iostream>

using namespace std;

int main() {
    string v, j;
    int t;
    t = 0;
    cin >> v;
    for (int i = 0; i < 4; ++i) {
        j = v[i];
        if(j == "+"){
            t++;
        }else{
            t--;
        }
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()
 
int main() {
  int a, b;
  cin >> a >> b;
  if(a <= b) cout << a << endl;
  else cout << a - 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,min=1000,max=0;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(min>a[i])min=a[i];
    if(max<a[i])max=a[i];
  }
  cout<<max-min<<endl;

  return 0;
}


Measured memory_bytes: 256
# frozen_string_literal: true

d = gets.to_i
c = gets.split.map(&:to_i)
s = d.times.map { gets.split.map(&:to_i) }
t = d.times.map { gets.to_i }
sum = 0
l = Hash.new { 0 }
d.times do |i|
  sum += s[i][t[i] - 1]
  l[t[i]] = i + 1
  c.each_index do |j|
    sum -= c[j] * (i + 1 - l[j + 1])
  end
  puts sum
end


Measured memory_bytes: 14260
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;


int main()
{
  

   string alpha = "abcdefghijklmnopqrstuvwxyz";
   ll n;
   cin>>n;
   string res;
   while(n!=0)
   {
    n--;
    ll i = n%26;
    res.push_back(alpha[i]);
    n/=26;

   }
   for(ll j=res.size()-1;j>=0;j--)
    cout<<res[j];
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll R, G, B, N;
    cin >> R >> G >> B >> N;
    ll ans = 0;
    REP(i, 3001)
    {
        REP(j, 3001)
        {
            ll g = N - (R * i + j * B);
            if (g >= 0 && g % G == 0)
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N; cin >>N;
  vector<int> a(N);
  rep(i,0,N) cin >>a[i];
  sort(a.rbegin(),a.rend());
  int ans=0;
  rep(i,0,N) {
    if (!(i%2)) ans+=a[i];
    else ans-=a[i];
  }
  cout <<ans <<endl;
  return 0;
}


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

int main() {
  int total;

  // カード配列 : 太郎君の手元にある場合に true
  // axis 0 : 絵柄 S=0, H=1, C=2, D=3
  // axis 1 : 数字 1, 2, 3, がそれぞれ対応 (0は対応させない)
  bool flag[4][14];

  // 初期化
  for (int i = 0; i < 4; i++)
    for (int j = 1; j <= 13; j++)
      flag[i][j] = false;

  // カード枚数読み込み
  cin >> total;

  char type;
  int type_num, number;

  // 太郎君のカード情報読み込み
  for (int k = 0; k < total; k++) {
    cin >> type >> number;

    switch (type) {
      case 'S':
        type_num = 0; break;
      case 'H':
        type_num = 1; break;
      case 'C':
        type_num = 2; break;
      case 'D':
      default:
        type_num = 3; break;
    }
    flag[type_num][number] = true;
  }

  // もっていないカードを出力
  for (int i = 0; i < 4; i++) {
    for (int j = 1; j <= 13; j++) {
      if (!flag[i][j]) {
        switch (i) {
          case 0:
            type = 'S'; break;
          case 1:
            type = 'H'; break;
          case 2:
            type = 'C'; break;
          case 3:
          default:
            type = 'D'; break;
        }
        cout << type << " " << j << endl;
      }
    }
  }

  return 0;
}



Measured memory_bytes: 3080
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
using P=pair<int,int>;
vector<int> d(200005,0);
signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,m,k,l,sum=0;
  cin>>n>>m;
  queue<int> q;
  d[0]=1;
  q.push(0);
  vector<int> L[n+m];//人間は0~n-1,言語はn~n+l-1
  for(int i=0;i<n;i++){
    cin>>k;
    for(int j=0;j<k;j++){
      cin>>l;
      L[i].emplace_back(l+n-1);
      L[l+n-1].emplace_back(i);
    }
  }
  while(q.size()){
        int t=q.front();q.pop();
        for(auto y:L[t]){
            if(d[y]==0){d[y]=1;q.push(y);}
            else{continue;}
        }
    }
  for(int i=0;i<n;i++){
    sum+=d[i];
  }
  if(sum!=n){cout<<"NO";return 0;}
  cout<<"YES";
}


Measured memory_bytes: 9720
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define int long long
int gcd(int x, int y) {
  if (x > y) swap(x, y);
  if (x == 0) return y;
  return gcd(y%x, x);
}

bool solve(int A, int B, int C, int D) {
  if (D < B || A < B) return false;
  if (B <= C) return true;
  int gain = (D-B) % B;
  int cur = A - (C+1);
  if (cur < 0) return false;
  cur %= B;
  int border = B-C-1;
  int step = gcd(gain, B);
  cur %= step;
  if (cur < border) return false;
  return true;
}

int T;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> T;
  rep(_, T) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << (solve(a, b, c, d)?"Yes":"No") << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main() {
	int n, m, m_sum[101], b,tokuten[101];
	memset(m_sum, 0, sizeof(m_sum));
	memset(tokuten, 0, sizeof(tokuten));
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> m_sum[i];
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < n; j++) {
			cin >> b;
			if (b == m_sum[i]) {
				tokuten[j]++;
			}
			else {
				tokuten[m_sum[i]-1]++;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << tokuten[i] << endl;
	}
}

Measured memory_bytes: 3096
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<cmath>
#define MAX_N 10005
using namespace std;

typedef struct edge
{
	int from,to,cost;
} edge;

bool mcmp(edge x,edge y)
{
	return x.cost<y.cost;
}

int uft[MAX_N];
vector<edge>e;

void init(int n)
{
	int i;
	for (i=0;i<=n;i++)
	uft[i]=i;
}

int parent(int n)
{
	if (uft[n]==n)
		return n;
	else
		return uft[n]=parent(uft[n]);
}

void unit(int p, int q)
{
	uft[parent(p)]=parent(q);
}

int same(int p, int q)
{
	return parent(p)==parent(q);
}

int kruskal(int n,int r)
{
	int res=0;
	sort(e.begin(),e.end(),mcmp);
	init(n);
	for(int i=0;i<r;i++)
	{
		edge tmp=e[i];
		if(!same(tmp.from,tmp.to))
		{
			res+=tmp.cost;
			unit(tmp.from,tmp.to);
			e[i].cost=0;
		}
	}
	return res;
}

int piles[10001][2];
int m_distance(int f,int t)
{
	return pow((double)piles[f][0]-piles[t][0],2)+pow((double)piles[f][1]-piles[t][1],2);
}

int main()
{
	int N,M;
	int all_cost=0;
	scanf("%d%d",&N,&M);
	for(int i=1;i<=N;i++)
		scanf("%d%d",&piles[i][0],&piles[i][1]);
	for(int j=0;j<M;j++)
	{
		edge tmp;
		scanf("%d%d",&tmp.from,&tmp.to);
		tmp.cost=-m_distance(tmp.from,tmp.to);
		e.push_back(tmp);
	}
	kruskal(N,M);
	double res=0.0;
	for(int i=0;i<M;i++)
		res+=sqrt(-(double)e[i].cost);
	printf("%.3lf\n",res);
	e.clear();
	return 0;
}

Measured memory_bytes: 1572
function main(input) {
    var nums = input.split('\n')[1].split(' ').map((n) => parseInt(n));

    var count = 0;
    while(nums.every((n) => (n % 2) === 0)) {
        count++;
        nums = nums.map((n) => n / 2);
    }
    
    console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7500
#include<cstdio>

using namespace std;

int p[300005];
int n;

int main() {
	p[0]=p[1]=1;
	for(int i=2;i<=300000;++i) {
		if(p[i]) continue;
		for(int j=i*2;j<=300000;j+=i) p[j]=1;
	}

	while(scanf("%d",&n),n) {
		int c=0;
		for(int i=n+1;i<=2*n;++i) c+=!p[i];
		printf("%d\n",c);
	}
}

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

typedef long long int ll;
#define mamba() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
	ll n;cin>>n;
  	if(n>=500)
  	cout<<1000*(n/500)+5*((n%500)/5);
  	else
      cout<<5*(n/5);
}

Measured memory_bytes: 256
N, M = map(int, input().split())
shops = [None] * N
for i in range(N):
  shops[i] = list(map(int, input().split()))
shops.sort()
cnt = 0
ans = 0
for shop in shops:
  ans += shop[0] * shop[1]
  cnt += shop[1]
  if cnt > M:
    ans -= (cnt - M) * shop[0]
    break
print(ans)


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e10;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    ll goal=0;
    REP(i,0,n){
        goal |= (1<<i);
    }
    Vec c(m+1);
    Vec a(m+1);
    Vec b(m+1);
    VV dp(m+1,Vec(goal+1,INF));
    rep(i,m){
        ll tmp = 0;
        cin>>a[i]>>b[i];
        int tmp2;

        rep(j,b[i]){
            cin>>tmp2;
            tmp2--;
            tmp |= (1<<tmp2);
        }
        c[i]=tmp;
    }

    rep(i,m){
        if(i==0){
            dp[0][0] = 0;
            dp[0][c[0]] = a[0];
            continue;
        }
        rep(j,goal+1){
            dp[i][j] = dp[i-1][j];
        }
        rep(j,goal+1){
            dp[i][j|c[i]] = min(dp[i-1][j]+a[i],dp[i][j|c[i]]);
        }
    }
    if(dp[m-1][goal]==INF){
        cout<<-1<<endl;
    }else{
        cout<<dp[m-1][goal]<<endl;
    }
 //   dbg(dp);
    return  0;
}




Measured memory_bytes: 32384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
int main()
{
    fast;
    ll int n;
    cin>>n;
    ll int a[n];
    ll int i,val=0;
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=1;i<n;i++)
    {
        if(a[i-1]>a[i])
        {
            val+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    cout<<val<<endl;
}

Measured memory_bytes: 5180
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
typedef tuple<int, int, int> T;

int n;
T t[100000];

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		t[i] = T(a + b, a, b);
	}
	sort(t, t + n);
	
	int p = 0;
	int r = n - 1;
	int ans = 0;
	while (r >= 0) {
		if (p == 0) {
			ans += get<1>(t[r]);
			//cout << "takahasi = " << get<1>(t[r]) << endl;
			r--;
		}
		else {
			ans -= get<2>(t[r]);
			//cout << "aoki = " << get<2>(t[r]) << endl;
			r--;
		}
		p = !p;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
    int a, b;
    cin >> a >> b;
    if ((a*b)%2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
}

Measured memory_bytes: 3520
x ,y , A , B ,C = map(int , input().split())

p = list(map(int , input().split()))

q = list(map(int , input().split()))

r = list(map(int , input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

answer = sum(p[:x]) + sum(q[:y])

i = x-1
j = y-1

for k in range(C):
	
	if (i >= 0) and (j >= 0) :
		if r[k] > min(p[i],q[j]):
			answer += r[k]
			
			if p[i] < q[j]:
				answer -= p[i]
				i -= 1
		
			else:
				answer -= q[j]
				j -= 1
				
		else:
			break
				
	elif (i >= 0) and (j<0):
		if r[k] > p[i]:
			answer += r[k]
			answer -= p[i]
			i -= 1
		
		else:
			break
	
	elif (j >= 0) and (i < 0):
		if r[k] > q[j]:
			answer += r[k]
			answer -= q[j]
			j -= 1
		
		else:
			break
	

	else:
		break
		
print(answer)

Measured memory_bytes: 23216
x,y,z,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)


AB=[a+b for a in A for b in B]
AB.sort(reverse=True)

ABC=[ab+c for ab in AB[:min(k,x*y)] for c in C]
ABC.sort(reverse=True)

for i in range(k):
    print(ABC[i])



Measured memory_bytes: 207548
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define PI 3.14159265358979323846
const int MOD = 1e9 + 7 ;
const int EPS = 1e-9;
const int N=5*1e6;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

      int n;
      cin>>n;
      string s;
      cin>>s;
      int cnt1=0,cnt2=0;
      for(int i=0;i<n;i++) if(s[i]=='R') cnt1++; else cnt2++;
      if(cnt1>cnt2) cout<<"Yes\n";
      else cout<<"No\n";
}


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

typedef pair<long long,long long> P;
#define U 0
#define D 1
#define L 2
#define R 3

long long min(long long x1,long long x2,long long x3,long long x4){
    long long a=x1<x2?x1:x2;
    long long b=x3<x4?x3:x4;
    return a<b?a:b;
}

long long max(long long x1,long long x2,long long x3,long long x4){
    return -min(-x1,-x2,-x3,-x4);
}

long long* cor(P x1,P x2,P x3,P x4){
    long long *c=new long long[4];
    c[U]=min(x1.second,x2.second,x3.second,x4.second);
    c[D]=max(x1.second,x2.second,x3.second,x4.second);
    c[L]=min(x1.first,x2.first,x3.first,x4.first);
    c[R]=max(x1.first,x2.first,x3.first,x4.first);

    return c;
}

int main(){
    int N,K;
    P pt[50];

    cin >> N >> K;
    for(int i=0;i<N;i++){
        long long x,y;
        cin >> x >> y;
        pt[i]=make_pair(x,y);
    }

    unsigned long long min=5000000000000000000;
    for(int p1=0;p1<N;p1++){
        for(int p2=p1;p2<N;p2++){
            for(int p3=p2;p3<N;p3++){
                for(int p4=p3;p4<N;p4++){
                    long long *c=cor(pt[p1],pt[p2],pt[p3],pt[p4]);
                    int cnt=0;
                    for(int i=0;i<N;i++){
                        if(pt[i].first>=c[L] && pt[i].first<=c[R] && pt[i].second>=c[U] && pt[i].second<=c[D]) cnt++;
                    }
                    if(cnt>=K){
                        if(min>(c[D]-c[U])*(c[R]-c[L])) min=(c[D]-c[U])*(c[R]-c[L]);
                    }
                    delete[] c;
                }
            }
        }
    }

    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in();
    vec s(n+1);
    s[0]=0;
    rep(i,n){
        s[i+1]=in()+s[i];
    }
    int ans=INT_MAX;
    rep(i,n+1){
        ans=min(ans,abs(s[i]-s[n]+s[i]));
    }
    cout<<ans<<endl;
}



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

using namespace std;

typedef long long  ll;

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

    int m, min_n, max_n;

    while (cin >> m >> min_n >> max_n, m) {
        vector<int> p(m);
        for (int i = 0; i < m; ++i)
            cin >> p[i];
        sort(p.begin(), p.end(), greater<int>());

        int n = 0, gap = 0;
        for (int i = min_n; i <= max_n; ++i) {
            int tmp_gap = p[i - 1] - p[i];
            if (gap <= tmp_gap) {
                gap = tmp_gap;
                n = i;
            }
        }

        cout << n << endl;
    }

    return 0;
}

Measured memory_bytes: 3088
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll w,h,ans=0; cin>>w>>h;
    vector<pair<ll,ll>> e(w+h,mk(0,0));
    rep(i,w){
        ll p; cin>>p;
        e[i]=mk(p,0);
    }
    rep(i,h){
        ll q; cin>>q;
        e[w+i]=mk(q,1);
    }
    sort(al(e));
    ll wcnt=w+1,hcnt=h+1;
    rep(i,w+h){
        if(e[i].second){
            ans+=wcnt*e[i].first;
            hcnt--;
        }
        else{
            ans+=hcnt*e[i].first;
            wcnt--;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6364
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
void pk()
{
    string s,t;
    cin>>s>>t;
    ll n=s.size();
    ll m=t.size();
    ll mi=INT64_MAX;
    for(ll i=0;i<n-m+1;i++)
    {
        string temp;
        for(ll j=i;j<i+m;j++)
        {
            temp+=s[j];
        }
        ll cn=0;
            for(ll h=0;h<temp.size();h++)
            {
                if(t[h]!=temp[h])
                  cn++;
            }
        mi=min(mi,cn);
    }
    cout<<mi;
}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    //a #ifndef ONLINE_JUDGE 
    // freopen("/home/priyanshu/Hackercup/input.txt", "r", stdin); 
    // freopen("/home/priyanshu/Hackercup/output.txt", "w", stdout); 
    // #endif 
	ll t=1;
   // cin>>t;
    while(t--)
    {
        pk();
    }
} 

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
ll c[200005],pre[200005],sx[200005],mod=2019;
ll qpow(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1) res=res*a%mod;
        b/=2;
        a=a*a%mod;
    }
    return res%mod;
}
map<ll,ll> t;
int main(){
    string s;
    cin>>s;
    ll now=0,ans=0,n=s.length();
    s=" "+s;
    for(ll i=1;i<=n;i++){
        c[i]=qpow((ll)10,n-i)*(s[i]-'0');
        c[i]%=2019;
    }
    for(int i=1;i<=n;i++){
        pre[i]=(c[i]+pre[i-1])%2019;
        if(pre[i]==0) ans++;
    }
    for(int i=n;i>=1;i--){
        sx[i]=(c[i]+sx[i+1])%2019;
        if(sx[i]==0) ans++;
        t[sx[i]]++;
    }
    for(int i=1;i<n;i++){
        t[sx[i]]--;t[sx[i+1]]--;
        ans+=t[(pre[n]+2019-pre[i])%2019];
        t[sx[i+1]]++;
    }
    cout<<ans<<endl;
} 

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

int main() {
    
	string a, b; cin >> a >> b;
	string s = a + b;
	int x = stoi(s);
	string ans = "No";
	for (int i = 1; i * i <= x; i++) {
		if (i * i == x) {
			ans = "Yes";
			break;
		}
	}
	cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string N;
  cin >> N;
  reverse(N.begin(), N.end());
  N.push_back('0');
  int res = 0;
  for (int i = 0; i < (int)N.size(); i++) {
    if (N[i] > '5' || (N[i] == '5' && N[i + 1] >= '5')) {
      res += 10 - (N[i] - '0');
      int p = i + 1;
      while (N[p] == '9') {
        N[p++] = '0';
      }
      N[p] = N[p] + 1;
    } else {
      res += N[i] - '0';
    }
  }
  cout << res << '\n';
  return 0;
}


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

int main() {
  int A, B, X;
  cin >> A >> B >> X;
  int ans = 0;
  while (X > 0) {
    if (X > 500) X -= 1000, ans += min(A, B * 2);
    else X = 0, ans += min(A, B);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3108